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