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