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