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 only
40 images loaded from PNG files with transparency information will have an alpha
41 channel but alpha support will be added to the other formats as well (as well
42 as support for saving images with alpha channel which also isn't implemented).
44 \wxheading{Available image handlers
}
46 The following image handlers are available.
{\bf wxBMPHandler
} is always
47 installed by default. To use other image formats, install the appropriate
48 handler with
\helpref{wxImage::AddHandler
}{wximageaddhandler
} or call
49 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}.
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{wxTGAHandler
}}{For loading only.
}
61 \twocolitem{\indexit{wxIFFHandler
}}{For loading only.
}
62 \twocolitem{\indexit{wxXPMHandler
}}{For loading and saving.
}
63 \twocolitem{\indexit{wxICOHandler
}}{For loading and saving.
}
64 \twocolitem{\indexit{wxCURHandler
}}{For loading and saving.
}
65 \twocolitem{\indexit{wxANIHandler
}}{For loading only.
}
68 When saving in PCX format,
{\bf wxPCXHandler
} will count the number of
69 different colours in the image; if there are
256 or less colours, it will
70 save as
8 bit, else it will save as
24 bit.
72 Loading PNMs only works for ASCII or raw RGB images. When saving in
73 PNM format,
{\bf wxPNMHandler
} will always save as raw RGB.
75 \wxheading{Derived from
}
77 \helpref{wxObject
}{wxobject
}
79 \wxheading{Include files
}
85 \helpref{wxBitmap
}{wxbitmap
},
86 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}
88 \latexignore{\rtfignore{\wxheading{Members
}}}
91 \membersection{wxImage::wxImage
}\label{wximagector
}
93 \func{}{wxImage
}{\void}
97 \func{}{wxImage
}{\param{const wxImage\&
}{image
}}
99 Copy constructor, uses
\helpref{reference counting
}{trefcount
}.
101 \func{}{wxImage
}{\param{const wxBitmap\&
}{ bitmap
}}
103 (Deprecated form, use
\helpref{wxBitmap::ConvertToImage
}{wxbitmapconverttoimage
}
104 instead.) Constructs an image from a platform-dependent bitmap. This preserves
105 mask information so that bitmaps and images can be converted back
106 and forth without loss in that respect.
108 \func{}{wxImage
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{bool
}{ clear=true
}}
110 Creates an image with the given width and height. If
{\it clear
} is true, the new image will be initialized to black.
111 Otherwise, the image data will be uninitialized.
113 \func{}{wxImage
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{unsigned char*
}{ data
},
\param{bool
}{ static
\_data =
\false}}
115 Creates an image from given data with the given width and height. If
116 {\it static
\_data} is true, then wxImage will not delete the actual
117 image data in its destructor, otherwise it will free it by calling
120 \func{}{wxImage
}{\param{const wxString\&
}{name
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY},
\param{int
}{ index = -
1}}
122 \func{}{wxImage
}{\param{const wxString\&
}{name
},
\param{const wxString\&
}{ mimetype
},
\param{int
}{ index = -
1}}
124 Loads an image from a file.
126 \func{}{wxImage
}{\param{wxInputStream\&
}{stream
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY},
\param{int
}{ index = -
1}}
128 \func{}{wxImage
}{\param{wxInputStream\&
}{stream
},
\param{const wxString\&
}{ mimetype
},
\param{int
}{ index = -
1}}
130 Loads an image from an input stream.
132 \func{}{wxImage
}{\param{const char* const*
}{xpmData
}}
134 Creates an image from XPM data.
136 \wxheading{Parameters
}
138 \docparam{width
}{Specifies the width of the image.
}
140 \docparam{height
}{Specifies the height of the image.
}
142 \docparam{name
}{Name of the file from which to load the image.
}
144 \docparam{stream
}{Opened input stream from which to load the image. Currently, the stream must support seeking.
}
146 \docparam{type
}{May be one of the following:
150 \twocolitem{\indexit{wxBITMAP
\_TYPE\_BMP}}{Load a Windows bitmap file.
}
151 \twocolitem{\indexit{wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
152 \twocolitem{\indexit{wxBITMAP
\_TYPE\_JPEG}}{Load a JPEG bitmap file.
}
153 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PNG}}{Load a PNG bitmap file.
}
154 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PCX}}{Load a PCX bitmap file.
}
155 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PNM}}{Load a PNM bitmap file.
}
156 \twocolitem{\indexit{wxBITMAP
\_TYPE\_TIF}}{Load a TIFF bitmap file.
}
157 \twocolitem{\indexit{wxBITMAP
\_TYPE\_TGA}}{Load a TGA bitmap file.
}
158 \twocolitem{\indexit{wxBITMAP
\_TYPE\_XPM}}{Load a XPM bitmap file.
}
159 \twocolitem{\indexit{wxBITMAP
\_TYPE\_ICO}}{Load a Windows icon file (ICO).
}
160 \twocolitem{\indexit{wxBITMAP
\_TYPE\_CUR}}{Load a Windows cursor file (CUR).
}
161 \twocolitem{\indexit{wxBITMAP
\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).
}
162 \twocolitem{\indexit{wxBITMAP
\_TYPE\_ANY}}{Will try to autodetect the format.
}
165 \docparam{mimetype
}{MIME type string (for example 'image/jpeg')
}
167 \docparam{index
}{Index of the image to load in the case that the image file contains multiple images.
168 This is only used by GIF, ICO and TIFF handlers. The default value (-
1) means
169 "choose the default image" and is interpreted as the first image (index=
0) by
170 the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.
}
172 \docparam{xpmData
}{A pointer to XPM image data.
}
176 Depending on how wxWidgets has been configured, not all formats may be available.
178 Note: any handler other than BMP must be previously
179 initialized with
\helpref{wxImage::AddHandler
}{wximageaddhandler
} or
180 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}.
182 Note: you can use
\helpref{GetOptionInt
}{wximagegetoptionint
} to get the
183 hotspot for loaded cursor file:
185 int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
186 int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
192 \helpref{wxImage::LoadFile
}{wximageloadfile
}
194 \pythonnote{Constructors supported by wxPython are:
\par
195 \indented{2cm
}{\begin{twocollist
}
196 \twocolitem{{\bf wxImage(name, flag)
}}{Loads an image from a file
}
197 \twocolitem{{\bf wxNullImage()
}}{Create a null image (has no size or
199 \twocolitem{{\bf wxEmptyImage(width, height)
}}{Creates an empty image
201 \twocolitem{{\bf wxImageFromMime(name, mimetype
}}{Creates an image from
202 the given file of the given mimetype
}
203 \twocolitem{{\bf wxImageFromBitmap(bitmap)
}}{Creates an image from a
204 platform-dependent bitmap
}
208 \perlnote{Constructors supported by wxPerl are:
\par
210 \item{Wx::Image->new( bitmap )
}
211 \item{Wx::Image->new( icon )
}
212 \item{Wx::Image->new( width, height )
}
213 \item{Wx::Image->new( width, height, data )
}
214 \item{Wx::Image->new( file, type, index )
}
215 \item{Wx::Image->new( file, mimetype, index )
}
216 \item{Wx::Image->new( stream, type, index )
}
217 \item{Wx::Image->new( stream, mimetype, index )
}
222 \membersection{wxImage::
\destruct{wxImage
}}\label{wximagedtor
}
224 \func{}{\destruct{wxImage
}}{\void}
229 \membersection{wxImage::AddHandler
}\label{wximageaddhandler
}
231 \func{static void
}{AddHandler
}{\param{wxImageHandler*
}{ handler
}}
233 Adds a handler to the end of the static list of format handlers.
235 \docparam{handler
}{A new image format handler object. There is usually only one instance
236 of a given handler class in an application session.
}
240 \helpref{wxImageHandler
}{wximagehandler
}
242 \func{bool
}{CanRead
}{\param{const wxString\&
}{ filename
}}
244 returns true if the current image handlers can read this file
246 \pythonnote{In wxPython this static method is named
{\tt wxImage
\_AddHandler}.
}
249 \membersection{wxImage::Blur
}\label{wximageblur
}
251 \func{wxImage
}{Blur
}{\param{int
}{ blurRadius
}}
253 Blurs the image in both horizontal and vertical directions by the specified pixel
254 {\it blurRadius
}. This should not be used when using a single mask colour
259 \helpref{BlurHorizontal
}{wximagehorzblur
}
260 \helpref{BlurVertical
}{wximagevertblur
}
263 \membersection{wxImage::BlurHorizontal
}\label{wximagehorzblur
}
265 \func{wxImage
}{BlurHorizontal
}{\param{int
}{ blurRadius
}}
267 Blurs the image in the horizontal direction only. This should not be used
268 when using a single mask colour for transparency.
271 \helpref{Blur
}{wximageblur
}
272 \helpref{BlurVertical
}{wximagevertblur
}
275 \membersection{wxImage::BlurVertical
}\label{wximagevertblur
}
277 \func{wxImage
}{BlurVertical
}{\param{int
}{ blurRadius
}}
279 Blurs the image in the vertical direction only. This should not be used
280 when using a single mask colour for transparency.
284 \helpref{Blur
}{wximageblur
}
285 \helpref{BlurHorizontal
}{wximagehorzblur
}
288 \membersection{wxImage::CleanUpHandlers
}\label{wximagecleanuphandlers
}
290 \func{static void
}{CleanUpHandlers
}{\void}
292 Deletes all image handlers.
294 This function is called by wxWidgets on exit.
297 \membersection{wxImage::ComputeHistogram
}\label{wximagecomputehistogram
}
299 \constfunc{unsigned long
}{ComputeHistogram
}{\param{wxImageHistogram\&
}{histogram
}}
301 Computes the histogram of the image.
{\it histogram
} is a reference to
302 wxImageHistogram object. wxImageHistogram is a specialization of
303 \helpref{wxHashMap
}{wxhashmap
} "template" and is defined as follows:
306 class WXDLLEXPORT wxImageHistogramEntry
309 wxImageHistogramEntry() : index(
0), value(
0)
{}
314 WX_DECLARE_EXPORTED_HASH_MAP(unsigned long, wxImageHistogramEntry,
315 wxIntegerHash, wxIntegerEqual,
319 \wxheading{Return value
}
321 Returns number of colours in the histogram.
324 \membersection{wxImage::ConvertAlphaToMask
}\label{wximageconvertalphatomask
}
326 \func{bool
}{ConvertAlphaToMask
}{\param{unsigned char
}{ threshold = $
128$
}}
328 If the image has alpha channel, this method converts it to mask. All pixels
329 with alpha value less than
\arg{threshold
} are replaced with mask colour
330 and the alpha channel is removed. Mask colour is chosen automatically using
331 \helpref{FindFirstUnusedColour
}{wximagefindfirstunusedcolour
}.
333 If the image image doesn't have alpha channel,
334 ConvertAlphaToMask does nothing.
336 \wxheading{Return value
}
338 \false if FindFirstUnusedColour returns
\false,
\true otherwise.
341 \membersection{wxImage::ConvertToBitmap
}\label{wximageconverttobitmap
}
343 \constfunc{wxBitmap
}{ConvertToBitmap
}{\void}
345 Deprecated, use equivalent
\helpref{wxBitmap constructor
}{wxbitmapctor
}
346 (which takes wxImage and depth as its arguments) instead.
349 \membersection{wxImage::ConvertToGreyscale
}\label{wximageconverttogreyscale
}
351 \constfunc{wxImage
}{ConvertToGreyscale
}{\param{double
}{ lr =
0.299},
\param{double
}{ lg =
0.587},
\param{double
}{ lb =
0.114}}
353 Returns a greyscale version of the image. The returned image uses the luminance
354 component of the original to calculate the greyscale. Defaults to using
355 ITU-T BT
.601 when converting to YUV, where every pixel equals
356 (R *
{\it lr
}) + (G *
{\it lg
}) + (B *
{\it lb
}).
359 \membersection{wxImage::ConvertToMono
}\label{wxbitmapconverttomono
}
361 \constfunc{wxImage
}{ConvertToMono
}{\param{unsigned char
}{ r
},
\param{unsigned char
}{ g
},
\param{unsigned char
}{ b
}}
363 Returns monochromatic version of the image. The returned image has white
364 colour where the original has
{\it (r,g,b)
} colour and black colour
368 \membersection{wxImage::Copy
}\label{wximagecopy
}
370 \constfunc{wxImage
}{Copy
}{\void}
372 Returns an identical copy of the image.
375 \membersection{wxImage::Create
}\label{wximagecreate
}
377 \func{bool
}{Create
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{bool
}{ clear=true
}}
379 Creates a fresh image. If
{\it clear
} is true, the new image will be initialized to black.
380 Otherwise, the image data will be uninitialized.
382 \wxheading{Parameters
}
384 \docparam{width
}{The width of the image in pixels.
}
386 \docparam{height
}{The height of the image in pixels.
}
388 \wxheading{Return value
}
390 true if the call succeeded, false otherwise.
393 \membersection{wxImage::Destroy
}\label{wximagedestroy
}
395 \func{void
}{Destroy
}{\void}
397 Destroys the image data.
400 \membersection{wxImage::FindFirstUnusedColour
}\label{wximagefindfirstunusedcolour
}
402 \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}}
404 \wxheading{Parameters
}
406 \docparam{r,g,b
}{Pointers to variables to save the colour.
}
408 \docparam{startR,startG,startB
}{Initial values of the colour. Returned colour
409 will have RGB values equal to or greater than these.
}
411 Finds the first colour that is never used in the image. The search begins at
412 given initial colour and continues by increasing R, G and B components (in this
413 order) by
1 until an unused colour is found or the colour space exhausted.
415 \wxheading{Return value
}
417 Returns false if there is no unused colour left, true on success.
421 Note that this method involves computing the histogram, which is
422 computationally intensive operation.
425 \membersection{wxImage::FindHandler
}\label{wximagefindhandler
}
427 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{name
}}
429 Finds the handler with the given name.
431 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{extension
},
\param{long
}{ imageType
}}
433 Finds the handler associated with the given extension and type.
435 \func{static wxImageHandler*
}{FindHandler
}{\param{long
}{imageType
}}
437 Finds the handler associated with the given image type.
439 \func{static wxImageHandler*
}{FindHandlerMime
}{\param{const wxString\&
}{mimetype
}}
441 Finds the handler associated with the given MIME type.
443 \docparam{name
}{The handler name.
}
445 \docparam{extension
}{The file extension, such as ``bmp".
}
447 \docparam{imageType
}{The image type, such as wxBITMAP
\_TYPE\_BMP.
}
449 \docparam{mimetype
}{MIME type.
}
451 \wxheading{Return value
}
453 A pointer to the handler if found, NULL otherwise.
457 \helpref{wxImageHandler
}{wximagehandler
}
460 \membersection{wxImage::GetImageExtWildcard
}\label{wximagegetimageextwildcard
}
462 \func{static wxString
}{GetImageExtWildcard
}{\void}
464 Iterates all registered wxImageHandler objects, and returns a string containing file extension masks
465 suitable for passing to file open/save dialog boxes.
467 \wxheading{Return value
}
469 The format of the returned string is "
(*.ext1;*.ext2)|*.ext1;*.ext2".
471 It is usually a good idea to prepend a description before passing the result to the dialog.
476 wxFileDialog FileDlg( this, "Choose Image", ::wxGetCwd(), "", _("Image Files ") + wxImage::GetImageExtWildcard(), wxOPEN );
481 \helpref{wxImageHandler}{wximagehandler}
484 \membersection{wxImage::GetAlpha}\label{wximagegetalpha}
486 \constfunc{unsigned char}{GetAlpha}{\param{int}{ x}, \param{int}{ y}}
488 Returns the alpha value for the given pixel. This function may only be called
489 for the images with alpha channel, use \helpref{HasAlpha}{wximagehasalpha} to
492 The returned value is the {\it opacity} of the image, i.e. the value of $0$
493 corresponds to the transparent pixels while the value of $255$ -- to the opaque
496 \constfunc{unsigned char *}{GetAlpha}{\void}
498 Returns pointer to the array storing the alpha values for this image. This
499 pointer is {\tt NULL} for the images without the alpha channel. If the image
500 does have it, this pointer may be used to directly manipulate the alpha values
501 which are stored as the \helpref{RGB}{wximagegetdata} ones.
504 \membersection{wxImage::GetBlue}\label{wximagegetblue}
506 \constfunc{unsigned char}{GetBlue}{\param{int}{ x}, \param{int}{ y}}
508 Returns the blue intensity at the given coordinate.
511 \membersection{wxImage::GetData}\label{wximagegetdata}
513 \constfunc{unsigned char*}{GetData}{\void}
515 Returns the image data as an array. This is most often used when doing
516 direct image manipulation. The return value points to an array of
517 characters in RGBRGBRGB$\ldots$ format in the top-to-bottom, left-to-right
518 order, that is the first RGB triplet corresponds to the pixel first pixel of
519 the first row, the second one --- to the second pixel of the first row and so
520 on until the end of the first row, with second row following after it and so
523 You should not delete the returned pointer nor pass it to
524 \helpref{wxImage::SetData}{wximagesetdata}.
527 \membersection{wxImage::GetGreen}\label{wximagegetgreen}
529 \constfunc{unsigned char}{GetGreen}{\param{int}{ x}, \param{int}{ y}}
531 Returns the green intensity at the given coordinate.
534 \membersection{wxImage::GetImageCount}\label{wximagegetimagecount}
536 \func{static int}{GetImageCount}{\param{const wxString\&}{ filename}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}}
538 \func{static int}{GetImageCount}{\param{wxInputStream\&}{ stream}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}}
540 If the image file contains more than one image and the image handler is capable
541 of retrieving these individually, this function will return the number of
544 \docparam{name}{Name of the file to query.}
546 \docparam{stream}{Opened input stream with image data. Currently, the stream must support seeking.}
548 \docparam{type}{May be one of the following:
552 \twocolitem{\indexit{wxBITMAP\_TYPE\_BMP}}{Load a Windows bitmap file.}
553 \twocolitem{\indexit{wxBITMAP\_TYPE\_GIF}}{Load a GIF bitmap file.}
554 \twocolitem{\indexit{wxBITMAP\_TYPE\_JPEG}}{Load a JPEG bitmap file.}
555 \twocolitem{\indexit{wxBITMAP\_TYPE\_PNG}}{Load a PNG bitmap file.}
556 \twocolitem{\indexit{wxBITMAP\_TYPE\_PCX}}{Load a PCX bitmap file.}
557 \twocolitem{\indexit{wxBITMAP\_TYPE\_PNM}}{Load a PNM bitmap file.}
558 \twocolitem{\indexit{wxBITMAP\_TYPE\_TIF}}{Load a TIFF bitmap file.}
559 \twocolitem{\indexit{wxBITMAP\_TYPE\_XPM}}{Load a XPM bitmap file.}
560 \twocolitem{\indexit{wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
561 \twocolitem{\indexit{wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
562 \twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
563 \twocolitem{\indexit{wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
566 \wxheading{Return value}
568 Number of available images. For most image handlers, this is 1 (exceptions
569 are TIFF and ICO formats).
572 \membersection{wxImage::GetHandlers}\label{wximagegethandlers}
574 \func{static wxList\&}{GetHandlers}{\void}
576 Returns the static list of image format handlers.
580 \helpref{wxImageHandler}{wximagehandler}
583 \membersection{wxImage::GetHeight}\label{wximagegetheight}
585 \constfunc{int}{GetHeight}{\void}
587 Gets the height of the image in pixels.
590 \membersection{wxImage::GetMaskBlue}\label{wximagegetmaskblue}
592 \constfunc{unsigned char}{GetMaskBlue}{\void}
594 Gets the blue value of the mask colour.
597 \membersection{wxImage::GetMaskGreen}\label{wximagegetmaskgreen}
599 \constfunc{unsigned char}{GetMaskGreen}{\void}
601 Gets the green value of the mask colour.
604 \membersection{wxImage::GetMaskRed}\label{wximagegetmaskred}
606 \constfunc{unsigned char}{GetMaskRed}{\void}
608 Gets the red value of the mask colour.
611 \membersection{wxImage::GetOrFindMaskColour}\label{wximagegetgetorsetmaskcolour}
613 \constfunc{bool}{GetOrFindMaskColour}{\param{unsigned char}{ *r}, \param{unsigned char}{ *g}, \param{unsigned char}{ *b}}
615 Get the current mask colour or find a suitable unused colour that could be
616 used as a mask colour. Returns {\tt true} if the image currently has a mask.
619 \membersection{wxImage::GetPalette}\label{wximagegetpalette}
621 \constfunc{const wxPalette\&}{GetPalette}{\void}
623 Returns the palette associated with the image. Currently the palette is only
624 used when converting to wxBitmap under Windows. Some of the wxImage handlers
625 have been modified to set the palette if one exists in the image file (usually
626 256 or less colour images in GIF or PNG format).
629 \membersection{wxImage::GetRed}\label{wximagegetred}
631 \constfunc{unsigned char}{GetRed}{\param{int}{ x}, \param{int}{ y}}
633 Returns the red intensity at the given coordinate.
636 \membersection{wxImage::GetSubImage}\label{wximagegetsubimage}
638 \constfunc{wxImage}{GetSubImage}{\param{const wxRect\&}{ rect}}
640 Returns a sub image of the current one as long as the rect belongs entirely to
644 \membersection{wxImage::GetWidth}\label{wximagegetwidth}
646 \constfunc{int}{GetWidth}{\void}
648 Gets the width of the image in pixels.
652 \helpref{wxImage::GetHeight}{wximagegetheight}
655 \membersection{HSVValue::HSVValue}\label{hsvvaluehsvvalue}
657 \func{}{HSVValue}{\param{double }{h = 0.0}, \param{double }{s = 0.0}, \param{double }{v = 0.0}}
659 Constructor for HSVValue, an object that contains values for hue, saturation and value which
660 represent the value of a color. It is used by \helpref{wxImage::HSVtoRGB}{wximagehsvtorgb}
661 and \helpref{wxImage::RGBtoHSV}{wximagergbtohsv}, which
662 converts between HSV color space and RGB color space.
664 \pythonnote{use wxImage\_HSVValue in wxPython}
668 \membersection{wxImage::HSVtoRGB}\label{wximagehsvtorgb}
670 \func{wxImage::RGBValue}{HSVtoRGB}{\param{const HSVValue \& }{hsv}}
672 Converts a color in HSV color space to RGB color space.
675 \membersection{wxImage::HasAlpha}\label{wximagehasalpha}
677 \constfunc{bool}{HasAlpha}{\void}
679 Returns true if this image has alpha channel, false otherwise.
683 \helpref{GetAlpha}{wximagegetalpha}, \helpref{SetAlpha}{wximagesetalpha}
686 \membersection{wxImage::HasMask}\label{wximagehasmask}
688 \constfunc{bool}{HasMask}{\void}
690 Returns true if there is a mask active, false otherwise.
693 \membersection{wxImage::GetOption}\label{wximagegetoption}
695 \constfunc{wxString}{GetOption}{\param{const wxString\&}{ name}}
697 Gets a user-defined option. The function is case-insensitive to {\it name}.
699 For example, when saving as a JPEG file, the option {\bf quality} is
700 used, which is a number between 0 and 100 (0 is terrible, 100 is very good).
704 \helpref{wxImage::SetOption}{wximagesetoption},\rtfsp
705 \helpref{wxImage::GetOptionInt}{wximagegetoptionint},\rtfsp
706 \helpref{wxImage::HasOption}{wximagehasoption}
709 \membersection{wxImage::GetOptionInt}\label{wximagegetoptionint}
711 \constfunc{int}{GetOptionInt}{\param{const wxString\&}{ name}}
713 Gets a user-defined option as an integer. The function is case-insensitive to {\it name}.
715 If the given option is not present, the function returns $0$. Use
716 \helpref{wxImage::HasOption}{wximagehasoption} is $0$ is a possibly valid value
719 Options for wxPNGHandler
722 \twocolitem{wxIMAGE\_OPTION\_PNG\_FORMAT}{Format for saving a PNG file.}
723 \twocolitem{wxIMAGE\_OPTION\_PNG\_BITDEPTH}{Bit depth for every channel (R/G/B/A).}
726 Supported values for wxIMAGE\_OPTION\_PNG\_FORMAT:
729 \twocolitem{wxPNG\_TYPE\_COLOUR}{Stores RGB image.}
730 \twocolitem{wxPNG\_TYPE\_GREY}{Stores grey image, converts from RGB.}
731 \twocolitem{wxPNG\_TYPE\_GREY\_RED}{Stores grey image, uses red value as grey.}
737 \helpref{wxImage::SetOption}{wximagesetoption},\rtfsp
738 \helpref{wxImage::GetOption}{wximagegetoption}
741 \membersection{wxImage::HasOption}\label{wximagehasoption}
743 \constfunc{bool}{HasOption}{\param{const wxString\&}{ name}}
745 Returns true if the given option is present. The function is case-insensitive to {\it name}.
749 \helpref{wxImage::SetOption}{wximagesetoption},\rtfsp
750 \helpref{wxImage::GetOption}{wximagegetoption},\rtfsp
751 \helpref{wxImage::GetOptionInt}{wximagegetoptionint}
754 \membersection{wxImage::InitAlpha}\label{wximageinitalpha}
756 \func{void}{InitAlpha}{\void}
758 Initializes the image alpha channel data. It is an error to call it
759 if the image already has alpha data. If it doesn't, alpha data will be
760 by default initialized to all pixels being fully opaque. But if the image has a
761 a mask colour, all mask pixels will be completely transparent.
764 \membersection{wxImage::InitStandardHandlers}\label{wximageinitstandardhandlers}
766 \func{static void}{InitStandardHandlers}{\void}
768 Internal use only. Adds standard image format handlers. It only install BMP
769 for the time being, which is used by wxBitmap.
771 This function is called by wxWidgets on startup, and shouldn't be called by
776 \helpref{wxImageHandler}{wximagehandler},
777 \helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}
780 \membersection{wxImage::InsertHandler}\label{wximageinserthandler}
782 \func{static void}{InsertHandler}{\param{wxImageHandler*}{ handler}}
784 Adds a handler at the start of the static list of format handlers.
786 \docparam{handler}{A new image format handler object. There is usually only one instance
787 of a given handler class in an application session.}
791 \helpref{wxImageHandler}{wximagehandler}
794 \membersection{wxImage::IsTransparent}\label{wximageistransparent}
796 \constfunc{bool}{IsTransparent}{\param{int }{x}, \param{int }{y}, \param{unsigned char}{ threshold = $128$}}
798 Returns \true if the given pixel is transparent, i.e. either has the mask
799 colour if this image has a mask or if this image has alpha channel and alpha
800 value of this pixel is strictly less than \arg{threshold}.
803 \membersection{wxImage::LoadFile}\label{wximageloadfile}
805 \func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}, \param{int}{ index = -1}}
807 \func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}
809 Loads an image from a file. If no handler type is provided, the library will
810 try to autodetect the format.
812 \func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{long}{ type}, \param{int}{ index = -1}}
814 \func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}
816 Loads an image from an input stream.
818 \wxheading{Parameters}
820 \docparam{name}{Name of the file from which to load the image.}
822 \docparam{stream}{Opened input stream from which to load the image. Currently, the stream must support seeking.}
824 \docparam{type}{One of the following values:
828 \twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Load a Windows image file.}
829 \twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Load a GIF image file.}
830 \twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Load a JPEG image file.}
831 \twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Load a PCX image file.}
832 \twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Load a PNG image file.}
833 \twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Load a PNM image file.}
834 \twocolitem{{\bf wxBITMAP\_TYPE\_TIF}}{Load a TIFF image file.}
835 \twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Load a XPM image file.}
836 \twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
837 \twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
838 \twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
839 \twocolitem{{\bf wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
842 \docparam{mimetype}{MIME type string (for example 'image/jpeg')}
844 \docparam{index}{Index of the image to load in the case that the image file contains multiple images.
845 This is only used by GIF, ICO and TIFF handlers. The default value (-1) means
846 "choose the default image" and is interpreted as the first image (index=0) by
847 the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.}
851 Depending on how wxWidgets has been configured, not all formats may be available.
853 Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to get the
854 hotspot for loaded cursor file:
856 int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
857 int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
861 \wxheading{Return value}
863 true if the operation succeeded, false otherwise. If the optional index parameter is out of range,
864 false is returned and a call to wxLogError() takes place.
868 \helpref{wxImage::SaveFile}{wximagesavefile}
870 \pythonnote{In place of a single overloaded method name, wxPython
871 implements the following methods:\par
872 \indented{2cm}{\begin{twocollist}
873 \twocolitem{{\bf LoadFile(filename, type)}}{Loads an image of the given
875 \twocolitem{{\bf LoadMimeFile(filename, mimetype)}}{Loads an image of the given
876 mimetype from a file}
880 \perlnote{Methods supported by wxPerl are:\par
882 \item{bitmap->LoadFile( name, type )}
883 \item{bitmap->LoadFile( name, mimetype )}
889 \membersection{wxImage::IsOk}\label{wximageisok}
891 \constfunc{bool}{IsOk}{\void}
893 Returns true if image data is present.
896 \membersection{RGBValue::RGBValue}\label{rgbvaluergbvalue}
898 \func{}{RGBValue}{\param{unsigned char }{r = 0}, \param{unsigned char }{g = 0}, \param{unsigned char }{b = 0}}
900 Constructor for RGBValue, an object that contains values for red, green and blue which
901 represent the value of a color. It is used by \helpref{wxImage::HSVtoRGB}{wximagehsvtorgb}
902 and \helpref{wxImage::RGBtoHSV}{wximagergbtohsv}, which
903 converts between HSV color space and RGB color space.
905 \pythonnote{use wxImage\_RGBValue in wxPython}
908 \membersection{wxImage::RGBtoHSV}\label{wximagergbtohsv}
910 \func{wxImage::HSVValue}{RGBtoHSV}{\param{const RGBValue\& }{rgb}}
912 Converts a color in RGB color space to HSV color space.
915 \membersection{wxImage::RemoveHandler}\label{wximageremovehandler}
917 \func{static bool}{RemoveHandler}{\param{const wxString\& }{name}}
919 Finds the handler with the given name, and removes it. The handler
922 \docparam{name}{The handler name.}
924 \wxheading{Return value}
926 true if the handler was found and removed, false otherwise.
930 \helpref{wxImageHandler}{wximagehandler}
933 \membersection{wxImage::Mirror}\label{wximagemirror}
935 \constfunc{wxImage}{Mirror}{\param{bool}{ horizontally = true}}
937 Returns a mirrored copy of the image. The parameter {\it horizontally}
938 indicates the orientation.
941 \membersection{wxImage::Replace}\label{wximagereplace}
943 \func{void}{Replace}{\param{unsigned char}{ r1}, \param{unsigned char}{ g1}, \param{unsigned char}{ b1},
944 \param{unsigned char}{ r2}, \param{unsigned char}{ g2}, \param{unsigned char}{ b2}}
946 Replaces the colour specified by {\it r1,g1,b1} by the colour {\it r2,g2,b2}.
949 \membersection{wxImage::Rescale}\label{wximagerescale}
951 \func{wxImage \&}{Rescale}{\param{int}{ width}, \param{int}{ height}, \param{int}{ quality = wxIMAGE\_QUALITY\_NORMAL}}
953 Changes the size of the image in-place by scaling it: after a call to this function,
954 the image will have the given width and height.
956 For a description of the {\it quality} parameter, see the \helpref{Scale}{wximagescale} function.
958 Returns the (modified) image itself.
962 \helpref{Scale}{wximagescale}
965 \membersection{wxImage::Resize}\label{wximageresize}
967 \func{wxImage \&}{Resize}{\param{const wxSize\&}{ size}, \param{const wxPoint&}{ pos}, \param{int}{ red = -1}, \param{int}{ green = -1}, \param{int}{ blue = -1}}
969 Changes the size of the image in-place without scaling it by adding either a border
970 with the given colour or cropping as necessary. The image is pasted into a new
971 image with the given {\it size} and background colour at the position {\it pos}
972 relative to the upper left of the new image. If {\it red = green = blue = -1}
973 then use either the current mask colour if set or find, use, and set a
974 suitable mask colour for any newly exposed areas.
976 Returns the (modified) image itself.
980 \helpref{Size}{wximagesize}
983 \membersection{wxImage::Rotate}\label{wximagerotate}
985 \func{wxImage}{Rotate}{\param{double}{ angle}, \param{const wxPoint\& }{rotationCentre},
986 \param{bool}{ interpolating = true}, \param{wxPoint*}{ offsetAfterRotation = NULL}}
988 Rotates the image about the given point, by {\it angle} radians. Passing true
989 to {\it interpolating} results in better image quality, but is slower. If the
990 image has a mask, then the mask colour is used for the uncovered pixels in the
991 rotated image background. Else, black (rgb 0, 0, 0) will be used.
993 Returns the rotated image, leaving this image intact.
996 \membersection{wxImage::RotateHue}\label{wximagerotatehue}
998 \func{void}{RotateHue}{\param{double}{ angle}}
1000 Rotates the hue of each pixel in the image by {\it angle}, which is a double in
1001 the range of -1.0 to +1.0, where -1.0 corresponds to -360 degrees and +1.0 corresponds
1005 \membersection{wxImage::Rotate90}\label{wximagerotate90}
1007 \constfunc{wxImage}{Rotate90}{\param{bool}{ clockwise = true}}
1009 Returns a copy of the image rotated 90 degrees in the direction
1010 indicated by {\it clockwise}.
1013 \membersection{wxImage::SaveFile}\label{wximagesavefile}
1015 \constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{int}{ type}}
1017 \constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{const wxString\&}{ mimetype}}
1019 Saves an image in the named file.
1021 \constfunc{bool}{SaveFile}{\param{const wxString\& }{name}}
1023 Saves an image in the named file. File type is determined from the extension of the
1024 file name. Note that this function may fail if the extension is not recognized! You
1025 can use one of the forms above to save images to files with non-standard extensions.
1027 \constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{int}{ type}}
1029 \constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{const wxString\&}{ mimetype}}
1031 Saves an image in the given stream.
1033 \wxheading{Parameters}
1035 \docparam{name}{Name of the file to save the image to.}
1037 \docparam{stream}{Opened output stream to save the image to.}
1039 \docparam{type}{Currently these types can be used:
1043 \twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Save a BMP image file.}
1044 \twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Save a JPEG image file.}
1045 \twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Save a PNG image file.}
1046 \twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Save a PCX image file (tries to save as 8-bit if possible, falls back to 24-bit otherwise).}
1047 \twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Save a PNM image file (as raw RGB always).}
1048 \twocolitem{{\bf wxBITMAP\_TYPE\_TIFF}}{Save a TIFF image file.}
1049 \twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Save a XPM image file.}
1050 \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).}
1051 \twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Save a Windows cursor file (CUR).}
1054 \docparam{mimetype}{MIME type.}
1056 \wxheading{Return value}
1058 true if the operation succeeded, false otherwise.
1062 Depending on how wxWidgets has been configured, not all formats may be available.
1064 Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to set the
1065 hotspot before saving an image into a cursor file (default hotspot is in
1066 the centre of the image):
1068 image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, hotspotX);
1069 image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotspotY);
1073 \wxheading{See also}
1075 \helpref{wxImage::LoadFile}{wximageloadfile}
1077 \pythonnote{In place of a single overloaded method name, wxPython
1078 implements the following methods:\par
1079 \indented{2cm}{\begin{twocollist}
1080 \twocolitem{{\bf SaveFile(filename, type)}}{Saves the image using the given
1081 type to the named file}
1082 \twocolitem{{\bf SaveMimeFile(filename, mimetype)}}{Saves the image using the given
1083 mimetype to the named file}
1087 \perlnote{Methods supported by wxPerl are:\par
1089 \item{bitmap->SaveFile( name, type )}
1090 \item{bitmap->SaveFile( name, mimetype )}
1095 \membersection{wxImage::Scale}\label{wximagescale}
1097 \constfunc{wxImage}{Scale}{\param{int}{ width}, \param{int}{ height}, \param{int}{ quality = wxIMAGE\_QUALITY\_NORMAL}}
1099 Returns a scaled version of the image. This is also useful for
1100 scaling bitmaps in general as the only other way to scale bitmaps
1101 is to blit a wxMemoryDC into another wxMemoryDC.
1103 \docparam{quality}{Determines what method to use for resampling the image. Can be one of the following:
1107 \twocolitem{{\bf wxIMAGE\_QUALITY\_NORMAL}}{Uses the normal default scaling method of pixel replication}
1108 \twocolitem{{\bf wxIMAGE\_QUALITY\_HIGH}}{Uses bicubic and box averaging resampling methods for upsampling and downsampling respectively}
1111 It should be noted that although using wxIMAGE\_QUALITY\_HIGH produces much nicer
1112 looking results it is a slower method. Downsampling will use the box averaging method
1113 which seems to operate very fast. If you are upsampling larger images using
1114 this method you will most likely notice that it is a bit slower and in extreme cases
1115 it will be quite substantially slower as the bicubic algorithm has to process a lot of
1118 It should also be noted that the high quality scaling may not work as expected
1119 when using a single mask colour for transparency, as the scaling will blur the
1120 image and will therefore remove the mask partially. Using the alpha channel
1126 // get the bitmap from somewhere
1129 // rescale it to have size of 32*32
1130 if ( bmp.GetWidth() != 32 || bmp.GetHeight() != 32 )
1132 wxImage image = bmp.ConvertToImage();
1133 bmp = wxBitmap(image.Scale(32, 32));
1135 // another possibility:
1136 image.Rescale(32, 32);
1142 \wxheading{See also}
1144 \helpref{Rescale}{wximagerescale}
1147 \membersection{wxImage::Size}\label{wximagesize}
1149 \constfunc{wxImage}{Size}{\param{const wxSize\&}{ size}, \param{const wxPoint&}{ pos}, \param{int}{ red = -1}, \param{int}{ green = -1}, \param{int}{ blue = -1}}
1151 Returns a resized version of this image without scaling it by adding either a border
1152 with the given colour or cropping as necessary. The image is pasted into a new
1153 image with the given {\it size} and background colour at the position {\it pos}
1154 relative to the upper left of the new image. If {\it red = green = blue = -1}
1155 then use either the current mask colour if set or find, use, and set a
1156 suitable mask colour for any newly exposed areas.
1158 \wxheading{See also}
1160 \helpref{Resize}{wximageresize}
1163 \membersection{wxImage::SetAlpha}\label{wximagesetalpha}
1165 \func{void}{SetAlpha}{\param{unsigned char *}{alpha = {\tt NULL}},\param{bool}{ static\_data = \false}}
1167 This function is similar to \helpref{SetData}{wximagesetdata} and has similar
1168 restrictions. The pointer passed to it may however be {\tt NULL} in which case
1169 the function will allocate the alpha array internally -- this is useful to add
1170 alpha channel data to an image which doesn't have any. If the pointer is not
1171 {\tt NULL}, it must have one byte for each image pixel and be allocated with
1172 {\tt malloc()}. wxImage takes ownership of the pointer and will free it unless
1173 \arg{static\_data} parameter is set to \true -- in this case the caller should
1176 \func{void}{SetAlpha}{\param{int }{x}, \param{int }{y}, \param{unsigned char }{alpha}}
1178 Sets the alpha value for the given pixel. This function should only be called
1179 if the image has alpha channel data, use \helpref{HasAlpha}{wximagehasalpha} to
1183 \membersection{wxImage::SetData}\label{wximagesetdata}
1185 \func{void}{SetData}{\param{unsigned char*}{data}}
1187 Sets the image data without performing checks. The data given must have
1188 the size (width*height*3) or results will be unexpected. Don't use this
1189 method if you aren't sure you know what you are doing.
1191 The data must have been allocated with {\tt malloc()}, {\large {\bf NOT}} with
1194 After this call the pointer to the data is owned by the wxImage object,
1195 that will be responsible for deleting it.
1196 Do not pass to this function a pointer obtained through
1197 \helpref{wxImage::GetData}{wximagegetdata}.
1200 \membersection{wxImage::SetMask}\label{wximagesetmask}
1202 \func{void}{SetMask}{\param{bool}{ hasMask = true}}
1204 Specifies whether there is a mask or not. The area of the mask is determined by the current mask colour.
1207 \membersection{wxImage::SetMaskColour}\label{wximagesetmaskcolour}
1209 \func{void}{SetMaskColour}{\param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}}
1211 Sets the mask colour for this image (and tells the image to use the mask).
1214 \membersection{wxImage::SetMaskFromImage}\label{wximagesetmaskfromimage}
1216 \func{bool}{SetMaskFromImage}{\param{const wxImage\&}{ mask}, \param{unsigned char}{ mr}, \param{unsigned char}{ mg}, \param{unsigned char}{ mb}}
1218 \wxheading{Parameters}
1220 \docparam{mask}{The mask image to extract mask shape from. Must have same dimensions as the image.}
1222 \docparam{mr,mg,mb}{RGB value of pixels in {\it mask} that will be used to create the mask.}
1224 Sets image's mask so that the pixels that have RGB value of {\it mr,mg,mb}
1225 in {\it mask} will be masked in the image. This is done by first finding an
1226 unused colour in the image, setting this colour as the mask colour and then
1227 using this colour to draw all pixels in the image who corresponding pixel
1228 in {\it mask} has given RGB value.
1230 \wxheading{Return value}
1232 Returns false if {\it mask} does not have same dimensions as the image or if
1233 there is no unused colour left. Returns true if the mask was successfully
1238 Note that this method involves computing the histogram, which is
1239 computationally intensive operation.
1242 \membersection{wxImage::SetOption}\label{wximagesetoption}
1244 \func{void}{SetOption}{\param{const wxString\&}{ name}, \param{const wxString\&}{ value}}
1246 \func{void}{SetOption}{\param{const wxString\&}{ name}, \param{int}{ value}}
1248 Sets a user-defined option. The function is case-insensitive to {\it name}.
1250 For example, when saving as a JPEG file, the option {\bf quality} is
1251 used, which is a number between 0 and 100 (0 is terrible, 100 is very good).
1253 \wxheading{See also}
1255 \helpref{wxImage::GetOption}{wximagegetoption},\rtfsp
1256 \helpref{wxImage::GetOptionInt}{wximagegetoptionint},\rtfsp
1257 \helpref{wxImage::HasOption}{wximagehasoption}
1260 \membersection{wxImage::SetPalette}\label{wximagesetpalette}
1262 \func{void}{SetPalette}{\param{const wxPalette\&}{ palette}}
1264 Associates a palette with the image. The palette may be used when converting
1265 wxImage to wxBitmap (MSW only at present) or in file save operations (none as yet).
1268 \membersection{wxImage::SetRGB}\label{wximagesetrgb}
1270 \func{void}{SetRGB}{\param{int }{x}, \param{int }{y}, \param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}}
1272 Sets the pixel at the given coordinate. This routine performs bounds-checks
1273 for the coordinate so it can be considered a safe way to manipulate the
1274 data, but in some cases this might be too slow so that the data will have to
1275 be set directly. In that case you will have to get access to the image data
1276 using the \helpref{GetData}{wximagegetdata} method.
1279 \membersection{wxImage::SetRGB}\label{wximagesetrgbrect}
1281 \func{void}{SetRGB}{\param{wxRect \& }{rect}, \param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}}
1283 Sets the colour of the pixels within the given rectangle. This routine performs
1284 bounds-checks for the coordinate so it can be considered a safe way to manipulate the
1288 \membersection{wxImage::operator $=$}\label{wximageassign}
1290 \func{wxImage\& }{operator $=$}{\param{const wxImage\& }{image}}
1292 Assignment operator, using \helpref{reference counting}{trefcount}.
1294 \wxheading{Parameters}
1296 \docparam{image}{Image to assign.}
1298 \wxheading{Return value}
1300 Returns 'this' object.
1303 \membersection{wxImage::operator $==$}\label{wximageequal}
1305 \constfunc{bool}{operator $==$}{\param{const wxImage\& }{image}}
1307 Equality operator. This operator tests whether the internal data pointers are
1308 equal (a fast test).
1310 \wxheading{Parameters}
1312 \docparam{image}{Image to compare with 'this'}
1314 \wxheading{Return value}
1316 Returns true if the images were effectively equal, false otherwise.
1319 \membersection{wxImage::operator $!=$}\label{wximagenotequal}
1321 \constfunc{bool}{operator $!=$}{\param{const wxImage\& }{image}}
1323 Inequality operator. This operator tests whether the internal data pointers are
1324 unequal (a fast test).
1326 \wxheading{Parameters}
1328 \docparam{image}{Image to compare with 'this'}
1330 \wxheading{Return value}
1332 Returns true if the images were unequal, false otherwise.
1334 \section{\class{wxImageHandler}}\label{wximagehandler}
1336 This is the base class for implementing image file loading/saving, and image creation from data.
1337 It is used within wxImage and is not normally seen by the application.
1339 If you wish to extend the capabilities of wxImage, derive a class from wxImageHandler
1340 and add the handler using \helpref{wxImage::AddHandler}{wximageaddhandler} in your
1341 application initialisation.
1343 \wxheading{Note (Legal Issue)}
1345 This software is based in part on the work of the Independent JPEG Group.
1347 (Applies when wxWidgets is linked with JPEG support. wxJPEGHandler uses libjpeg
1350 \wxheading{Derived from}
1352 \helpref{wxObject}{wxobject}
1354 \wxheading{Include files}
1358 \wxheading{See also}
1360 \helpref{wxImage}{wximage},
1361 \helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}
1363 \latexignore{\rtfignore{\wxheading{Members}}}
1366 \membersection{wxImageHandler::wxImageHandler}\label{wximagehandlerctor}
1368 \func{}{wxImageHandler}{\void}
1370 Default constructor. In your own default constructor, initialise the members
1371 m\_name, m\_extension and m\_type.
1374 \membersection{wxImageHandler::\destruct{wxImageHandler}}\label{wximagehandlerdtor}
1376 \func{}{\destruct{wxImageHandler}}{\void}
1378 Destroys the wxImageHandler object.
1381 \membersection{wxImageHandler::GetName}\label{wximagehandlergetname}
1383 \constfunc{const wxString\&}{GetName}{\void}
1385 Gets the name of this handler.
1388 \membersection{wxImageHandler::GetExtension}\label{wximagehandlergetextension}
1390 \constfunc{const wxString\&}{GetExtension}{\void}
1392 Gets the file extension associated with this handler.
1395 \membersection{wxImageHandler::GetImageCount}\label{wximagehandlergetimagecount}
1397 \func{int}{GetImageCount}{\param{wxInputStream\&}{ stream}}
1399 If the image file contains more than one image and the image handler is capable
1400 of retrieving these individually, this function will return the number of
1403 \docparam{stream}{Opened input stream for reading image data. Currently, the stream must support seeking.}
1405 \wxheading{Return value}
1407 Number of available images. For most image handlers, this is 1 (exceptions
1408 are TIFF and ICO formats).
1411 \membersection{wxImageHandler::GetType}\label{wximagehandlergettype}
1413 \constfunc{long}{GetType}{\void}
1415 Gets the image type associated with this handler.
1418 \membersection{wxImageHandler::GetMimeType}\label{wximagehandlergetmimetype}
1420 \constfunc{const wxString\&}{GetMimeType}{\void}
1422 Gets the MIME type associated with this handler.
1425 \membersection{wxImageHandler::LoadFile}\label{wximagehandlerloadfile}
1427 \func{bool}{LoadFile}{\param{wxImage* }{image}, \param{wxInputStream\&}{ stream}, \param{bool}{ verbose=true}, \param{int}{ index=0}}
1429 Loads a image from a stream, putting the resulting data into {\it image}. If the image file contains
1430 more than one image and the image handler is capable of retrieving these individually, {\it index}
1431 indicates which image to read from the stream.
1433 \wxheading{Parameters}
1435 \docparam{image}{The image object which is to be affected by this operation.}
1437 \docparam{stream}{Opened input stream for reading image data.}
1439 \docparam{verbose}{If set to true, errors reported by the image handler will produce wxLogMessages.}
1441 \docparam{index}{The index of the image in the file (starting from zero).}
1443 \wxheading{Return value}
1445 true if the operation succeeded, false otherwise.
1447 \wxheading{See also}
1449 \helpref{wxImage::LoadFile}{wximageloadfile},
1450 \helpref{wxImage::SaveFile}{wximagesavefile},
1451 \helpref{wxImageHandler::SaveFile}{wximagehandlersavefile}
1454 \membersection{wxImageHandler::SaveFile}\label{wximagehandlersavefile}
1456 \func{bool}{SaveFile}{\param{wxImage* }{image}, \param{wxOutputStream\& }{stream}}
1458 Saves a image in the output stream.
1460 \wxheading{Parameters}
1462 \docparam{image}{The image object which is to be affected by this operation.}
1464 \docparam{stream}{Opened output stream for writing the data.}
1466 \wxheading{Return value}
1468 true if the operation succeeded, false otherwise.
1470 \wxheading{See also}
1472 \helpref{wxImage::LoadFile}{wximageloadfile},
1473 \helpref{wxImage::SaveFile}{wximagesavefile},
1474 \helpref{wxImageHandler::LoadFile}{wximagehandlerloadfile}
1477 \membersection{wxImageHandler::SetName}\label{wximagehandlersetname}
1479 \func{void}{SetName}{\param{const wxString\& }{name}}
1481 Sets the handler name.
1483 \wxheading{Parameters}
1485 \docparam{name}{Handler name.}
1488 \membersection{wxImageHandler::SetExtension}\label{wximagehandlersetextension}
1490 \func{void}{SetExtension}{\param{const wxString\& }{extension}}
1492 Sets the handler extension.
1494 \wxheading{Parameters}
1496 \docparam{extension}{Handler extension.}
1499 \membersection{wxImageHandler::SetMimeType}\label{wximagehandlersetmimetype}
1501 \func{void}{SetMimeType}{\param{const wxString\& }{mimetype}}
1503 Sets the handler MIME type.
1505 \wxheading{Parameters}
1507 \docparam{mimename}{Handler MIME type.}
1510 \membersection{wxImageHandler::SetType}\label{wximagehandlersettype}
1512 \func{void}{SetType}{\param{long }{type}}
1514 Sets the handler type.
1516 \wxheading{Parameters}
1518 \docparam{name}{Handler type.}