1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxImage documentation
4 %% Author: wxWidgets Team
8 %% Copyright: (c) wxWidgets Team
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxImage
}}\label{wximage
}
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.
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.
24 be drawn in a device context, using
\helpref{wxDC::DrawBitmap
}{wxdcdrawbitmap
}.
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.
29 \wxheading{Alpha channel support
}
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.
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.
46 \wxheading{Available image handlers
}
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
}.
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.
}
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.
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.
77 \wxheading{Derived from
}
79 \helpref{wxObject
}{wxobject
}
81 \wxheading{Include files
}
87 \helpref{wxCore
}{librarieslist
}
91 \helpref{wxBitmap
}{wxbitmap
},
92 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}
94 \latexignore{\rtfignore{\wxheading{Members
}}}
97 \membersection{wxImage::wxImage
}\label{wximagector
}
99 \func{}{wxImage
}{\void}
103 \func{}{wxImage
}{\param{const wxImage\&
}{image
}}
105 Copy constructor, uses
\helpref{reference counting
}{trefcount
}.
107 \func{}{wxImage
}{\param{const wxBitmap\&
}{ bitmap
}}
109 (Deprecated form, use
\helpref{wxBitmap::ConvertToImage
}{wxbitmapconverttoimage
}
110 instead.) Constructs an image from a platform-dependent bitmap. This preserves
111 mask information so that bitmaps and images can be converted back
112 and forth without loss in that respect.
114 \func{}{wxImage
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{bool
}{ clear=true
}}
116 Creates an image with the given width and height. If
{\it clear
} is true, the new image will be initialized to black.
117 Otherwise, the image data will be uninitialized.
119 \func{}{wxImage
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{unsigned char*
}{ data
},
\param{bool
}{ static
\_data =
\false}}
121 Creates an image from given data with the given width and height. If
122 {\it static
\_data} is true, then wxImage will not delete the actual
123 image data in its destructor, otherwise it will free it by calling
126 \func{}{wxImage
}{\param{const wxString\&
}{name
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY},
\param{int
}{ index = -
1}}
128 \func{}{wxImage
}{\param{const wxString\&
}{name
},
\param{const wxString\&
}{ mimetype
},
\param{int
}{ index = -
1}}
130 Loads an image from a file.
132 \func{}{wxImage
}{\param{wxInputStream\&
}{stream
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY},
\param{int
}{ index = -
1}}
134 \func{}{wxImage
}{\param{wxInputStream\&
}{stream
},
\param{const wxString\&
}{ mimetype
},
\param{int
}{ index = -
1}}
136 Loads an image from an input stream.
138 \func{}{wxImage
}{\param{const char* const*
}{xpmData
}}
140 Creates an image from XPM data.
142 \wxheading{Parameters
}
144 \docparam{width
}{Specifies the width of the image.
}
146 \docparam{height
}{Specifies the height of the image.
}
148 \docparam{name
}{Name of the file from which to load the image.
}
150 \docparam{stream
}{Opened input stream from which to load the image. Currently, the stream must support seeking.
}
152 \docparam{type
}{May be one of the following:
156 \twocolitem{\indexit{wxBITMAP
\_TYPE\_BMP}}{Load a Windows bitmap file.
}
157 \twocolitem{\indexit{wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
158 \twocolitem{\indexit{wxBITMAP
\_TYPE\_JPEG}}{Load a JPEG bitmap file.
}
159 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PNG}}{Load a PNG bitmap file.
}
160 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PCX}}{Load a PCX bitmap file.
}
161 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PNM}}{Load a PNM bitmap file.
}
162 \twocolitem{\indexit{wxBITMAP
\_TYPE\_TIF}}{Load a TIFF bitmap file.
}
163 \twocolitem{\indexit{wxBITMAP
\_TYPE\_TGA}}{Load a TGA bitmap file.
}
164 \twocolitem{\indexit{wxBITMAP
\_TYPE\_XPM}}{Load a XPM bitmap file.
}
165 \twocolitem{\indexit{wxBITMAP
\_TYPE\_ICO}}{Load a Windows icon file (ICO).
}
166 \twocolitem{\indexit{wxBITMAP
\_TYPE\_CUR}}{Load a Windows cursor file (CUR).
}
167 \twocolitem{\indexit{wxBITMAP
\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).
}
168 \twocolitem{\indexit{wxBITMAP
\_TYPE\_ANY}}{Will try to autodetect the format.
}
171 \docparam{mimetype
}{MIME type string (for example 'image/jpeg')
}
173 \docparam{index
}{Index of the image to load in the case that the image file contains multiple images.
174 This is only used by GIF, ICO and TIFF handlers. The default value (-
1) means
175 "choose the default image" and is interpreted as the first image (index=
0) by
176 the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.
}
178 \docparam{xpmData
}{A pointer to XPM image data.
}
182 Depending on how wxWidgets has been configured, not all formats may be available.
184 Note: any handler other than BMP must be previously
185 initialized with
\helpref{wxImage::AddHandler
}{wximageaddhandler
} or
186 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}.
188 Note: you can use
\helpref{GetOptionInt
}{wximagegetoptionint
} to get the
189 hotspot for loaded cursor file:
191 int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
192 int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
198 \helpref{wxImage::LoadFile
}{wximageloadfile
}
200 \pythonnote{Constructors supported by wxPython are:
\par
201 \indented{2cm
}{\begin{twocollist
}
202 \twocolitem{{\bf wxImage(name, flag)
}}{Loads an image from a file
}
203 \twocolitem{{\bf wxNullImage()
}}{Create a null image (has no size or
205 \twocolitem{{\bf wxEmptyImage(width, height)
}}{Creates an empty image
207 \twocolitem{{\bf wxImageFromMime(name, mimetype
}}{Creates an image from
208 the given file of the given mimetype
}
209 \twocolitem{{\bf wxImageFromBitmap(bitmap)
}}{Creates an image from a
210 platform-dependent bitmap
}
214 \perlnote{Constructors supported by wxPerl are:
\par
216 \item{Wx::Image->new( bitmap )
}
217 \item{Wx::Image->new( icon )
}
218 \item{Wx::Image->new( width, height )
}
219 \item{Wx::Image->new( width, height, data )
}
220 \item{Wx::Image->new( file, type, index )
}
221 \item{Wx::Image->new( file, mimetype, index )
}
222 \item{Wx::Image->new( stream, type, index )
}
223 \item{Wx::Image->new( stream, mimetype, index )
}
228 \membersection{wxImage::
\destruct{wxImage
}}\label{wximagedtor
}
230 \func{}{\destruct{wxImage
}}{\void}
233 See
\helpref{reference-counted object destruction
}{refcountdestruct
} for more info.
236 \membersection{wxImage::AddHandler
}\label{wximageaddhandler
}
238 \func{static void
}{AddHandler
}{\param{wxImageHandler*
}{ handler
}}
240 Adds a handler to the end of the static list of format handlers.
242 \docparam{handler
}{A new image format handler object. There is usually only one instance
243 of a given handler class in an application session.
}
247 \helpref{wxImageHandler
}{wximagehandler
}
249 \func{bool
}{CanRead
}{\param{const wxString\&
}{ filename
}}
251 returns true if the current image handlers can read this file
253 \pythonnote{In wxPython this static method is named
{\tt wxImage
\_AddHandler}.
}
256 \membersection{wxImage::Blur
}\label{wximageblur
}
258 \func{wxImage
}{Blur
}{\param{int
}{ blurRadius
}}
260 Blurs the image in both horizontal and vertical directions by the specified pixel
261 {\it blurRadius
}. This should not be used when using a single mask colour
266 \helpref{BlurHorizontal
}{wximagehorzblur
}
267 \helpref{BlurVertical
}{wximagevertblur
}
270 \membersection{wxImage::BlurHorizontal
}\label{wximagehorzblur
}
272 \func{wxImage
}{BlurHorizontal
}{\param{int
}{ blurRadius
}}
274 Blurs the image in the horizontal direction only. This should not be used
275 when using a single mask colour for transparency.
278 \helpref{Blur
}{wximageblur
}
279 \helpref{BlurVertical
}{wximagevertblur
}
282 \membersection{wxImage::BlurVertical
}\label{wximagevertblur
}
284 \func{wxImage
}{BlurVertical
}{\param{int
}{ blurRadius
}}
286 Blurs the image in the vertical direction only. This should not be used
287 when using a single mask colour for transparency.
291 \helpref{Blur
}{wximageblur
}
292 \helpref{BlurHorizontal
}{wximagehorzblur
}
295 \membersection{wxImage::CleanUpHandlers
}\label{wximagecleanuphandlers
}
297 \func{static void
}{CleanUpHandlers
}{\void}
299 Deletes all image handlers.
301 This function is called by wxWidgets on exit.
304 \membersection{wxImage::ComputeHistogram
}\label{wximagecomputehistogram
}
306 \constfunc{unsigned long
}{ComputeHistogram
}{\param{wxImageHistogram\&
}{histogram
}}
308 Computes the histogram of the image.
{\it histogram
} is a reference to
309 wxImageHistogram object. wxImageHistogram is a specialization of
310 \helpref{wxHashMap
}{wxhashmap
} "template" and is defined as follows:
313 class WXDLLEXPORT wxImageHistogramEntry
316 wxImageHistogramEntry() : index(
0), value(
0)
{}
321 WX_DECLARE_EXPORTED_HASH_MAP(unsigned long, wxImageHistogramEntry,
322 wxIntegerHash, wxIntegerEqual,
326 \wxheading{Return value
}
328 Returns number of colours in the histogram.
331 \membersection{wxImage::ConvertAlphaToMask
}\label{wximageconvertalphatomask
}
333 \func{bool
}{ConvertAlphaToMask
}{\param{unsigned char
}{ threshold = $
128$
}}
335 If the image has alpha channel, this method converts it to mask. All pixels
336 with alpha value less than
\arg{threshold
} are replaced with mask colour
337 and the alpha channel is removed. Mask colour is chosen automatically using
338 \helpref{FindFirstUnusedColour
}{wximagefindfirstunusedcolour
}.
340 If the image image doesn't have alpha channel,
341 ConvertAlphaToMask does nothing.
343 \wxheading{Return value
}
345 \false if FindFirstUnusedColour returns
\false,
\true otherwise.
348 \membersection{wxImage::ConvertToBitmap
}\label{wximageconverttobitmap
}
350 \constfunc{wxBitmap
}{ConvertToBitmap
}{\void}
352 Deprecated, use equivalent
\helpref{wxBitmap constructor
}{wxbitmapctor
}
353 (which takes wxImage and depth as its arguments) instead.
356 \membersection{wxImage::ConvertToGreyscale
}\label{wximageconverttogreyscale
}
358 \constfunc{wxImage
}{ConvertToGreyscale
}{\param{double
}{ lr =
0.299},
\param{double
}{ lg =
0.587},
\param{double
}{ lb =
0.114}}
360 Returns a greyscale version of the image. The returned image uses the luminance
361 component of the original to calculate the greyscale. Defaults to using
362 ITU-T BT
.601 when converting to YUV, where every pixel equals
363 (R *
{\it lr
}) + (G *
{\it lg
}) + (B *
{\it lb
}).
366 \membersection{wxImage::ConvertToMono
}\label{wxbitmapconverttomono
}
368 \constfunc{wxImage
}{ConvertToMono
}{\param{unsigned char
}{ r
},
\param{unsigned char
}{ g
},
\param{unsigned char
}{ b
}}
370 Returns monochromatic version of the image. The returned image has white
371 colour where the original has
{\it (r,g,b)
} colour and black colour
375 \membersection{wxImage::Copy
}\label{wximagecopy
}
377 \constfunc{wxImage
}{Copy
}{\void}
379 Returns an identical copy of the image.
382 \membersection{wxImage::Create
}\label{wximagecreate
}
384 \func{bool
}{Create
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{bool
}{ clear=true
}}
386 Creates a fresh image. If
{\it clear
} is true, the new image will be initialized to black.
387 Otherwise, the image data will be uninitialized.
389 \wxheading{Parameters
}
391 \docparam{width
}{The width of the image in pixels.
}
393 \docparam{height
}{The height of the image in pixels.
}
395 \wxheading{Return value
}
397 true if the call succeeded, false otherwise.
400 \membersection{wxImage::Destroy
}\label{wximagedestroy
}
402 \func{void
}{Destroy
}{\void}
404 Destroys the image data.
407 \membersection{wxImage::FindFirstUnusedColour
}\label{wximagefindfirstunusedcolour
}
409 \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}}
411 \wxheading{Parameters
}
413 \docparam{r,g,b
}{Pointers to variables to save the colour.
}
415 \docparam{startR,startG,startB
}{Initial values of the colour. Returned colour
416 will have RGB values equal to or greater than these.
}
418 Finds the first colour that is never used in the image. The search begins at
419 given initial colour and continues by increasing R, G and B components (in this
420 order) by
1 until an unused colour is found or the colour space exhausted.
422 \wxheading{Return value
}
424 Returns false if there is no unused colour left, true on success.
428 Note that this method involves computing the histogram, which is
429 computationally intensive operation.
432 \membersection{wxImage::FindHandler
}\label{wximagefindhandler
}
434 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{name
}}
436 Finds the handler with the given name.
438 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{extension
},
\param{long
}{ imageType
}}
440 Finds the handler associated with the given extension and type.
442 \func{static wxImageHandler*
}{FindHandler
}{\param{long
}{imageType
}}
444 Finds the handler associated with the given image type.
446 \func{static wxImageHandler*
}{FindHandlerMime
}{\param{const wxString\&
}{mimetype
}}
448 Finds the handler associated with the given MIME type.
450 \docparam{name
}{The handler name.
}
452 \docparam{extension
}{The file extension, such as ``bmp".
}
454 \docparam{imageType
}{The image type, such as wxBITMAP
\_TYPE\_BMP.
}
456 \docparam{mimetype
}{MIME type.
}
458 \wxheading{Return value
}
460 A pointer to the handler if found, NULL otherwise.
464 \helpref{wxImageHandler
}{wximagehandler
}
467 \membersection{wxImage::GetImageExtWildcard
}\label{wximagegetimageextwildcard
}
469 \func{static wxString
}{GetImageExtWildcard
}{\void}
471 Iterates all registered wxImageHandler objects, and returns a string containing file extension masks
472 suitable for passing to file open/save dialog boxes.
474 \wxheading{Return value
}
476 The format of the returned string is "
(*.ext1;*.ext2)|*.ext1;*.ext2".
478 It is usually a good idea to prepend a description before passing the result to the dialog.
483 wxFileDialog FileDlg( this, "Choose Image", ::wxGetCwd(), "", _("Image Files ") + wxImage::GetImageExtWildcard(), wxFD_OPEN );
488 \helpref{wxImageHandler}{wximagehandler}
491 \membersection{wxImage::GetAlpha}\label{wximagegetalpha}
493 \constfunc{unsigned char}{GetAlpha}{\param{int}{ x}, \param{int}{ y}}
495 Returns the alpha value for the given pixel. This function may only be called
496 for the images with alpha channel, use \helpref{HasAlpha}{wximagehasalpha} to
499 The returned value is the {\it opacity} of the image, i.e. the value of $0$
500 corresponds to the transparent pixels while the value of $255$ -- to the opaque
503 \constfunc{unsigned char *}{GetAlpha}{\void}
505 Returns pointer to the array storing the alpha values for this image. This
506 pointer is {\tt NULL} for the images without the alpha channel. If the image
507 does have it, this pointer may be used to directly manipulate the alpha values
508 which are stored as the \helpref{RGB}{wximagegetdata} ones.
511 \membersection{wxImage::GetBlue}\label{wximagegetblue}
513 \constfunc{unsigned char}{GetBlue}{\param{int}{ x}, \param{int}{ y}}
515 Returns the blue intensity at the given coordinate.
518 \membersection{wxImage::GetData}\label{wximagegetdata}
520 \constfunc{unsigned char*}{GetData}{\void}
522 Returns the image data as an array. This is most often used when doing
523 direct image manipulation. The return value points to an array of
524 characters in RGBRGBRGB$\ldots$ format in the top-to-bottom, left-to-right
525 order, that is the first RGB triplet corresponds to the pixel first pixel of
526 the first row, the second one --- to the second pixel of the first row and so
527 on until the end of the first row, with second row following after it and so
530 You should not delete the returned pointer nor pass it to
531 \helpref{wxImage::SetData}{wximagesetdata}.
534 \membersection{wxImage::GetGreen}\label{wximagegetgreen}
536 \constfunc{unsigned char}{GetGreen}{\param{int}{ x}, \param{int}{ y}}
538 Returns the green intensity at the given coordinate.
541 \membersection{wxImage::GetImageCount}\label{wximagegetimagecount}
543 \func{static int}{GetImageCount}{\param{const wxString\&}{ filename}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}}
545 \func{static int}{GetImageCount}{\param{wxInputStream\&}{ stream}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}}
547 If the image file contains more than one image and the image handler is capable
548 of retrieving these individually, this function will return the number of
551 \docparam{name}{Name of the file to query.}
553 \docparam{stream}{Opened input stream with image data. Currently, the stream must support seeking.}
555 \docparam{type}{May be one of the following:
559 \twocolitem{\indexit{wxBITMAP\_TYPE\_BMP}}{Load a Windows bitmap file.}
560 \twocolitem{\indexit{wxBITMAP\_TYPE\_GIF}}{Load a GIF bitmap file.}
561 \twocolitem{\indexit{wxBITMAP\_TYPE\_JPEG}}{Load a JPEG bitmap file.}
562 \twocolitem{\indexit{wxBITMAP\_TYPE\_PNG}}{Load a PNG bitmap file.}
563 \twocolitem{\indexit{wxBITMAP\_TYPE\_PCX}}{Load a PCX bitmap file.}
564 \twocolitem{\indexit{wxBITMAP\_TYPE\_PNM}}{Load a PNM bitmap file.}
565 \twocolitem{\indexit{wxBITMAP\_TYPE\_TIF}}{Load a TIFF bitmap file.}
566 \twocolitem{\indexit{wxBITMAP\_TYPE\_XPM}}{Load a XPM bitmap file.}
567 \twocolitem{\indexit{wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
568 \twocolitem{\indexit{wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
569 \twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
570 \twocolitem{\indexit{wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
573 \wxheading{Return value}
575 Number of available images. For most image handlers, this is 1 (exceptions
576 are TIFF and ICO formats).
579 \membersection{wxImage::GetHandlers}\label{wximagegethandlers}
581 \func{static wxList\&}{GetHandlers}{\void}
583 Returns the static list of image format handlers.
587 \helpref{wxImageHandler}{wximagehandler}
590 \membersection{wxImage::GetHeight}\label{wximagegetheight}
592 \constfunc{int}{GetHeight}{\void}
594 Gets the height of the image in pixels.
597 \membersection{wxImage::GetMaskBlue}\label{wximagegetmaskblue}
599 \constfunc{unsigned char}{GetMaskBlue}{\void}
601 Gets the blue value of the mask colour.
604 \membersection{wxImage::GetMaskGreen}\label{wximagegetmaskgreen}
606 \constfunc{unsigned char}{GetMaskGreen}{\void}
608 Gets the green value of the mask colour.
611 \membersection{wxImage::GetMaskRed}\label{wximagegetmaskred}
613 \constfunc{unsigned char}{GetMaskRed}{\void}
615 Gets the red value of the mask colour.
618 \membersection{wxImage::GetOrFindMaskColour}\label{wximagegetgetorsetmaskcolour}
620 \constfunc{bool}{GetOrFindMaskColour}{\param{unsigned char}{ *r}, \param{unsigned char}{ *g}, \param{unsigned char}{ *b}}
622 Get the current mask colour or find a suitable unused colour that could be
623 used as a mask colour. Returns {\tt true} if the image currently has a mask.
626 \membersection{wxImage::GetPalette}\label{wximagegetpalette}
628 \constfunc{const wxPalette\&}{GetPalette}{\void}
630 Returns the palette associated with the image. Currently the palette is only
631 used when converting to wxBitmap under Windows. Some of the wxImage handlers
632 have been modified to set the palette if one exists in the image file (usually
633 256 or less colour images in GIF or PNG format).
636 \membersection{wxImage::GetRed}\label{wximagegetred}
638 \constfunc{unsigned char}{GetRed}{\param{int}{ x}, \param{int}{ y}}
640 Returns the red intensity at the given coordinate.
643 \membersection{wxImage::GetSubImage}\label{wximagegetsubimage}
645 \constfunc{wxImage}{GetSubImage}{\param{const wxRect\&}{ rect}}
647 Returns a sub image of the current one as long as the rect belongs entirely to
651 \membersection{wxImage::GetWidth}\label{wximagegetwidth}
653 \constfunc{int}{GetWidth}{\void}
655 Gets the width of the image in pixels.
659 \helpref{wxImage::GetHeight}{wximagegetheight}
662 \membersection{HSVValue::HSVValue}\label{hsvvaluehsvvalue}
664 \func{}{HSVValue}{\param{double }{h = 0.0}, \param{double }{s = 0.0}, \param{double }{v = 0.0}}
666 Constructor for HSVValue, an object that contains values for hue, saturation and value which
667 represent the value of a color. It is used by \helpref{wxImage::HSVtoRGB}{wximagehsvtorgb}
668 and \helpref{wxImage::RGBtoHSV}{wximagergbtohsv}, which
669 converts between HSV color space and RGB color space.
671 \pythonnote{use wxImage\_HSVValue in wxPython}
675 \membersection{wxImage::HSVtoRGB}\label{wximagehsvtorgb}
677 \func{wxImage::RGBValue}{HSVtoRGB}{\param{const HSVValue \& }{hsv}}
679 Converts a color in HSV color space to RGB color space.
682 \membersection{wxImage::HasAlpha}\label{wximagehasalpha}
684 \constfunc{bool}{HasAlpha}{\void}
686 Returns true if this image has alpha channel, false otherwise.
690 \helpref{GetAlpha}{wximagegetalpha}, \helpref{SetAlpha}{wximagesetalpha}
693 \membersection{wxImage::HasMask}\label{wximagehasmask}
695 \constfunc{bool}{HasMask}{\void}
697 Returns true if there is a mask active, false otherwise.
700 \membersection{wxImage::GetOption}\label{wximagegetoption}
702 \constfunc{wxString}{GetOption}{\param{const wxString\&}{ name}}
704 Gets a user-defined option. The function is case-insensitive to {\it name}.
706 For example, when saving as a JPEG file, the option {\bf quality} is
707 used, which is a number between 0 and 100 (0 is terrible, 100 is very good).
711 \helpref{wxImage::SetOption}{wximagesetoption},\rtfsp
712 \helpref{wxImage::GetOptionInt}{wximagegetoptionint},\rtfsp
713 \helpref{wxImage::HasOption}{wximagehasoption}
716 \membersection{wxImage::GetOptionInt}\label{wximagegetoptionint}
718 \constfunc{int}{GetOptionInt}{\param{const wxString\&}{ name}}
720 Gets a user-defined option as an integer. The function is case-insensitive to {\it name}.
722 If the given option is not present, the function returns $0$. Use
723 \helpref{wxImage::HasOption}{wximagehasoption} is $0$ is a possibly valid value
726 Options for wxPNGHandler
729 \twocolitem{wxIMAGE\_OPTION\_PNG\_FORMAT}{Format for saving a PNG file.}
730 \twocolitem{wxIMAGE\_OPTION\_PNG\_BITDEPTH}{Bit depth for every channel (R/G/B/A).}
733 Supported values for wxIMAGE\_OPTION\_PNG\_FORMAT:
736 \twocolitem{wxPNG\_TYPE\_COLOUR}{Stores RGB image.}
737 \twocolitem{wxPNG\_TYPE\_GREY}{Stores grey image, converts from RGB.}
738 \twocolitem{wxPNG\_TYPE\_GREY\_RED}{Stores grey image, uses red value as grey.}
744 \helpref{wxImage::SetOption}{wximagesetoption},\rtfsp
745 \helpref{wxImage::GetOption}{wximagegetoption}
748 \membersection{wxImage::HasOption}\label{wximagehasoption}
750 \constfunc{bool}{HasOption}{\param{const wxString\&}{ name}}
752 Returns true if the given option is present. The function is case-insensitive to {\it name}.
756 \helpref{wxImage::SetOption}{wximagesetoption},\rtfsp
757 \helpref{wxImage::GetOption}{wximagegetoption},\rtfsp
758 \helpref{wxImage::GetOptionInt}{wximagegetoptionint}
761 \membersection{wxImage::InitAlpha}\label{wximageinitalpha}
763 \func{void}{InitAlpha}{\void}
765 Initializes the image alpha channel data. It is an error to call it
766 if the image already has alpha data. If it doesn't, alpha data will be
767 by default initialized to all pixels being fully opaque. But if the image has a
768 a mask colour, all mask pixels will be completely transparent.
771 \membersection{wxImage::InitStandardHandlers}\label{wximageinitstandardhandlers}
773 \func{static void}{InitStandardHandlers}{\void}
775 Internal use only. Adds standard image format handlers. It only install BMP
776 for the time being, which is used by wxBitmap.
778 This function is called by wxWidgets on startup, and shouldn't be called by
783 \helpref{wxImageHandler}{wximagehandler},
784 \helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}
787 \membersection{wxImage::InsertHandler}\label{wximageinserthandler}
789 \func{static void}{InsertHandler}{\param{wxImageHandler*}{ handler}}
791 Adds a handler at the start of the static list of format handlers.
793 \docparam{handler}{A new image format handler object. There is usually only one instance
794 of a given handler class in an application session.}
798 \helpref{wxImageHandler}{wximagehandler}
801 \membersection{wxImage::IsTransparent}\label{wximageistransparent}
803 \constfunc{bool}{IsTransparent}{\param{int }{x}, \param{int }{y}, \param{unsigned char}{ threshold = $128$}}
805 Returns \true if the given pixel is transparent, i.e. either has the mask
806 colour if this image has a mask or if this image has alpha channel and alpha
807 value of this pixel is strictly less than \arg{threshold}.
810 \membersection{wxImage::LoadFile}\label{wximageloadfile}
812 \func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}, \param{int}{ index = -1}}
814 \func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}
816 Loads an image from a file. If no handler type is provided, the library will
817 try to autodetect the format.
819 \func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{long}{ type}, \param{int}{ index = -1}}
821 \func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}
823 Loads an image from an input stream.
825 \wxheading{Parameters}
827 \docparam{name}{Name of the file from which to load the image.}
829 \docparam{stream}{Opened input stream from which to load the image. Currently, the stream must support seeking.}
831 \docparam{type}{One of the following values:
835 \twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Load a Windows image file.}
836 \twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Load a GIF image file.}
837 \twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Load a JPEG image file.}
838 \twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Load a PCX image file.}
839 \twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Load a PNG image file.}
840 \twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Load a PNM image file.}
841 \twocolitem{{\bf wxBITMAP\_TYPE\_TIF}}{Load a TIFF image file.}
842 \twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Load a XPM image file.}
843 \twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
844 \twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
845 \twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
846 \twocolitem{{\bf wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
849 \docparam{mimetype}{MIME type string (for example 'image/jpeg')}
851 \docparam{index}{Index of the image to load in the case that the image file contains multiple images.
852 This is only used by GIF, ICO and TIFF handlers. The default value (-1) means
853 "choose the default image" and is interpreted as the first image (index=0) by
854 the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.}
858 Depending on how wxWidgets has been configured, not all formats may be available.
860 Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to get the
861 hotspot for loaded cursor file:
863 int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
864 int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
868 \wxheading{Return value}
870 true if the operation succeeded, false otherwise. If the optional index parameter is out of range,
871 false is returned and a call to wxLogError() takes place.
875 \helpref{wxImage::SaveFile}{wximagesavefile}
877 \pythonnote{In place of a single overloaded method name, wxPython
878 implements the following methods:\par
879 \indented{2cm}{\begin{twocollist}
880 \twocolitem{{\bf LoadFile(filename, type)}}{Loads an image of the given
882 \twocolitem{{\bf LoadMimeFile(filename, mimetype)}}{Loads an image of the given
883 mimetype from a file}
887 \perlnote{Methods supported by wxPerl are:\par
889 \item{bitmap->LoadFile( name, type )}
890 \item{bitmap->LoadFile( name, mimetype )}
896 \membersection{wxImage::IsOk}\label{wximageisok}
898 \constfunc{bool}{IsOk}{\void}
900 Returns true if image data is present.
903 \membersection{RGBValue::RGBValue}\label{rgbvaluergbvalue}
905 \func{}{RGBValue}{\param{unsigned char }{r = 0}, \param{unsigned char }{g = 0}, \param{unsigned char }{b = 0}}
907 Constructor for RGBValue, an object that contains values for red, green and blue which
908 represent the value of a color. It is used by \helpref{wxImage::HSVtoRGB}{wximagehsvtorgb}
909 and \helpref{wxImage::RGBtoHSV}{wximagergbtohsv}, which
910 converts between HSV color space and RGB color space.
912 \pythonnote{use wxImage\_RGBValue in wxPython}
915 \membersection{wxImage::RGBtoHSV}\label{wximagergbtohsv}
917 \func{wxImage::HSVValue}{RGBtoHSV}{\param{const RGBValue\& }{rgb}}
919 Converts a color in RGB color space to HSV color space.
922 \membersection{wxImage::RemoveHandler}\label{wximageremovehandler}
924 \func{static bool}{RemoveHandler}{\param{const wxString\& }{name}}
926 Finds the handler with the given name, and removes it. The handler
929 \docparam{name}{The handler name.}
931 \wxheading{Return value}
933 true if the handler was found and removed, false otherwise.
937 \helpref{wxImageHandler}{wximagehandler}
940 \membersection{wxImage::Mirror}\label{wximagemirror}
942 \constfunc{wxImage}{Mirror}{\param{bool}{ horizontally = true}}
944 Returns a mirrored copy of the image. The parameter {\it horizontally}
945 indicates the orientation.
948 \membersection{wxImage::Replace}\label{wximagereplace}
950 \func{void}{Replace}{\param{unsigned char}{ r1}, \param{unsigned char}{ g1}, \param{unsigned char}{ b1},
951 \param{unsigned char}{ r2}, \param{unsigned char}{ g2}, \param{unsigned char}{ b2}}
953 Replaces the colour specified by {\it r1,g1,b1} by the colour {\it r2,g2,b2}.
956 \membersection{wxImage::Rescale}\label{wximagerescale}
958 \func{wxImage \&}{Rescale}{\param{int}{ width}, \param{int}{ height}, \param{int}{ quality = wxIMAGE\_QUALITY\_NORMAL}}
960 Changes the size of the image in-place by scaling it: after a call to this function,
961 the image will have the given width and height.
963 For a description of the {\it quality} parameter, see the \helpref{Scale}{wximagescale} function.
965 Returns the (modified) image itself.
969 \helpref{Scale}{wximagescale}
972 \membersection{wxImage::Resize}\label{wximageresize}
974 \func{wxImage \&}{Resize}{\param{const wxSize\&}{ size}, \param{const wxPoint&}{ pos}, \param{int}{ red = -1}, \param{int}{ green = -1}, \param{int}{ blue = -1}}
976 Changes the size of the image in-place without scaling it by adding either a border
977 with the given colour or cropping as necessary. The image is pasted into a new
978 image with the given {\it size} and background colour at the position {\it pos}
979 relative to the upper left of the new image. If {\it red = green = blue = -1}
980 then use either the current mask colour if set or find, use, and set a
981 suitable mask colour for any newly exposed areas.
983 Returns the (modified) image itself.
987 \helpref{Size}{wximagesize}
990 \membersection{wxImage::Rotate}\label{wximagerotate}
992 \func{wxImage}{Rotate}{\param{double}{ angle}, \param{const wxPoint\& }{rotationCentre},
993 \param{bool}{ interpolating = true}, \param{wxPoint*}{ offsetAfterRotation = NULL}}
995 Rotates the image about the given point, by {\it angle} radians. Passing true
996 to {\it interpolating} results in better image quality, but is slower. If the
997 image has a mask, then the mask colour is used for the uncovered pixels in the
998 rotated image background. Else, black (rgb 0, 0, 0) will be used.
1000 Returns the rotated image, leaving this image intact.
1003 \membersection{wxImage::RotateHue}\label{wximagerotatehue}
1005 \func{void}{RotateHue}{\param{double}{ angle}}
1007 Rotates the hue of each pixel in the image by {\it angle}, which is a double in
1008 the range of -1.0 to +1.0, where -1.0 corresponds to -360 degrees and +1.0 corresponds
1012 \membersection{wxImage::Rotate90}\label{wximagerotate90}
1014 \constfunc{wxImage}{Rotate90}{\param{bool}{ clockwise = true}}
1016 Returns a copy of the image rotated 90 degrees in the direction
1017 indicated by {\it clockwise}.
1020 \membersection{wxImage::SaveFile}\label{wximagesavefile}
1022 \constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{int}{ type}}
1024 \constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{const wxString\&}{ mimetype}}
1026 Saves an image in the named file.
1028 \constfunc{bool}{SaveFile}{\param{const wxString\& }{name}}
1030 Saves an image in the named file. File type is determined from the extension of the
1031 file name. Note that this function may fail if the extension is not recognized! You
1032 can use one of the forms above to save images to files with non-standard extensions.
1034 \constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{int}{ type}}
1036 \constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{const wxString\&}{ mimetype}}
1038 Saves an image in the given stream.
1040 \wxheading{Parameters}
1042 \docparam{name}{Name of the file to save the image to.}
1044 \docparam{stream}{Opened output stream to save the image to.}
1046 \docparam{type}{Currently these types can be used:
1050 \twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Save a BMP image file.}
1051 \twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Save a JPEG image file.}
1052 \twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Save a PNG image file.}
1053 \twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Save a PCX image file (tries to save as 8-bit if possible, falls back to 24-bit otherwise).}
1054 \twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Save a PNM image file (as raw RGB always).}
1055 \twocolitem{{\bf wxBITMAP\_TYPE\_TIFF}}{Save a TIFF image file.}
1056 \twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Save a XPM image file.}
1057 \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).}
1058 \twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Save a Windows cursor file (CUR).}
1061 \docparam{mimetype}{MIME type.}
1063 \wxheading{Return value}
1065 true if the operation succeeded, false otherwise.
1069 Depending on how wxWidgets has been configured, not all formats may be available.
1071 Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to set the
1072 hotspot before saving an image into a cursor file (default hotspot is in
1073 the centre of the image):
1075 image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, hotspotX);
1076 image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotspotY);
1080 \wxheading{See also}
1082 \helpref{wxImage::LoadFile}{wximageloadfile}
1084 \pythonnote{In place of a single overloaded method name, wxPython
1085 implements the following methods:\par
1086 \indented{2cm}{\begin{twocollist}
1087 \twocolitem{{\bf SaveFile(filename, type)}}{Saves the image using the given
1088 type to the named file}
1089 \twocolitem{{\bf SaveMimeFile(filename, mimetype)}}{Saves the image using the given
1090 mimetype to the named file}
1094 \perlnote{Methods supported by wxPerl are:\par
1096 \item{bitmap->SaveFile( name, type )}
1097 \item{bitmap->SaveFile( name, mimetype )}
1102 \membersection{wxImage::Scale}\label{wximagescale}
1104 \constfunc{wxImage}{Scale}{\param{int}{ width}, \param{int}{ height}, \param{int}{ quality = wxIMAGE\_QUALITY\_NORMAL}}
1106 Returns a scaled version of the image. This is also useful for
1107 scaling bitmaps in general as the only other way to scale bitmaps
1108 is to blit a wxMemoryDC into another wxMemoryDC.
1110 \docparam{quality}{Determines what method to use for resampling the image. Can be one of the following:
1114 \twocolitem{{\bf wxIMAGE\_QUALITY\_NORMAL}}{Uses the normal default scaling method of pixel replication}
1115 \twocolitem{{\bf wxIMAGE\_QUALITY\_HIGH}}{Uses bicubic and box averaging resampling methods for upsampling and downsampling respectively}
1118 It should be noted that although using wxIMAGE\_QUALITY\_HIGH produces much nicer
1119 looking results it is a slower method. Downsampling will use the box averaging method
1120 which seems to operate very fast. If you are upsampling larger images using
1121 this method you will most likely notice that it is a bit slower and in extreme cases
1122 it will be quite substantially slower as the bicubic algorithm has to process a lot of
1125 It should also be noted that the high quality scaling may not work as expected
1126 when using a single mask colour for transparency, as the scaling will blur the
1127 image and will therefore remove the mask partially. Using the alpha channel
1133 // get the bitmap from somewhere
1136 // rescale it to have size of 32*32
1137 if ( bmp.GetWidth() != 32 || bmp.GetHeight() != 32 )
1139 wxImage image = bmp.ConvertToImage();
1140 bmp = wxBitmap(image.Scale(32, 32));
1142 // another possibility:
1143 image.Rescale(32, 32);
1149 \wxheading{See also}
1151 \helpref{Rescale}{wximagerescale}
1154 \membersection{wxImage::Size}\label{wximagesize}
1156 \constfunc{wxImage}{Size}{\param{const wxSize\&}{ size}, \param{const wxPoint&}{ pos}, \param{int}{ red = -1}, \param{int}{ green = -1}, \param{int}{ blue = -1}}
1158 Returns a resized version of this image without scaling it by adding either a border
1159 with the given colour or cropping as necessary. The image is pasted into a new
1160 image with the given {\it size} and background colour at the position {\it pos}
1161 relative to the upper left of the new image. If {\it red = green = blue = -1}
1162 then use either the current mask colour if set or find, use, and set a
1163 suitable mask colour for any newly exposed areas.
1165 \wxheading{See also}
1167 \helpref{Resize}{wximageresize}
1170 \membersection{wxImage::SetAlpha}\label{wximagesetalpha}
1172 \func{void}{SetAlpha}{\param{unsigned char *}{alpha = {\tt NULL}},\param{bool}{ static\_data = \false}}
1174 This function is similar to \helpref{SetData}{wximagesetdata} and has similar
1175 restrictions. The pointer passed to it may however be {\tt NULL} in which case
1176 the function will allocate the alpha array internally -- this is useful to add
1177 alpha channel data to an image which doesn't have any. If the pointer is not
1178 {\tt NULL}, it must have one byte for each image pixel and be allocated with
1179 {\tt malloc()}. wxImage takes ownership of the pointer and will free it unless
1180 \arg{static\_data} parameter is set to \true -- in this case the caller should
1183 \func{void}{SetAlpha}{\param{int }{x}, \param{int }{y}, \param{unsigned char }{alpha}}
1185 Sets the alpha value for the given pixel. This function should only be called
1186 if the image has alpha channel data, use \helpref{HasAlpha}{wximagehasalpha} to
1190 \membersection{wxImage::SetData}\label{wximagesetdata}
1192 \func{void}{SetData}{\param{unsigned char*}{data}}
1194 Sets the image data without performing checks. The data given must have
1195 the size (width*height*3) or results will be unexpected. Don't use this
1196 method if you aren't sure you know what you are doing.
1198 The data must have been allocated with {\tt malloc()}, {\large {\bf NOT}} with
1201 After this call the pointer to the data is owned by the wxImage object,
1202 that will be responsible for deleting it.
1203 Do not pass to this function a pointer obtained through
1204 \helpref{wxImage::GetData}{wximagegetdata}.
1207 \membersection{wxImage::SetMask}\label{wximagesetmask}
1209 \func{void}{SetMask}{\param{bool}{ hasMask = true}}
1211 Specifies whether there is a mask or not. The area of the mask is determined by the current mask colour.
1214 \membersection{wxImage::SetMaskColour}\label{wximagesetmaskcolour}
1216 \func{void}{SetMaskColour}{\param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}}
1218 Sets the mask colour for this image (and tells the image to use the mask).
1221 \membersection{wxImage::SetMaskFromImage}\label{wximagesetmaskfromimage}
1223 \func{bool}{SetMaskFromImage}{\param{const wxImage\&}{ mask}, \param{unsigned char}{ mr}, \param{unsigned char}{ mg}, \param{unsigned char}{ mb}}
1225 \wxheading{Parameters}
1227 \docparam{mask}{The mask image to extract mask shape from. Must have same dimensions as the image.}
1229 \docparam{mr,mg,mb}{RGB value of pixels in {\it mask} that will be used to create the mask.}
1231 Sets image's mask so that the pixels that have RGB value of {\it mr,mg,mb}
1232 in {\it mask} will be masked in the image. This is done by first finding an
1233 unused colour in the image, setting this colour as the mask colour and then
1234 using this colour to draw all pixels in the image who corresponding pixel
1235 in {\it mask} has given RGB value.
1237 \wxheading{Return value}
1239 Returns false if {\it mask} does not have same dimensions as the image or if
1240 there is no unused colour left. Returns true if the mask was successfully
1245 Note that this method involves computing the histogram, which is
1246 computationally intensive operation.
1249 \membersection{wxImage::SetOption}\label{wximagesetoption}
1251 \func{void}{SetOption}{\param{const wxString\&}{ name}, \param{const wxString\&}{ value}}
1253 \func{void}{SetOption}{\param{const wxString\&}{ name}, \param{int}{ value}}
1255 Sets a user-defined option. The function is case-insensitive to {\it name}.
1257 For example, when saving as a JPEG file, the option {\bf quality} is
1258 used, which is a number between 0 and 100 (0 is terrible, 100 is very good).
1260 \wxheading{See also}
1262 \helpref{wxImage::GetOption}{wximagegetoption},\rtfsp
1263 \helpref{wxImage::GetOptionInt}{wximagegetoptionint},\rtfsp
1264 \helpref{wxImage::HasOption}{wximagehasoption}
1267 \membersection{wxImage::SetPalette}\label{wximagesetpalette}
1269 \func{void}{SetPalette}{\param{const wxPalette\&}{ palette}}
1271 Associates a palette with the image. The palette may be used when converting
1272 wxImage to wxBitmap (MSW only at present) or in file save operations (none as yet).
1275 \membersection{wxImage::SetRGB}\label{wximagesetrgb}
1277 \func{void}{SetRGB}{\param{int }{x}, \param{int }{y}, \param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}}
1279 Sets the pixel at the given coordinate. This routine performs bounds-checks
1280 for the coordinate so it can be considered a safe way to manipulate the
1281 data, but in some cases this might be too slow so that the data will have to
1282 be set directly. In that case you will have to get access to the image data
1283 using the \helpref{GetData}{wximagegetdata} method.
1286 \membersection{wxImage::SetRGB}\label{wximagesetrgbrect}
1288 \func{void}{SetRGB}{\param{wxRect \& }{rect}, \param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}}
1290 Sets the colour of the pixels within the given rectangle. This routine performs
1291 bounds-checks for the coordinate so it can be considered a safe way to manipulate the
1295 \membersection{wxImage::operator $=$}\label{wximageassign}
1297 \func{wxImage\& }{operator $=$}{\param{const wxImage\& }{image}}
1299 Assignment operator, using \helpref{reference counting}{trefcount}.
1301 \wxheading{Parameters}
1303 \docparam{image}{Image to assign.}
1305 \wxheading{Return value}
1307 Returns 'this' object.
1311 \section{\class{wxImageHandler}}\label{wximagehandler}
1313 This is the base class for implementing image file loading/saving, and image creation from data.
1314 It is used within wxImage and is not normally seen by the application.
1316 If you wish to extend the capabilities of wxImage, derive a class from wxImageHandler
1317 and add the handler using \helpref{wxImage::AddHandler}{wximageaddhandler} in your
1318 application initialisation.
1320 \wxheading{Note (Legal Issue)}
1322 This software is based in part on the work of the Independent JPEG Group.
1324 (Applies when wxWidgets is linked with JPEG support. wxJPEGHandler uses libjpeg
1327 \wxheading{Derived from}
1329 \helpref{wxObject}{wxobject}
1331 \wxheading{Include files}
1337 \helpref{wxCore}{librarieslist}
1339 \wxheading{See also}
1341 \helpref{wxImage}{wximage},
1342 \helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}
1344 \latexignore{\rtfignore{\wxheading{Members}}}
1347 \membersection{wxImageHandler::wxImageHandler}\label{wximagehandlerctor}
1349 \func{}{wxImageHandler}{\void}
1351 Default constructor. In your own default constructor, initialise the members
1352 m\_name, m\_extension and m\_type.
1355 \membersection{wxImageHandler::\destruct{wxImageHandler}}\label{wximagehandlerdtor}
1357 \func{}{\destruct{wxImageHandler}}{\void}
1359 Destroys the wxImageHandler object.
1362 \membersection{wxImageHandler::GetName}\label{wximagehandlergetname}
1364 \constfunc{const wxString\&}{GetName}{\void}
1366 Gets the name of this handler.
1369 \membersection{wxImageHandler::GetExtension}\label{wximagehandlergetextension}
1371 \constfunc{const wxString\&}{GetExtension}{\void}
1373 Gets the file extension associated with this handler.
1376 \membersection{wxImageHandler::GetImageCount}\label{wximagehandlergetimagecount}
1378 \func{int}{GetImageCount}{\param{wxInputStream\&}{ stream}}
1380 If the image file contains more than one image and the image handler is capable
1381 of retrieving these individually, this function will return the number of
1384 \docparam{stream}{Opened input stream for reading image data. Currently, the stream must support seeking.}
1386 \wxheading{Return value}
1388 Number of available images. For most image handlers, this is 1 (exceptions
1389 are TIFF and ICO formats).
1392 \membersection{wxImageHandler::GetType}\label{wximagehandlergettype}
1394 \constfunc{long}{GetType}{\void}
1396 Gets the image type associated with this handler.
1399 \membersection{wxImageHandler::GetMimeType}\label{wximagehandlergetmimetype}
1401 \constfunc{const wxString\&}{GetMimeType}{\void}
1403 Gets the MIME type associated with this handler.
1406 \membersection{wxImageHandler::LoadFile}\label{wximagehandlerloadfile}
1408 \func{bool}{LoadFile}{\param{wxImage* }{image}, \param{wxInputStream\&}{ stream}, \param{bool}{ verbose=true}, \param{int}{ index=0}}
1410 Loads a image from a stream, putting the resulting data into {\it image}. If the image file contains
1411 more than one image and the image handler is capable of retrieving these individually, {\it index}
1412 indicates which image to read from the stream.
1414 \wxheading{Parameters}
1416 \docparam{image}{The image object which is to be affected by this operation.}
1418 \docparam{stream}{Opened input stream for reading image data.}
1420 \docparam{verbose}{If set to true, errors reported by the image handler will produce wxLogMessages.}
1422 \docparam{index}{The index of the image in the file (starting from zero).}
1424 \wxheading{Return value}
1426 true if the operation succeeded, false otherwise.
1428 \wxheading{See also}
1430 \helpref{wxImage::LoadFile}{wximageloadfile},
1431 \helpref{wxImage::SaveFile}{wximagesavefile},
1432 \helpref{wxImageHandler::SaveFile}{wximagehandlersavefile}
1435 \membersection{wxImageHandler::SaveFile}\label{wximagehandlersavefile}
1437 \func{bool}{SaveFile}{\param{wxImage* }{image}, \param{wxOutputStream\& }{stream}}
1439 Saves a image in the output stream.
1441 \wxheading{Parameters}
1443 \docparam{image}{The image object which is to be affected by this operation.}
1445 \docparam{stream}{Opened output stream for writing the data.}
1447 \wxheading{Return value}
1449 true if the operation succeeded, false otherwise.
1451 \wxheading{See also}
1453 \helpref{wxImage::LoadFile}{wximageloadfile},
1454 \helpref{wxImage::SaveFile}{wximagesavefile},
1455 \helpref{wxImageHandler::LoadFile}{wximagehandlerloadfile}
1458 \membersection{wxImageHandler::SetName}\label{wximagehandlersetname}
1460 \func{void}{SetName}{\param{const wxString\& }{name}}
1462 Sets the handler name.
1464 \wxheading{Parameters}
1466 \docparam{name}{Handler name.}
1469 \membersection{wxImageHandler::SetExtension}\label{wximagehandlersetextension}
1471 \func{void}{SetExtension}{\param{const wxString\& }{extension}}
1473 Sets the handler extension.
1475 \wxheading{Parameters}
1477 \docparam{extension}{Handler extension.}
1480 \membersection{wxImageHandler::SetMimeType}\label{wximagehandlersetmimetype}
1482 \func{void}{SetMimeType}{\param{const wxString\& }{mimetype}}
1484 Sets the handler MIME type.
1486 \wxheading{Parameters}
1488 \docparam{mimename}{Handler MIME type.}
1491 \membersection{wxImageHandler::SetType}\label{wximagehandlersettype}
1493 \func{void}{SetType}{\param{long }{type}}
1495 Sets the handler type.
1497 \wxheading{Parameters}
1499 \docparam{name}{Handler type.}