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{wxBitmap
}{wxbitmap
},
88 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}
90 \latexignore{\rtfignore{\wxheading{Members
}}}
93 \membersection{wxImage::wxImage
}\label{wximagector
}
95 \func{}{wxImage
}{\void}
99 \func{}{wxImage
}{\param{const wxImage\&
}{image
}}
101 Copy constructor, uses
\helpref{reference counting
}{trefcount
}.
103 \func{}{wxImage
}{\param{const wxBitmap\&
}{ bitmap
}}
105 (Deprecated form, use
\helpref{wxBitmap::ConvertToImage
}{wxbitmapconverttoimage
}
106 instead.) Constructs an image from a platform-dependent bitmap. This preserves
107 mask information so that bitmaps and images can be converted back
108 and forth without loss in that respect.
110 \func{}{wxImage
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{bool
}{ clear=true
}}
112 Creates an image with the given width and height. If
{\it clear
} is true, the new image will be initialized to black.
113 Otherwise, the image data will be uninitialized.
115 \func{}{wxImage
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{unsigned char*
}{ data
},
\param{bool
}{ static
\_data =
\false}}
117 Creates an image from given data with the given width and height. If
118 {\it static
\_data} is true, then wxImage will not delete the actual
119 image data in its destructor, otherwise it will free it by calling
122 \func{}{wxImage
}{\param{const wxString\&
}{name
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY},
\param{int
}{ index = -
1}}
124 \func{}{wxImage
}{\param{const wxString\&
}{name
},
\param{const wxString\&
}{ mimetype
},
\param{int
}{ index = -
1}}
126 Loads an image from a file.
128 \func{}{wxImage
}{\param{wxInputStream\&
}{stream
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY},
\param{int
}{ index = -
1}}
130 \func{}{wxImage
}{\param{wxInputStream\&
}{stream
},
\param{const wxString\&
}{ mimetype
},
\param{int
}{ index = -
1}}
132 Loads an image from an input stream.
134 \func{}{wxImage
}{\param{const char* const*
}{xpmData
}}
136 Creates an image from XPM data.
138 \wxheading{Parameters
}
140 \docparam{width
}{Specifies the width of the image.
}
142 \docparam{height
}{Specifies the height of the image.
}
144 \docparam{name
}{Name of the file from which to load the image.
}
146 \docparam{stream
}{Opened input stream from which to load the image. Currently, the stream must support seeking.
}
148 \docparam{type
}{May be one of the following:
152 \twocolitem{\indexit{wxBITMAP
\_TYPE\_BMP}}{Load a Windows bitmap file.
}
153 \twocolitem{\indexit{wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
154 \twocolitem{\indexit{wxBITMAP
\_TYPE\_JPEG}}{Load a JPEG bitmap file.
}
155 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PNG}}{Load a PNG bitmap file.
}
156 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PCX}}{Load a PCX bitmap file.
}
157 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PNM}}{Load a PNM bitmap file.
}
158 \twocolitem{\indexit{wxBITMAP
\_TYPE\_TIF}}{Load a TIFF bitmap file.
}
159 \twocolitem{\indexit{wxBITMAP
\_TYPE\_TGA}}{Load a TGA bitmap file.
}
160 \twocolitem{\indexit{wxBITMAP
\_TYPE\_XPM}}{Load a XPM bitmap file.
}
161 \twocolitem{\indexit{wxBITMAP
\_TYPE\_ICO}}{Load a Windows icon file (ICO).
}
162 \twocolitem{\indexit{wxBITMAP
\_TYPE\_CUR}}{Load a Windows cursor file (CUR).
}
163 \twocolitem{\indexit{wxBITMAP
\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).
}
164 \twocolitem{\indexit{wxBITMAP
\_TYPE\_ANY}}{Will try to autodetect the format.
}
167 \docparam{mimetype
}{MIME type string (for example 'image/jpeg')
}
169 \docparam{index
}{Index of the image to load in the case that the image file contains multiple images.
170 This is only used by GIF, ICO and TIFF handlers. The default value (-
1) means
171 "choose the default image" and is interpreted as the first image (index=
0) by
172 the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.
}
174 \docparam{xpmData
}{A pointer to XPM image data.
}
178 Depending on how wxWidgets has been configured, not all formats may be available.
180 Note: any handler other than BMP must be previously
181 initialized with
\helpref{wxImage::AddHandler
}{wximageaddhandler
} or
182 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}.
184 Note: you can use
\helpref{GetOptionInt
}{wximagegetoptionint
} to get the
185 hotspot for loaded cursor file:
187 int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
188 int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
194 \helpref{wxImage::LoadFile
}{wximageloadfile
}
196 \pythonnote{Constructors supported by wxPython are:
\par
197 \indented{2cm
}{\begin{twocollist
}
198 \twocolitem{{\bf wxImage(name, flag)
}}{Loads an image from a file
}
199 \twocolitem{{\bf wxNullImage()
}}{Create a null image (has no size or
201 \twocolitem{{\bf wxEmptyImage(width, height)
}}{Creates an empty image
203 \twocolitem{{\bf wxImageFromMime(name, mimetype
}}{Creates an image from
204 the given file of the given mimetype
}
205 \twocolitem{{\bf wxImageFromBitmap(bitmap)
}}{Creates an image from a
206 platform-dependent bitmap
}
210 \perlnote{Constructors supported by wxPerl are:
\par
212 \item{Wx::Image->new( bitmap )
}
213 \item{Wx::Image->new( icon )
}
214 \item{Wx::Image->new( width, height )
}
215 \item{Wx::Image->new( width, height, data )
}
216 \item{Wx::Image->new( file, type, index )
}
217 \item{Wx::Image->new( file, mimetype, index )
}
218 \item{Wx::Image->new( stream, type, index )
}
219 \item{Wx::Image->new( stream, mimetype, index )
}
224 \membersection{wxImage::
\destruct{wxImage
}}\label{wximagedtor
}
226 \func{}{\destruct{wxImage
}}{\void}
229 See
\helpref{reference-counted object destruction
}{refcountdestruct
} for more info.
232 \membersection{wxImage::AddHandler
}\label{wximageaddhandler
}
234 \func{static void
}{AddHandler
}{\param{wxImageHandler*
}{ handler
}}
236 Adds a handler to the end of the static list of format handlers.
238 \docparam{handler
}{A new image format handler object. There is usually only one instance
239 of a given handler class in an application session.
}
243 \helpref{wxImageHandler
}{wximagehandler
}
245 \func{bool
}{CanRead
}{\param{const wxString\&
}{ filename
}}
247 returns true if the current image handlers can read this file
249 \pythonnote{In wxPython this static method is named
{\tt wxImage
\_AddHandler}.
}
252 \membersection{wxImage::Blur
}\label{wximageblur
}
254 \func{wxImage
}{Blur
}{\param{int
}{ blurRadius
}}
256 Blurs the image in both horizontal and vertical directions by the specified pixel
257 {\it blurRadius
}. This should not be used when using a single mask colour
262 \helpref{BlurHorizontal
}{wximagehorzblur
}
263 \helpref{BlurVertical
}{wximagevertblur
}
266 \membersection{wxImage::BlurHorizontal
}\label{wximagehorzblur
}
268 \func{wxImage
}{BlurHorizontal
}{\param{int
}{ blurRadius
}}
270 Blurs the image in the horizontal direction only. This should not be used
271 when using a single mask colour for transparency.
274 \helpref{Blur
}{wximageblur
}
275 \helpref{BlurVertical
}{wximagevertblur
}
278 \membersection{wxImage::BlurVertical
}\label{wximagevertblur
}
280 \func{wxImage
}{BlurVertical
}{\param{int
}{ blurRadius
}}
282 Blurs the image in the vertical direction only. This should not be used
283 when using a single mask colour for transparency.
287 \helpref{Blur
}{wximageblur
}
288 \helpref{BlurHorizontal
}{wximagehorzblur
}
291 \membersection{wxImage::CleanUpHandlers
}\label{wximagecleanuphandlers
}
293 \func{static void
}{CleanUpHandlers
}{\void}
295 Deletes all image handlers.
297 This function is called by wxWidgets on exit.
300 \membersection{wxImage::ComputeHistogram
}\label{wximagecomputehistogram
}
302 \constfunc{unsigned long
}{ComputeHistogram
}{\param{wxImageHistogram\&
}{histogram
}}
304 Computes the histogram of the image.
{\it histogram
} is a reference to
305 wxImageHistogram object. wxImageHistogram is a specialization of
306 \helpref{wxHashMap
}{wxhashmap
} "template" and is defined as follows:
309 class WXDLLEXPORT wxImageHistogramEntry
312 wxImageHistogramEntry() : index(
0), value(
0)
{}
317 WX_DECLARE_EXPORTED_HASH_MAP(unsigned long, wxImageHistogramEntry,
318 wxIntegerHash, wxIntegerEqual,
322 \wxheading{Return value
}
324 Returns number of colours in the histogram.
327 \membersection{wxImage::ConvertAlphaToMask
}\label{wximageconvertalphatomask
}
329 \func{bool
}{ConvertAlphaToMask
}{\param{unsigned char
}{ threshold = $
128$
}}
331 If the image has alpha channel, this method converts it to mask. All pixels
332 with alpha value less than
\arg{threshold
} are replaced with mask colour
333 and the alpha channel is removed. Mask colour is chosen automatically using
334 \helpref{FindFirstUnusedColour
}{wximagefindfirstunusedcolour
}.
336 If the image image doesn't have alpha channel,
337 ConvertAlphaToMask does nothing.
339 \wxheading{Return value
}
341 \false if FindFirstUnusedColour returns
\false,
\true otherwise.
344 \membersection{wxImage::ConvertToBitmap
}\label{wximageconverttobitmap
}
346 \constfunc{wxBitmap
}{ConvertToBitmap
}{\void}
348 Deprecated, use equivalent
\helpref{wxBitmap constructor
}{wxbitmapctor
}
349 (which takes wxImage and depth as its arguments) instead.
352 \membersection{wxImage::ConvertToGreyscale
}\label{wximageconverttogreyscale
}
354 \constfunc{wxImage
}{ConvertToGreyscale
}{\param{double
}{ lr =
0.299},
\param{double
}{ lg =
0.587},
\param{double
}{ lb =
0.114}}
356 Returns a greyscale version of the image. The returned image uses the luminance
357 component of the original to calculate the greyscale. Defaults to using
358 ITU-T BT
.601 when converting to YUV, where every pixel equals
359 (R *
{\it lr
}) + (G *
{\it lg
}) + (B *
{\it lb
}).
362 \membersection{wxImage::ConvertToMono
}\label{wxbitmapconverttomono
}
364 \constfunc{wxImage
}{ConvertToMono
}{\param{unsigned char
}{ r
},
\param{unsigned char
}{ g
},
\param{unsigned char
}{ b
}}
366 Returns monochromatic version of the image. The returned image has white
367 colour where the original has
{\it (r,g,b)
} colour and black colour
371 \membersection{wxImage::Copy
}\label{wximagecopy
}
373 \constfunc{wxImage
}{Copy
}{\void}
375 Returns an identical copy of the image.
378 \membersection{wxImage::Create
}\label{wximagecreate
}
380 \func{bool
}{Create
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{bool
}{ clear=true
}}
382 Creates a fresh image. If
{\it clear
} is true, the new image will be initialized to black.
383 Otherwise, the image data will be uninitialized.
385 \wxheading{Parameters
}
387 \docparam{width
}{The width of the image in pixels.
}
389 \docparam{height
}{The height of the image in pixels.
}
391 \wxheading{Return value
}
393 true if the call succeeded, false otherwise.
396 \membersection{wxImage::Destroy
}\label{wximagedestroy
}
398 \func{void
}{Destroy
}{\void}
400 Destroys the image data.
403 \membersection{wxImage::FindFirstUnusedColour
}\label{wximagefindfirstunusedcolour
}
405 \func{bool
}{FindFirstUnusedColour
}{\param{unsigned char *
}{ r
},
\param{unsigned char *
}{ g
},
\param{unsigned char *
}{ b
},
\param{unsigned char
}{ startR =
1},
\param{unsigned char
}{ startG =
0},
\param{unsigned char
}{ startB =
0}}
407 \wxheading{Parameters
}
409 \docparam{r,g,b
}{Pointers to variables to save the colour.
}
411 \docparam{startR,startG,startB
}{Initial values of the colour. Returned colour
412 will have RGB values equal to or greater than these.
}
414 Finds the first colour that is never used in the image. The search begins at
415 given initial colour and continues by increasing R, G and B components (in this
416 order) by
1 until an unused colour is found or the colour space exhausted.
418 \wxheading{Return value
}
420 Returns false if there is no unused colour left, true on success.
424 Note that this method involves computing the histogram, which is
425 computationally intensive operation.
428 \membersection{wxImage::FindHandler
}\label{wximagefindhandler
}
430 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{name
}}
432 Finds the handler with the given name.
434 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{extension
},
\param{long
}{ imageType
}}
436 Finds the handler associated with the given extension and type.
438 \func{static wxImageHandler*
}{FindHandler
}{\param{long
}{imageType
}}
440 Finds the handler associated with the given image type.
442 \func{static wxImageHandler*
}{FindHandlerMime
}{\param{const wxString\&
}{mimetype
}}
444 Finds the handler associated with the given MIME type.
446 \docparam{name
}{The handler name.
}
448 \docparam{extension
}{The file extension, such as ``bmp".
}
450 \docparam{imageType
}{The image type, such as wxBITMAP
\_TYPE\_BMP.
}
452 \docparam{mimetype
}{MIME type.
}
454 \wxheading{Return value
}
456 A pointer to the handler if found, NULL otherwise.
460 \helpref{wxImageHandler
}{wximagehandler
}
463 \membersection{wxImage::GetImageExtWildcard
}\label{wximagegetimageextwildcard
}
465 \func{static wxString
}{GetImageExtWildcard
}{\void}
467 Iterates all registered wxImageHandler objects, and returns a string containing file extension masks
468 suitable for passing to file open/save dialog boxes.
470 \wxheading{Return value
}
472 The format of the returned string is "
(*.ext1;*.ext2)|*.ext1;*.ext2".
474 It is usually a good idea to prepend a description before passing the result to the dialog.
479 wxFileDialog FileDlg( this, "Choose Image", ::wxGetCwd(), "", _("Image Files ") + wxImage::GetImageExtWildcard(), wxFD_OPEN );
484 \helpref{wxImageHandler}{wximagehandler}
487 \membersection{wxImage::GetAlpha}\label{wximagegetalpha}
489 \constfunc{unsigned char}{GetAlpha}{\param{int}{ x}, \param{int}{ y}}
491 Returns the alpha value for the given pixel. This function may only be called
492 for the images with alpha channel, use \helpref{HasAlpha}{wximagehasalpha} to
495 The returned value is the {\it opacity} of the image, i.e. the value of $0$
496 corresponds to the transparent pixels while the value of $255$ -- to the opaque
499 \constfunc{unsigned char *}{GetAlpha}{\void}
501 Returns pointer to the array storing the alpha values for this image. This
502 pointer is {\tt NULL} for the images without the alpha channel. If the image
503 does have it, this pointer may be used to directly manipulate the alpha values
504 which are stored as the \helpref{RGB}{wximagegetdata} ones.
507 \membersection{wxImage::GetBlue}\label{wximagegetblue}
509 \constfunc{unsigned char}{GetBlue}{\param{int}{ x}, \param{int}{ y}}
511 Returns the blue intensity at the given coordinate.
514 \membersection{wxImage::GetData}\label{wximagegetdata}
516 \constfunc{unsigned char*}{GetData}{\void}
518 Returns the image data as an array. This is most often used when doing
519 direct image manipulation. The return value points to an array of
520 characters in RGBRGBRGB$\ldots$ format in the top-to-bottom, left-to-right
521 order, that is the first RGB triplet corresponds to the pixel first pixel of
522 the first row, the second one --- to the second pixel of the first row and so
523 on until the end of the first row, with second row following after it and so
526 You should not delete the returned pointer nor pass it to
527 \helpref{wxImage::SetData}{wximagesetdata}.
530 \membersection{wxImage::GetGreen}\label{wximagegetgreen}
532 \constfunc{unsigned char}{GetGreen}{\param{int}{ x}, \param{int}{ y}}
534 Returns the green intensity at the given coordinate.
537 \membersection{wxImage::GetImageCount}\label{wximagegetimagecount}
539 \func{static int}{GetImageCount}{\param{const wxString\&}{ filename}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}}
541 \func{static int}{GetImageCount}{\param{wxInputStream\&}{ stream}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}}
543 If the image file contains more than one image and the image handler is capable
544 of retrieving these individually, this function will return the number of
547 \docparam{name}{Name of the file to query.}
549 \docparam{stream}{Opened input stream with image data. Currently, the stream must support seeking.}
551 \docparam{type}{May be one of the following:
555 \twocolitem{\indexit{wxBITMAP\_TYPE\_BMP}}{Load a Windows bitmap file.}
556 \twocolitem{\indexit{wxBITMAP\_TYPE\_GIF}}{Load a GIF bitmap file.}
557 \twocolitem{\indexit{wxBITMAP\_TYPE\_JPEG}}{Load a JPEG bitmap file.}
558 \twocolitem{\indexit{wxBITMAP\_TYPE\_PNG}}{Load a PNG bitmap file.}
559 \twocolitem{\indexit{wxBITMAP\_TYPE\_PCX}}{Load a PCX bitmap file.}
560 \twocolitem{\indexit{wxBITMAP\_TYPE\_PNM}}{Load a PNM bitmap file.}
561 \twocolitem{\indexit{wxBITMAP\_TYPE\_TIF}}{Load a TIFF bitmap file.}
562 \twocolitem{\indexit{wxBITMAP\_TYPE\_XPM}}{Load a XPM bitmap file.}
563 \twocolitem{\indexit{wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
564 \twocolitem{\indexit{wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
565 \twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
566 \twocolitem{\indexit{wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
569 \wxheading{Return value}
571 Number of available images. For most image handlers, this is 1 (exceptions
572 are TIFF and ICO formats).
575 \membersection{wxImage::GetHandlers}\label{wximagegethandlers}
577 \func{static wxList\&}{GetHandlers}{\void}
579 Returns the static list of image format handlers.
583 \helpref{wxImageHandler}{wximagehandler}
586 \membersection{wxImage::GetHeight}\label{wximagegetheight}
588 \constfunc{int}{GetHeight}{\void}
590 Gets the height of the image in pixels.
593 \membersection{wxImage::GetMaskBlue}\label{wximagegetmaskblue}
595 \constfunc{unsigned char}{GetMaskBlue}{\void}
597 Gets the blue value of the mask colour.
600 \membersection{wxImage::GetMaskGreen}\label{wximagegetmaskgreen}
602 \constfunc{unsigned char}{GetMaskGreen}{\void}
604 Gets the green value of the mask colour.
607 \membersection{wxImage::GetMaskRed}\label{wximagegetmaskred}
609 \constfunc{unsigned char}{GetMaskRed}{\void}
611 Gets the red value of the mask colour.
614 \membersection{wxImage::GetOrFindMaskColour}\label{wximagegetgetorsetmaskcolour}
616 \constfunc{bool}{GetOrFindMaskColour}{\param{unsigned char}{ *r}, \param{unsigned char}{ *g}, \param{unsigned char}{ *b}}
618 Get the current mask colour or find a suitable unused colour that could be
619 used as a mask colour. Returns {\tt true} if the image currently has a mask.
622 \membersection{wxImage::GetPalette}\label{wximagegetpalette}
624 \constfunc{const wxPalette\&}{GetPalette}{\void}
626 Returns the palette associated with the image. Currently the palette is only
627 used when converting to wxBitmap under Windows. Some of the wxImage handlers
628 have been modified to set the palette if one exists in the image file (usually
629 256 or less colour images in GIF or PNG format).
632 \membersection{wxImage::GetRed}\label{wximagegetred}
634 \constfunc{unsigned char}{GetRed}{\param{int}{ x}, \param{int}{ y}}
636 Returns the red intensity at the given coordinate.
639 \membersection{wxImage::GetSubImage}\label{wximagegetsubimage}
641 \constfunc{wxImage}{GetSubImage}{\param{const wxRect\&}{ rect}}
643 Returns a sub image of the current one as long as the rect belongs entirely to
647 \membersection{wxImage::GetWidth}\label{wximagegetwidth}
649 \constfunc{int}{GetWidth}{\void}
651 Gets the width of the image in pixels.
655 \helpref{wxImage::GetHeight}{wximagegetheight}
658 \membersection{HSVValue::HSVValue}\label{hsvvaluehsvvalue}
660 \func{}{HSVValue}{\param{double }{h = 0.0}, \param{double }{s = 0.0}, \param{double }{v = 0.0}}
662 Constructor for HSVValue, an object that contains values for hue, saturation and value which
663 represent the value of a color. It is used by \helpref{wxImage::HSVtoRGB}{wximagehsvtorgb}
664 and \helpref{wxImage::RGBtoHSV}{wximagergbtohsv}, which
665 converts between HSV color space and RGB color space.
667 \pythonnote{use wxImage\_HSVValue in wxPython}
671 \membersection{wxImage::HSVtoRGB}\label{wximagehsvtorgb}
673 \func{wxImage::RGBValue}{HSVtoRGB}{\param{const HSVValue \& }{hsv}}
675 Converts a color in HSV color space to RGB color space.
678 \membersection{wxImage::HasAlpha}\label{wximagehasalpha}
680 \constfunc{bool}{HasAlpha}{\void}
682 Returns true if this image has alpha channel, false otherwise.
686 \helpref{GetAlpha}{wximagegetalpha}, \helpref{SetAlpha}{wximagesetalpha}
689 \membersection{wxImage::HasMask}\label{wximagehasmask}
691 \constfunc{bool}{HasMask}{\void}
693 Returns true if there is a mask active, false otherwise.
696 \membersection{wxImage::GetOption}\label{wximagegetoption}
698 \constfunc{wxString}{GetOption}{\param{const wxString\&}{ name}}
700 Gets a user-defined option. The function is case-insensitive to {\it name}.
702 For example, when saving as a JPEG file, the option {\bf quality} is
703 used, which is a number between 0 and 100 (0 is terrible, 100 is very good).
707 \helpref{wxImage::SetOption}{wximagesetoption},\rtfsp
708 \helpref{wxImage::GetOptionInt}{wximagegetoptionint},\rtfsp
709 \helpref{wxImage::HasOption}{wximagehasoption}
712 \membersection{wxImage::GetOptionInt}\label{wximagegetoptionint}
714 \constfunc{int}{GetOptionInt}{\param{const wxString\&}{ name}}
716 Gets a user-defined option as an integer. The function is case-insensitive to {\it name}.
718 If the given option is not present, the function returns $0$. Use
719 \helpref{wxImage::HasOption}{wximagehasoption} is $0$ is a possibly valid value
722 Options for wxPNGHandler
725 \twocolitem{wxIMAGE\_OPTION\_PNG\_FORMAT}{Format for saving a PNG file.}
726 \twocolitem{wxIMAGE\_OPTION\_PNG\_BITDEPTH}{Bit depth for every channel (R/G/B/A).}
729 Supported values for wxIMAGE\_OPTION\_PNG\_FORMAT:
732 \twocolitem{wxPNG\_TYPE\_COLOUR}{Stores RGB image.}
733 \twocolitem{wxPNG\_TYPE\_GREY}{Stores grey image, converts from RGB.}
734 \twocolitem{wxPNG\_TYPE\_GREY\_RED}{Stores grey image, uses red value as grey.}
740 \helpref{wxImage::SetOption}{wximagesetoption},\rtfsp
741 \helpref{wxImage::GetOption}{wximagegetoption}
744 \membersection{wxImage::HasOption}\label{wximagehasoption}
746 \constfunc{bool}{HasOption}{\param{const wxString\&}{ name}}
748 Returns true if the given option is present. The function is case-insensitive to {\it name}.
752 \helpref{wxImage::SetOption}{wximagesetoption},\rtfsp
753 \helpref{wxImage::GetOption}{wximagegetoption},\rtfsp
754 \helpref{wxImage::GetOptionInt}{wximagegetoptionint}
757 \membersection{wxImage::InitAlpha}\label{wximageinitalpha}
759 \func{void}{InitAlpha}{\void}
761 Initializes the image alpha channel data. It is an error to call it
762 if the image already has alpha data. If it doesn't, alpha data will be
763 by default initialized to all pixels being fully opaque. But if the image has a
764 a mask colour, all mask pixels will be completely transparent.
767 \membersection{wxImage::InitStandardHandlers}\label{wximageinitstandardhandlers}
769 \func{static void}{InitStandardHandlers}{\void}
771 Internal use only. Adds standard image format handlers. It only install BMP
772 for the time being, which is used by wxBitmap.
774 This function is called by wxWidgets on startup, and shouldn't be called by
779 \helpref{wxImageHandler}{wximagehandler},
780 \helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}
783 \membersection{wxImage::InsertHandler}\label{wximageinserthandler}
785 \func{static void}{InsertHandler}{\param{wxImageHandler*}{ handler}}
787 Adds a handler at the start of the static list of format handlers.
789 \docparam{handler}{A new image format handler object. There is usually only one instance
790 of a given handler class in an application session.}
794 \helpref{wxImageHandler}{wximagehandler}
797 \membersection{wxImage::IsTransparent}\label{wximageistransparent}
799 \constfunc{bool}{IsTransparent}{\param{int }{x}, \param{int }{y}, \param{unsigned char}{ threshold = $128$}}
801 Returns \true if the given pixel is transparent, i.e. either has the mask
802 colour if this image has a mask or if this image has alpha channel and alpha
803 value of this pixel is strictly less than \arg{threshold}.
806 \membersection{wxImage::LoadFile}\label{wximageloadfile}
808 \func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}, \param{int}{ index = -1}}
810 \func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}
812 Loads an image from a file. If no handler type is provided, the library will
813 try to autodetect the format.
815 \func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{long}{ type}, \param{int}{ index = -1}}
817 \func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}}
819 Loads an image from an input stream.
821 \wxheading{Parameters}
823 \docparam{name}{Name of the file from which to load the image.}
825 \docparam{stream}{Opened input stream from which to load the image. Currently, the stream must support seeking.}
827 \docparam{type}{One of the following values:
831 \twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Load a Windows image file.}
832 \twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Load a GIF image file.}
833 \twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Load a JPEG image file.}
834 \twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Load a PCX image file.}
835 \twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Load a PNG image file.}
836 \twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Load a PNM image file.}
837 \twocolitem{{\bf wxBITMAP\_TYPE\_TIF}}{Load a TIFF image file.}
838 \twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Load a XPM image file.}
839 \twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
840 \twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
841 \twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
842 \twocolitem{{\bf wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
845 \docparam{mimetype}{MIME type string (for example 'image/jpeg')}
847 \docparam{index}{Index of the image to load in the case that the image file contains multiple images.
848 This is only used by GIF, ICO and TIFF handlers. The default value (-1) means
849 "choose the default image" and is interpreted as the first image (index=0) by
850 the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.}
854 Depending on how wxWidgets has been configured, not all formats may be available.
856 Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to get the
857 hotspot for loaded cursor file:
859 int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
860 int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
864 \wxheading{Return value}
866 true if the operation succeeded, false otherwise. If the optional index parameter is out of range,
867 false is returned and a call to wxLogError() takes place.
871 \helpref{wxImage::SaveFile}{wximagesavefile}
873 \pythonnote{In place of a single overloaded method name, wxPython
874 implements the following methods:\par
875 \indented{2cm}{\begin{twocollist}
876 \twocolitem{{\bf LoadFile(filename, type)}}{Loads an image of the given
878 \twocolitem{{\bf LoadMimeFile(filename, mimetype)}}{Loads an image of the given
879 mimetype from a file}
883 \perlnote{Methods supported by wxPerl are:\par
885 \item{bitmap->LoadFile( name, type )}
886 \item{bitmap->LoadFile( name, mimetype )}
892 \membersection{wxImage::IsOk}\label{wximageisok}
894 \constfunc{bool}{IsOk}{\void}
896 Returns true if image data is present.
899 \membersection{RGBValue::RGBValue}\label{rgbvaluergbvalue}
901 \func{}{RGBValue}{\param{unsigned char }{r = 0}, \param{unsigned char }{g = 0}, \param{unsigned char }{b = 0}}
903 Constructor for RGBValue, an object that contains values for red, green and blue which
904 represent the value of a color. It is used by \helpref{wxImage::HSVtoRGB}{wximagehsvtorgb}
905 and \helpref{wxImage::RGBtoHSV}{wximagergbtohsv}, which
906 converts between HSV color space and RGB color space.
908 \pythonnote{use wxImage\_RGBValue in wxPython}
911 \membersection{wxImage::RGBtoHSV}\label{wximagergbtohsv}
913 \func{wxImage::HSVValue}{RGBtoHSV}{\param{const RGBValue\& }{rgb}}
915 Converts a color in RGB color space to HSV color space.
918 \membersection{wxImage::RemoveHandler}\label{wximageremovehandler}
920 \func{static bool}{RemoveHandler}{\param{const wxString\& }{name}}
922 Finds the handler with the given name, and removes it. The handler
925 \docparam{name}{The handler name.}
927 \wxheading{Return value}
929 true if the handler was found and removed, false otherwise.
933 \helpref{wxImageHandler}{wximagehandler}
936 \membersection{wxImage::Mirror}\label{wximagemirror}
938 \constfunc{wxImage}{Mirror}{\param{bool}{ horizontally = true}}
940 Returns a mirrored copy of the image. The parameter {\it horizontally}
941 indicates the orientation.
944 \membersection{wxImage::Replace}\label{wximagereplace}
946 \func{void}{Replace}{\param{unsigned char}{ r1}, \param{unsigned char}{ g1}, \param{unsigned char}{ b1},
947 \param{unsigned char}{ r2}, \param{unsigned char}{ g2}, \param{unsigned char}{ b2}}
949 Replaces the colour specified by {\it r1,g1,b1} by the colour {\it r2,g2,b2}.
952 \membersection{wxImage::Rescale}\label{wximagerescale}
954 \func{wxImage \&}{Rescale}{\param{int}{ width}, \param{int}{ height}, \param{int}{ quality = wxIMAGE\_QUALITY\_NORMAL}}
956 Changes the size of the image in-place by scaling it: after a call to this function,
957 the image will have the given width and height.
959 For a description of the {\it quality} parameter, see the \helpref{Scale}{wximagescale} function.
961 Returns the (modified) image itself.
965 \helpref{Scale}{wximagescale}
968 \membersection{wxImage::Resize}\label{wximageresize}
970 \func{wxImage \&}{Resize}{\param{const wxSize\&}{ size}, \param{const wxPoint&}{ pos}, \param{int}{ red = -1}, \param{int}{ green = -1}, \param{int}{ blue = -1}}
972 Changes the size of the image in-place without scaling it by adding either a border
973 with the given colour or cropping as necessary. The image is pasted into a new
974 image with the given {\it size} and background colour at the position {\it pos}
975 relative to the upper left of the new image. If {\it red = green = blue = -1}
976 then use either the current mask colour if set or find, use, and set a
977 suitable mask colour for any newly exposed areas.
979 Returns the (modified) image itself.
983 \helpref{Size}{wximagesize}
986 \membersection{wxImage::Rotate}\label{wximagerotate}
988 \func{wxImage}{Rotate}{\param{double}{ angle}, \param{const wxPoint\& }{rotationCentre},
989 \param{bool}{ interpolating = true}, \param{wxPoint*}{ offsetAfterRotation = NULL}}
991 Rotates the image about the given point, by {\it angle} radians. Passing true
992 to {\it interpolating} results in better image quality, but is slower. If the
993 image has a mask, then the mask colour is used for the uncovered pixels in the
994 rotated image background. Else, black (rgb 0, 0, 0) will be used.
996 Returns the rotated image, leaving this image intact.
999 \membersection{wxImage::RotateHue}\label{wximagerotatehue}
1001 \func{void}{RotateHue}{\param{double}{ angle}}
1003 Rotates the hue of each pixel in the image by {\it angle}, which is a double in
1004 the range of -1.0 to +1.0, where -1.0 corresponds to -360 degrees and +1.0 corresponds
1008 \membersection{wxImage::Rotate90}\label{wximagerotate90}
1010 \constfunc{wxImage}{Rotate90}{\param{bool}{ clockwise = true}}
1012 Returns a copy of the image rotated 90 degrees in the direction
1013 indicated by {\it clockwise}.
1016 \membersection{wxImage::SaveFile}\label{wximagesavefile}
1018 \constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{int}{ type}}
1020 \constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{const wxString\&}{ mimetype}}
1022 Saves an image in the named file.
1024 \constfunc{bool}{SaveFile}{\param{const wxString\& }{name}}
1026 Saves an image in the named file. File type is determined from the extension of the
1027 file name. Note that this function may fail if the extension is not recognized! You
1028 can use one of the forms above to save images to files with non-standard extensions.
1030 \constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{int}{ type}}
1032 \constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{const wxString\&}{ mimetype}}
1034 Saves an image in the given stream.
1036 \wxheading{Parameters}
1038 \docparam{name}{Name of the file to save the image to.}
1040 \docparam{stream}{Opened output stream to save the image to.}
1042 \docparam{type}{Currently these types can be used:
1046 \twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Save a BMP image file.}
1047 \twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Save a JPEG image file.}
1048 \twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Save a PNG image file.}
1049 \twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Save a PCX image file (tries to save as 8-bit if possible, falls back to 24-bit otherwise).}
1050 \twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Save a PNM image file (as raw RGB always).}
1051 \twocolitem{{\bf wxBITMAP\_TYPE\_TIFF}}{Save a TIFF image file.}
1052 \twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Save a XPM image file.}
1053 \twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Save a Windows icon file (ICO) (the size may be up to 255 wide by 127 high. A single image is saved in 8 colors at the size supplied).}
1054 \twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Save a Windows cursor file (CUR).}
1057 \docparam{mimetype}{MIME type.}
1059 \wxheading{Return value}
1061 true if the operation succeeded, false otherwise.
1065 Depending on how wxWidgets has been configured, not all formats may be available.
1067 Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to set the
1068 hotspot before saving an image into a cursor file (default hotspot is in
1069 the centre of the image):
1071 image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, hotspotX);
1072 image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotspotY);
1076 \wxheading{See also}
1078 \helpref{wxImage::LoadFile}{wximageloadfile}
1080 \pythonnote{In place of a single overloaded method name, wxPython
1081 implements the following methods:\par
1082 \indented{2cm}{\begin{twocollist}
1083 \twocolitem{{\bf SaveFile(filename, type)}}{Saves the image using the given
1084 type to the named file}
1085 \twocolitem{{\bf SaveMimeFile(filename, mimetype)}}{Saves the image using the given
1086 mimetype to the named file}
1090 \perlnote{Methods supported by wxPerl are:\par
1092 \item{bitmap->SaveFile( name, type )}
1093 \item{bitmap->SaveFile( name, mimetype )}
1098 \membersection{wxImage::Scale}\label{wximagescale}
1100 \constfunc{wxImage}{Scale}{\param{int}{ width}, \param{int}{ height}, \param{int}{ quality = wxIMAGE\_QUALITY\_NORMAL}}
1102 Returns a scaled version of the image. This is also useful for
1103 scaling bitmaps in general as the only other way to scale bitmaps
1104 is to blit a wxMemoryDC into another wxMemoryDC.
1106 \docparam{quality}{Determines what method to use for resampling the image. Can be one of the following:
1110 \twocolitem{{\bf wxIMAGE\_QUALITY\_NORMAL}}{Uses the normal default scaling method of pixel replication}
1111 \twocolitem{{\bf wxIMAGE\_QUALITY\_HIGH}}{Uses bicubic and box averaging resampling methods for upsampling and downsampling respectively}
1114 It should be noted that although using wxIMAGE\_QUALITY\_HIGH produces much nicer
1115 looking results it is a slower method. Downsampling will use the box averaging method
1116 which seems to operate very fast. If you are upsampling larger images using
1117 this method you will most likely notice that it is a bit slower and in extreme cases
1118 it will be quite substantially slower as the bicubic algorithm has to process a lot of
1121 It should also be noted that the high quality scaling may not work as expected
1122 when using a single mask colour for transparency, as the scaling will blur the
1123 image and will therefore remove the mask partially. Using the alpha channel
1129 // get the bitmap from somewhere
1132 // rescale it to have size of 32*32
1133 if ( bmp.GetWidth() != 32 || bmp.GetHeight() != 32 )
1135 wxImage image = bmp.ConvertToImage();
1136 bmp = wxBitmap(image.Scale(32, 32));
1138 // another possibility:
1139 image.Rescale(32, 32);
1145 \wxheading{See also}
1147 \helpref{Rescale}{wximagerescale}
1150 \membersection{wxImage::Size}\label{wximagesize}
1152 \constfunc{wxImage}{Size}{\param{const wxSize\&}{ size}, \param{const wxPoint&}{ pos}, \param{int}{ red = -1}, \param{int}{ green = -1}, \param{int}{ blue = -1}}
1154 Returns a resized version of this image without scaling it by adding either a border
1155 with the given colour or cropping as necessary. The image is pasted into a new
1156 image with the given {\it size} and background colour at the position {\it pos}
1157 relative to the upper left of the new image. If {\it red = green = blue = -1}
1158 then use either the current mask colour if set or find, use, and set a
1159 suitable mask colour for any newly exposed areas.
1161 \wxheading{See also}
1163 \helpref{Resize}{wximageresize}
1166 \membersection{wxImage::SetAlpha}\label{wximagesetalpha}
1168 \func{void}{SetAlpha}{\param{unsigned char *}{alpha = {\tt NULL}},\param{bool}{ static\_data = \false}}
1170 This function is similar to \helpref{SetData}{wximagesetdata} and has similar
1171 restrictions. The pointer passed to it may however be {\tt NULL} in which case
1172 the function will allocate the alpha array internally -- this is useful to add
1173 alpha channel data to an image which doesn't have any. If the pointer is not
1174 {\tt NULL}, it must have one byte for each image pixel and be allocated with
1175 {\tt malloc()}. wxImage takes ownership of the pointer and will free it unless
1176 \arg{static\_data} parameter is set to \true -- in this case the caller should
1179 \func{void}{SetAlpha}{\param{int }{x}, \param{int }{y}, \param{unsigned char }{alpha}}
1181 Sets the alpha value for the given pixel. This function should only be called
1182 if the image has alpha channel data, use \helpref{HasAlpha}{wximagehasalpha} to
1186 \membersection{wxImage::SetData}\label{wximagesetdata}
1188 \func{void}{SetData}{\param{unsigned char*}{data}}
1190 Sets the image data without performing checks. The data given must have
1191 the size (width*height*3) or results will be unexpected. Don't use this
1192 method if you aren't sure you know what you are doing.
1194 The data must have been allocated with {\tt malloc()}, {\large {\bf NOT}} with
1197 After this call the pointer to the data is owned by the wxImage object,
1198 that will be responsible for deleting it.
1199 Do not pass to this function a pointer obtained through
1200 \helpref{wxImage::GetData}{wximagegetdata}.
1203 \membersection{wxImage::SetMask}\label{wximagesetmask}
1205 \func{void}{SetMask}{\param{bool}{ hasMask = true}}
1207 Specifies whether there is a mask or not. The area of the mask is determined by the current mask colour.
1210 \membersection{wxImage::SetMaskColour}\label{wximagesetmaskcolour}
1212 \func{void}{SetMaskColour}{\param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}}
1214 Sets the mask colour for this image (and tells the image to use the mask).
1217 \membersection{wxImage::SetMaskFromImage}\label{wximagesetmaskfromimage}
1219 \func{bool}{SetMaskFromImage}{\param{const wxImage\&}{ mask}, \param{unsigned char}{ mr}, \param{unsigned char}{ mg}, \param{unsigned char}{ mb}}
1221 \wxheading{Parameters}
1223 \docparam{mask}{The mask image to extract mask shape from. Must have same dimensions as the image.}
1225 \docparam{mr,mg,mb}{RGB value of pixels in {\it mask} that will be used to create the mask.}
1227 Sets image's mask so that the pixels that have RGB value of {\it mr,mg,mb}
1228 in {\it mask} will be masked in the image. This is done by first finding an
1229 unused colour in the image, setting this colour as the mask colour and then
1230 using this colour to draw all pixels in the image who corresponding pixel
1231 in {\it mask} has given RGB value.
1233 \wxheading{Return value}
1235 Returns false if {\it mask} does not have same dimensions as the image or if
1236 there is no unused colour left. Returns true if the mask was successfully
1241 Note that this method involves computing the histogram, which is
1242 computationally intensive operation.
1245 \membersection{wxImage::SetOption}\label{wximagesetoption}
1247 \func{void}{SetOption}{\param{const wxString\&}{ name}, \param{const wxString\&}{ value}}
1249 \func{void}{SetOption}{\param{const wxString\&}{ name}, \param{int}{ value}}
1251 Sets a user-defined option. The function is case-insensitive to {\it name}.
1253 For example, when saving as a JPEG file, the option {\bf quality} is
1254 used, which is a number between 0 and 100 (0 is terrible, 100 is very good).
1256 \wxheading{See also}
1258 \helpref{wxImage::GetOption}{wximagegetoption},\rtfsp
1259 \helpref{wxImage::GetOptionInt}{wximagegetoptionint},\rtfsp
1260 \helpref{wxImage::HasOption}{wximagehasoption}
1263 \membersection{wxImage::SetPalette}\label{wximagesetpalette}
1265 \func{void}{SetPalette}{\param{const wxPalette\&}{ palette}}
1267 Associates a palette with the image. The palette may be used when converting
1268 wxImage to wxBitmap (MSW only at present) or in file save operations (none as yet).
1271 \membersection{wxImage::SetRGB}\label{wximagesetrgb}
1273 \func{void}{SetRGB}{\param{int }{x}, \param{int }{y}, \param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}}
1275 Sets the pixel at the given coordinate. This routine performs bounds-checks
1276 for the coordinate so it can be considered a safe way to manipulate the
1277 data, but in some cases this might be too slow so that the data will have to
1278 be set directly. In that case you will have to get access to the image data
1279 using the \helpref{GetData}{wximagegetdata} method.
1282 \membersection{wxImage::SetRGB}\label{wximagesetrgbrect}
1284 \func{void}{SetRGB}{\param{wxRect \& }{rect}, \param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}}
1286 Sets the colour of the pixels within the given rectangle. This routine performs
1287 bounds-checks for the coordinate so it can be considered a safe way to manipulate the
1291 \membersection{wxImage::operator $=$}\label{wximageassign}
1293 \func{wxImage\& }{operator $=$}{\param{const wxImage\& }{image}}
1295 Assignment operator, using \helpref{reference counting}{trefcount}.
1297 \wxheading{Parameters}
1299 \docparam{image}{Image to assign.}
1301 \wxheading{Return value}
1303 Returns 'this' object.
1307 \section{\class{wxImageHandler}}\label{wximagehandler}
1309 This is the base class for implementing image file loading/saving, and image creation from data.
1310 It is used within wxImage and is not normally seen by the application.
1312 If you wish to extend the capabilities of wxImage, derive a class from wxImageHandler
1313 and add the handler using \helpref{wxImage::AddHandler}{wximageaddhandler} in your
1314 application initialisation.
1316 \wxheading{Note (Legal Issue)}
1318 This software is based in part on the work of the Independent JPEG Group.
1320 (Applies when wxWidgets is linked with JPEG support. wxJPEGHandler uses libjpeg
1323 \wxheading{Derived from}
1325 \helpref{wxObject}{wxobject}
1327 \wxheading{Include files}
1331 \wxheading{See also}
1333 \helpref{wxImage}{wximage},
1334 \helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}
1336 \latexignore{\rtfignore{\wxheading{Members}}}
1339 \membersection{wxImageHandler::wxImageHandler}\label{wximagehandlerctor}
1341 \func{}{wxImageHandler}{\void}
1343 Default constructor. In your own default constructor, initialise the members
1344 m\_name, m\_extension and m\_type.
1347 \membersection{wxImageHandler::\destruct{wxImageHandler}}\label{wximagehandlerdtor}
1349 \func{}{\destruct{wxImageHandler}}{\void}
1351 Destroys the wxImageHandler object.
1354 \membersection{wxImageHandler::GetName}\label{wximagehandlergetname}
1356 \constfunc{const wxString\&}{GetName}{\void}
1358 Gets the name of this handler.
1361 \membersection{wxImageHandler::GetExtension}\label{wximagehandlergetextension}
1363 \constfunc{const wxString\&}{GetExtension}{\void}
1365 Gets the file extension associated with this handler.
1368 \membersection{wxImageHandler::GetImageCount}\label{wximagehandlergetimagecount}
1370 \func{int}{GetImageCount}{\param{wxInputStream\&}{ stream}}
1372 If the image file contains more than one image and the image handler is capable
1373 of retrieving these individually, this function will return the number of
1376 \docparam{stream}{Opened input stream for reading image data. Currently, the stream must support seeking.}
1378 \wxheading{Return value}
1380 Number of available images. For most image handlers, this is 1 (exceptions
1381 are TIFF and ICO formats).
1384 \membersection{wxImageHandler::GetType}\label{wximagehandlergettype}
1386 \constfunc{long}{GetType}{\void}
1388 Gets the image type associated with this handler.
1391 \membersection{wxImageHandler::GetMimeType}\label{wximagehandlergetmimetype}
1393 \constfunc{const wxString\&}{GetMimeType}{\void}
1395 Gets the MIME type associated with this handler.
1398 \membersection{wxImageHandler::LoadFile}\label{wximagehandlerloadfile}
1400 \func{bool}{LoadFile}{\param{wxImage* }{image}, \param{wxInputStream\&}{ stream}, \param{bool}{ verbose=true}, \param{int}{ index=0}}
1402 Loads a image from a stream, putting the resulting data into {\it image}. If the image file contains
1403 more than one image and the image handler is capable of retrieving these individually, {\it index}
1404 indicates which image to read from the stream.
1406 \wxheading{Parameters}
1408 \docparam{image}{The image object which is to be affected by this operation.}
1410 \docparam{stream}{Opened input stream for reading image data.}
1412 \docparam{verbose}{If set to true, errors reported by the image handler will produce wxLogMessages.}
1414 \docparam{index}{The index of the image in the file (starting from zero).}
1416 \wxheading{Return value}
1418 true if the operation succeeded, false otherwise.
1420 \wxheading{See also}
1422 \helpref{wxImage::LoadFile}{wximageloadfile},
1423 \helpref{wxImage::SaveFile}{wximagesavefile},
1424 \helpref{wxImageHandler::SaveFile}{wximagehandlersavefile}
1427 \membersection{wxImageHandler::SaveFile}\label{wximagehandlersavefile}
1429 \func{bool}{SaveFile}{\param{wxImage* }{image}, \param{wxOutputStream\& }{stream}}
1431 Saves a image in the output stream.
1433 \wxheading{Parameters}
1435 \docparam{image}{The image object which is to be affected by this operation.}
1437 \docparam{stream}{Opened output stream for writing the data.}
1439 \wxheading{Return value}
1441 true if the operation succeeded, false otherwise.
1443 \wxheading{See also}
1445 \helpref{wxImage::LoadFile}{wximageloadfile},
1446 \helpref{wxImage::SaveFile}{wximagesavefile},
1447 \helpref{wxImageHandler::LoadFile}{wximagehandlerloadfile}
1450 \membersection{wxImageHandler::SetName}\label{wximagehandlersetname}
1452 \func{void}{SetName}{\param{const wxString\& }{name}}
1454 Sets the handler name.
1456 \wxheading{Parameters}
1458 \docparam{name}{Handler name.}
1461 \membersection{wxImageHandler::SetExtension}\label{wximagehandlersetextension}
1463 \func{void}{SetExtension}{\param{const wxString\& }{extension}}
1465 Sets the handler extension.
1467 \wxheading{Parameters}
1469 \docparam{extension}{Handler extension.}
1472 \membersection{wxImageHandler::SetMimeType}\label{wximagehandlersetmimetype}
1474 \func{void}{SetMimeType}{\param{const wxString\& }{mimetype}}
1476 Sets the handler MIME type.
1478 \wxheading{Parameters}
1480 \docparam{mimename}{Handler MIME type.}
1483 \membersection{wxImageHandler::SetType}\label{wximagehandlersettype}
1485 \func{void}{SetType}{\param{long }{type}}
1487 Sets the handler type.
1489 \wxheading{Parameters}
1491 \docparam{name}{Handler type.}