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