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