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