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