]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/image.tex
msgdlg.h missing - please try compiling without precompiled headers before commiting
[wxWidgets.git] / docs / latex / wx / image.tex
CommitLineData
1e6d9499
JS
1\section{\class{wxImage}}\label{wximage}
2
3This class encapsulates a platform-independent image. An image can be created
4from data, or using the constructor taking a wxBitmap object. An image
5can be loaded from a file in a variety of formats, and is extensible to new formats
6via image format handlers. Functions are available to set and get image bits, so
7it can be used for basic image manipulation.
8
7468b994
RR
9A wxImage cannot (currently) be drawn directly to a \helpref{wxDC}{wxdc}. Instead,
10a platform-specific \helpref{wxBitmap}{wxbitmap} object must be created from it using
11the \helpref{ConvertToBitmap}{wximageconverttobitmap} function. This bitmap can then
12be drawn in a device context, using \helpref{wxDC::DrawBitmap}{wxdcdrawbitmap}.
13
14One colour value of the image may be used as a mask colour which will lead to the automatic
15creation of a \helpref{wxMask}{wxmask} object associated to the bitmap object.
12a44087 16
1e6d9499
JS
17\wxheading{Derived from}
18
19\helpref{wxObject}{wxobject}
20
954b8ae6
JS
21\wxheading{Include files}
22
23<wx/image.h>
24
1e6d9499
JS
25\wxheading{See also}
26
27\helpref{wxBitmap}{wxbitmap}
b5a4a47d 28\helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}
1e6d9499
JS
29
30\latexignore{\rtfignore{\wxheading{Members}}}
31
32\membersection{wxImage::wxImage}\label{wximageconstr}
33
34\func{}{wxImage}{\void}
35
36Default constructor.
37
38\func{}{wxImage}{\param{const wxImage\& }{image}}
39
40Copy constructor.
41
42\func{}{wxImage}{\param{const wxBitmap\&}{ bitmap}}
43
12a44087
RR
44Constructs an image from a platform-dependent bitmap. This preserves
45mask information so that bitmaps and images can be converted back
46and forth without loss in that respect.
1e6d9499
JS
47
48\func{}{wxImage}{\param{int}{ width}, \param{int}{ height}}
49
50Creates an image with the given width and height.
51
f6fcbb63 52\func{}{wxImage}{\param{const wxString\& }{name}, \param{long}{ type = wxBITMAP\_TYPE\_PNG}}
1e6d9499 53
9e9ee68e
VS
54\func{}{wxImage}{\param{const wxString\& }{name}, \param{const wxString\&}{ mimetype}}
55
1e6d9499
JS
56Loads an image from a file.
57
f6fcbb63 58\func{}{wxImage}{\param{wxInputStream\& }{stream}, \param{long}{ type = wxBITMAP\_TYPE\_PNG}}
45b5751f 59
9e9ee68e
VS
60\func{}{wxImage}{\param{wxInputStream\& }{stream}, \param{const wxString\&}{ mimetype}}
61
45b5751f
JS
62Loads an image from an input stream.
63
1e6d9499
JS
64\wxheading{Parameters}
65
66\docparam{width}{Specifies the width of the image.}
67
68\docparam{height}{Specifies the height of the image.}
69
70\docparam{name}{This refers to an image filename. Its meaning is determined by the {\it type} parameter.}
71
45b5751f
JS
72\docparam{stream}{This refers to an input stream. Its meaning is determined by the {\it type} parameter. It is equal to loading from file except that you provide opened stream (file, HTTP or any other custom class).}
73
1e6d9499
JS
74\docparam{type}{May be one of the following:
75
6be663cf 76\twocolwidtha{5cm}%
1e6d9499 77\begin{twocollist}
f6fcbb63
RR
78\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_BMP}}}{Load a Windows bitmap file.}
79\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_PNG}}}{Load a PNG bitmap file.}
48b4e302 80\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_JPEG}}}{Load a JPEG bitmap file.}
2376d03d
VS
81\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_GIF}}}{Load a GIF bitmap file.}
82\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_PCX}}}{Load a PCX bitmap file.}
83\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_PNM}}}{Load a PNM bitmap file.}
1e6d9499
JS
84\end{twocollist}
85
86The validity of these flags depends on the platform and wxWindows configuration.
48b4e302
VS
87If all possible wxWindows settings are used, the loading a BMP (Windows bitmap) file,
88a PNG (portable network graphics) file and a JPEG file is supported on all platforms that
12a44087 89implement wxImage.}
1e6d9499 90
9e9ee68e
VS
91\docparam{mimetype}{MIME type string (for example 'image/jpeg')}
92
f899db6d 93Note : you must call wxImage::AddHandler(new wxJPEGHandler) during application
0a9f2522
VS
94initialization in order to work with JPEGs.
95
1e6d9499
JS
96\wxheading{See also}
97
98\helpref{wxImage::LoadFile}{wximageloadfile}
99
f899db6d
RD
100\pythonnote{Constructors supported by wxPython are:\par
101\indented{2cm}{\begin{twocollist}
c9110876
VS
102\twocolitem{{\bf wxImage(name, flag)}}{Loads an image from a file}
103\twocolitem{{\bf wxNullImage()}}{Create a null image (has no size or
f899db6d 104image data)}
c9110876 105\twocolitem{{\bf wxEmptyImage(width, height)}}{Creates an empty image
f899db6d 106of the given size}
c9110876 107\twocolitem{{\bf wxImageFromMime(name, mimetype}}{Creates an image from
f899db6d 108the given file of the given mimetype}
c9110876 109\twocolitem{{\bf wxImageFromBitmap(bitmap)}}{Creates an image from a
f899db6d
RD
110platform-dependent bitmap}
111\end{twocollist}}
112}
113
1e6d9499
JS
114\membersection{wxImage::\destruct{wxImage}}
115
116\func{}{\destruct{wxImage}}{\void}
117
118Destructor.
119
120\membersection{wxImage::AddHandler}\label{wximageaddhandler}
121
122\func{static void}{AddHandler}{\param{wxImageHandler*}{ handler}}
123
124Adds a handler to the end of the static list of format handlers.
125
126\docparam{handler}{A new image format handler object. There is usually only one instance
127of a given handler class in an application session.}
128
129\wxheading{See also}
130
131\helpref{wxImageHandler}{wximagehandler}
132
c9110876 133\pythonnote{In wxPython this static method is named {\tt wxImage_AddHandler}.}
1e6d9499
JS
134\membersection{wxImage::CleanUpHandlers}
135
136\func{static void}{CleanUpHandlers}{\void}
137
138Deletes all image handlers.
139
140This function is called by wxWindows on exit.
141
142\membersection{wxImage::ConvertToBitmap}\label{wximageconverttobitmap}
143
144\constfunc{wxBitmap}{ConvertToBitmap}{\void}
145
12a44087
RR
146Converts the image to a platform-specific bitmap object. This has to be done
147to actually display an image as you cannot draw an image directly on a window.
148The resulting bitmap will use the colour depth of the current system which entails
7468b994
RR
149that a colour reduction has to take place.
150
151When in 8-bit mode (PseudoColour mode), the GTK port will use a color cube created
152on program start-up to look up colors. This ensures a very fast conversion, but
153the image quality won't be perfect (and could be better for photo images using more
154sophisticated dithering algorithms).
1e6d9499
JS
155
156\membersection{wxImage::Create}\label{wximagecreate}
157
158\func{bool}{Create}{\param{int}{ width}, \param{int}{ height}}
159
160Creates a fresh image.
161
162\wxheading{Parameters}
163
164\docparam{width}{The width of the image in pixels.}
165
166\docparam{height}{The height of the image in pixels.}
167
168\wxheading{Return value}
169
170TRUE if the call succeeded, FALSE otherwise.
171
172\membersection{wxImage::Destroy}\label{wximagedestroy}
173
174\func{bool}{Destroy}{\void}
175
176Destroys the image data.
177
178\membersection{wxImage::FindHandler}
179
180\func{static wxImageHandler*}{FindHandler}{\param{const wxString\& }{name}}
181
182Finds the handler with the given name.
183
184\func{static wxImageHandler*}{FindHandler}{\param{const wxString\& }{extension}, \param{long}{ imageType}}
185
186Finds the handler associated with the given extension and type.
187
188\func{static wxImageHandler*}{FindHandler}{\param{long }{imageType}}
189
190Finds the handler associated with the given image type.
191
9e9ee68e
VS
192\func{static wxImageHandler*}{FindHandlerMime}{\param{const wxString\& }{mimetype}}
193
194Finds the handler associated with the given MIME type.
195
1e6d9499
JS
196\docparam{name}{The handler name.}
197
198\docparam{extension}{The file extension, such as ``bmp".}
199
f6fcbb63 200\docparam{imageType}{The image type, such as wxBITMAP\_TYPE\_BMP.}
1e6d9499 201
9e9ee68e
VS
202\docparam{mimetype}{MIME type.}
203
1e6d9499
JS
204\wxheading{Return value}
205
206A pointer to the handler if found, NULL otherwise.
207
208\wxheading{See also}
209
210\helpref{wxImageHandler}{wximagehandler}
211
212\membersection{wxImage::GetBlue}\label{wximagegetblue}
213
214\constfunc{unsigned char}{GetBlue}{\param{int}{ x}, \param{int}{ y}}
215
216Returns the blue intensity at the given coordinate.
217
218\membersection{wxImage::GetData}\label{wximagegetdata}
219
220\constfunc{unsigned char*}{GetData}{\void}
221
12a44087
RR
222Returns the image data as an array. This is most often used when doing
223direct image manipulation. The return value points to an array of
224chararcters in RGBGBRGB... format.
1e6d9499
JS
225
226\membersection{wxImage::GetGreen}\label{wximagegetgreen}
227
228\constfunc{unsigned char}{GetGreen}{\param{int}{ x}, \param{int}{ y}}
229
230Returns the green intensity at the given coordinate.
231
232\membersection{wxImage::GetRed}\label{wximagegetred}
233
234\constfunc{unsigned char}{GetRed}{\param{int}{ x}, \param{int}{ y}}
235
236Returns the red intensity at the given coordinate.
237
238\membersection{wxImage::GetHandlers}
239
240\func{static wxList\&}{GetHandlers}{\void}
241
242Returns the static list of image format handlers.
243
244\wxheading{See also}
245
246\helpref{wxImageHandler}{wximagehandler}
247
248\membersection{wxImage::GetHeight}\label{wximagegetheight}
249
250\constfunc{int}{GetHeight}{\void}
251
252Gets the height of the image in pixels.
253
254\membersection{wxImage::GetMaskBlue}\label{wximagegetmaskblue}
255
256\constfunc{unsigned char}{GetMaskBlue}{\void}
257
258Gets the blue value of the mask colour.
259
260\membersection{wxImage::GetMaskGreen}\label{wximagegetmaskgreen}
261
262\constfunc{unsigned char}{GetMaskGreen}{\void}
263
264Gets the green value of the mask colour.
265
266\membersection{wxImage::GetMaskRed}\label{wximagegetmaskred}
267
268\constfunc{unsigned char}{GetMaskRed}{\void}
269
270Gets the red value of the mask colour.
271
fc9c7c09
RR
272\membersection{wxImage::GetSubImage}\label{wximagegetsubimage}
273
7468b994 274\constfunc{wxImage}{GetSubImage}{\param{const wxRect\&}{ rect}}
fc9c7c09
RR
275
276Returns a sub image of the current one as long as the rect belongs entirely to
277the image.
278
1e6d9499
JS
279\membersection{wxImage::GetWidth}\label{wximagegetwidth}
280
281\constfunc{int}{GetWidth}{\void}
282
283Gets the width of the image in pixels.
284
285\wxheading{See also}
286
287\helpref{wxImage::GetHeight}{wximagegetheight}
288
289\membersection{wxImage::HasMask}\label{wximagehasmask}
290
291\constfunc{bool}{HasMask}{\void}
292
293Returns TRUE if there is a mask active, FALSE otherwise.
294
295\membersection{wxImage::InitStandardHandlers}
296
297\func{static void}{InitStandardHandlers}{\void}
298
a14e57f9
SB
299Internal use only. Adds standard image format handlers. It only install BMP
300for the time being, which is use by wxBitmap.
1e6d9499 301
a14e57f9
SB
302This function is called by wxWindows on startup, and shouldn't be called by
303the user.
1e6d9499
JS
304
305\wxheading{See also}
306
307\helpref{wxImageHandler}{wximagehandler}
b5a4a47d 308\helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}
1e6d9499
JS
309
310\membersection{wxImage::InsertHandler}
311
312\func{static void}{InsertHandler}{\param{wxImageHandler*}{ handler}}
313
314Adds a handler at the start of the static list of format handlers.
315
316\docparam{handler}{A new image format handler object. There is usually only one instance
317of a given handler class in an application session.}
318
319\wxheading{See also}
320
321\helpref{wxImageHandler}{wximagehandler}
322
323\membersection{wxImage::LoadFile}\label{wximageloadfile}
324
a14e57f9 325\func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}}
1e6d9499 326
9e9ee68e
VS
327\func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{const wxString\&}{ mimetype}}
328
a14e57f9 329Loads an image from a file. If no handler type is provided, the library will
88b1927c 330try to use wxBITMAP\_TYPE\_BMP.
1e6d9499 331
45b5751f
JS
332\func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{long}{ type}}
333
9e9ee68e
VS
334\func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{const wxString\&}{ mimetype}}
335
45b5751f
JS
336Loads an image from an input stream.
337
1e6d9499
JS
338\wxheading{Parameters}
339
340\docparam{name}{A filename.
341The meaning of {\it name} is determined by the {\it type} parameter.}
342
45b5751f
JS
343\docparam{stream}{An input stream.
344The meaning of {\it stream} data is determined by the {\it type} parameter.}
345
1e6d9499
JS
346\docparam{type}{One of the following values:
347
6be663cf 348\twocolwidtha{5cm}%
1e6d9499 349\begin{twocollist}
f6fcbb63 350\twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Load a Windows image file.}
a14e57f9 351\twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Load a GIF image file.}
7468b994 352\twocolitem{{\bf wxBITMAP\_TYPE\_TIF}}{Load a TIFF image file.}
48b4e302 353\twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Load a JPEG image file.}
a14e57f9
SB
354\twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Load a PCX image file.}
355\twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Load a PNG image file.}
356\twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Load a PNM image file.}
1e6d9499
JS
357\end{twocollist}
358
359The validity of these flags depends on the platform and wxWindows configuration.}
360
9e9ee68e
VS
361\docparam{mimetype}{MIME type string (for example 'image/jpeg')}
362
1e6d9499
JS
363\wxheading{Return value}
364
365TRUE if the operation succeeded, FALSE otherwise.
366
367\wxheading{See also}
368
369\helpref{wxImage::SaveFile}{wximagesavefile}
370
f899db6d
RD
371\pythonnote{In place of a single overloaded method name, wxPython
372implements the following methods:\par
373\indented{2cm}{\begin{twocollist}
c9110876 374\twocolitem{{\bf LoadFile(filename, type)}}{Loads an image of the given
f899db6d 375type from a file}
c9110876 376\twocolitem{{\bf LoadMimeFile(filename, mimetype)}}{Loads an image of the given
f899db6d
RD
377mimetype from a file}
378\end{twocollist}}
379}
380
381
1e6d9499
JS
382\membersection{wxImage::Ok}\label{wximageok}
383
384\constfunc{bool}{Ok}{\void}
385
386Returns TRUE if image data is present.
387
388\membersection{wxImage::RemoveHandler}
389
390\func{static bool}{RemoveHandler}{\param{const wxString\& }{name}}
391
392Finds the handler with the given name, and removes it. The handler
393is not deleted.
394
395\docparam{name}{The handler name.}
396
397\wxheading{Return value}
398
399TRUE if the handler was found and removed, FALSE otherwise.
400
401\wxheading{See also}
402
403\helpref{wxImageHandler}{wximagehandler}
404
405\membersection{wxImage::SaveFile}\label{wximagesavefile}
406
407\func{bool}{SaveFile}{\param{const wxString\& }{name}, \param{int}{ type}}
408
9e9ee68e
VS
409\func{bool}{SaveFile}{\param{const wxString\& }{name}, \param{const wxString\&}{ mimetype}}
410
1e6d9499
JS
411Saves a image in the named file.
412
45b5751f
JS
413\func{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{int}{ type}}
414
9e9ee68e
VS
415\func{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{const wxString\&}{ mimetype}}
416
45b5751f
JS
417Saves a image in the given stream.
418
1e6d9499
JS
419\wxheading{Parameters}
420
421\docparam{name}{A filename. The meaning of {\it name} is determined by the {\it type} parameter.}
422
45b5751f
JS
423\docparam{stream}{An output stream. The meaning of {\it stream} is determined by the {\it type} parameter.}
424
7468b994 425\docparam{type}{Currently three types can be used:
1e6d9499 426
6be663cf 427\twocolwidtha{5cm}%
1e6d9499 428\begin{twocollist}
f6fcbb63 429\twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Save a PNG image file.}
48b4e302 430\twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Save a JPEG image file.}
7468b994 431\twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Save a PCX image file.}
1e6d9499
JS
432\end{twocollist}
433
12a44087
RR
434The validity of these flags depends on the platform and wxWindows configuration
435as well as user-added handlers.}
1e6d9499 436
9e9ee68e
VS
437\docparam{mimetype}{MIME type.}
438
1e6d9499
JS
439\wxheading{Return value}
440
441TRUE if the operation succeeded, FALSE otherwise.
442
443\wxheading{Remarks}
444
445Depending on how wxWindows has been configured, not all formats may be available.
446
447\wxheading{See also}
448
449\helpref{wxImage::LoadFile}{wximageloadfile}
450
f899db6d
RD
451\pythonnote{In place of a single overloaded method name, wxPython
452implements the following methods:\par
453\indented{2cm}{\begin{twocollist}
c9110876 454\twocolitem{{\bf SaveFile(filename, type)}}{Saves the image using the given
f899db6d 455type to the named file}
c9110876 456\twocolitem{{\bf SaveMimeFile(filename, mimetype)}}{Saves the image using the given
f899db6d
RD
457mimetype to the named file}
458\end{twocollist}}
459}
460
7468b994
RR
461\membersection{wxImage::Replace}\label{wximagereplace}
462
463\func{void}{Replace}{\param{unsigned char}{ r1}, \param{unsigned char}{ g1}, \param{unsigned char}{ b1},
464\param{unsigned char}{ r2}, \param{unsigned char}{ g2}, \param{unsigned char}{ b2}}
465
466Replaces the colour specified by {\it r1,g1,b1} by the colour {\it r2,g2,b2}.
467
ce9a75d2
VZ
468\membersection{wxImage::Rescale}\label{wximagerescale}
469
6e807169 470\func{wxImage \&}{Rescale}{\param{int}{ width}, \param{int}{ height}}
ce9a75d2 471
9c884972
RR
472Changes the size of the image in-place: after a call to this function, the
473image will have the given width and height.
ce9a75d2 474
6e807169
VZ
475Returns the (modified) image itself.
476
ce9a75d2
VZ
477\wxheading{See also}
478
479\helpref{Scale}{wximagescale}
480
1e6d9499
JS
481\membersection{wxImage::Scale}\label{wximagescale}
482
ce9a75d2 483\constfunc{wxImage}{Scale}{\param{int}{ width}, \param{int}{ height}}
1e6d9499 484
12a44087
RR
485Returns a scaled version of the image. This is also useful for
486scaling bitmaps in general as the only other way to scale bitmaps
ce9a75d2
VZ
487is to blit a wxMemoryDC into another wxMemoryDC.
488
7468b994 489It may be mentioned that the GTK port uses this function internally
fc9c7c09 490to scale bitmaps when using mapping mode in wxDC.
ce9a75d2
VZ
491
492Example:
493
494\begin{verbatim}
495 // get the bitmap from somewhere
496 wxBitmap bmp = ...;
497
498 // rescale it to have size of 32*32
499 if ( bmp.GetWidth() != 32 || bmp.GetHeight() != 32 )
500 {
501 wxImage image(bmp);
502 bmp = image.Scale(32, 32).ConvertToBitmap();
503
504 // another possibility:
505 image.Rescale(32, 32);
506 bmp = image;
507 }
508
509\end{verbatim}
510
511\wxheading{See also}
512
513\helpref{Rescale}{wximagerescale}
1e6d9499
JS
514
515\membersection{wxImage::SetData}\label{wximagesetdata}
516
517\func{void}{SetData}{\param{unsigned char*}{data}}
518
f899db6d 519Sets the image data without performing checks. The data given must have
12a44087
RR
520the size (width*height*3) or results will be unexpected. Don't use this
521method if you aren't sure you know what you are doing.
1e6d9499
JS
522
523\membersection{wxImage::SetMask}\label{wximagesetmask}
524
525\func{void}{SetMask}{\param{bool}{ hasMask = TRUE}}
526
527Specifies whether there is a mask or not. The area of the mask is determined by the current mask colour.
528
529\membersection{wxImage::SetMaskColour}\label{wximagesetmaskcolour}
530
531\func{void}{SetMaskColour}{\param{unsigned char }{red}, \param{unsigned char }{blue}, \param{unsigned char }{green}}
532
b1170810 533Sets the mask colour for this image (and tells the image to use the mask).
1e6d9499
JS
534
535\membersection{wxImage::SetRGB}\label{wximagesetrgb}
536
537\func{void}{SetRGB}{\param{int }{x}, \param{int }{y}, \param{unsigned char }{red}, \param{unsigned char }{blue}, \param{unsigned char }{green}}
538
12a44087
RR
539Sets the pixel at the given coordinate. This routine performs bounds-checks
540for the coordinate so it can be considered a safe way to manipulate the
541data, but in some cases this might be too slow so that the data will have to
7468b994
RR
542be set directly. In that case you will have to get access to the image data
543using the \helpref{GetData}{wximagegetdata} method.
1e6d9499
JS
544
545\membersection{wxImage::operator $=$}
546
547\func{wxImage\& }{operator $=$}{\param{const wxImage\& }{image}}
548
549Assignment operator. This operator does not copy any data, but instead
550passes a pointer to the data in {\it image} and increments a reference
551counter. It is a fast operation.
552
553\wxheading{Parameters}
554
555\docparam{image}{Image to assign.}
556
557\wxheading{Return value}
558
559Returns 'this' object.
560
561\membersection{wxImage::operator $==$}
562
563\func{bool}{operator $==$}{\param{const wxImage\& }{image}}
564
565Equality operator. This operator tests whether the internal data pointers are
566equal (a fast test).
567
568\wxheading{Parameters}
569
570\docparam{image}{Image to compare with 'this'}
571
572\wxheading{Return value}
573
574Returns TRUE if the images were effectively equal, FALSE otherwise.
575
576\membersection{wxImage::operator $!=$}
577
578\func{bool}{operator $!=$}{\param{const wxImage\& }{image}}
579
580Inequality operator. This operator tests whether the internal data pointers are
581unequal (a fast test).
582
583\wxheading{Parameters}
584
585\docparam{image}{Image to compare with 'this'}
586
587\wxheading{Return value}
588
589Returns TRUE if the images were unequal, FALSE otherwise.
590
591\section{\class{wxImageHandler}}\label{wximagehandler}
592
1e6d9499
JS
593This is the base class for implementing image file loading/saving, and image creation from data.
594It is used within wxImage and is not normally seen by the application.
595
596If you wish to extend the capabilities of wxImage, derive a class from wxImageHandler
597and add the handler using \helpref{wxImage::AddHandler}{wximageaddhandler} in your
598application initialisation.
599
48b4e302
VS
600\wxheading{Note (Legal Issue)}
601
954b8ae6 602This software is based in part on the work of the Independent JPEG Group.
48b4e302
VS
603
604(Applies when wxWindows is linked with JPEG support. wxJPEGHandler uses libjpeg
605created by IJG.)
606
1e6d9499
JS
607\wxheading{Derived from}
608
609\helpref{wxObject}{wxobject}
610
954b8ae6
JS
611\wxheading{Include files}
612
613<wx/image.h>
614
1e6d9499
JS
615\wxheading{See also}
616
617\helpref{wxImage}{wximage}
b5a4a47d 618\helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}
1e6d9499
JS
619
620\latexignore{\rtfignore{\wxheading{Members}}}
621
622\membersection{wxImageHandler::wxImageHandler}\label{wximagehandlerconstr}
623
624\func{}{wxImageHandler}{\void}
625
626Default constructor. In your own default constructor, initialise the members
627m\_name, m\_extension and m\_type.
628
629\membersection{wxImageHandler::\destruct{wxImageHandler}}
630
631\func{}{\destruct{wxImageHandler}}{\void}
632
633Destroys the wxImageHandler object.
634
635\membersection{wxImageHandler::GetName}
636
637\constfunc{wxString}{GetName}{\void}
638
639Gets the name of this handler.
640
641\membersection{wxImageHandler::GetExtension}
642
643\constfunc{wxString}{GetExtension}{\void}
644
645Gets the file extension associated with this handler.
646
7941ba11
RR
647\membersection{wxImageHandler::GetImageCount}\label{wximagehandlergetimagecount}
648
649\func{int}{GetImageCount}{\param{wxInputStream\&}{ stream}}
650
651If the image file contains more than one image and the image handler is capable
652of retrieving these individually, this function will return the number of
653available images.
654
655\docparam{stream}{Opened input stream for reading image file.}
656
657\wxheading{Return value}
658
659Number of available images. For most image handles, this defaults to 1.
660
1e6d9499
JS
661\membersection{wxImageHandler::GetType}
662
663\constfunc{long}{GetType}{\void}
664
665Gets the image type associated with this handler.
666
9e9ee68e
VS
667\membersection{wxImageHandler::GetMimeType}
668
669\constfunc{wxString}{GetMimeType}{\void}
670
671Gets the MIME type associated with this handler.
672
1e6d9499
JS
673\membersection{wxImageHandler::LoadFile}\label{wximagehandlerloadfile}
674
7941ba11 675\func{bool}{LoadFile}{\param{wxImage* }{image}, \param{wxInputStream\&}{ stream}, \param{bool}{ verbose=TRUE}, \param{int}{ index=0}}
1e6d9499 676
7941ba11
RR
677Loads a image from a stream, putting the resulting data into {\it image}. If the image file contains
678more than one image and the image handler is capable of retrieving these individually, {\it index}
679indicates which image to read from the stream.
1e6d9499
JS
680
681\wxheading{Parameters}
682
683\docparam{image}{The image object which is to be affected by this operation.}
684
7941ba11
RR
685\docparam{stream}{Opened input stream for reading images.}
686
687\docparam{verbose}{If set to TRUE, errors reported by the image handler will produce wxLogMessages.}
688
689\docparam{index}{The index of the image in the file (starting from zero).}
1e6d9499
JS
690
691\wxheading{Return value}
692
693TRUE if the operation succeeded, FALSE otherwise.
694
695\wxheading{See also}
696
697\helpref{wxImage::LoadFile}{wximageloadfile}\\
698\helpref{wxImage::SaveFile}{wximagesavefile}\\
699\helpref{wxImageHandler::SaveFile}{wximagehandlersavefile}
700
701\membersection{wxImageHandler::SaveFile}\label{wximagehandlersavefile}
702
45b5751f 703\func{bool}{SaveFile}{\param{wxImage* }{image}, \param{wxOutputStream\& }{stream}}
1e6d9499 704
45b5751f 705Saves a image in the output stream.
1e6d9499
JS
706
707\wxheading{Parameters}
708
709\docparam{image}{The image object which is to be affected by this operation.}
710
7941ba11 711\docparam{stream}{An opened stream for writing images.}
1e6d9499
JS
712
713\wxheading{Return value}
714
715TRUE if the operation succeeded, FALSE otherwise.
716
717\wxheading{See also}
718
719\helpref{wxImage::LoadFile}{wximageloadfile}\\
720\helpref{wxImage::SaveFile}{wximagesavefile}\\
721\helpref{wxImageHandler::LoadFile}{wximagehandlerloadfile}
722
723\membersection{wxImageHandler::SetName}
724
725\func{void}{SetName}{\param{const wxString\& }{name}}
726
727Sets the handler name.
728
729\wxheading{Parameters}
730
731\docparam{name}{Handler name.}
732
733\membersection{wxImageHandler::SetExtension}
734
735\func{void}{SetExtension}{\param{const wxString\& }{extension}}
736
737Sets the handler extension.
738
739\wxheading{Parameters}
740
741\docparam{extension}{Handler extension.}
742
743\membersection{wxImageHandler::SetType}
744
745\func{void}{SetType}{\param{long }{type}}
746
747Sets the handler type.
748
749\wxheading{Parameters}
750
751\docparam{name}{Handler type.}
752
9e9ee68e
VS
753
754\membersection{wxImageHandler::SetMimeType}
755
756\func{void}{SetMimeType}{\param{const wxString\& }{mimetype}}
757
758Sets the handler MIME type.
759
760\wxheading{Parameters}
761
762\docparam{mimename}{Handler MIME type.}
763