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