]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/image.tex
fixed indentation in case there's only one cell on line
[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
b06a6b20 4from data, or using \helpref{wxBitmap::ConvertToImage}{wxbitmapconverttoimage}. An image
1e6d9499
JS
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
b06a6b20
VS
11the \helpref{wxBitmap::wxBitmap(wxImage,int depth)}{wxbitmapconstr} constructor.
12This bitmap can then
7468b994
RR
13be drawn in a device context, using \helpref{wxDC::DrawBitmap}{wxdcdrawbitmap}.
14
15One colour value of the image may be used as a mask colour which will lead to the automatic
16creation of a \helpref{wxMask}{wxmask} object associated to the bitmap object.
12a44087 17
487659e0
VZ
18\wxheading{Alpha channel support}
19
fc2171bd 20Starting from wxWidgets 2.5.0 wxImage supports alpha channel data, that is in
487659e0
VZ
21addition to a byte for the red, green and blue colour components for each pixel
22it also stores a byte representing the pixel opacity. The alpha value of $0$
23corresponds to a transparent pixel (null opacity) while the value of $255$
24means that the pixel is 100\% opaque.
25
26Unlike the RGB data, not all images have the alpha channel and before using
27\helpref{GetAlpha}{wximagegetalpha} you should check if this image contains
28alpha value with \helpref{HasAlpha}{wximagehasalpha}. In fact, currently only
29images loaded from PNG files with transparency information will have alpha
30channel but support for it will be added to the other formats as well (as well
31as support for saving images with alpha channel which is not still implemented
939fadc8 32either).
487659e0 33
8727a1fe
GRG
34\wxheading{Available image handlers}
35
36The following image handlers are available. {\bf wxBMPHandler} is always
2edb0bde 37installed by default. To use other image formats, install the appropriate
fa482912 38handler with \helpref{wxImage::AddHandler}{wximageaddhandler} or
8727a1fe
GRG
39\helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}.
40
41\twocolwidtha{5cm}%
42\begin{twocollist}
4fa0a5b4 43\twocolitem{\indexit{wxBMPHandler}}{For loading and saving, always installed.}
487659e0 44\twocolitem{\indexit{wxPNGHandler}}{For loading (including alpha support) and saving.}
606a3178
GT
45\twocolitem{\indexit{wxJPEGHandler}}{For loading and saving.}
46\twocolitem{\indexit{wxGIFHandler}}{Only for loading, due to legal issues.}
47\twocolitem{\indexit{wxPCXHandler}}{For loading and saving (see below).}
48\twocolitem{\indexit{wxPNMHandler}}{For loading and saving (see below).}
b86e511a 49\twocolitem{\indexit{wxTIFFHandler}}{For loading and saving.}
4fa0a5b4 50\twocolitem{\indexit{wxIFFHandler}}{For loading only.}
b86e511a 51\twocolitem{\indexit{wxXPMHandler}}{For loading and saving.}
37b83ca6 52\twocolitem{\indexit{wxICOHandler}}{For loading and saving.}
a61d25e6 53\twocolitem{\indexit{wxCURHandler}}{For loading and saving.}
4fa0a5b4 54\twocolitem{\indexit{wxANIHandler}}{For loading only.}
8727a1fe
GRG
55\end{twocollist}
56
57When saving in PCX format, {\bf wxPCXHandler} will count the number of
58different colours in the image; if there are 256 or less colours, it will
59save as 8 bit, else it will save as 24 bit.
60
61Loading PNMs only works for ASCII or raw RGB images. When saving in
62PNM format, {\bf wxPNMHandler} will always save as raw RGB.
63
1e6d9499
JS
64\wxheading{Derived from}
65
66\helpref{wxObject}{wxobject}
67
954b8ae6
JS
68\wxheading{Include files}
69
70<wx/image.h>
71
1e6d9499
JS
72\wxheading{See also}
73
f6081a04 74\helpref{wxBitmap}{wxbitmap},
b5a4a47d 75\helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}
1e6d9499
JS
76
77\latexignore{\rtfignore{\wxheading{Members}}}
78
79\membersection{wxImage::wxImage}\label{wximageconstr}
80
81\func{}{wxImage}{\void}
82
83Default constructor.
84
85\func{}{wxImage}{\param{const wxImage\& }{image}}
86
87Copy constructor.
88
89\func{}{wxImage}{\param{const wxBitmap\&}{ bitmap}}
90
b06a6b20
VS
91(Deprecated form, use \helpref{wxBitmap::ConvertToImage}{wxbitmapconverttoimage}
92instead.) Constructs an image from a platform-dependent bitmap. This preserves
12a44087
RR
93mask information so that bitmaps and images can be converted back
94and forth without loss in that respect.
1e6d9499 95
ff865c13 96\func{}{wxImage}{\param{int}{ width}, \param{int}{ height}, \param{bool}{ clear=true}}
1e6d9499 97
ff865c13
JS
98Creates an image with the given width and height. If {\it clear} is true, the new image will be initialized to black.
99Otherwise, the image data will be uninitialized.
1e6d9499 100
cc81d32f 101\func{}{wxImage}{\param{int}{ width}, \param{int}{ height}, \param{unsigned char*}{ data}, \param{bool}{ static\_data=false}}
f6bcfd97
BP
102
103Creates an image from given data with the given width and height. If
cc81d32f 104{\it static\_data} is true, then wxImage will not delete the actual
f6bcfd97
BP
105image data in its destructor, otherwise it will free it by calling
106{\it free()}.
107
a61d25e6 108\func{}{wxImage}{\param{const wxString\& }{name}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}, \param{int}{ index = -1}}
1e6d9499 109
a61d25e6 110\func{}{wxImage}{\param{const wxString\& }{name}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}
9e9ee68e 111
1e6d9499
JS
112Loads an image from a file.
113
a61d25e6 114\func{}{wxImage}{\param{wxInputStream\& }{stream}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}, \param{int}{ index = -1}}
45b5751f 115
a61d25e6 116\func{}{wxImage}{\param{wxInputStream\& }{stream}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}
9e9ee68e 117
45b5751f
JS
118Loads an image from an input stream.
119
1e6d9499
JS
120\wxheading{Parameters}
121
122\docparam{width}{Specifies the width of the image.}
123
124\docparam{height}{Specifies the height of the image.}
125
31fd9b6b 126\docparam{name}{Name of the file from which to load the image.}
1e6d9499 127
31fd9b6b 128\docparam{stream}{Opened input stream from which to load the image. Currently, the stream must support seeking.}
45b5751f 129
1e6d9499
JS
130\docparam{type}{May be one of the following:
131
6be663cf 132\twocolwidtha{5cm}%
1e6d9499 133\begin{twocollist}
606a3178
GT
134\twocolitem{\indexit{wxBITMAP\_TYPE\_BMP}}{Load a Windows bitmap file.}
135\twocolitem{\indexit{wxBITMAP\_TYPE\_GIF}}{Load a GIF bitmap file.}
136\twocolitem{\indexit{wxBITMAP\_TYPE\_JPEG}}{Load a JPEG bitmap file.}
137\twocolitem{\indexit{wxBITMAP\_TYPE\_PNG}}{Load a PNG bitmap file.}
138\twocolitem{\indexit{wxBITMAP\_TYPE\_PCX}}{Load a PCX bitmap file.}
139\twocolitem{\indexit{wxBITMAP\_TYPE\_PNM}}{Load a PNM bitmap file.}
140\twocolitem{\indexit{wxBITMAP\_TYPE\_TIF}}{Load a TIFF bitmap file.}
b86e511a 141\twocolitem{\indexit{wxBITMAP\_TYPE\_XPM}}{Load a XPM bitmap file.}
a61d25e6
VS
142\twocolitem{\indexit{wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
143\twocolitem{\indexit{wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
658974ae 144\twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
606a3178 145\twocolitem{\indexit{wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
31fd9b6b 146\end{twocollist}}
1e6d9499 147
9e9ee68e
VS
148\docparam{mimetype}{MIME type string (for example 'image/jpeg')}
149
a61d25e6 150\docparam{index}{Index of the image to load in the case that the image file contains multiple images.
b931f7ee 151This is only used by GIF, ICO and TIFF handlers. The default value (-1) means
a61d25e6 152"choose the default image" and is interpreted as the first image (index=0) by
b931f7ee 153the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.}
a61d25e6 154
31fd9b6b
GRG
155\wxheading{Remarks}
156
fc2171bd 157Depending on how wxWidgets has been configured, not all formats may be available.
31fd9b6b 158
fa482912
JS
159Note: any handler other than BMP must be previously
160initialized with \helpref{wxImage::AddHandler}{wximageaddhandler} or
31fd9b6b 161\helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}.
0a9f2522 162
a61d25e6
VS
163Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to get the
164hotspot for loaded cursor file:
165\begin{verbatim}
fd94e8aa
VS
166 int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
167 int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
a61d25e6
VS
168
169\end{verbatim}
170
1e6d9499
JS
171\wxheading{See also}
172
173\helpref{wxImage::LoadFile}{wximageloadfile}
174
f899db6d
RD
175\pythonnote{Constructors supported by wxPython are:\par
176\indented{2cm}{\begin{twocollist}
c9110876
VS
177\twocolitem{{\bf wxImage(name, flag)}}{Loads an image from a file}
178\twocolitem{{\bf wxNullImage()}}{Create a null image (has no size or
f899db6d 179image data)}
c9110876 180\twocolitem{{\bf wxEmptyImage(width, height)}}{Creates an empty image
f899db6d 181of the given size}
c9110876 182\twocolitem{{\bf wxImageFromMime(name, mimetype}}{Creates an image from
f899db6d 183the given file of the given mimetype}
c9110876 184\twocolitem{{\bf wxImageFromBitmap(bitmap)}}{Creates an image from a
f899db6d
RD
185platform-dependent bitmap}
186\end{twocollist}}
187}
188
5873607e
VZ
189\perlnote{Constructors supported by wxPerl are:\par
190\begin{itemize}
191\item{Wx::Image->new( bitmap )}
25e4b4bf 192\item{Wx::Image->new( icon )}
5873607e 193\item{Wx::Image->new( width, height )}
25e4b4bf
MB
194\item{Wx::Image->new( width, height, data )}
195\item{Wx::Image->new( file, type, index )}
196\item{Wx::Image->new( file, mimetype, index )}
197\item{Wx::Image->new( stream, type, index )}
198\item{Wx::Image->new( stream, mimetype, index )}
5873607e
VZ
199\end{itemize}
200}
201
1e6d9499
JS
202\membersection{wxImage::\destruct{wxImage}}
203
204\func{}{\destruct{wxImage}}{\void}
205
206Destructor.
207
208\membersection{wxImage::AddHandler}\label{wximageaddhandler}
209
210\func{static void}{AddHandler}{\param{wxImageHandler*}{ handler}}
211
212Adds a handler to the end of the static list of format handlers.
213
214\docparam{handler}{A new image format handler object. There is usually only one instance
215of a given handler class in an application session.}
216
217\wxheading{See also}
218
219\helpref{wxImageHandler}{wximagehandler}
220
4fa0a5b4
VS
221\func{bool}{CanRead}{\param{const wxString\&}{ filename}}
222
cc81d32f 223returns true if the current image handlers can read this file
4fa0a5b4 224
e7240349 225\pythonnote{In wxPython this static method is named {\tt wxImage\_AddHandler}.}
1e6d9499
JS
226\membersection{wxImage::CleanUpHandlers}
227
228\func{static void}{CleanUpHandlers}{\void}
229
230Deletes all image handlers.
231
fc2171bd 232This function is called by wxWidgets on exit.
1e6d9499 233
d7af2fea
VS
234\membersection{wxImage::ComputeHistogram}\label{wximagecomputehistogram}
235
236\constfunc{unsigned long}{ComputeHistogram}{\param{wxImageHistogram\& }{histogram}}
237
238Computes the histogram of the image. {\it histogram} is a reference to
239wxImageHistogram object. wxImageHistogram is a specialization of
240\helpref{wxHashMap}{wxhashmap} "template" and is defined as follows:
241
242\begin{verbatim}
243class WXDLLEXPORT wxImageHistogramEntry
244{
245public:
246 wxImageHistogramEntry() : index(0), value(0) {}
247 unsigned long index;
248 unsigned long value;
249};
250
251WX_DECLARE_EXPORTED_HASH_MAP(unsigned long, wxImageHistogramEntry,
252 wxIntegerHash, wxIntegerEqual,
253 wxImageHistogram);
254\end{verbatim}
255
256\wxheading{Return value}
257
258Returns number of colours in the histogram.
259
1e6d9499
JS
260\membersection{wxImage::ConvertToBitmap}\label{wximageconverttobitmap}
261
262\constfunc{wxBitmap}{ConvertToBitmap}{\void}
263
b06a6b20
VS
264Deprecated, use equivalent \helpref{wxBitmap constructor}{wxbitmapconstr}
265(which takes wxImage and depth as its arguments) instead.
7468b994 266
b06a6b20 267\membersection{wxImage::ConvertToMono}\label{wxbitmapconverttomono}
1e6d9499 268
b06a6b20
VS
269\constfunc{wxImage}{ConvertToMono}{\param{unsigned char}{ r}, \param{unsigned char}{ g}, \param{unsigned char}{ b}}
270
271Returns monochromatic version of the image. The returned image has white
272colour where the original has {\it (r,g,b)} colour and black colour
273everywhere else.
3ca6a5f0 274
f6bcfd97
BP
275\membersection{wxImage::Copy}\label{wximagecopy}
276
277\constfunc{wxImage}{Copy}{\void}
278
279Returns an identical copy of the image.
280
1e6d9499
JS
281\membersection{wxImage::Create}\label{wximagecreate}
282
ff865c13 283\func{bool}{Create}{\param{int}{ width}, \param{int}{ height}, \param{bool}{ clear=true}}
1e6d9499 284
ff865c13
JS
285Creates a fresh image. If {\it clear} is true, the new image will be initialized to black.
286Otherwise, the image data will be uninitialized.
1e6d9499
JS
287
288\wxheading{Parameters}
289
290\docparam{width}{The width of the image in pixels.}
291
292\docparam{height}{The height of the image in pixels.}
293
294\wxheading{Return value}
295
cc81d32f 296true if the call succeeded, false otherwise.
1e6d9499
JS
297
298\membersection{wxImage::Destroy}\label{wximagedestroy}
299
300\func{bool}{Destroy}{\void}
301
302Destroys the image data.
303
37b83ca6
VS
304\membersection{wxImage::FindFirstUnusedColour}\label{wximagefindfirstunusedcolour}
305
306\func{bool}{FindFirstUnusedColour}{\param{unsigned char *}{ r}, \param{unsigned char *}{ g}, \param{unsigned char *}{ b}, \param{unsigned char}{ startR = 1}, \param{unsigned char}{ startG = 0}, \param{unsigned char}{ startB = 0}}
307
308\wxheading{Parameters}
309
310\docparam{r,g,b}{Pointers to variables to save the colour.}
311
312\docparam{startR,startG,startB}{Initial values of the colour. Returned colour
313will have RGB values equal to or greater than these.}
314
315Finds the first colour that is never used in the image. The search begins at
316given initial colour and continues by increasing R, G and B components (in this
317order) by 1 until an unused colour is found or the colour space exhausted.
318
319\wxheading{Return value}
320
cc81d32f 321Returns false if there is no unused colour left, true on success.
37b83ca6
VS
322
323\wxheading{Notes}
324
325Note that this method involves computing the histogram, which is
326computationally intensive operation.
327
1e6d9499
JS
328\membersection{wxImage::FindHandler}
329
330\func{static wxImageHandler*}{FindHandler}{\param{const wxString\& }{name}}
331
332Finds the handler with the given name.
333
334\func{static wxImageHandler*}{FindHandler}{\param{const wxString\& }{extension}, \param{long}{ imageType}}
335
336Finds the handler associated with the given extension and type.
337
338\func{static wxImageHandler*}{FindHandler}{\param{long }{imageType}}
339
340Finds the handler associated with the given image type.
341
9e9ee68e
VS
342\func{static wxImageHandler*}{FindHandlerMime}{\param{const wxString\& }{mimetype}}
343
344Finds the handler associated with the given MIME type.
345
1e6d9499
JS
346\docparam{name}{The handler name.}
347
348\docparam{extension}{The file extension, such as ``bmp".}
349
f6fcbb63 350\docparam{imageType}{The image type, such as wxBITMAP\_TYPE\_BMP.}
1e6d9499 351
9e9ee68e
VS
352\docparam{mimetype}{MIME type.}
353
1e6d9499
JS
354\wxheading{Return value}
355
356A pointer to the handler if found, NULL otherwise.
357
358\wxheading{See also}
359
360\helpref{wxImageHandler}{wximagehandler}
361
939fadc8
JS
362\membersection{wxImage::GetImageExtWildcard}
363
364\func{static wxString}{GetImageExtWildcard}{\void}
365
366Iterates all registered wxImageHandler objects, and returns a string containing file extension masks
367suitable for passing to file open/save dialog boxes.
368
369\wxheading{Return value}
370
371The format of the returned string is "(*.ext1;*.ext2)|*.ext1;*.ext2".
372
373It is usually a good idea to prepend a description before passing the result to the dialog.
374
375Example:
376
377\begin{verbatim}
378 wxFileDialog FileDlg( this, "Choose Image", ::wxGetWorkingDirectory(), "", _("Image Files ") + wxImage::GetImageExtWildcard(), wxOPEN );
379\end{verbatim}
380
381\wxheading{See also}
382
383\helpref{wxImageHandler}{wximagehandler}
384
487659e0
VZ
385\membersection{wxImage::GetAlpha}\label{wximagegetalpha}
386
387\constfunc{unsigned char}{GetAlpha}{\param{int}{ x}, \param{int}{ y}}
388
389Returns the alpha value for the given pixel. This function may only be called
390for the images with alpha channel, use \helpref{HasAlpha}{wximagehasalpha} to
391check for this.
392
393The returned value is the {\it opacity} of the image, i.e. the value of $0$
394corresponds to the transparent pixels while the value of $255$ -- to the opaque
395ones.
396
397\constfunc{unsigned char *}{GetAlpha}{\void}
398
399Returns pointer to the array storing the alpha values for this image. This
400pointer is {\tt NULL} for the images without the alpha channel. If the image
401does have it, this pointer may be used to directly manipulate the alpha values
402which are stored as the \helpref{RGB}{wximagegetdata} ones.
403
1e6d9499
JS
404\membersection{wxImage::GetBlue}\label{wximagegetblue}
405
406\constfunc{unsigned char}{GetBlue}{\param{int}{ x}, \param{int}{ y}}
407
408Returns the blue intensity at the given coordinate.
409
410\membersection{wxImage::GetData}\label{wximagegetdata}
411
412\constfunc{unsigned char*}{GetData}{\void}
413
12a44087
RR
414Returns the image data as an array. This is most often used when doing
415direct image manipulation. The return value points to an array of
487659e0
VZ
416characters in RGBRGBRGB$\ldots$ format in the top-to-bottom, left-to-right
417order, that is the first RGB triplet corresponds to the pixel $(0, 0)$, the
418second one --- to $(0, 1)$ and so on.
1e6d9499 419
f811bc9a
MB
420You should not delete the returned pointer nor pass it to
421\helpref{wxImage::SetData}{wximagesetdata}.
422
1e6d9499
JS
423\membersection{wxImage::GetGreen}\label{wximagegetgreen}
424
425\constfunc{unsigned char}{GetGreen}{\param{int}{ x}, \param{int}{ y}}
426
427Returns the green intensity at the given coordinate.
428
649d13e8 429\membersection{wxImage::GetImageCount}\label{wximagegetimagecount}
a61d25e6 430
649d13e8 431\func{static int}{GetImageCount}{\param{const wxString\&}{ filename}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}}
a61d25e6 432
649d13e8 433\func{static int}{GetImageCount}{\param{wxInputStream\&}{ stream}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}}
a61d25e6
VS
434
435If the image file contains more than one image and the image handler is capable
436of retrieving these individually, this function will return the number of
437available images.
438
439\docparam{name}{Name of the file to query.}
440
441\docparam{stream}{Opened input stream with image data. Currently, the stream must support seeking.}
442
443\docparam{type}{May be one of the following:
444
445\twocolwidtha{5cm}%
446\begin{twocollist}
447\twocolitem{\indexit{wxBITMAP\_TYPE\_BMP}}{Load a Windows bitmap file.}
448\twocolitem{\indexit{wxBITMAP\_TYPE\_GIF}}{Load a GIF bitmap file.}
449\twocolitem{\indexit{wxBITMAP\_TYPE\_JPEG}}{Load a JPEG bitmap file.}
450\twocolitem{\indexit{wxBITMAP\_TYPE\_PNG}}{Load a PNG bitmap file.}
451\twocolitem{\indexit{wxBITMAP\_TYPE\_PCX}}{Load a PCX bitmap file.}
452\twocolitem{\indexit{wxBITMAP\_TYPE\_PNM}}{Load a PNM bitmap file.}
453\twocolitem{\indexit{wxBITMAP\_TYPE\_TIF}}{Load a TIFF bitmap file.}
454\twocolitem{\indexit{wxBITMAP\_TYPE\_XPM}}{Load a XPM bitmap file.}
455\twocolitem{\indexit{wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
456\twocolitem{\indexit{wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
658974ae 457\twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
a61d25e6
VS
458\twocolitem{\indexit{wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
459\end{twocollist}}
460
461\wxheading{Return value}
462
463Number of available images. For most image handlers, this is 1 (exceptions
464are TIFF and ICO formats).
465
1e6d9499
JS
466\membersection{wxImage::GetHandlers}
467
468\func{static wxList\&}{GetHandlers}{\void}
469
470Returns the static list of image format handlers.
471
472\wxheading{See also}
473
474\helpref{wxImageHandler}{wximagehandler}
475
476\membersection{wxImage::GetHeight}\label{wximagegetheight}
477
478\constfunc{int}{GetHeight}{\void}
479
480Gets the height of the image in pixels.
481
482\membersection{wxImage::GetMaskBlue}\label{wximagegetmaskblue}
483
484\constfunc{unsigned char}{GetMaskBlue}{\void}
485
486Gets the blue value of the mask colour.
487
488\membersection{wxImage::GetMaskGreen}\label{wximagegetmaskgreen}
489
490\constfunc{unsigned char}{GetMaskGreen}{\void}
491
492Gets the green value of the mask colour.
493
494\membersection{wxImage::GetMaskRed}\label{wximagegetmaskred}
495
496\constfunc{unsigned char}{GetMaskRed}{\void}
497
498Gets the red value of the mask colour.
499
3ca6a5f0
BP
500\membersection{wxImage::GetPalette}\label{wximagegetpalette}
501
502\constfunc{const wxPalette\&}{GetPalette}{\void}
503
504Returns the palette associated with the image. Currently the palette is only
b06a6b20 505used when converting to wxBitmap under Windows.
3ca6a5f0
BP
506
507Eventually wxImage handlers will set the palette if one exists in the image file.
508
7b4c3149
VZ
509\membersection{wxImage::GetRed}\label{wximagegetred}
510
511\constfunc{unsigned char}{GetRed}{\param{int}{ x}, \param{int}{ y}}
512
513Returns the red intensity at the given coordinate.
514
fc9c7c09
RR
515\membersection{wxImage::GetSubImage}\label{wximagegetsubimage}
516
7468b994 517\constfunc{wxImage}{GetSubImage}{\param{const wxRect\&}{ rect}}
fc9c7c09
RR
518
519Returns a sub image of the current one as long as the rect belongs entirely to
520the image.
521
1e6d9499
JS
522\membersection{wxImage::GetWidth}\label{wximagegetwidth}
523
524\constfunc{int}{GetWidth}{\void}
525
526Gets the width of the image in pixels.
527
528\wxheading{See also}
529
530\helpref{wxImage::GetHeight}{wximagegetheight}
531
487659e0
VZ
532\membersection{wxImage::HasAlpha}\label{wximagehasalpha}
533
534\constfunc{bool}{HasAlpha}{\void}
535
536Returns true if this image has alpha channel, false otherwise.
537
538\wxheading{See also}
539
540\helpref{GetAlpha}{wximagegetalpha}, \helpref{SetAlpha}{wximagesetalpha}
541
1e6d9499
JS
542\membersection{wxImage::HasMask}\label{wximagehasmask}
543
544\constfunc{bool}{HasMask}{\void}
545
cc81d32f 546Returns true if there is a mask active, false otherwise.
1e6d9499 547
5e5437e0
JS
548\membersection{wxImage::GetOption}\label{wximagegetoption}
549
550\constfunc{wxString}{GetOption}{\param{const wxString\&}{ name}}
551
552Gets a user-defined option. The function is case-insensitive to {\it name}.
553
554For example, when saving as a JPEG file, the option {\bf quality} is
555used, which is a number between 0 and 100 (0 is terrible, 100 is very good).
556
557\wxheading{See also}
558
559\helpref{wxImage::SetOption}{wximagesetoption},\rtfsp
560\helpref{wxImage::GetOptionInt}{wximagegetoptionint},\rtfsp
561\helpref{wxImage::HasOption}{wximagehasoption}
562
563\membersection{wxImage::GetOptionInt}\label{wximagegetoptionint}
564
565\constfunc{int}{GetOptionInt}{\param{const wxString\&}{ name}}
566
567Gets a user-defined option as an integer. The function is case-insensitive to {\it name}.
568
569\wxheading{See also}
570
571\helpref{wxImage::SetOption}{wximagesetoption},\rtfsp
572\helpref{wxImage::GetOption}{wximagegetoption},\rtfsp
573\helpref{wxImage::HasOption}{wximagehasoption}
574
575\membersection{wxImage::HasOption}\label{wximagehasoption}
576
577\constfunc{bool}{HasOption}{\param{const wxString\&}{ name}}
578
cc81d32f 579Returns true if the given option is present. The function is case-insensitive to {\it name}.
5e5437e0
JS
580
581\wxheading{See also}
582
583\helpref{wxImage::SetOption}{wximagesetoption},\rtfsp
584\helpref{wxImage::GetOption}{wximagegetoption},\rtfsp
585\helpref{wxImage::GetOptionInt}{wximagegetoptionint}
586
1e6d9499
JS
587\membersection{wxImage::InitStandardHandlers}
588
589\func{static void}{InitStandardHandlers}{\void}
590
a14e57f9 591Internal use only. Adds standard image format handlers. It only install BMP
31fd9b6b 592for the time being, which is used by wxBitmap.
1e6d9499 593
fc2171bd 594This function is called by wxWidgets on startup, and shouldn't be called by
a14e57f9 595the user.
1e6d9499
JS
596
597\wxheading{See also}
598
fa482912 599\helpref{wxImageHandler}{wximagehandler},
b5a4a47d 600\helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}
1e6d9499
JS
601
602\membersection{wxImage::InsertHandler}
603
604\func{static void}{InsertHandler}{\param{wxImageHandler*}{ handler}}
605
606Adds a handler at the start of the static list of format handlers.
607
608\docparam{handler}{A new image format handler object. There is usually only one instance
609of a given handler class in an application session.}
610
611\wxheading{See also}
612
613\helpref{wxImageHandler}{wximagehandler}
614
615\membersection{wxImage::LoadFile}\label{wximageloadfile}
616
a61d25e6 617\func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}, \param{int}{ index = -1}}
1e6d9499 618
a61d25e6 619\func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}
9e9ee68e 620
a14e57f9 621Loads an image from a file. If no handler type is provided, the library will
31fd9b6b 622try to autodetect the format.
1e6d9499 623
a61d25e6 624\func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{long}{ type}, \param{int}{ index = -1}}
45b5751f 625
a61d25e6 626\func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}
9e9ee68e 627
45b5751f
JS
628Loads an image from an input stream.
629
1e6d9499
JS
630\wxheading{Parameters}
631
31fd9b6b 632\docparam{name}{Name of the file from which to load the image.}
1e6d9499 633
31fd9b6b 634\docparam{stream}{Opened input stream from which to load the image. Currently, the stream must support seeking.}
45b5751f 635
1e6d9499
JS
636\docparam{type}{One of the following values:
637
6be663cf 638\twocolwidtha{5cm}%
1e6d9499 639\begin{twocollist}
f6fcbb63 640\twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Load a Windows image file.}
a14e57f9 641\twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Load a GIF image file.}
48b4e302 642\twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Load a JPEG image file.}
a14e57f9
SB
643\twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Load a PCX image file.}
644\twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Load a PNG image file.}
645\twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Load a PNM image file.}
31fd9b6b 646\twocolitem{{\bf wxBITMAP\_TYPE\_TIF}}{Load a TIFF image file.}
b86e511a 647\twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Load a XPM image file.}
a61d25e6
VS
648\twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
649\twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
658974ae 650\twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
31fd9b6b
GRG
651\twocolitem{{\bf wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
652\end{twocollist}}
1e6d9499 653
9e9ee68e
VS
654\docparam{mimetype}{MIME type string (for example 'image/jpeg')}
655
a61d25e6 656\docparam{index}{Index of the image to load in the case that the image file contains multiple images.
b931f7ee 657This is only used by GIF, ICO and TIFF handlers. The default value (-1) means
a61d25e6 658"choose the default image" and is interpreted as the first image (index=0) by
b931f7ee 659the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.}
a61d25e6 660
31fd9b6b
GRG
661\wxheading{Remarks}
662
fc2171bd 663Depending on how wxWidgets has been configured, not all formats may be available.
31fd9b6b 664
a61d25e6
VS
665Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to get the
666hotspot for loaded cursor file:
667\begin{verbatim}
fd94e8aa
VS
668 int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
669 int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
a61d25e6
VS
670
671\end{verbatim}
37b83ca6 672
1e6d9499
JS
673\wxheading{Return value}
674
cc81d32f
VS
675true if the operation succeeded, false otherwise. If the optional index parameter is out of range,
676false is returned and a call to wxLogError() takes place.
1e6d9499
JS
677
678\wxheading{See also}
679
680\helpref{wxImage::SaveFile}{wximagesavefile}
681
f899db6d
RD
682\pythonnote{In place of a single overloaded method name, wxPython
683implements the following methods:\par
684\indented{2cm}{\begin{twocollist}
c9110876 685\twocolitem{{\bf LoadFile(filename, type)}}{Loads an image of the given
f899db6d 686type from a file}
c9110876 687\twocolitem{{\bf LoadMimeFile(filename, mimetype)}}{Loads an image of the given
f899db6d
RD
688mimetype from a file}
689\end{twocollist}}
690}
691
5873607e
VZ
692\perlnote{Methods supported by wxPerl are:\par
693\begin{itemize}
606a3178
GT
694\item{bitmap->LoadFile( name, type )}
695\item{bitmap->LoadFile( name, mimetype )}
5873607e
VZ
696\end{itemize}
697}
698
f899db6d 699
1e6d9499
JS
700\membersection{wxImage::Ok}\label{wximageok}
701
702\constfunc{bool}{Ok}{\void}
703
cc81d32f 704Returns true if image data is present.
1e6d9499
JS
705
706\membersection{wxImage::RemoveHandler}
707
708\func{static bool}{RemoveHandler}{\param{const wxString\& }{name}}
709
710Finds the handler with the given name, and removes it. The handler
711is not deleted.
712
713\docparam{name}{The handler name.}
714
715\wxheading{Return value}
716
cc81d32f 717true if the handler was found and removed, false otherwise.
1e6d9499
JS
718
719\wxheading{See also}
720
721\helpref{wxImageHandler}{wximagehandler}
722
e119d049
JS
723\membersection{wxImage::Mirror}\label{wximagemirror}
724
725\constfunc{wxImage}{Mirror}{\param{bool}{ horizontally = true}}
726
727Returns a mirrored copy of the image. The parameter {\it horizontally}
728indicates the orientation.
729
730\membersection{wxImage::Replace}\label{wximagereplace}
731
732\func{void}{Replace}{\param{unsigned char}{ r1}, \param{unsigned char}{ g1}, \param{unsigned char}{ b1},
733\param{unsigned char}{ r2}, \param{unsigned char}{ g2}, \param{unsigned char}{ b2}}
734
735Replaces the colour specified by {\it r1,g1,b1} by the colour {\it r2,g2,b2}.
736
737\membersection{wxImage::Rescale}\label{wximagerescale}
738
739\func{wxImage \&}{Rescale}{\param{int}{ width}, \param{int}{ height}}
740
741Changes the size of the image in-place: after a call to this function, the
742image will have the given width and height.
743
744Returns the (modified) image itself.
745
746\wxheading{See also}
747
748\helpref{Scale}{wximagescale}
749
750\membersection{wxImage::Rotate}\label{wximagerotate}
751
752\func{wxImage}{Rotate}{\param{double}{ angle}, \param{const wxPoint\& }{rotationCentre},
753 \param{bool}{ interpolating = true}, \param{wxPoint*}{ offsetAfterRotation = NULL}}
754
755Rotates the image about the given point, by {\it angle} radians. Passing true
756to {\it interpolating} results in better image quality, but is slower. If the
757image has a mask, then the mask colour is used for the uncovered pixels in the
758rotated image background. Else, black (rgb 0, 0, 0) will be used.
759
760Returns the rotated image, leaving this image intact.
761
762\membersection{wxImage::Rotate90}\label{wximagerotate90}
763
764\constfunc{wxImage}{Rotate90}{\param{bool}{ clockwise = true}}
765
766Returns a copy of the image rotated 90 degrees in the direction
767indicated by {\it clockwise}.
768
1e6d9499
JS
769\membersection{wxImage::SaveFile}\label{wximagesavefile}
770
d7af2fea 771\constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{int}{ type}}
1e6d9499 772
d7af2fea 773\constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{const wxString\&}{ mimetype}}
9e9ee68e 774
4fa0a5b4
VS
775Saves an image in the named file.
776
777\constfunc{bool}{SaveFile}{\param{const wxString\& }{name}}
778
779Saves an image in the named file. File type is determined from the extension of the
780file name. Note that this function may fail if the extension is not recognized! You
781can use one of the forms above to save images to files with non-standard extensions.
1e6d9499 782
d7af2fea 783\constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{int}{ type}}
45b5751f 784
d7af2fea 785\constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{const wxString\&}{ mimetype}}
9e9ee68e 786
4fa0a5b4 787Saves an image in the given stream.
45b5751f 788
1e6d9499
JS
789\wxheading{Parameters}
790
31fd9b6b 791\docparam{name}{Name of the file to save the image to.}
1e6d9499 792
31fd9b6b 793\docparam{stream}{Opened output stream to save the image to.}
45b5751f 794
4fa0a5b4 795\docparam{type}{Currently these types can be used:
1e6d9499 796
6be663cf 797\twocolwidtha{5cm}%
1e6d9499 798\begin{twocollist}
4fa0a5b4 799\twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Save a BMP image file.}
48b4e302 800\twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Save a JPEG image file.}
31fd9b6b
GRG
801\twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Save a PNG image file.}
802\twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Save a PCX image file (tries to save as 8-bit if possible, falls back to 24-bit otherwise).}
803\twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Save a PNM image file (as raw RGB always).}
b86e511a
VS
804\twocolitem{{\bf wxBITMAP\_TYPE\_TIFF}}{Save a TIFF image file.}
805\twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Save a XPM image file.}
a61d25e6
VS
806\twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Save a Windows icon file (ICO) (the size may be up to 255 wide by 127 high. A single image is saved in 8 colors at the size supplied).}
807\twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Save a Windows cursor file (CUR).}
31fd9b6b 808\end{twocollist}}
1e6d9499 809
9e9ee68e
VS
810\docparam{mimetype}{MIME type.}
811
1e6d9499
JS
812\wxheading{Return value}
813
cc81d32f 814true if the operation succeeded, false otherwise.
1e6d9499
JS
815
816\wxheading{Remarks}
817
fc2171bd 818Depending on how wxWidgets has been configured, not all formats may be available.
1e6d9499 819
a61d25e6
VS
820Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to set the
821hotspot before saving an image into a cursor file (default hotspot is in
822the centre of the image):
823\begin{verbatim}
fd94e8aa
VS
824 image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, hotspotX);
825 image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotspotY);
a61d25e6
VS
826
827\end{verbatim}
828
1e6d9499
JS
829\wxheading{See also}
830
831\helpref{wxImage::LoadFile}{wximageloadfile}
832
f899db6d
RD
833\pythonnote{In place of a single overloaded method name, wxPython
834implements the following methods:\par
835\indented{2cm}{\begin{twocollist}
c9110876 836\twocolitem{{\bf SaveFile(filename, type)}}{Saves the image using the given
f899db6d 837type to the named file}
c9110876 838\twocolitem{{\bf SaveMimeFile(filename, mimetype)}}{Saves the image using the given
f899db6d
RD
839mimetype to the named file}
840\end{twocollist}}
841}
842
5873607e
VZ
843\perlnote{Methods supported by wxPerl are:\par
844\begin{itemize}
606a3178
GT
845\item{bitmap->SaveFile( name, type )}
846\item{bitmap->SaveFile( name, mimetype )}
5873607e
VZ
847\end{itemize}
848}
849
1e6d9499
JS
850\membersection{wxImage::Scale}\label{wximagescale}
851
ce9a75d2 852\constfunc{wxImage}{Scale}{\param{int}{ width}, \param{int}{ height}}
1e6d9499 853
12a44087
RR
854Returns a scaled version of the image. This is also useful for
855scaling bitmaps in general as the only other way to scale bitmaps
ce9a75d2
VZ
856is to blit a wxMemoryDC into another wxMemoryDC.
857
7468b994 858It may be mentioned that the GTK port uses this function internally
f6bcfd97 859to scale bitmaps when using mapping modes in wxDC.
ce9a75d2
VZ
860
861Example:
862
863\begin{verbatim}
864 // get the bitmap from somewhere
865 wxBitmap bmp = ...;
866
867 // rescale it to have size of 32*32
868 if ( bmp.GetWidth() != 32 || bmp.GetHeight() != 32 )
869 {
af494043 870 wxImage image = bmp.ConvertToImage();
b06a6b20 871 bmp = wxBitmap(image.Scale(32, 32));
ce9a75d2
VZ
872
873 // another possibility:
874 image.Rescale(32, 32);
875 bmp = image;
876 }
877
878\end{verbatim}
879
880\wxheading{See also}
881
882\helpref{Rescale}{wximagerescale}
1e6d9499 883
487659e0
VZ
884\membersection{wxImage::SetAlpha}\label{wximagesetalpha}
885
886\func{void}{SetAlpha}{\param{unsigned char *}{alpha = {\tt NULL}}}
887
888This function is similar to \helpref{SetData}{wximagesetdata} and has similar
889restrictions. The pointer passed to it may however be {\tt NULL} in which case
890the function will allocate the alpha array internally -- this is useful to add
891alpha channel data to an image which doesn't have any. If the pointer is not
892{\tt NULL}, it must have one byte for each image pixel and be allocated with
893{\tt malloc()}. wxImage takes ownership of the pointer and will free it.
894
895\func{void}{SetAlpha}{\param{int }{x}, \param{int }{y}, \param{unsigned char }{alpha}}
896
897Sets the alpha value for the given pixel. This function should only be called
898if the image has alpha channel data, use \helpref{HasAlpha}{wximagehasalpha} to
899check for this.
900
1e6d9499
JS
901\membersection{wxImage::SetData}\label{wximagesetdata}
902
903\func{void}{SetData}{\param{unsigned char*}{data}}
904
f899db6d 905Sets the image data without performing checks. The data given must have
12a44087
RR
906the size (width*height*3) or results will be unexpected. Don't use this
907method if you aren't sure you know what you are doing.
1e6d9499 908
b1ef8821 909The data must have been allocated with {\tt malloc()}, {\large {\bf NOT}} with
487659e0 910{\tt operator new}.
f811bc9a
MB
911
912After this call the pointer to the data is owned by the wxImage object,
913that will be responsible for deleting it.
914Do not pass to this function a pointer obtained through
915\helpref{wxImage::GetData}{wximagegetdata}.
916
1e6d9499
JS
917\membersection{wxImage::SetMask}\label{wximagesetmask}
918
cc81d32f 919\func{void}{SetMask}{\param{bool}{ hasMask = true}}
1e6d9499
JS
920
921Specifies whether there is a mask or not. The area of the mask is determined by the current mask colour.
922
923\membersection{wxImage::SetMaskColour}\label{wximagesetmaskcolour}
924
80793cda 925\func{void}{SetMaskColour}{\param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}}
1e6d9499 926
b1170810 927Sets the mask colour for this image (and tells the image to use the mask).
1e6d9499 928
37b83ca6
VS
929\membersection{wxImage::SetMaskFromImage}\label{wximagesetmaskfromimage}
930
931\func{bool}{SetMaskFromImage}{\param{const wxImage\&}{ mask}, \param{unsigned char}{ mr}, \param{unsigned char}{ mg}, \param{unsigned char}{ mb}}
932
933\wxheading{Parameters}
934
935\docparam{mask}{The mask image to extract mask shape from. Must have same dimensions as the image.}
936
937\docparam{mr,mg,mb}{RGB value of pixels in {\it mask} that will be used to create the mask.}
938
939Sets image's mask so that the pixels that have RGB value of {\it mr,mg,mb}
940in {\it mask} will be masked in the image. This is done by first finding an
941unused colour in the image, setting this colour as the mask colour and then
942using this colour to draw all pixels in the image who corresponding pixel
943in {\it mask} has given RGB value.
944
945\wxheading{Return value}
946
cc81d32f
VS
947Returns false if {\it mask} does not have same dimensions as the image or if
948there is no unused colour left. Returns true if the mask was successfully
37b83ca6
VS
949applied.
950
951\wxheading{Notes}
952
953Note that this method involves computing the histogram, which is
954computationally intensive operation.
955
5e5437e0
JS
956\membersection{wxImage::SetOption}\label{wximagesetoption}
957
958\func{void}{SetOption}{\param{const wxString\&}{ name}, \param{const wxString\&}{ value}}
959
960\func{void}{SetOption}{\param{const wxString\&}{ name}, \param{int}{ value}}
961
962Sets a user-defined option. The function is case-insensitive to {\it name}.
963
964For example, when saving as a JPEG file, the option {\bf quality} is
965used, which is a number between 0 and 100 (0 is terrible, 100 is very good).
966
967\wxheading{See also}
968
969\helpref{wxImage::GetOption}{wximagegetoption},\rtfsp
970\helpref{wxImage::GetOptionInt}{wximagegetoptionint},\rtfsp
971\helpref{wxImage::HasOption}{wximagehasoption}
972
3ca6a5f0
BP
973\membersection{wxImage::SetPalette}\label{wximagesetpalette}
974
975\func{void}{SetPalette}{\param{const wxPalette\&}{ palette}}
976
b06a6b20
VS
977Associates a palette with the image. The palette may be used when converting
978wxImage to wxBitmap (MSW only at present) or in file save operations (none as yet).
3ca6a5f0 979
1e6d9499
JS
980\membersection{wxImage::SetRGB}\label{wximagesetrgb}
981
f6bcfd97 982\func{void}{SetRGB}{\param{int }{x}, \param{int }{y}, \param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}}
1e6d9499 983
12a44087
RR
984Sets the pixel at the given coordinate. This routine performs bounds-checks
985for the coordinate so it can be considered a safe way to manipulate the
986data, but in some cases this might be too slow so that the data will have to
7468b994
RR
987be set directly. In that case you will have to get access to the image data
988using the \helpref{GetData}{wximagegetdata} method.
1e6d9499
JS
989
990\membersection{wxImage::operator $=$}
991
992\func{wxImage\& }{operator $=$}{\param{const wxImage\& }{image}}
993
994Assignment operator. This operator does not copy any data, but instead
995passes a pointer to the data in {\it image} and increments a reference
996counter. It is a fast operation.
997
998\wxheading{Parameters}
999
1000\docparam{image}{Image to assign.}
1001
1002\wxheading{Return value}
1003
1004Returns 'this' object.
1005
1006\membersection{wxImage::operator $==$}
1007
2b5f62a0 1008\constfunc{bool}{operator $==$}{\param{const wxImage\& }{image}}
1e6d9499
JS
1009
1010Equality operator. This operator tests whether the internal data pointers are
1011equal (a fast test).
1012
1013\wxheading{Parameters}
1014
1015\docparam{image}{Image to compare with 'this'}
1016
1017\wxheading{Return value}
1018
cc81d32f 1019Returns true if the images were effectively equal, false otherwise.
1e6d9499
JS
1020
1021\membersection{wxImage::operator $!=$}
1022
2b5f62a0 1023\constfunc{bool}{operator $!=$}{\param{const wxImage\& }{image}}
1e6d9499
JS
1024
1025Inequality operator. This operator tests whether the internal data pointers are
1026unequal (a fast test).
1027
1028\wxheading{Parameters}
1029
1030\docparam{image}{Image to compare with 'this'}
1031
1032\wxheading{Return value}
1033
cc81d32f 1034Returns true if the images were unequal, false otherwise.
1e6d9499
JS
1035
1036\section{\class{wxImageHandler}}\label{wximagehandler}
1037
1e6d9499
JS
1038This is the base class for implementing image file loading/saving, and image creation from data.
1039It is used within wxImage and is not normally seen by the application.
1040
1041If you wish to extend the capabilities of wxImage, derive a class from wxImageHandler
1042and add the handler using \helpref{wxImage::AddHandler}{wximageaddhandler} in your
1043application initialisation.
1044
48b4e302
VS
1045\wxheading{Note (Legal Issue)}
1046
954b8ae6 1047This software is based in part on the work of the Independent JPEG Group.
48b4e302 1048
fc2171bd 1049(Applies when wxWidgets is linked with JPEG support. wxJPEGHandler uses libjpeg
48b4e302
VS
1050created by IJG.)
1051
1e6d9499
JS
1052\wxheading{Derived from}
1053
1054\helpref{wxObject}{wxobject}
1055
954b8ae6
JS
1056\wxheading{Include files}
1057
1058<wx/image.h>
1059
1e6d9499
JS
1060\wxheading{See also}
1061
fa482912 1062\helpref{wxImage}{wximage},
b5a4a47d 1063\helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}
1e6d9499
JS
1064
1065\latexignore{\rtfignore{\wxheading{Members}}}
1066
1067\membersection{wxImageHandler::wxImageHandler}\label{wximagehandlerconstr}
1068
1069\func{}{wxImageHandler}{\void}
1070
1071Default constructor. In your own default constructor, initialise the members
1072m\_name, m\_extension and m\_type.
1073
1074\membersection{wxImageHandler::\destruct{wxImageHandler}}
1075
1076\func{}{\destruct{wxImageHandler}}{\void}
1077
1078Destroys the wxImageHandler object.
1079
1080\membersection{wxImageHandler::GetName}
1081
1082\constfunc{wxString}{GetName}{\void}
1083
1084Gets the name of this handler.
1085
1086\membersection{wxImageHandler::GetExtension}
1087
1088\constfunc{wxString}{GetExtension}{\void}
1089
1090Gets the file extension associated with this handler.
1091
649d13e8 1092\membersection{wxImageHandler::GetImageCount}\label{wximagehandlergetimagecount}
7941ba11 1093
649d13e8 1094\func{int}{GetImageCount}{\param{wxInputStream\&}{ stream}}
7941ba11
RR
1095
1096If the image file contains more than one image and the image handler is capable
1097of retrieving these individually, this function will return the number of
1098available images.
1099
31fd9b6b 1100\docparam{stream}{Opened input stream for reading image data. Currently, the stream must support seeking.}
7941ba11
RR
1101
1102\wxheading{Return value}
1103
a61d25e6
VS
1104Number of available images. For most image handlers, this is 1 (exceptions
1105are TIFF and ICO formats).
7941ba11 1106
1e6d9499
JS
1107\membersection{wxImageHandler::GetType}
1108
1109\constfunc{long}{GetType}{\void}
1110
1111Gets the image type associated with this handler.
1112
9e9ee68e
VS
1113\membersection{wxImageHandler::GetMimeType}
1114
1115\constfunc{wxString}{GetMimeType}{\void}
1116
1117Gets the MIME type associated with this handler.
1118
1e6d9499
JS
1119\membersection{wxImageHandler::LoadFile}\label{wximagehandlerloadfile}
1120
cc81d32f 1121\func{bool}{LoadFile}{\param{wxImage* }{image}, \param{wxInputStream\&}{ stream}, \param{bool}{ verbose=true}, \param{int}{ index=0}}
1e6d9499 1122
7941ba11
RR
1123Loads a image from a stream, putting the resulting data into {\it image}. If the image file contains
1124more than one image and the image handler is capable of retrieving these individually, {\it index}
1125indicates which image to read from the stream.
1e6d9499
JS
1126
1127\wxheading{Parameters}
1128
1129\docparam{image}{The image object which is to be affected by this operation.}
1130
31fd9b6b 1131\docparam{stream}{Opened input stream for reading image data.}
7941ba11 1132
cc81d32f 1133\docparam{verbose}{If set to true, errors reported by the image handler will produce wxLogMessages.}
7941ba11
RR
1134
1135\docparam{index}{The index of the image in the file (starting from zero).}
1e6d9499
JS
1136
1137\wxheading{Return value}
1138
cc81d32f 1139true if the operation succeeded, false otherwise.
1e6d9499
JS
1140
1141\wxheading{See also}
1142
fa482912
JS
1143\helpref{wxImage::LoadFile}{wximageloadfile},
1144\helpref{wxImage::SaveFile}{wximagesavefile},
1e6d9499
JS
1145\helpref{wxImageHandler::SaveFile}{wximagehandlersavefile}
1146
1147\membersection{wxImageHandler::SaveFile}\label{wximagehandlersavefile}
1148
45b5751f 1149\func{bool}{SaveFile}{\param{wxImage* }{image}, \param{wxOutputStream\& }{stream}}
1e6d9499 1150
45b5751f 1151Saves a image in the output stream.
1e6d9499
JS
1152
1153\wxheading{Parameters}
1154
1155\docparam{image}{The image object which is to be affected by this operation.}
1156
31fd9b6b 1157\docparam{stream}{Opened output stream for writing the data.}
1e6d9499
JS
1158
1159\wxheading{Return value}
1160
cc81d32f 1161true if the operation succeeded, false otherwise.
1e6d9499
JS
1162
1163\wxheading{See also}
1164
fa482912
JS
1165\helpref{wxImage::LoadFile}{wximageloadfile},
1166\helpref{wxImage::SaveFile}{wximagesavefile},
1e6d9499
JS
1167\helpref{wxImageHandler::LoadFile}{wximagehandlerloadfile}
1168
1169\membersection{wxImageHandler::SetName}
1170
1171\func{void}{SetName}{\param{const wxString\& }{name}}
1172
1173Sets the handler name.
1174
1175\wxheading{Parameters}
1176
1177\docparam{name}{Handler name.}
1178
1179\membersection{wxImageHandler::SetExtension}
1180
1181\func{void}{SetExtension}{\param{const wxString\& }{extension}}
1182
1183Sets the handler extension.
1184
1185\wxheading{Parameters}
1186
1187\docparam{extension}{Handler extension.}
1188
f6bcfd97 1189\membersection{wxImageHandler::SetMimeType}\label{wximagehandlersetmimetype}
1e6d9499 1190
f6bcfd97 1191\func{void}{SetMimeType}{\param{const wxString\& }{mimetype}}
1e6d9499 1192
f6bcfd97 1193Sets the handler MIME type.
1e6d9499
JS
1194
1195\wxheading{Parameters}
1196
f6bcfd97 1197\docparam{mimename}{Handler MIME type.}
9e9ee68e 1198
f6bcfd97 1199\membersection{wxImageHandler::SetType}
9e9ee68e 1200
f6bcfd97 1201\func{void}{SetType}{\param{long }{type}}
9e9ee68e 1202
f6bcfd97 1203Sets the handler type.
9e9ee68e
VS
1204
1205\wxheading{Parameters}
1206
f6bcfd97 1207\docparam{name}{Handler type.}
9e9ee68e 1208