]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/image.tex
Added wxWrapSizer (modified patch: [1826950] Wrapping Sizer) from Arne Steinarson
[wxWidgets.git] / docs / latex / wx / image.tex
CommitLineData
ce045aed
WS
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%% Name: image.tex
3%% Purpose: wxImage documentation
4%% Author: wxWidgets Team
5%% Modified by:
6%% Created:
7%% RCS-ID: $Id$
8%% Copyright: (c) wxWidgets Team
9%% License: wxWindows license
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
1e6d9499
JS
12\section{\class{wxImage}}\label{wximage}
13
14This class encapsulates a platform-independent image. An image can be created
b06a6b20 15from data, or using \helpref{wxBitmap::ConvertToImage}{wxbitmapconverttoimage}. An image
1e6d9499
JS
16can be loaded from a file in a variety of formats, and is extensible to new formats
17via image format handlers. Functions are available to set and get image bits, so
18it can be used for basic image manipulation.
19
ce045aed 20A wxImage cannot (currently) be drawn directly to a \helpref{wxDC}{wxdc}. Instead,
7468b994 21a platform-specific \helpref{wxBitmap}{wxbitmap} object must be created from it using
ce045aed 22the \helpref{wxBitmap::wxBitmap(wxImage,int depth)}{wxbitmapctor} constructor.
b06a6b20 23This bitmap can then
7468b994
RR
24be drawn in a device context, using \helpref{wxDC::DrawBitmap}{wxdcdrawbitmap}.
25
26One colour value of the image may be used as a mask colour which will lead to the automatic
27creation of a \helpref{wxMask}{wxmask} object associated to the bitmap object.
12a44087 28
487659e0
VZ
29\wxheading{Alpha channel support}
30
fc2171bd 31Starting from wxWidgets 2.5.0 wxImage supports alpha channel data, that is in
487659e0 32addition to a byte for the red, green and blue colour components for each pixel
e0cb07e3
DS
33it also stores a byte representing the pixel opacity. An alpha value of $0$
34corresponds to a transparent pixel (null opacity) while a value of $255$
487659e0
VZ
35means that the pixel is 100\% opaque.
36
ce045aed 37Unlike RGB data, not all images have an alpha channel and before using
487659e0 38\helpref{GetAlpha}{wximagegetalpha} you should check if this image contains
c3316efa
VZ
39an alpha channel with \helpref{HasAlpha}{wximagehasalpha}. Note that currently
40only the PNG format has full alpha channel support so only the images loaded
41from PNG files can have alpha and, if you initialize the image alpha channel
42yourself using \helpref{SetAlpha}{wximagesetalpha}, you should save it in PNG
43format to avoid losing it.
44
487659e0 45
8727a1fe
GRG
46\wxheading{Available image handlers}
47
48The following image handlers are available. {\bf wxBMPHandler} is always
2edb0bde 49installed by default. To use other image formats, install the appropriate
3af706cc 50handler with \helpref{wxImage::AddHandler}{wximageaddhandler} or call
8727a1fe
GRG
51\helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}.
52
53\twocolwidtha{5cm}%
54\begin{twocollist}
4fa0a5b4 55\twocolitem{\indexit{wxBMPHandler}}{For loading and saving, always installed.}
487659e0 56\twocolitem{\indexit{wxPNGHandler}}{For loading (including alpha support) and saving.}
606a3178
GT
57\twocolitem{\indexit{wxJPEGHandler}}{For loading and saving.}
58\twocolitem{\indexit{wxGIFHandler}}{Only for loading, due to legal issues.}
59\twocolitem{\indexit{wxPCXHandler}}{For loading and saving (see below).}
60\twocolitem{\indexit{wxPNMHandler}}{For loading and saving (see below).}
b86e511a 61\twocolitem{\indexit{wxTIFFHandler}}{For loading and saving.}
3af706cc 62\twocolitem{\indexit{wxTGAHandler}}{For loading only.}
4fa0a5b4 63\twocolitem{\indexit{wxIFFHandler}}{For loading only.}
b86e511a 64\twocolitem{\indexit{wxXPMHandler}}{For loading and saving.}
37b83ca6 65\twocolitem{\indexit{wxICOHandler}}{For loading and saving.}
a61d25e6 66\twocolitem{\indexit{wxCURHandler}}{For loading and saving.}
4fa0a5b4 67\twocolitem{\indexit{wxANIHandler}}{For loading only.}
8727a1fe
GRG
68\end{twocollist}
69
70When saving in PCX format, {\bf wxPCXHandler} will count the number of
71different colours in the image; if there are 256 or less colours, it will
72save as 8 bit, else it will save as 24 bit.
73
74Loading PNMs only works for ASCII or raw RGB images. When saving in
75PNM format, {\bf wxPNMHandler} will always save as raw RGB.
76
1e6d9499
JS
77\wxheading{Derived from}
78
79\helpref{wxObject}{wxobject}
80
954b8ae6
JS
81\wxheading{Include files}
82
83<wx/image.h>
84
a7af285d
VZ
85\wxheading{Library}
86
87\helpref{wxCore}{librarieslist}
88
1e6d9499
JS
89\wxheading{See also}
90
ce045aed 91\helpref{wxBitmap}{wxbitmap},
b5a4a47d 92\helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}
1e6d9499
JS
93
94\latexignore{\rtfignore{\wxheading{Members}}}
95
07d0abae 96
f0e8a2d0 97\membersection{wxImage::wxImage}\label{wximagector}
1e6d9499
JS
98
99\func{}{wxImage}{\void}
100
101Default constructor.
102
103\func{}{wxImage}{\param{const wxImage\& }{image}}
104
a91225b2 105Copy constructor, uses \helpref{reference counting}{trefcount}.
1e6d9499
JS
106
107\func{}{wxImage}{\param{const wxBitmap\&}{ bitmap}}
108
b06a6b20
VS
109(Deprecated form, use \helpref{wxBitmap::ConvertToImage}{wxbitmapconverttoimage}
110instead.) Constructs an image from a platform-dependent bitmap. This preserves
12a44087
RR
111mask information so that bitmaps and images can be converted back
112and forth without loss in that respect.
1e6d9499 113
ff865c13 114\func{}{wxImage}{\param{int}{ width}, \param{int}{ height}, \param{bool}{ clear=true}}
1e6d9499 115
ff865c13
JS
116Creates an image with the given width and height. If {\it clear} is true, the new image will be initialized to black.
117Otherwise, the image data will be uninitialized.
1e6d9499 118
60b1fda2 119\func{}{wxImage}{\param{int}{ width}, \param{int}{ height}, \param{unsigned char*}{ data}, \param{bool}{ static\_data = \false}}
f6bcfd97 120
ce045aed 121Creates an image from given data with the given width and height. If
cc81d32f 122{\it static\_data} is true, then wxImage will not delete the actual
f6bcfd97
BP
123image data in its destructor, otherwise it will free it by calling
124{\it free()}.
125
a61d25e6 126\func{}{wxImage}{\param{const wxString\& }{name}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}, \param{int}{ index = -1}}
1e6d9499 127
a61d25e6 128\func{}{wxImage}{\param{const wxString\& }{name}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}
9e9ee68e 129
1e6d9499
JS
130Loads an image from a file.
131
a61d25e6 132\func{}{wxImage}{\param{wxInputStream\& }{stream}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}, \param{int}{ index = -1}}
45b5751f 133
a61d25e6 134\func{}{wxImage}{\param{wxInputStream\& }{stream}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}
9e9ee68e 135
45b5751f
JS
136Loads an image from an input stream.
137
452418c4 138\func{}{wxImage}{\param{const char* const* }{xpmData}}
7ab37822
JS
139
140Creates an image from XPM data.
141
1e6d9499
JS
142\wxheading{Parameters}
143
144\docparam{width}{Specifies the width of the image.}
145
146\docparam{height}{Specifies the height of the image.}
147
31fd9b6b 148\docparam{name}{Name of the file from which to load the image.}
1e6d9499 149
31fd9b6b 150\docparam{stream}{Opened input stream from which to load the image. Currently, the stream must support seeking.}
45b5751f 151
1e6d9499
JS
152\docparam{type}{May be one of the following:
153
6be663cf 154\twocolwidtha{5cm}%
1e6d9499 155\begin{twocollist}
606a3178
GT
156\twocolitem{\indexit{wxBITMAP\_TYPE\_BMP}}{Load a Windows bitmap file.}
157\twocolitem{\indexit{wxBITMAP\_TYPE\_GIF}}{Load a GIF bitmap file.}
158\twocolitem{\indexit{wxBITMAP\_TYPE\_JPEG}}{Load a JPEG bitmap file.}
159\twocolitem{\indexit{wxBITMAP\_TYPE\_PNG}}{Load a PNG bitmap file.}
160\twocolitem{\indexit{wxBITMAP\_TYPE\_PCX}}{Load a PCX bitmap file.}
161\twocolitem{\indexit{wxBITMAP\_TYPE\_PNM}}{Load a PNM bitmap file.}
162\twocolitem{\indexit{wxBITMAP\_TYPE\_TIF}}{Load a TIFF bitmap file.}
3af706cc 163\twocolitem{\indexit{wxBITMAP\_TYPE\_TGA}}{Load a TGA bitmap file.}
b86e511a 164\twocolitem{\indexit{wxBITMAP\_TYPE\_XPM}}{Load a XPM bitmap file.}
a61d25e6
VS
165\twocolitem{\indexit{wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
166\twocolitem{\indexit{wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
658974ae 167\twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
606a3178 168\twocolitem{\indexit{wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
31fd9b6b 169\end{twocollist}}
1e6d9499 170
9e9ee68e
VS
171\docparam{mimetype}{MIME type string (for example 'image/jpeg')}
172
a61d25e6 173\docparam{index}{Index of the image to load in the case that the image file contains multiple images.
ce045aed
WS
174This is only used by GIF, ICO and TIFF handlers. The default value (-1) means
175"choose the default image" and is interpreted as the first image (index=0) by
b931f7ee 176the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.}
a61d25e6 177
7ab37822
JS
178\docparam{xpmData}{A pointer to XPM image data.}
179
31fd9b6b
GRG
180\wxheading{Remarks}
181
fc2171bd 182Depending on how wxWidgets has been configured, not all formats may be available.
31fd9b6b 183
fa482912 184Note: any handler other than BMP must be previously
ce045aed 185initialized with \helpref{wxImage::AddHandler}{wximageaddhandler} or
31fd9b6b 186\helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}.
0a9f2522 187
ce045aed 188Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to get the
a61d25e6
VS
189hotspot for loaded cursor file:
190\begin{verbatim}
fd94e8aa
VS
191 int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
192 int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
a61d25e6
VS
193
194\end{verbatim}
195
1e6d9499
JS
196\wxheading{See also}
197
198\helpref{wxImage::LoadFile}{wximageloadfile}
199
f899db6d
RD
200\pythonnote{Constructors supported by wxPython are:\par
201\indented{2cm}{\begin{twocollist}
c9110876
VS
202\twocolitem{{\bf wxImage(name, flag)}}{Loads an image from a file}
203\twocolitem{{\bf wxNullImage()}}{Create a null image (has no size or
f899db6d 204image data)}
c9110876 205\twocolitem{{\bf wxEmptyImage(width, height)}}{Creates an empty image
f899db6d 206of the given size}
c9110876 207\twocolitem{{\bf wxImageFromMime(name, mimetype}}{Creates an image from
f899db6d 208the given file of the given mimetype}
c9110876 209\twocolitem{{\bf wxImageFromBitmap(bitmap)}}{Creates an image from a
f899db6d
RD
210platform-dependent bitmap}
211\end{twocollist}}
212}
213
5873607e
VZ
214\perlnote{Constructors supported by wxPerl are:\par
215\begin{itemize}
216\item{Wx::Image->new( bitmap )}
25e4b4bf 217\item{Wx::Image->new( icon )}
5873607e 218\item{Wx::Image->new( width, height )}
25e4b4bf
MB
219\item{Wx::Image->new( width, height, data )}
220\item{Wx::Image->new( file, type, index )}
221\item{Wx::Image->new( file, mimetype, index )}
222\item{Wx::Image->new( stream, type, index )}
223\item{Wx::Image->new( stream, mimetype, index )}
5873607e
VZ
224\end{itemize}
225}
226
07d0abae 227
f0e8a2d0 228\membersection{wxImage::\destruct{wxImage}}\label{wximagedtor}
1e6d9499
JS
229
230\func{}{\destruct{wxImage}}{\void}
231
232Destructor.
55ccdb93 233See \helpref{reference-counted object destruction}{refcountdestruct} for more info.
1e6d9499 234
07d0abae 235
1e6d9499
JS
236\membersection{wxImage::AddHandler}\label{wximageaddhandler}
237
238\func{static void}{AddHandler}{\param{wxImageHandler*}{ handler}}
239
240Adds a handler to the end of the static list of format handlers.
241
242\docparam{handler}{A new image format handler object. There is usually only one instance
243of a given handler class in an application session.}
244
245\wxheading{See also}
246
247\helpref{wxImageHandler}{wximagehandler}
248
4fa0a5b4
VS
249\func{bool}{CanRead}{\param{const wxString\&}{ filename}}
250
cc81d32f 251returns true if the current image handlers can read this file
4fa0a5b4 252
e7240349 253\pythonnote{In wxPython this static method is named {\tt wxImage\_AddHandler}.}
07d0abae 254
07aaa1a4
RR
255
256\membersection{wxImage::Blur}\label{wximageblur}
257
258\func{wxImage}{Blur}{\param{int}{ blurRadius}}
259
f164c52b
RR
260Blurs the image in both horizontal and vertical directions by the specified pixel
261{\it blurRadius}. This should not be used when using a single mask colour
262for transparency.
07aaa1a4
RR
263
264\wxheading{See also}
265
266\helpref{BlurHorizontal}{wximagehorzblur}
267\helpref{BlurVertical}{wximagevertblur}
268
269
270\membersection{wxImage::BlurHorizontal}\label{wximagehorzblur}
271
272\func{wxImage}{BlurHorizontal}{\param{int}{ blurRadius}}
273
f164c52b
RR
274Blurs the image in the horizontal direction only. This should not be used
275when using a single mask colour for transparency.
07aaa1a4
RR
276\wxheading{See also}
277
278\helpref{Blur}{wximageblur}
279\helpref{BlurVertical}{wximagevertblur}
280
281
282\membersection{wxImage::BlurVertical}\label{wximagevertblur}
283
284\func{wxImage}{BlurVertical}{\param{int}{ blurRadius}}
285
f164c52b
RR
286Blurs the image in the vertical direction only. This should not be used
287when using a single mask colour for transparency.
07aaa1a4
RR
288
289\wxheading{See also}
290
291\helpref{Blur}{wximageblur}
292\helpref{BlurHorizontal}{wximagehorzblur}
293
294
f0e8a2d0 295\membersection{wxImage::CleanUpHandlers}\label{wximagecleanuphandlers}
1e6d9499
JS
296
297\func{static void}{CleanUpHandlers}{\void}
298
299Deletes all image handlers.
300
fc2171bd 301This function is called by wxWidgets on exit.
1e6d9499 302
07d0abae 303
d7af2fea
VS
304\membersection{wxImage::ComputeHistogram}\label{wximagecomputehistogram}
305
306\constfunc{unsigned long}{ComputeHistogram}{\param{wxImageHistogram\& }{histogram}}
307
ce045aed
WS
308Computes the histogram of the image. {\it histogram} is a reference to
309wxImageHistogram object. wxImageHistogram is a specialization of
d7af2fea
VS
310\helpref{wxHashMap}{wxhashmap} "template" and is defined as follows:
311
312\begin{verbatim}
313class WXDLLEXPORT wxImageHistogramEntry
314{
315public:
316 wxImageHistogramEntry() : index(0), value(0) {}
317 unsigned long index;
318 unsigned long value;
319};
320
321WX_DECLARE_EXPORTED_HASH_MAP(unsigned long, wxImageHistogramEntry,
322 wxIntegerHash, wxIntegerEqual,
323 wxImageHistogram);
324\end{verbatim}
325
326\wxheading{Return value}
327
328Returns number of colours in the histogram.
329
07d0abae 330
ff5ad794
VS
331\membersection{wxImage::ConvertAlphaToMask}\label{wximageconvertalphatomask}
332
21dc4be5 333\func{bool}{ConvertAlphaToMask}{\param{unsigned char}{ threshold = $128$}}
ff5ad794
VS
334
335If the image has alpha channel, this method converts it to mask. All pixels
336with alpha value less than \arg{threshold} are replaced with mask colour
337and the alpha channel is removed. Mask colour is chosen automatically using
338\helpref{FindFirstUnusedColour}{wximagefindfirstunusedcolour}.
339
340If the image image doesn't have alpha channel,
341ConvertAlphaToMask does nothing.
342
343\wxheading{Return value}
344
ce045aed 345\false if FindFirstUnusedColour returns \false, \true otherwise.
ff5ad794 346
07d0abae 347
1e6d9499
JS
348\membersection{wxImage::ConvertToBitmap}\label{wximageconverttobitmap}
349
350\constfunc{wxBitmap}{ConvertToBitmap}{\void}
351
f510b7b2 352Deprecated, use equivalent \helpref{wxBitmap constructor}{wxbitmapctor}
b06a6b20 353(which takes wxImage and depth as its arguments) instead.
7468b994 354
07d0abae 355
ec85956a
JS
356\membersection{wxImage::ConvertToGreyscale}\label{wximageconverttogreyscale}
357
358\constfunc{wxImage}{ConvertToGreyscale}{\param{double}{ lr = 0.299}, \param{double}{ lg = 0.587}, \param{double}{ lb = 0.114}}
359
360Returns a greyscale version of the image. The returned image uses the luminance
361component of the original to calculate the greyscale. Defaults to using
362ITU-T BT.601 when converting to YUV, where every pixel equals
363(R * {\it lr}) + (G * {\it lg}) + (B * {\it lb}).
364
365
b06a6b20 366\membersection{wxImage::ConvertToMono}\label{wxbitmapconverttomono}
1e6d9499 367
b06a6b20
VS
368\constfunc{wxImage}{ConvertToMono}{\param{unsigned char}{ r}, \param{unsigned char}{ g}, \param{unsigned char}{ b}}
369
370Returns monochromatic version of the image. The returned image has white
ce045aed 371colour where the original has {\it (r,g,b)} colour and black colour
b06a6b20 372everywhere else.
3ca6a5f0 373
07d0abae 374
f6bcfd97
BP
375\membersection{wxImage::Copy}\label{wximagecopy}
376
377\constfunc{wxImage}{Copy}{\void}
378
379Returns an identical copy of the image.
380
07d0abae 381
1e6d9499
JS
382\membersection{wxImage::Create}\label{wximagecreate}
383
ff865c13 384\func{bool}{Create}{\param{int}{ width}, \param{int}{ height}, \param{bool}{ clear=true}}
1e6d9499 385
ff865c13
JS
386Creates a fresh image. If {\it clear} is true, the new image will be initialized to black.
387Otherwise, the image data will be uninitialized.
1e6d9499
JS
388
389\wxheading{Parameters}
390
391\docparam{width}{The width of the image in pixels.}
392
393\docparam{height}{The height of the image in pixels.}
394
395\wxheading{Return value}
396
cc81d32f 397true if the call succeeded, false otherwise.
1e6d9499 398
07d0abae 399
1e6d9499
JS
400\membersection{wxImage::Destroy}\label{wximagedestroy}
401
f6e9a818 402\func{void}{Destroy}{\void}
1e6d9499
JS
403
404Destroys the image data.
405
07d0abae 406
37b83ca6
VS
407\membersection{wxImage::FindFirstUnusedColour}\label{wximagefindfirstunusedcolour}
408
409\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}}
410
411\wxheading{Parameters}
412
413\docparam{r,g,b}{Pointers to variables to save the colour.}
414
415\docparam{startR,startG,startB}{Initial values of the colour. Returned colour
416will have RGB values equal to or greater than these.}
417
418Finds the first colour that is never used in the image. The search begins at
419given initial colour and continues by increasing R, G and B components (in this
420order) by 1 until an unused colour is found or the colour space exhausted.
421
422\wxheading{Return value}
423
cc81d32f 424Returns false if there is no unused colour left, true on success.
37b83ca6
VS
425
426\wxheading{Notes}
427
428Note that this method involves computing the histogram, which is
429computationally intensive operation.
430
07d0abae 431
f0e8a2d0 432\membersection{wxImage::FindHandler}\label{wximagefindhandler}
1e6d9499
JS
433
434\func{static wxImageHandler*}{FindHandler}{\param{const wxString\& }{name}}
435
436Finds the handler with the given name.
437
438\func{static wxImageHandler*}{FindHandler}{\param{const wxString\& }{extension}, \param{long}{ imageType}}
439
440Finds the handler associated with the given extension and type.
441
442\func{static wxImageHandler*}{FindHandler}{\param{long }{imageType}}
443
444Finds the handler associated with the given image type.
445
9e9ee68e
VS
446\func{static wxImageHandler*}{FindHandlerMime}{\param{const wxString\& }{mimetype}}
447
448Finds the handler associated with the given MIME type.
449
1e6d9499
JS
450\docparam{name}{The handler name.}
451
452\docparam{extension}{The file extension, such as ``bmp".}
453
f6fcbb63 454\docparam{imageType}{The image type, such as wxBITMAP\_TYPE\_BMP.}
1e6d9499 455
9e9ee68e
VS
456\docparam{mimetype}{MIME type.}
457
1e6d9499
JS
458\wxheading{Return value}
459
460A pointer to the handler if found, NULL otherwise.
461
462\wxheading{See also}
463
464\helpref{wxImageHandler}{wximagehandler}
465
07d0abae 466
f0e8a2d0 467\membersection{wxImage::GetImageExtWildcard}\label{wximagegetimageextwildcard}
939fadc8
JS
468
469\func{static wxString}{GetImageExtWildcard}{\void}
470
471Iterates all registered wxImageHandler objects, and returns a string containing file extension masks
472suitable for passing to file open/save dialog boxes.
473
474\wxheading{Return value}
475
476The format of the returned string is "(*.ext1;*.ext2)|*.ext1;*.ext2".
477
478It is usually a good idea to prepend a description before passing the result to the dialog.
479
480Example:
481
482\begin{verbatim}
f4f5d569 483 wxFileDialog FileDlg( this, "Choose Image", ::wxGetCwd(), "", _("Image Files ") + wxImage::GetImageExtWildcard(), wxFD_OPEN );
939fadc8
JS
484\end{verbatim}
485
486\wxheading{See also}
487
488\helpref{wxImageHandler}{wximagehandler}
489
07d0abae 490
487659e0
VZ
491\membersection{wxImage::GetAlpha}\label{wximagegetalpha}
492
493\constfunc{unsigned char}{GetAlpha}{\param{int}{ x}, \param{int}{ y}}
494
495Returns the alpha value for the given pixel. This function may only be called
496for the images with alpha channel, use \helpref{HasAlpha}{wximagehasalpha} to
497check for this.
498
499The returned value is the {\it opacity} of the image, i.e. the value of $0$
500corresponds to the transparent pixels while the value of $255$ -- to the opaque
501ones.
502
503\constfunc{unsigned char *}{GetAlpha}{\void}
504
505Returns pointer to the array storing the alpha values for this image. This
506pointer is {\tt NULL} for the images without the alpha channel. If the image
507does have it, this pointer may be used to directly manipulate the alpha values
508which are stored as the \helpref{RGB}{wximagegetdata} ones.
509
07d0abae 510
1e6d9499
JS
511\membersection{wxImage::GetBlue}\label{wximagegetblue}
512
513\constfunc{unsigned char}{GetBlue}{\param{int}{ x}, \param{int}{ y}}
514
515Returns the blue intensity at the given coordinate.
516
07d0abae 517
1e6d9499
JS
518\membersection{wxImage::GetData}\label{wximagegetdata}
519
520\constfunc{unsigned char*}{GetData}{\void}
521
12a44087
RR
522Returns the image data as an array. This is most often used when doing
523direct image manipulation. The return value points to an array of
487659e0 524characters in RGBRGBRGB$\ldots$ format in the top-to-bottom, left-to-right
6028be3f
VZ
525order, that is the first RGB triplet corresponds to the pixel first pixel of
526the first row, the second one --- to the second pixel of the first row and so
527on until the end of the first row, with second row following after it and so
528on.
1e6d9499 529
f811bc9a
MB
530You should not delete the returned pointer nor pass it to
531\helpref{wxImage::SetData}{wximagesetdata}.
532
07d0abae 533
1e6d9499
JS
534\membersection{wxImage::GetGreen}\label{wximagegetgreen}
535
536\constfunc{unsigned char}{GetGreen}{\param{int}{ x}, \param{int}{ y}}
537
538Returns the green intensity at the given coordinate.
539
07d0abae 540
649d13e8 541\membersection{wxImage::GetImageCount}\label{wximagegetimagecount}
a61d25e6 542
649d13e8 543\func{static int}{GetImageCount}{\param{const wxString\&}{ filename}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}}
a61d25e6 544
649d13e8 545\func{static int}{GetImageCount}{\param{wxInputStream\&}{ stream}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}}
a61d25e6 546
ce045aed 547If the image file contains more than one image and the image handler is capable
a61d25e6
VS
548of retrieving these individually, this function will return the number of
549available images.
550
551\docparam{name}{Name of the file to query.}
552
553\docparam{stream}{Opened input stream with image data. Currently, the stream must support seeking.}
554
555\docparam{type}{May be one of the following:
556
557\twocolwidtha{5cm}%
558\begin{twocollist}
559\twocolitem{\indexit{wxBITMAP\_TYPE\_BMP}}{Load a Windows bitmap file.}
560\twocolitem{\indexit{wxBITMAP\_TYPE\_GIF}}{Load a GIF bitmap file.}
561\twocolitem{\indexit{wxBITMAP\_TYPE\_JPEG}}{Load a JPEG bitmap file.}
562\twocolitem{\indexit{wxBITMAP\_TYPE\_PNG}}{Load a PNG bitmap file.}
563\twocolitem{\indexit{wxBITMAP\_TYPE\_PCX}}{Load a PCX bitmap file.}
564\twocolitem{\indexit{wxBITMAP\_TYPE\_PNM}}{Load a PNM bitmap file.}
565\twocolitem{\indexit{wxBITMAP\_TYPE\_TIF}}{Load a TIFF bitmap file.}
566\twocolitem{\indexit{wxBITMAP\_TYPE\_XPM}}{Load a XPM bitmap file.}
567\twocolitem{\indexit{wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
568\twocolitem{\indexit{wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
658974ae 569\twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
a61d25e6
VS
570\twocolitem{\indexit{wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
571\end{twocollist}}
572
573\wxheading{Return value}
574
575Number of available images. For most image handlers, this is 1 (exceptions
576are TIFF and ICO formats).
577
07d0abae 578
f0e8a2d0 579\membersection{wxImage::GetHandlers}\label{wximagegethandlers}
1e6d9499
JS
580
581\func{static wxList\&}{GetHandlers}{\void}
582
583Returns the static list of image format handlers.
584
585\wxheading{See also}
586
587\helpref{wxImageHandler}{wximagehandler}
588
07d0abae 589
1e6d9499
JS
590\membersection{wxImage::GetHeight}\label{wximagegetheight}
591
592\constfunc{int}{GetHeight}{\void}
593
594Gets the height of the image in pixels.
595
07d0abae 596
1e6d9499
JS
597\membersection{wxImage::GetMaskBlue}\label{wximagegetmaskblue}
598
599\constfunc{unsigned char}{GetMaskBlue}{\void}
600
601Gets the blue value of the mask colour.
602
07d0abae 603
1e6d9499
JS
604\membersection{wxImage::GetMaskGreen}\label{wximagegetmaskgreen}
605
606\constfunc{unsigned char}{GetMaskGreen}{\void}
607
608Gets the green value of the mask colour.
609
07d0abae 610
1e6d9499
JS
611\membersection{wxImage::GetMaskRed}\label{wximagegetmaskred}
612
613\constfunc{unsigned char}{GetMaskRed}{\void}
614
615Gets the red value of the mask colour.
616
07d0abae 617
b737ad10
RR
618\membersection{wxImage::GetOrFindMaskColour}\label{wximagegetgetorsetmaskcolour}
619
620\constfunc{bool}{GetOrFindMaskColour}{\param{unsigned char}{ *r}, \param{unsigned char}{ *g}, \param{unsigned char}{ *b}}
621
ce045aed 622Get the current mask colour or find a suitable unused colour that could be
b737ad10
RR
623used as a mask colour. Returns {\tt true} if the image currently has a mask.
624
625
3ca6a5f0
BP
626\membersection{wxImage::GetPalette}\label{wximagegetpalette}
627
628\constfunc{const wxPalette\&}{GetPalette}{\void}
629
630Returns the palette associated with the image. Currently the palette is only
df816ad9
RR
631used when converting to wxBitmap under Windows. Some of the wxImage handlers
632have been modified to set the palette if one exists in the image file (usually
633256 or less colour images in GIF or PNG format).
3ca6a5f0 634
07d0abae 635
7b4c3149
VZ
636\membersection{wxImage::GetRed}\label{wximagegetred}
637
638\constfunc{unsigned char}{GetRed}{\param{int}{ x}, \param{int}{ y}}
639
640Returns the red intensity at the given coordinate.
641
07d0abae 642
fc9c7c09
RR
643\membersection{wxImage::GetSubImage}\label{wximagegetsubimage}
644
7468b994 645\constfunc{wxImage}{GetSubImage}{\param{const wxRect\&}{ rect}}
fc9c7c09 646
ce045aed 647Returns a sub image of the current one as long as the rect belongs entirely to
fc9c7c09
RR
648the image.
649
07d0abae 650
1e6d9499
JS
651\membersection{wxImage::GetWidth}\label{wximagegetwidth}
652
653\constfunc{int}{GetWidth}{\void}
654
655Gets the width of the image in pixels.
656
657\wxheading{See also}
658
659\helpref{wxImage::GetHeight}{wximagegetheight}
660
07d0abae 661
978d3d36
VZ
662\membersection{HSVValue::HSVValue}\label{hsvvaluehsvvalue}
663
664\func{}{HSVValue}{\param{double }{h = 0.0}, \param{double }{s = 0.0}, \param{double }{v = 0.0}}
665
666Constructor for HSVValue, an object that contains values for hue, saturation and value which
667represent the value of a color. It is used by \helpref{wxImage::HSVtoRGB}{wximagehsvtorgb}
668and \helpref{wxImage::RGBtoHSV}{wximagergbtohsv}, which
669converts between HSV color space and RGB color space.
670
671\pythonnote{use wxImage\_HSVValue in wxPython}
672
673
674
675\membersection{wxImage::HSVtoRGB}\label{wximagehsvtorgb}
676
677\func{wxImage::RGBValue}{HSVtoRGB}{\param{const HSVValue \& }{hsv}}
678
679Converts a color in HSV color space to RGB color space.
680
681
487659e0
VZ
682\membersection{wxImage::HasAlpha}\label{wximagehasalpha}
683
684\constfunc{bool}{HasAlpha}{\void}
685
686Returns true if this image has alpha channel, false otherwise.
687
688\wxheading{See also}
689
690\helpref{GetAlpha}{wximagegetalpha}, \helpref{SetAlpha}{wximagesetalpha}
691
07d0abae 692
1e6d9499
JS
693\membersection{wxImage::HasMask}\label{wximagehasmask}
694
695\constfunc{bool}{HasMask}{\void}
696
cc81d32f 697Returns true if there is a mask active, false otherwise.
1e6d9499 698
07d0abae 699
5e5437e0
JS
700\membersection{wxImage::GetOption}\label{wximagegetoption}
701
702\constfunc{wxString}{GetOption}{\param{const wxString\&}{ name}}
703
704Gets a user-defined option. The function is case-insensitive to {\it name}.
705
706For example, when saving as a JPEG file, the option {\bf quality} is
707used, which is a number between 0 and 100 (0 is terrible, 100 is very good).
708
709\wxheading{See also}
710
711\helpref{wxImage::SetOption}{wximagesetoption},\rtfsp
712\helpref{wxImage::GetOptionInt}{wximagegetoptionint},\rtfsp
713\helpref{wxImage::HasOption}{wximagehasoption}
714
07d0abae 715
5e5437e0
JS
716\membersection{wxImage::GetOptionInt}\label{wximagegetoptionint}
717
718\constfunc{int}{GetOptionInt}{\param{const wxString\&}{ name}}
719
720Gets a user-defined option as an integer. The function is case-insensitive to {\it name}.
721
ce045aed 722If the given option is not present, the function returns $0$. Use
07d0abae
VZ
723\helpref{wxImage::HasOption}{wximagehasoption} is $0$ is a possibly valid value
724for the option.
725
a4efa721
VZ
726Options for wxPNGHandler
727\twocolwidtha{5cm}%
728\begin{twocollist}
729\twocolitem{wxIMAGE\_OPTION\_PNG\_FORMAT}{Format for saving a PNG file.}
730\twocolitem{wxIMAGE\_OPTION\_PNG\_BITDEPTH}{Bit depth for every channel (R/G/B/A).}
731\end{twocollist}
732
733Supported values for wxIMAGE\_OPTION\_PNG\_FORMAT:
734\twocolwidtha{5cm}%
735\begin{twocollist}
736\twocolitem{wxPNG\_TYPE\_COLOUR}{Stores RGB image.}
737\twocolitem{wxPNG\_TYPE\_GREY}{Stores grey image, converts from RGB.}
738\twocolitem{wxPNG\_TYPE\_GREY\_RED}{Stores grey image, uses red value as grey.}
739\end{twocollist}
740
741
5e5437e0
JS
742\wxheading{See also}
743
744\helpref{wxImage::SetOption}{wximagesetoption},\rtfsp
07d0abae
VZ
745\helpref{wxImage::GetOption}{wximagegetoption}
746
5e5437e0
JS
747
748\membersection{wxImage::HasOption}\label{wximagehasoption}
749
750\constfunc{bool}{HasOption}{\param{const wxString\&}{ name}}
751
cc81d32f 752Returns true if the given option is present. The function is case-insensitive to {\it name}.
5e5437e0
JS
753
754\wxheading{See also}
755
756\helpref{wxImage::SetOption}{wximagesetoption},\rtfsp
757\helpref{wxImage::GetOption}{wximagegetoption},\rtfsp
758\helpref{wxImage::GetOptionInt}{wximagegetoptionint}
759
07d0abae 760
828f0936
VZ
761\membersection{wxImage::InitAlpha}\label{wximageinitalpha}
762
763\func{void}{InitAlpha}{\void}
764
765Initializes the image alpha channel data. It is an error to call it
766if the image already has alpha data. If it doesn't, alpha data will be
767by default initialized to all pixels being fully opaque. But if the image has a
768a mask colour, all mask pixels will be completely transparent.
769
770
f0e8a2d0 771\membersection{wxImage::InitStandardHandlers}\label{wximageinitstandardhandlers}
1e6d9499
JS
772
773\func{static void}{InitStandardHandlers}{\void}
774
a14e57f9 775Internal use only. Adds standard image format handlers. It only install BMP
31fd9b6b 776for the time being, which is used by wxBitmap.
1e6d9499 777
fc2171bd 778This function is called by wxWidgets on startup, and shouldn't be called by
a14e57f9 779the user.
1e6d9499
JS
780
781\wxheading{See also}
782
ce045aed 783\helpref{wxImageHandler}{wximagehandler},
576b18f2
VZ
784\helpref{wxInitAllImageHandlers}{wxinitallimagehandlers},
785\helpref{wxQuantize}{wxquantize}
1e6d9499 786
07d0abae 787
f0e8a2d0 788\membersection{wxImage::InsertHandler}\label{wximageinserthandler}
1e6d9499
JS
789
790\func{static void}{InsertHandler}{\param{wxImageHandler*}{ handler}}
791
792Adds a handler at the start of the static list of format handlers.
793
794\docparam{handler}{A new image format handler object. There is usually only one instance
795of a given handler class in an application session.}
796
797\wxheading{See also}
798
799\helpref{wxImageHandler}{wximagehandler}
800
07d0abae 801
21dc4be5
VZ
802\membersection{wxImage::IsTransparent}\label{wximageistransparent}
803
3a40452d 804\constfunc{bool}{IsTransparent}{\param{int }{x}, \param{int }{y}, \param{unsigned char}{ threshold = $128$}}
21dc4be5
VZ
805
806Returns \true if the given pixel is transparent, i.e. either has the mask
807colour if this image has a mask or if this image has alpha channel and alpha
808value of this pixel is strictly less than \arg{threshold}.
809
810
1e6d9499
JS
811\membersection{wxImage::LoadFile}\label{wximageloadfile}
812
a61d25e6 813\func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}, \param{int}{ index = -1}}
1e6d9499 814
a61d25e6 815\func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}
9e9ee68e 816
a14e57f9 817Loads an image from a file. If no handler type is provided, the library will
31fd9b6b 818try to autodetect the format.
1e6d9499 819
a61d25e6 820\func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{long}{ type}, \param{int}{ index = -1}}
45b5751f 821
a61d25e6 822\func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}
9e9ee68e 823
45b5751f
JS
824Loads an image from an input stream.
825
1e6d9499
JS
826\wxheading{Parameters}
827
31fd9b6b 828\docparam{name}{Name of the file from which to load the image.}
1e6d9499 829
31fd9b6b 830\docparam{stream}{Opened input stream from which to load the image. Currently, the stream must support seeking.}
45b5751f 831
1e6d9499
JS
832\docparam{type}{One of the following values:
833
6be663cf 834\twocolwidtha{5cm}%
1e6d9499 835\begin{twocollist}
f6fcbb63 836\twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Load a Windows image file.}
a14e57f9 837\twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Load a GIF image file.}
48b4e302 838\twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Load a JPEG image file.}
a14e57f9
SB
839\twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Load a PCX image file.}
840\twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Load a PNG image file.}
841\twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Load a PNM image file.}
31fd9b6b 842\twocolitem{{\bf wxBITMAP\_TYPE\_TIF}}{Load a TIFF image file.}
b86e511a 843\twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Load a XPM image file.}
a61d25e6
VS
844\twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
845\twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
658974ae 846\twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
31fd9b6b
GRG
847\twocolitem{{\bf wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
848\end{twocollist}}
1e6d9499 849
9e9ee68e
VS
850\docparam{mimetype}{MIME type string (for example 'image/jpeg')}
851
a61d25e6 852\docparam{index}{Index of the image to load in the case that the image file contains multiple images.
ce045aed
WS
853This is only used by GIF, ICO and TIFF handlers. The default value (-1) means
854"choose the default image" and is interpreted as the first image (index=0) by
b931f7ee 855the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.}
a61d25e6 856
31fd9b6b
GRG
857\wxheading{Remarks}
858
fc2171bd 859Depending on how wxWidgets has been configured, not all formats may be available.
31fd9b6b 860
ce045aed 861Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to get the
a61d25e6
VS
862hotspot for loaded cursor file:
863\begin{verbatim}
fd94e8aa
VS
864 int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
865 int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
a61d25e6
VS
866
867\end{verbatim}
37b83ca6 868
1e6d9499
JS
869\wxheading{Return value}
870
cc81d32f
VS
871true if the operation succeeded, false otherwise. If the optional index parameter is out of range,
872false is returned and a call to wxLogError() takes place.
1e6d9499
JS
873
874\wxheading{See also}
875
876\helpref{wxImage::SaveFile}{wximagesavefile}
877
f899db6d
RD
878\pythonnote{In place of a single overloaded method name, wxPython
879implements the following methods:\par
880\indented{2cm}{\begin{twocollist}
c9110876 881\twocolitem{{\bf LoadFile(filename, type)}}{Loads an image of the given
f899db6d 882type from a file}
c9110876 883\twocolitem{{\bf LoadMimeFile(filename, mimetype)}}{Loads an image of the given
f899db6d
RD
884mimetype from a file}
885\end{twocollist}}
886}
887
5873607e
VZ
888\perlnote{Methods supported by wxPerl are:\par
889\begin{itemize}
606a3178
GT
890\item{bitmap->LoadFile( name, type )}
891\item{bitmap->LoadFile( name, mimetype )}
5873607e
VZ
892\end{itemize}
893}
894
f899db6d 895
07d0abae 896
b7cacb43 897\membersection{wxImage::IsOk}\label{wximageisok}
1e6d9499 898
b7cacb43 899\constfunc{bool}{IsOk}{\void}
1e6d9499 900
cc81d32f 901Returns true if image data is present.
1e6d9499 902
07d0abae 903
978d3d36
VZ
904\membersection{RGBValue::RGBValue}\label{rgbvaluergbvalue}
905
906\func{}{RGBValue}{\param{unsigned char }{r = 0}, \param{unsigned char }{g = 0}, \param{unsigned char }{b = 0}}
907
07aaa1a4 908Constructor for RGBValue, an object that contains values for red, green and blue which
978d3d36
VZ
909represent the value of a color. It is used by \helpref{wxImage::HSVtoRGB}{wximagehsvtorgb}
910and \helpref{wxImage::RGBtoHSV}{wximagergbtohsv}, which
911converts between HSV color space and RGB color space.
912
913\pythonnote{use wxImage\_RGBValue in wxPython}
914
915
916\membersection{wxImage::RGBtoHSV}\label{wximagergbtohsv}
917
918\func{wxImage::HSVValue}{RGBtoHSV}{\param{const RGBValue\& }{rgb}}
919
920Converts a color in RGB color space to HSV color space.
921
922
f0e8a2d0 923\membersection{wxImage::RemoveHandler}\label{wximageremovehandler}
1e6d9499
JS
924
925\func{static bool}{RemoveHandler}{\param{const wxString\& }{name}}
926
927Finds the handler with the given name, and removes it. The handler
928is not deleted.
929
930\docparam{name}{The handler name.}
931
932\wxheading{Return value}
933
cc81d32f 934true if the handler was found and removed, false otherwise.
1e6d9499
JS
935
936\wxheading{See also}
937
938\helpref{wxImageHandler}{wximagehandler}
939
07d0abae 940
e119d049
JS
941\membersection{wxImage::Mirror}\label{wximagemirror}
942
943\constfunc{wxImage}{Mirror}{\param{bool}{ horizontally = true}}
944
945Returns a mirrored copy of the image. The parameter {\it horizontally}
946indicates the orientation.
947
07d0abae 948
576b18f2
VZ
949\membersection{wxImage::Paste}\label{wximagepaste}
950
951\func{void}{Paste}{\param{const wxImage\& }{image}, \param{int }{x}, \param{int }{y}}
952
953Copy the data of the given \arg{image} to the specified position in this image.
954
e119d049
JS
955\membersection{wxImage::Replace}\label{wximagereplace}
956
957\func{void}{Replace}{\param{unsigned char}{ r1}, \param{unsigned char}{ g1}, \param{unsigned char}{ b1},
958\param{unsigned char}{ r2}, \param{unsigned char}{ g2}, \param{unsigned char}{ b2}}
959
960Replaces the colour specified by {\it r1,g1,b1} by the colour {\it r2,g2,b2}.
961
07d0abae 962
e119d049
JS
963\membersection{wxImage::Rescale}\label{wximagerescale}
964
07aaa1a4 965\func{wxImage \&}{Rescale}{\param{int}{ width}, \param{int}{ height}, \param{int}{ quality = wxIMAGE\_QUALITY\_NORMAL}}
e119d049 966
ce045aed 967Changes the size of the image in-place by scaling it: after a call to this function,
b737ad10 968the image will have the given width and height.
e119d049 969
07aaa1a4
RR
970For a description of the {\it quality} parameter, see the \helpref{Scale}{wximagescale} function.
971
e119d049
JS
972Returns the (modified) image itself.
973
974\wxheading{See also}
975
976\helpref{Scale}{wximagescale}
977
07d0abae 978
b737ad10
RR
979\membersection{wxImage::Resize}\label{wximageresize}
980
981\func{wxImage \&}{Resize}{\param{const wxSize\&}{ size}, \param{const wxPoint&}{ pos}, \param{int}{ red = -1}, \param{int}{ green = -1}, \param{int}{ blue = -1}}
982
ce045aed
WS
983Changes the size of the image in-place without scaling it by adding either a border
984with the given colour or cropping as necessary. The image is pasted into a new
985image with the given {\it size} and background colour at the position {\it pos}
986relative to the upper left of the new image. If {\it red = green = blue = -1}
987then use either the current mask colour if set or find, use, and set a
b737ad10
RR
988suitable mask colour for any newly exposed areas.
989
990Returns the (modified) image itself.
991
992\wxheading{See also}
993
994\helpref{Size}{wximagesize}
995
996
e119d049
JS
997\membersection{wxImage::Rotate}\label{wximagerotate}
998
999\func{wxImage}{Rotate}{\param{double}{ angle}, \param{const wxPoint\& }{rotationCentre},
1000 \param{bool}{ interpolating = true}, \param{wxPoint*}{ offsetAfterRotation = NULL}}
1001
1002Rotates the image about the given point, by {\it angle} radians. Passing true
1003to {\it interpolating} results in better image quality, but is slower. If the
1004image has a mask, then the mask colour is used for the uncovered pixels in the
1005rotated image background. Else, black (rgb 0, 0, 0) will be used.
1006
1007Returns the rotated image, leaving this image intact.
1008
07d0abae 1009
978d3d36
VZ
1010\membersection{wxImage::RotateHue}\label{wximagerotatehue}
1011
1012\func{void}{RotateHue}{\param{double}{ angle}}
1013
1014Rotates the hue of each pixel in the image by {\it angle}, which is a double in
1015the range of -1.0 to +1.0, where -1.0 corresponds to -360 degrees and +1.0 corresponds
1016to +360 degrees.
1017
1018
e119d049
JS
1019\membersection{wxImage::Rotate90}\label{wximagerotate90}
1020
1021\constfunc{wxImage}{Rotate90}{\param{bool}{ clockwise = true}}
1022
1023Returns a copy of the image rotated 90 degrees in the direction
1024indicated by {\it clockwise}.
1025
07d0abae 1026
1e6d9499
JS
1027\membersection{wxImage::SaveFile}\label{wximagesavefile}
1028
d7af2fea 1029\constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{int}{ type}}
1e6d9499 1030
d7af2fea 1031\constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{const wxString\&}{ mimetype}}
9e9ee68e 1032
4fa0a5b4
VS
1033Saves an image in the named file.
1034
1035\constfunc{bool}{SaveFile}{\param{const wxString\& }{name}}
1036
1037Saves an image in the named file. File type is determined from the extension of the
1038file name. Note that this function may fail if the extension is not recognized! You
1039can use one of the forms above to save images to files with non-standard extensions.
1e6d9499 1040
d7af2fea 1041\constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{int}{ type}}
45b5751f 1042
d7af2fea 1043\constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{const wxString\&}{ mimetype}}
9e9ee68e 1044
4fa0a5b4 1045Saves an image in the given stream.
45b5751f 1046
1e6d9499
JS
1047\wxheading{Parameters}
1048
31fd9b6b 1049\docparam{name}{Name of the file to save the image to.}
1e6d9499 1050
31fd9b6b 1051\docparam{stream}{Opened output stream to save the image to.}
45b5751f 1052
4fa0a5b4 1053\docparam{type}{Currently these types can be used:
1e6d9499 1054
6be663cf 1055\twocolwidtha{5cm}%
1e6d9499 1056\begin{twocollist}
4fa0a5b4 1057\twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Save a BMP image file.}
48b4e302 1058\twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Save a JPEG image file.}
31fd9b6b
GRG
1059\twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Save a PNG image file.}
1060\twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Save a PCX image file (tries to save as 8-bit if possible, falls back to 24-bit otherwise).}
1061\twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Save a PNM image file (as raw RGB always).}
b86e511a
VS
1062\twocolitem{{\bf wxBITMAP\_TYPE\_TIFF}}{Save a TIFF image file.}
1063\twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Save a XPM image file.}
a61d25e6
VS
1064\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).}
1065\twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Save a Windows cursor file (CUR).}
31fd9b6b 1066\end{twocollist}}
1e6d9499 1067
9e9ee68e
VS
1068\docparam{mimetype}{MIME type.}
1069
1e6d9499
JS
1070\wxheading{Return value}
1071
cc81d32f 1072true if the operation succeeded, false otherwise.
1e6d9499
JS
1073
1074\wxheading{Remarks}
1075
fc2171bd 1076Depending on how wxWidgets has been configured, not all formats may be available.
1e6d9499 1077
ce045aed
WS
1078Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to set the
1079hotspot before saving an image into a cursor file (default hotspot is in
a61d25e6
VS
1080the centre of the image):
1081\begin{verbatim}
fd94e8aa
VS
1082 image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, hotspotX);
1083 image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotspotY);
a61d25e6
VS
1084
1085\end{verbatim}
1086
1e6d9499
JS
1087\wxheading{See also}
1088
1089\helpref{wxImage::LoadFile}{wximageloadfile}
1090
f899db6d
RD
1091\pythonnote{In place of a single overloaded method name, wxPython
1092implements the following methods:\par
1093\indented{2cm}{\begin{twocollist}
c9110876 1094\twocolitem{{\bf SaveFile(filename, type)}}{Saves the image using the given
f899db6d 1095type to the named file}
c9110876 1096\twocolitem{{\bf SaveMimeFile(filename, mimetype)}}{Saves the image using the given
f899db6d
RD
1097mimetype to the named file}
1098\end{twocollist}}
1099}
1100
5873607e
VZ
1101\perlnote{Methods supported by wxPerl are:\par
1102\begin{itemize}
606a3178
GT
1103\item{bitmap->SaveFile( name, type )}
1104\item{bitmap->SaveFile( name, mimetype )}
5873607e
VZ
1105\end{itemize}
1106}
1107
07d0abae 1108
1e6d9499
JS
1109\membersection{wxImage::Scale}\label{wximagescale}
1110
07aaa1a4 1111\constfunc{wxImage}{Scale}{\param{int}{ width}, \param{int}{ height}, \param{int}{ quality = wxIMAGE\_QUALITY\_NORMAL}}
1e6d9499 1112
12a44087
RR
1113Returns a scaled version of the image. This is also useful for
1114scaling bitmaps in general as the only other way to scale bitmaps
ce9a75d2
VZ
1115is to blit a wxMemoryDC into another wxMemoryDC.
1116
07aaa1a4
RR
1117\docparam{quality}{Determines what method to use for resampling the image. Can be one of the following:
1118
1119\twocolwidtha{5cm}%
1120\begin{twocollist}
1121\twocolitem{{\bf wxIMAGE\_QUALITY\_NORMAL}}{Uses the normal default scaling method of pixel replication}
1122\twocolitem{{\bf wxIMAGE\_QUALITY\_HIGH}}{Uses bicubic and box averaging resampling methods for upsampling and downsampling respectively}
1123\end{twocollist}}
1124
1125It should be noted that although using wxIMAGE\_QUALITY\_HIGH produces much nicer
1126looking results it is a slower method. Downsampling will use the box averaging method
1127which seems to operate very fast. If you are upsampling larger images using
1128this method you will most likely notice that it is a bit slower and in extreme cases
e5d1e06d
RR
1129it will be quite substantially slower as the bicubic algorithm has to process a lot of
1130data.
1131
1132It should also be noted that the high quality scaling may not work as expected
1133when using a single mask colour for transparency, as the scaling will blur the
1134image and will therefore remove the mask partially. Using the alpha channel
1135will work.
07aaa1a4 1136
ce9a75d2
VZ
1137Example:
1138
1139\begin{verbatim}
1140 // get the bitmap from somewhere
1141 wxBitmap bmp = ...;
1142
1143 // rescale it to have size of 32*32
1144 if ( bmp.GetWidth() != 32 || bmp.GetHeight() != 32 )
1145 {
af494043 1146 wxImage image = bmp.ConvertToImage();
b06a6b20 1147 bmp = wxBitmap(image.Scale(32, 32));
ce9a75d2
VZ
1148
1149 // another possibility:
1150 image.Rescale(32, 32);
1151 bmp = image;
1152 }
1153
1154\end{verbatim}
1155
1156\wxheading{See also}
1157
1158\helpref{Rescale}{wximagerescale}
1e6d9499 1159
07d0abae 1160
b737ad10
RR
1161\membersection{wxImage::Size}\label{wximagesize}
1162
1163\constfunc{wxImage}{Size}{\param{const wxSize\&}{ size}, \param{const wxPoint&}{ pos}, \param{int}{ red = -1}, \param{int}{ green = -1}, \param{int}{ blue = -1}}
1164
ce045aed
WS
1165Returns a resized version of this image without scaling it by adding either a border
1166with the given colour or cropping as necessary. The image is pasted into a new
1167image with the given {\it size} and background colour at the position {\it pos}
1168relative to the upper left of the new image. If {\it red = green = blue = -1}
576b18f2
VZ
1169then the areas of the larger image not covered by this image are made
1170transparent by filling them with the image mask colour (which will be allocated
1171automatically if it isn't currently set). Otherwise, the areas will be filled
1172with the colour with the specified RGB components.
b737ad10
RR
1173
1174\wxheading{See also}
1175
1176\helpref{Resize}{wximageresize}
1177
1178
487659e0
VZ
1179\membersection{wxImage::SetAlpha}\label{wximagesetalpha}
1180
60b1fda2 1181\func{void}{SetAlpha}{\param{unsigned char *}{alpha = {\tt NULL}},\param{bool}{ static\_data = \false}}
487659e0
VZ
1182
1183This function is similar to \helpref{SetData}{wximagesetdata} and has similar
1184restrictions. The pointer passed to it may however be {\tt NULL} in which case
1185the function will allocate the alpha array internally -- this is useful to add
ce045aed
WS
1186alpha channel data to an image which doesn't have any. If the pointer is not
1187{\tt NULL}, it must have one byte for each image pixel and be allocated with
60b1fda2 1188{\tt malloc()}. wxImage takes ownership of the pointer and will free it unless
7261746a 1189\arg{static\_data} parameter is set to \true -- in this case the caller should
60b1fda2 1190do it.
487659e0
VZ
1191
1192\func{void}{SetAlpha}{\param{int }{x}, \param{int }{y}, \param{unsigned char }{alpha}}
1193
1194Sets the alpha value for the given pixel. This function should only be called
1195if the image has alpha channel data, use \helpref{HasAlpha}{wximagehasalpha} to
1196check for this.
1197
07d0abae 1198
1e6d9499
JS
1199\membersection{wxImage::SetData}\label{wximagesetdata}
1200
1201\func{void}{SetData}{\param{unsigned char*}{data}}
1202
f899db6d 1203Sets the image data without performing checks. The data given must have
12a44087
RR
1204the size (width*height*3) or results will be unexpected. Don't use this
1205method if you aren't sure you know what you are doing.
1e6d9499 1206
b1ef8821 1207The data must have been allocated with {\tt malloc()}, {\large {\bf NOT}} with
487659e0 1208{\tt operator new}.
f811bc9a
MB
1209
1210After this call the pointer to the data is owned by the wxImage object,
1211that will be responsible for deleting it.
1212Do not pass to this function a pointer obtained through
1213\helpref{wxImage::GetData}{wximagegetdata}.
1214
07d0abae 1215
1e6d9499
JS
1216\membersection{wxImage::SetMask}\label{wximagesetmask}
1217
cc81d32f 1218\func{void}{SetMask}{\param{bool}{ hasMask = true}}
1e6d9499
JS
1219
1220Specifies whether there is a mask or not. The area of the mask is determined by the current mask colour.
1221
07d0abae 1222
1e6d9499
JS
1223\membersection{wxImage::SetMaskColour}\label{wximagesetmaskcolour}
1224
80793cda 1225\func{void}{SetMaskColour}{\param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}}
1e6d9499 1226
b1170810 1227Sets the mask colour for this image (and tells the image to use the mask).
1e6d9499 1228
07d0abae 1229
37b83ca6
VS
1230\membersection{wxImage::SetMaskFromImage}\label{wximagesetmaskfromimage}
1231
1232\func{bool}{SetMaskFromImage}{\param{const wxImage\&}{ mask}, \param{unsigned char}{ mr}, \param{unsigned char}{ mg}, \param{unsigned char}{ mb}}
1233
1234\wxheading{Parameters}
1235
1236\docparam{mask}{The mask image to extract mask shape from. Must have same dimensions as the image.}
1237
1238\docparam{mr,mg,mb}{RGB value of pixels in {\it mask} that will be used to create the mask.}
1239
1240Sets image's mask so that the pixels that have RGB value of {\it mr,mg,mb}
1241in {\it mask} will be masked in the image. This is done by first finding an
1242unused colour in the image, setting this colour as the mask colour and then
ce045aed 1243using this colour to draw all pixels in the image who corresponding pixel
37b83ca6
VS
1244in {\it mask} has given RGB value.
1245
1246\wxheading{Return value}
1247
cc81d32f 1248Returns false if {\it mask} does not have same dimensions as the image or if
ce045aed 1249there is no unused colour left. Returns true if the mask was successfully
37b83ca6
VS
1250applied.
1251
1252\wxheading{Notes}
1253
1254Note that this method involves computing the histogram, which is
1255computationally intensive operation.
1256
07d0abae 1257
5e5437e0
JS
1258\membersection{wxImage::SetOption}\label{wximagesetoption}
1259
1260\func{void}{SetOption}{\param{const wxString\&}{ name}, \param{const wxString\&}{ value}}
1261
1262\func{void}{SetOption}{\param{const wxString\&}{ name}, \param{int}{ value}}
1263
1264Sets a user-defined option. The function is case-insensitive to {\it name}.
1265
1266For example, when saving as a JPEG file, the option {\bf quality} is
1267used, which is a number between 0 and 100 (0 is terrible, 100 is very good).
1268
1269\wxheading{See also}
1270
1271\helpref{wxImage::GetOption}{wximagegetoption},\rtfsp
1272\helpref{wxImage::GetOptionInt}{wximagegetoptionint},\rtfsp
1273\helpref{wxImage::HasOption}{wximagehasoption}
1274
07d0abae 1275
3ca6a5f0
BP
1276\membersection{wxImage::SetPalette}\label{wximagesetpalette}
1277
1278\func{void}{SetPalette}{\param{const wxPalette\&}{ palette}}
1279
b06a6b20
VS
1280Associates a palette with the image. The palette may be used when converting
1281wxImage to wxBitmap (MSW only at present) or in file save operations (none as yet).
3ca6a5f0 1282
07d0abae 1283
1e6d9499
JS
1284\membersection{wxImage::SetRGB}\label{wximagesetrgb}
1285
f6bcfd97 1286\func{void}{SetRGB}{\param{int }{x}, \param{int }{y}, \param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}}
1e6d9499 1287
12a44087
RR
1288Sets the pixel at the given coordinate. This routine performs bounds-checks
1289for the coordinate so it can be considered a safe way to manipulate the
1290data, but in some cases this might be too slow so that the data will have to
ce045aed 1291be set directly. In that case you will have to get access to the image data
7468b994 1292using the \helpref{GetData}{wximagegetdata} method.
1e6d9499 1293
07d0abae 1294
b737ad10
RR
1295\membersection{wxImage::SetRGB}\label{wximagesetrgbrect}
1296
1297\func{void}{SetRGB}{\param{wxRect \& }{rect}, \param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}}
1298
1299Sets the colour of the pixels within the given rectangle. This routine performs
1300bounds-checks for the coordinate so it can be considered a safe way to manipulate the
1301data.
1302
1303
f0e8a2d0 1304\membersection{wxImage::operator $=$}\label{wximageassign}
1e6d9499
JS
1305
1306\func{wxImage\& }{operator $=$}{\param{const wxImage\& }{image}}
1307
a91225b2 1308Assignment operator, using \helpref{reference counting}{trefcount}.
1e6d9499
JS
1309
1310\wxheading{Parameters}
1311
1312\docparam{image}{Image to assign.}
1313
1314\wxheading{Return value}
1315
1316Returns 'this' object.
1317
07d0abae 1318
1e6d9499
JS
1319
1320\section{\class{wxImageHandler}}\label{wximagehandler}
1321
1e6d9499
JS
1322This is the base class for implementing image file loading/saving, and image creation from data.
1323It is used within wxImage and is not normally seen by the application.
1324
1325If you wish to extend the capabilities of wxImage, derive a class from wxImageHandler
1326and add the handler using \helpref{wxImage::AddHandler}{wximageaddhandler} in your
1327application initialisation.
1328
48b4e302
VS
1329\wxheading{Note (Legal Issue)}
1330
954b8ae6 1331This software is based in part on the work of the Independent JPEG Group.
48b4e302 1332
fc2171bd 1333(Applies when wxWidgets is linked with JPEG support. wxJPEGHandler uses libjpeg
48b4e302
VS
1334created by IJG.)
1335
1e6d9499
JS
1336\wxheading{Derived from}
1337
1338\helpref{wxObject}{wxobject}
1339
954b8ae6
JS
1340\wxheading{Include files}
1341
1342<wx/image.h>
1343
a7af285d
VZ
1344\wxheading{Library}
1345
1346\helpref{wxCore}{librarieslist}
1347
1e6d9499
JS
1348\wxheading{See also}
1349
ce045aed 1350\helpref{wxImage}{wximage},
b5a4a47d 1351\helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}
1e6d9499
JS
1352
1353\latexignore{\rtfignore{\wxheading{Members}}}
1354
07d0abae 1355
f0e8a2d0 1356\membersection{wxImageHandler::wxImageHandler}\label{wximagehandlerctor}
1e6d9499
JS
1357
1358\func{}{wxImageHandler}{\void}
1359
1360Default constructor. In your own default constructor, initialise the members
1361m\_name, m\_extension and m\_type.
1362
07d0abae 1363
f0e8a2d0 1364\membersection{wxImageHandler::\destruct{wxImageHandler}}\label{wximagehandlerdtor}
1e6d9499
JS
1365
1366\func{}{\destruct{wxImageHandler}}{\void}
1367
1368Destroys the wxImageHandler object.
1369
07d0abae 1370
f0e8a2d0 1371\membersection{wxImageHandler::GetName}\label{wximagehandlergetname}
1e6d9499 1372
452418c4 1373\constfunc{const wxString\&}{GetName}{\void}
1e6d9499
JS
1374
1375Gets the name of this handler.
1376
07d0abae 1377
f0e8a2d0 1378\membersection{wxImageHandler::GetExtension}\label{wximagehandlergetextension}
1e6d9499 1379
452418c4 1380\constfunc{const wxString\&}{GetExtension}{\void}
1e6d9499
JS
1381
1382Gets the file extension associated with this handler.
1383
07d0abae 1384
649d13e8 1385\membersection{wxImageHandler::GetImageCount}\label{wximagehandlergetimagecount}
7941ba11 1386
649d13e8 1387\func{int}{GetImageCount}{\param{wxInputStream\&}{ stream}}
7941ba11 1388
ce045aed 1389If the image file contains more than one image and the image handler is capable
7941ba11
RR
1390of retrieving these individually, this function will return the number of
1391available images.
1392
31fd9b6b 1393\docparam{stream}{Opened input stream for reading image data. Currently, the stream must support seeking.}
7941ba11
RR
1394
1395\wxheading{Return value}
1396
a61d25e6
VS
1397Number of available images. For most image handlers, this is 1 (exceptions
1398are TIFF and ICO formats).
7941ba11 1399
07d0abae 1400
f0e8a2d0 1401\membersection{wxImageHandler::GetType}\label{wximagehandlergettype}
1e6d9499
JS
1402
1403\constfunc{long}{GetType}{\void}
1404
1405Gets the image type associated with this handler.
1406
07d0abae 1407
f0e8a2d0 1408\membersection{wxImageHandler::GetMimeType}\label{wximagehandlergetmimetype}
9e9ee68e 1409
452418c4 1410\constfunc{const wxString\&}{GetMimeType}{\void}
9e9ee68e
VS
1411
1412Gets the MIME type associated with this handler.
1413
07d0abae 1414
1e6d9499
JS
1415\membersection{wxImageHandler::LoadFile}\label{wximagehandlerloadfile}
1416
cc81d32f 1417\func{bool}{LoadFile}{\param{wxImage* }{image}, \param{wxInputStream\&}{ stream}, \param{bool}{ verbose=true}, \param{int}{ index=0}}
1e6d9499 1418
7941ba11
RR
1419Loads a image from a stream, putting the resulting data into {\it image}. If the image file contains
1420more than one image and the image handler is capable of retrieving these individually, {\it index}
1421indicates which image to read from the stream.
1e6d9499
JS
1422
1423\wxheading{Parameters}
1424
1425\docparam{image}{The image object which is to be affected by this operation.}
1426
31fd9b6b 1427\docparam{stream}{Opened input stream for reading image data.}
7941ba11 1428
cc81d32f 1429\docparam{verbose}{If set to true, errors reported by the image handler will produce wxLogMessages.}
7941ba11
RR
1430
1431\docparam{index}{The index of the image in the file (starting from zero).}
1e6d9499
JS
1432
1433\wxheading{Return value}
1434
cc81d32f 1435true if the operation succeeded, false otherwise.
1e6d9499
JS
1436
1437\wxheading{See also}
1438
ce045aed
WS
1439\helpref{wxImage::LoadFile}{wximageloadfile},
1440\helpref{wxImage::SaveFile}{wximagesavefile},
1e6d9499
JS
1441\helpref{wxImageHandler::SaveFile}{wximagehandlersavefile}
1442
07d0abae 1443
1e6d9499
JS
1444\membersection{wxImageHandler::SaveFile}\label{wximagehandlersavefile}
1445
45b5751f 1446\func{bool}{SaveFile}{\param{wxImage* }{image}, \param{wxOutputStream\& }{stream}}
1e6d9499 1447
45b5751f 1448Saves a image in the output stream.
1e6d9499
JS
1449
1450\wxheading{Parameters}
1451
1452\docparam{image}{The image object which is to be affected by this operation.}
1453
31fd9b6b 1454\docparam{stream}{Opened output stream for writing the data.}
1e6d9499
JS
1455
1456\wxheading{Return value}
1457
cc81d32f 1458true if the operation succeeded, false otherwise.
1e6d9499
JS
1459
1460\wxheading{See also}
1461
ce045aed
WS
1462\helpref{wxImage::LoadFile}{wximageloadfile},
1463\helpref{wxImage::SaveFile}{wximagesavefile},
1e6d9499
JS
1464\helpref{wxImageHandler::LoadFile}{wximagehandlerloadfile}
1465
07d0abae 1466
f0e8a2d0 1467\membersection{wxImageHandler::SetName}\label{wximagehandlersetname}
1e6d9499
JS
1468
1469\func{void}{SetName}{\param{const wxString\& }{name}}
1470
1471Sets the handler name.
1472
1473\wxheading{Parameters}
1474
1475\docparam{name}{Handler name.}
1476
07d0abae 1477
f0e8a2d0 1478\membersection{wxImageHandler::SetExtension}\label{wximagehandlersetextension}
1e6d9499
JS
1479
1480\func{void}{SetExtension}{\param{const wxString\& }{extension}}
1481
1482Sets the handler extension.
1483
1484\wxheading{Parameters}
1485
1486\docparam{extension}{Handler extension.}
1487
07d0abae 1488
f6bcfd97 1489\membersection{wxImageHandler::SetMimeType}\label{wximagehandlersetmimetype}
1e6d9499 1490
f6bcfd97 1491\func{void}{SetMimeType}{\param{const wxString\& }{mimetype}}
1e6d9499 1492
f6bcfd97 1493Sets the handler MIME type.
1e6d9499
JS
1494
1495\wxheading{Parameters}
1496
f6bcfd97 1497\docparam{mimename}{Handler MIME type.}
9e9ee68e 1498
07d0abae 1499
f0e8a2d0 1500\membersection{wxImageHandler::SetType}\label{wximagehandlersettype}
9e9ee68e 1501
f6bcfd97 1502\func{void}{SetType}{\param{long }{type}}
9e9ee68e 1503
f6bcfd97 1504Sets the handler type.
9e9ee68e
VS
1505
1506\wxheading{Parameters}
1507
f6bcfd97 1508\docparam{name}{Handler type.}