1 \section{\class{wxImage
}}\label{wximage
}
3 This class encapsulates a platform-independent image. An image can be created
4 from data, or using
\helpref{wxBitmap::ConvertToImage
}{wxbitmapconverttoimage
}. An image
5 can be loaded from a file in a variety of formats, and is extensible to new formats
6 via image format handlers. Functions are available to set and get image bits, so
7 it can be used for basic image manipulation.
9 A wxImage cannot (currently) be drawn directly to a
\helpref{wxDC
}{wxdc
}. Instead,
10 a platform-specific
\helpref{wxBitmap
}{wxbitmap
} object must be created from it using
11 the
\helpref{wxBitmap::wxBitmap(wxImage,int depth)
}{wxbitmapconstr
} constructor.
13 be drawn in a device context, using
\helpref{wxDC::DrawBitmap
}{wxdcdrawbitmap
}.
15 One colour value of the image may be used as a mask colour which will lead to the automatic
16 creation of a
\helpref{wxMask
}{wxmask
} object associated to the bitmap object.
18 \wxheading{Available image handlers
}
20 The following image handlers are available.
{\bf wxBMPHandler
} is always
21 installed by default. To use other image formats, install the appropiate
22 handler with
\helpref{wxImage::AddHandler
}{wximageaddhandler
} or
23 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}.
27 \twocolitem{\indexit{wxBMPHandler
}}{Only for loading, always installed.
}
28 \twocolitem{\indexit{wxPNGHandler
}}{For loading and saving.
}
29 \twocolitem{\indexit{wxJPEGHandler
}}{For loading and saving.
}
30 \twocolitem{\indexit{wxGIFHandler
}}{Only for loading, due to legal issues.
}
31 \twocolitem{\indexit{wxPCXHandler
}}{For loading and saving (see below).
}
32 \twocolitem{\indexit{wxPNMHandler
}}{For loading and saving (see below).
}
33 \twocolitem{\indexit{wxTIFFHandler
}}{For loading and saving.
}
34 \twocolitem{\indexit{wxXPMHandler
}}{For loading and saving.
}
35 \twocolitem{\indexit{wxICOHandler
}}{For loading and saving.
}
38 When saving in PCX format,
{\bf wxPCXHandler
} will count the number of
39 different colours in the image; if there are
256 or less colours, it will
40 save as
8 bit, else it will save as
24 bit.
42 Loading PNMs only works for ASCII or raw RGB images. When saving in
43 PNM format,
{\bf wxPNMHandler
} will always save as raw RGB.
45 \wxheading{Derived from
}
47 \helpref{wxObject
}{wxobject
}
49 \wxheading{Include files
}
55 \helpref{wxBitmap
}{wxbitmap
},
56 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}
58 \latexignore{\rtfignore{\wxheading{Members
}}}
60 \membersection{wxImage::wxImage
}\label{wximageconstr
}
62 \func{}{wxImage
}{\void}
66 \func{}{wxImage
}{\param{const wxImage\&
}{image
}}
70 \func{}{wxImage
}{\param{const wxBitmap\&
}{ bitmap
}}
72 (Deprecated form, use
\helpref{wxBitmap::ConvertToImage
}{wxbitmapconverttoimage
}
73 instead.) Constructs an image from a platform-dependent bitmap. This preserves
74 mask information so that bitmaps and images can be converted back
75 and forth without loss in that respect.
77 \func{}{wxImage
}{\param{int
}{ width
},
\param{int
}{ height
}}
79 Creates an image with the given width and height.
81 \func{}{wxImage
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{unsigned char*
}{ data
},
\param{bool
}{ static
\_data=FALSE
}}
83 Creates an image from given data with the given width and height. If
84 {\it static
\_data} is TRUE, then wxImage will not delete the actual
85 image data in its destructor, otherwise it will free it by calling
88 \func{}{wxImage
}{\param{const wxString\&
}{name
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY}}
90 \func{}{wxImage
}{\param{const wxString\&
}{name
},
\param{const wxString\&
}{ mimetype
}}
92 Loads an image from a file.
94 \func{}{wxImage
}{\param{wxInputStream\&
}{stream
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY}}
96 \func{}{wxImage
}{\param{wxInputStream\&
}{stream
},
\param{const wxString\&
}{ mimetype
}}
98 Loads an image from an input stream.
100 \wxheading{Parameters
}
102 \docparam{width
}{Specifies the width of the image.
}
104 \docparam{height
}{Specifies the height of the image.
}
106 \docparam{name
}{Name of the file from which to load the image.
}
108 \docparam{stream
}{Opened input stream from which to load the image. Currently, the stream must support seeking.
}
110 \docparam{type
}{May be one of the following:
114 \twocolitem{\indexit{wxBITMAP
\_TYPE\_BMP}}{Load a Windows bitmap file.
}
115 \twocolitem{\indexit{wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
116 \twocolitem{\indexit{wxBITMAP
\_TYPE\_JPEG}}{Load a JPEG bitmap file.
}
117 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PNG}}{Load a PNG bitmap file.
}
118 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PCX}}{Load a PCX bitmap file.
}
119 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PNM}}{Load a PNM bitmap file.
}
120 \twocolitem{\indexit{wxBITMAP
\_TYPE\_TIF}}{Load a TIFF bitmap file.
}
121 \twocolitem{\indexit{wxBITMAP
\_TYPE\_XPM}}{Load a XPM bitmap file.
}
122 \twocolitem{\indexit{wxBITMAP
\_TYPE\_ICO}}{Load a ICO Icon file.
}
123 \twocolitem{\indexit{wxBITMAP
\_TYPE\_ANY}}{Will try to autodetect the format.
}
126 \docparam{mimetype
}{MIME type string (for example 'image/jpeg')
}
130 Depending on how wxWindows has been configured, not all formats may be available.
132 Note: any handler other than BMP must be previously
133 initialized with
\helpref{wxImage::AddHandler
}{wximageaddhandler
} or
134 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}.
138 \helpref{wxImage::LoadFile
}{wximageloadfile
}
140 \pythonnote{Constructors supported by wxPython are:
\par
141 \indented{2cm
}{\begin{twocollist
}
142 \twocolitem{{\bf wxImage(name, flag)
}}{Loads an image from a file
}
143 \twocolitem{{\bf wxNullImage()
}}{Create a null image (has no size or
145 \twocolitem{{\bf wxEmptyImage(width, height)
}}{Creates an empty image
147 \twocolitem{{\bf wxImageFromMime(name, mimetype
}}{Creates an image from
148 the given file of the given mimetype
}
149 \twocolitem{{\bf wxImageFromBitmap(bitmap)
}}{Creates an image from a
150 platform-dependent bitmap
}
154 \perlnote{Constructors supported by wxPerl are:
\par
156 \item{Wx::Image->new( bitmap )
}
157 \item{Wx::Image->new( width, height )
}
158 \item{Wx::Image->new( name, type )
}
159 \item{Wx::Image->new( name, mimetype )
}
163 \membersection{wxImage::
\destruct{wxImage
}}
165 \func{}{\destruct{wxImage
}}{\void}
169 \membersection{wxImage::AddHandler
}\label{wximageaddhandler
}
171 \func{static void
}{AddHandler
}{\param{wxImageHandler*
}{ handler
}}
173 Adds a handler to the end of the static list of format handlers.
175 \docparam{handler
}{A new image format handler object. There is usually only one instance
176 of a given handler class in an application session.
}
180 \helpref{wxImageHandler
}{wximagehandler
}
182 \pythonnote{In wxPython this static method is named
{\tt wxImage
\_AddHandler}.
}
183 \membersection{wxImage::CleanUpHandlers
}
185 \func{static void
}{CleanUpHandlers
}{\void}
187 Deletes all image handlers.
189 This function is called by wxWindows on exit.
191 \membersection{wxImage::ConvertToBitmap
}\label{wximageconverttobitmap
}
193 \constfunc{wxBitmap
}{ConvertToBitmap
}{\void}
195 Deprecated, use equivalent
\helpref{wxBitmap constructor
}{wxbitmapconstr
}
196 (which takes wxImage and depth as its arguments) instead.
198 \membersection{wxImage::ConvertToMono
}\label{wxbitmapconverttomono
}
200 \constfunc{wxImage
}{ConvertToMono
}{\param{unsigned char
}{ r
},
\param{unsigned char
}{ g
},
\param{unsigned char
}{ b
}}
202 Returns monochromatic version of the image. The returned image has white
203 colour where the original has
{\it (r,g,b)
} colour and black colour
206 \membersection{wxImage::Copy
}\label{wximagecopy
}
208 \constfunc{wxImage
}{Copy
}{\void}
210 Returns an identical copy of the image.
212 \membersection{wxImage::Create
}\label{wximagecreate
}
214 \func{bool
}{Create
}{\param{int
}{ width
},
\param{int
}{ height
}}
216 Creates a fresh image.
218 \wxheading{Parameters
}
220 \docparam{width
}{The width of the image in pixels.
}
222 \docparam{height
}{The height of the image in pixels.
}
224 \wxheading{Return value
}
226 TRUE if the call succeeded, FALSE otherwise.
228 \membersection{wxImage::Destroy
}\label{wximagedestroy
}
230 \func{bool
}{Destroy
}{\void}
232 Destroys the image data.
234 \membersection{wxImage::FindFirstUnusedColour
}\label{wximagefindfirstunusedcolour
}
236 \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}}
238 \wxheading{Parameters
}
240 \docparam{r,g,b
}{Pointers to variables to save the colour.
}
242 \docparam{startR,startG,startB
}{Initial values of the colour. Returned colour
243 will have RGB values equal to or greater than these.
}
245 Finds the first colour that is never used in the image. The search begins at
246 given initial colour and continues by increasing R, G and B components (in this
247 order) by
1 until an unused colour is found or the colour space exhausted.
249 \wxheading{Return value
}
251 Returns FALSE if there is no unused colour left, TRUE on success.
255 Note that this method involves computing the histogram, which is
256 computationally intensive operation.
258 \membersection{wxImage::FindHandler
}
260 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{name
}}
262 Finds the handler with the given name.
264 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{extension
},
\param{long
}{ imageType
}}
266 Finds the handler associated with the given extension and type.
268 \func{static wxImageHandler*
}{FindHandler
}{\param{long
}{imageType
}}
270 Finds the handler associated with the given image type.
272 \func{static wxImageHandler*
}{FindHandlerMime
}{\param{const wxString\&
}{mimetype
}}
274 Finds the handler associated with the given MIME type.
276 \docparam{name
}{The handler name.
}
278 \docparam{extension
}{The file extension, such as ``bmp".
}
280 \docparam{imageType
}{The image type, such as wxBITMAP
\_TYPE\_BMP.
}
282 \docparam{mimetype
}{MIME type.
}
284 \wxheading{Return value
}
286 A pointer to the handler if found, NULL otherwise.
290 \helpref{wxImageHandler
}{wximagehandler
}
292 \membersection{wxImage::GetBlue
}\label{wximagegetblue
}
294 \constfunc{unsigned char
}{GetBlue
}{\param{int
}{ x
},
\param{int
}{ y
}}
296 Returns the blue intensity at the given coordinate.
298 \membersection{wxImage::GetData
}\label{wximagegetdata
}
300 \constfunc{unsigned char*
}{GetData
}{\void}
302 Returns the image data as an array. This is most often used when doing
303 direct image manipulation. The return value points to an array of
304 chararcters in RGBGBRGB... format.
306 \membersection{wxImage::GetGreen
}\label{wximagegetgreen
}
308 \constfunc{unsigned char
}{GetGreen
}{\param{int
}{ x
},
\param{int
}{ y
}}
310 Returns the green intensity at the given coordinate.
312 \membersection{wxImage::GetRed
}\label{wximagegetred
}
314 \constfunc{unsigned char
}{GetRed
}{\param{int
}{ x
},
\param{int
}{ y
}}
316 Returns the red intensity at the given coordinate.
318 \membersection{wxImage::GetHandlers
}
320 \func{static wxList\&
}{GetHandlers
}{\void}
322 Returns the static list of image format handlers.
326 \helpref{wxImageHandler
}{wximagehandler
}
328 \membersection{wxImage::GetHeight
}\label{wximagegetheight
}
330 \constfunc{int
}{GetHeight
}{\void}
332 Gets the height of the image in pixels.
334 \membersection{wxImage::GetMaskBlue
}\label{wximagegetmaskblue
}
336 \constfunc{unsigned char
}{GetMaskBlue
}{\void}
338 Gets the blue value of the mask colour.
340 \membersection{wxImage::GetMaskGreen
}\label{wximagegetmaskgreen
}
342 \constfunc{unsigned char
}{GetMaskGreen
}{\void}
344 Gets the green value of the mask colour.
346 \membersection{wxImage::GetMaskRed
}\label{wximagegetmaskred
}
348 \constfunc{unsigned char
}{GetMaskRed
}{\void}
350 Gets the red value of the mask colour.
352 \membersection{wxImage::GetPalette
}\label{wximagegetpalette
}
354 \constfunc{const wxPalette\&
}{GetPalette
}{\void}
356 Returns the palette associated with the image. Currently the palette is only
357 used when converting to wxBitmap under Windows.
359 Eventually wxImage handlers will set the palette if one exists in the image file.
361 \membersection{wxImage::GetSubImage
}\label{wximagegetsubimage
}
363 \constfunc{wxImage
}{GetSubImage
}{\param{const wxRect\&
}{ rect
}}
365 Returns a sub image of the current one as long as the rect belongs entirely to
368 \membersection{wxImage::GetWidth
}\label{wximagegetwidth
}
370 \constfunc{int
}{GetWidth
}{\void}
372 Gets the width of the image in pixels.
376 \helpref{wxImage::GetHeight
}{wximagegetheight
}
378 \membersection{wxImage::HasMask
}\label{wximagehasmask
}
380 \constfunc{bool
}{HasMask
}{\void}
382 Returns TRUE if there is a mask active, FALSE otherwise.
384 \membersection{wxImage::GetOption
}\label{wximagegetoption
}
386 \constfunc{wxString
}{GetOption
}{\param{const wxString\&
}{ name
}}
388 Gets a user-defined option. The function is case-insensitive to
{\it name
}.
390 For example, when saving as a JPEG file, the option
{\bf quality
} is
391 used, which is a number between
0 and
100 (
0 is terrible,
100 is very good).
395 \helpref{wxImage::SetOption
}{wximagesetoption
},
\rtfsp
396 \helpref{wxImage::GetOptionInt
}{wximagegetoptionint
},
\rtfsp
397 \helpref{wxImage::HasOption
}{wximagehasoption
}
399 \membersection{wxImage::GetOptionInt
}\label{wximagegetoptionint
}
401 \constfunc{int
}{GetOptionInt
}{\param{const wxString\&
}{ name
}}
403 Gets a user-defined option as an integer. The function is case-insensitive to
{\it name
}.
407 \helpref{wxImage::SetOption
}{wximagesetoption
},
\rtfsp
408 \helpref{wxImage::GetOption
}{wximagegetoption
},
\rtfsp
409 \helpref{wxImage::HasOption
}{wximagehasoption
}
411 \membersection{wxImage::HasOption
}\label{wximagehasoption
}
413 \constfunc{bool
}{HasOption
}{\param{const wxString\&
}{ name
}}
415 Returns TRUE if the given option is present. The function is case-insensitive to
{\it name
}.
419 \helpref{wxImage::SetOption
}{wximagesetoption
},
\rtfsp
420 \helpref{wxImage::GetOption
}{wximagegetoption
},
\rtfsp
421 \helpref{wxImage::GetOptionInt
}{wximagegetoptionint
}
423 \membersection{wxImage::InitStandardHandlers
}
425 \func{static void
}{InitStandardHandlers
}{\void}
427 Internal use only. Adds standard image format handlers. It only install BMP
428 for the time being, which is used by wxBitmap.
430 This function is called by wxWindows on startup, and shouldn't be called by
435 \helpref{wxImageHandler
}{wximagehandler
},
436 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}
438 \membersection{wxImage::InsertHandler
}
440 \func{static void
}{InsertHandler
}{\param{wxImageHandler*
}{ handler
}}
442 Adds a handler at the start of the static list of format handlers.
444 \docparam{handler
}{A new image format handler object. There is usually only one instance
445 of a given handler class in an application session.
}
449 \helpref{wxImageHandler
}{wximagehandler
}
451 \membersection{wxImage::LoadFile
}\label{wximageloadfile
}
453 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY}}
455 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{const wxString\&
}{ mimetype
}}
457 Loads an image from a file. If no handler type is provided, the library will
458 try to autodetect the format.
460 \func{bool
}{LoadFile
}{\param{wxInputStream\&
}{ stream
},
\param{long
}{ type
}}
462 \func{bool
}{LoadFile
}{\param{wxInputStream\&
}{ stream
},
\param{const wxString\&
}{ mimetype
}}
464 Loads an image from an input stream.
466 \wxheading{Parameters
}
468 \docparam{name
}{Name of the file from which to load the image.
}
470 \docparam{stream
}{Opened input stream from which to load the image. Currently, the stream must support seeking.
}
472 \docparam{type
}{One of the following values:
476 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Load a Windows image file.
}
477 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Load a GIF image file.
}
478 \twocolitem{{\bf wxBITMAP
\_TYPE\_JPEG}}{Load a JPEG image file.
}
479 \twocolitem{{\bf wxBITMAP
\_TYPE\_PCX}}{Load a PCX image file.
}
480 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNG}}{Load a PNG image file.
}
481 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNM}}{Load a PNM image file.
}
482 \twocolitem{{\bf wxBITMAP
\_TYPE\_TIF}}{Load a TIFF image file.
}
483 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Load a XPM image file.
}
484 \twocolitem{{\bf wxBITMAP
\_TYPE\_ICO}}{Load a ICO icon file.
}
485 \twocolitem{{\bf wxBITMAP
\_TYPE\_ANY}}{Will try to autodetect the format.
}
488 \docparam{mimetype
}{MIME type string (for example 'image/jpeg')
}
492 Depending on how wxWindows has been configured, not all formats may be available.
494 wxBITMAP
\_TYPE\_ICO will laod the largest image found, with the most colours
496 \wxheading{Return value
}
498 TRUE if the operation succeeded, FALSE otherwise.
502 \helpref{wxImage::SaveFile
}{wximagesavefile
}
504 \pythonnote{In place of a single overloaded method name, wxPython
505 implements the following methods:
\par
506 \indented{2cm
}{\begin{twocollist
}
507 \twocolitem{{\bf LoadFile(filename, type)
}}{Loads an image of the given
509 \twocolitem{{\bf LoadMimeFile(filename, mimetype)
}}{Loads an image of the given
510 mimetype from a file
}
514 \perlnote{Methods supported by wxPerl are:
\par
516 \item{bitmap->LoadFile( name, type )
}
517 \item{bitmap->LoadFile( name, mimetype )
}
522 \membersection{wxImage::Ok
}\label{wximageok
}
524 \constfunc{bool
}{Ok
}{\void}
526 Returns TRUE if image data is present.
528 \membersection{wxImage::RemoveHandler
}
530 \func{static bool
}{RemoveHandler
}{\param{const wxString\&
}{name
}}
532 Finds the handler with the given name, and removes it. The handler
535 \docparam{name
}{The handler name.
}
537 \wxheading{Return value
}
539 TRUE if the handler was found and removed, FALSE otherwise.
543 \helpref{wxImageHandler
}{wximagehandler
}
545 \membersection{wxImage::SaveFile
}\label{wximagesavefile
}
547 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{int
}{ type
}}
549 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{const wxString\&
}{ mimetype
}}
551 Saves a image in the named file.
553 \func{bool
}{SaveFile
}{\param{wxOutputStream\&
}{stream
},
\param{int
}{ type
}}
555 \func{bool
}{SaveFile
}{\param{wxOutputStream\&
}{stream
},
\param{const wxString\&
}{ mimetype
}}
557 Saves a image in the given stream.
559 \wxheading{Parameters
}
561 \docparam{name
}{Name of the file to save the image to.
}
563 \docparam{stream
}{Opened output stream to save the image to.
}
565 \docparam{type
}{Currently three types can be used:
569 \twocolitem{{\bf wxBITMAP
\_TYPE\_JPEG}}{Save a JPEG image file.
}
570 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNG}}{Save a PNG image file.
}
571 \twocolitem{{\bf wxBITMAP
\_TYPE\_PCX}}{Save a PCX image file (tries to save as
8-bit if possible, falls back to
24-bit otherwise).
}
572 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNM}}{Save a PNM image file (as raw RGB always).
}
573 \twocolitem{{\bf wxBITMAP
\_TYPE\_TIFF}}{Save a TIFF image file.
}
574 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Save a XPM image file.
}
575 \twocolitem{{\bf wxBITMAP
\_TYPE\_ICO}}{Save a ICO image file. (The size may be up to
255 wide by
127 high. A single image is saved in
8 colors at the size supplied.)
}
578 \docparam{mimetype
}{MIME type.
}
580 \wxheading{Return value
}
582 TRUE if the operation succeeded, FALSE otherwise.
586 Depending on how wxWindows has been configured, not all formats may be available.
590 \helpref{wxImage::LoadFile
}{wximageloadfile
}
592 \pythonnote{In place of a single overloaded method name, wxPython
593 implements the following methods:
\par
594 \indented{2cm
}{\begin{twocollist
}
595 \twocolitem{{\bf SaveFile(filename, type)
}}{Saves the image using the given
596 type to the named file
}
597 \twocolitem{{\bf SaveMimeFile(filename, mimetype)
}}{Saves the image using the given
598 mimetype to the named file
}
602 \perlnote{Methods supported by wxPerl are:
\par
604 \item{bitmap->SaveFile( name, type )
}
605 \item{bitmap->SaveFile( name, mimetype )
}
609 \membersection{wxImage::Mirror
}\label{wximagemirror
}
611 \constfunc{wxImage
}{Mirror
}{\param{bool
}{ horizontally = TRUE
}}
613 Returns a mirrored copy of the image. The parameter
{\it horizontally
}
614 indicates the orientation.
616 \membersection{wxImage::Replace
}\label{wximagereplace
}
618 \func{void
}{Replace
}{\param{unsigned char
}{ r1
},
\param{unsigned char
}{ g1
},
\param{unsigned char
}{ b1
},
619 \param{unsigned char
}{ r2
},
\param{unsigned char
}{ g2
},
\param{unsigned char
}{ b2
}}
621 Replaces the colour specified by
{\it r1,g1,b1
} by the colour
{\it r2,g2,b2
}.
623 \membersection{wxImage::Rescale
}\label{wximagerescale
}
625 \func{wxImage \&
}{Rescale
}{\param{int
}{ width
},
\param{int
}{ height
}}
627 Changes the size of the image in-place: after a call to this function, the
628 image will have the given width and height.
630 Returns the (modified) image itself.
634 \helpref{Scale
}{wximagescale
}
636 \membersection{wxImage::Rotate
}\label{wximagerotate
}
638 \func{wxImage
}{Rotate
}{\param{double
}{ angle
},
\param{const wxPoint\&
}{rotationCentre
},
639 \param{bool
}{ interpolating = TRUE
},
\param{wxPoint*
}{ offsetAfterRotation = NULL
}}
641 Rotates the image about the given point, by
{\it angle
} radians. Passing TRUE
642 to
{\it interpolating
} results in better image quality, but is slower. If the
643 image has a mask, then the mask colour is used for the uncovered pixels in the
644 rotated image background. Else, black (rgb
0,
0,
0) will be used.
646 Returns the rotated image, leaving this image intact.
648 \membersection{wxImage::Rotate90
}\label{wximagerotate90
}
650 \constfunc{wxImage
}{Rotate90
}{\param{bool
}{ clockwise = TRUE
}}
652 Returns a copy of the image rotated
90 degrees in the direction
653 indicated by
{\it clockwise
}.
655 \membersection{wxImage::Scale
}\label{wximagescale
}
657 \constfunc{wxImage
}{Scale
}{\param{int
}{ width
},
\param{int
}{ height
}}
659 Returns a scaled version of the image. This is also useful for
660 scaling bitmaps in general as the only other way to scale bitmaps
661 is to blit a wxMemoryDC into another wxMemoryDC.
663 It may be mentioned that the GTK port uses this function internally
664 to scale bitmaps when using mapping modes in wxDC.
669 // get the bitmap from somewhere
672 // rescale it to have size of
32*
32
673 if ( bmp.GetWidth() !=
32 || bmp.GetHeight() !=
32 )
676 bmp = wxBitmap(image.Scale(
32,
32));
678 // another possibility:
679 image.Rescale(
32,
32);
687 \helpref{Rescale
}{wximagerescale
}
689 \membersection{wxImage::SetData
}\label{wximagesetdata
}
691 \func{void
}{SetData
}{\param{unsigned char*
}{data
}}
693 Sets the image data without performing checks. The data given must have
694 the size (width*height*
3) or results will be unexpected. Don't use this
695 method if you aren't sure you know what you are doing.
697 \membersection{wxImage::SetMask
}\label{wximagesetmask
}
699 \func{void
}{SetMask
}{\param{bool
}{ hasMask = TRUE
}}
701 Specifies whether there is a mask or not. The area of the mask is determined by the current mask colour.
703 \membersection{wxImage::SetMaskColour
}\label{wximagesetmaskcolour
}
705 \func{void
}{SetMaskColour
}{\param{unsigned char
}{red
},
\param{unsigned char
}{blue
},
\param{unsigned char
}{green
}}
707 Sets the mask colour for this image (and tells the image to use the mask).
709 \membersection{wxImage::SetMaskFromImage
}\label{wximagesetmaskfromimage
}
711 \func{bool
}{SetMaskFromImage
}{\param{const wxImage\&
}{ mask
},
\param{unsigned char
}{ mr
},
\param{unsigned char
}{ mg
},
\param{unsigned char
}{ mb
}}
713 \wxheading{Parameters
}
715 \docparam{mask
}{The mask image to extract mask shape from. Must have same dimensions as the image.
}
717 \docparam{mr,mg,mb
}{RGB value of pixels in
{\it mask
} that will be used to create the mask.
}
719 Sets image's mask so that the pixels that have RGB value of
{\it mr,mg,mb
}
720 in
{\it mask
} will be masked in the image. This is done by first finding an
721 unused colour in the image, setting this colour as the mask colour and then
722 using this colour to draw all pixels in the image who corresponding pixel
723 in
{\it mask
} has given RGB value.
725 \wxheading{Return value
}
727 Returns FALSE if
{\it mask
} does not have same dimensions as the image or if
728 there is no unused colour left. Returns TRUE if the mask was successfully
733 Note that this method involves computing the histogram, which is
734 computationally intensive operation.
736 \membersection{wxImage::SetOption
}\label{wximagesetoption
}
738 \func{void
}{SetOption
}{\param{const wxString\&
}{ name
},
\param{const wxString\&
}{ value
}}
740 \func{void
}{SetOption
}{\param{const wxString\&
}{ name
},
\param{int
}{ value
}}
742 Sets a user-defined option. The function is case-insensitive to
{\it name
}.
744 For example, when saving as a JPEG file, the option
{\bf quality
} is
745 used, which is a number between
0 and
100 (
0 is terrible,
100 is very good).
749 \helpref{wxImage::GetOption
}{wximagegetoption
},
\rtfsp
750 \helpref{wxImage::GetOptionInt
}{wximagegetoptionint
},
\rtfsp
751 \helpref{wxImage::HasOption
}{wximagehasoption
}
753 \membersection{wxImage::SetPalette
}\label{wximagesetpalette
}
755 \func{void
}{SetPalette
}{\param{const wxPalette\&
}{ palette
}}
757 Associates a palette with the image. The palette may be used when converting
758 wxImage to wxBitmap (MSW only at present) or in file save operations (none as yet).
760 \membersection{wxImage::SetRGB
}\label{wximagesetrgb
}
762 \func{void
}{SetRGB
}{\param{int
}{x
},
\param{int
}{y
},
\param{unsigned char
}{red
},
\param{unsigned char
}{green
},
\param{unsigned char
}{blue
}}
764 Sets the pixel at the given coordinate. This routine performs bounds-checks
765 for the coordinate so it can be considered a safe way to manipulate the
766 data, but in some cases this might be too slow so that the data will have to
767 be set directly. In that case you will have to get access to the image data
768 using the
\helpref{GetData
}{wximagegetdata
} method.
770 \membersection{wxImage::operator $=$
}
772 \func{wxImage\&
}{operator $=$
}{\param{const wxImage\&
}{image
}}
774 Assignment operator. This operator does not copy any data, but instead
775 passes a pointer to the data in
{\it image
} and increments a reference
776 counter. It is a fast operation.
778 \wxheading{Parameters
}
780 \docparam{image
}{Image to assign.
}
782 \wxheading{Return value
}
784 Returns 'this' object.
786 \membersection{wxImage::operator $==$
}
788 \func{bool
}{operator $==$
}{\param{const wxImage\&
}{image
}}
790 Equality operator. This operator tests whether the internal data pointers are
793 \wxheading{Parameters
}
795 \docparam{image
}{Image to compare with 'this'
}
797 \wxheading{Return value
}
799 Returns TRUE if the images were effectively equal, FALSE otherwise.
801 \membersection{wxImage::operator $!=$
}
803 \func{bool
}{operator $!=$
}{\param{const wxImage\&
}{image
}}
805 Inequality operator. This operator tests whether the internal data pointers are
806 unequal (a fast test).
808 \wxheading{Parameters
}
810 \docparam{image
}{Image to compare with 'this'
}
812 \wxheading{Return value
}
814 Returns TRUE if the images were unequal, FALSE otherwise.
816 \section{\class{wxImageHandler
}}\label{wximagehandler
}
818 This is the base class for implementing image file loading/saving, and image creation from data.
819 It is used within wxImage and is not normally seen by the application.
821 If you wish to extend the capabilities of wxImage, derive a class from wxImageHandler
822 and add the handler using
\helpref{wxImage::AddHandler
}{wximageaddhandler
} in your
823 application initialisation.
825 \wxheading{Note (Legal Issue)
}
827 This software is based in part on the work of the Independent JPEG Group.
829 (Applies when wxWindows is linked with JPEG support. wxJPEGHandler uses libjpeg
832 \wxheading{Derived from
}
834 \helpref{wxObject
}{wxobject
}
836 \wxheading{Include files
}
842 \helpref{wxImage
}{wximage
},
843 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}
845 \latexignore{\rtfignore{\wxheading{Members
}}}
847 \membersection{wxImageHandler::wxImageHandler
}\label{wximagehandlerconstr
}
849 \func{}{wxImageHandler
}{\void}
851 Default constructor. In your own default constructor, initialise the members
852 m
\_name, m
\_extension and m
\_type.
854 \membersection{wxImageHandler::
\destruct{wxImageHandler
}}
856 \func{}{\destruct{wxImageHandler
}}{\void}
858 Destroys the wxImageHandler object.
860 \membersection{wxImageHandler::GetName
}
862 \constfunc{wxString
}{GetName
}{\void}
864 Gets the name of this handler.
866 \membersection{wxImageHandler::GetExtension
}
868 \constfunc{wxString
}{GetExtension
}{\void}
870 Gets the file extension associated with this handler.
872 \membersection{wxImageHandler::GetImageCount
}\label{wximagehandlergetimagecount
}
874 \func{int
}{GetImageCount
}{\param{wxInputStream\&
}{ stream
}}
876 If the image file contains more than one image and the image handler is capable
877 of retrieving these individually, this function will return the number of
880 \docparam{stream
}{Opened input stream for reading image data. Currently, the stream must support seeking.
}
882 \wxheading{Return value
}
884 Number of available images. For most image handles, this defaults to
1.
886 \membersection{wxImageHandler::GetType
}
888 \constfunc{long
}{GetType
}{\void}
890 Gets the image type associated with this handler.
892 \membersection{wxImageHandler::GetMimeType
}
894 \constfunc{wxString
}{GetMimeType
}{\void}
896 Gets the MIME type associated with this handler.
898 \membersection{wxImageHandler::LoadFile
}\label{wximagehandlerloadfile
}
900 \func{bool
}{LoadFile
}{\param{wxImage*
}{image
},
\param{wxInputStream\&
}{ stream
},
\param{bool
}{ verbose=TRUE
},
\param{int
}{ index=
0}}
902 Loads a image from a stream, putting the resulting data into
{\it image
}. If the image file contains
903 more than one image and the image handler is capable of retrieving these individually,
{\it index
}
904 indicates which image to read from the stream.
906 \wxheading{Parameters
}
908 \docparam{image
}{The image object which is to be affected by this operation.
}
910 \docparam{stream
}{Opened input stream for reading image data.
}
912 \docparam{verbose
}{If set to TRUE, errors reported by the image handler will produce wxLogMessages.
}
914 \docparam{index
}{The index of the image in the file (starting from zero).
}
916 \wxheading{Return value
}
918 TRUE if the operation succeeded, FALSE otherwise.
922 \helpref{wxImage::LoadFile
}{wximageloadfile
},
923 \helpref{wxImage::SaveFile
}{wximagesavefile
},
924 \helpref{wxImageHandler::SaveFile
}{wximagehandlersavefile
}
926 \membersection{wxImageHandler::SaveFile
}\label{wximagehandlersavefile
}
928 \func{bool
}{SaveFile
}{\param{wxImage*
}{image
},
\param{wxOutputStream\&
}{stream
}}
930 Saves a image in the output stream.
932 \wxheading{Parameters
}
934 \docparam{image
}{The image object which is to be affected by this operation.
}
936 \docparam{stream
}{Opened output stream for writing the data.
}
938 \wxheading{Return value
}
940 TRUE if the operation succeeded, FALSE otherwise.
944 \helpref{wxImage::LoadFile
}{wximageloadfile
},
945 \helpref{wxImage::SaveFile
}{wximagesavefile
},
946 \helpref{wxImageHandler::LoadFile
}{wximagehandlerloadfile
}
948 \membersection{wxImageHandler::SetName
}
950 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
952 Sets the handler name.
954 \wxheading{Parameters
}
956 \docparam{name
}{Handler name.
}
958 \membersection{wxImageHandler::SetExtension
}
960 \func{void
}{SetExtension
}{\param{const wxString\&
}{extension
}}
962 Sets the handler extension.
964 \wxheading{Parameters
}
966 \docparam{extension
}{Handler extension.
}
968 \membersection{wxImageHandler::SetMimeType
}\label{wximagehandlersetmimetype
}
970 \func{void
}{SetMimeType
}{\param{const wxString\&
}{mimetype
}}
972 Sets the handler MIME type.
974 \wxheading{Parameters
}
976 \docparam{mimename
}{Handler MIME type.
}
978 \membersection{wxImageHandler::SetType
}
980 \func{void
}{SetType
}{\param{long
}{type
}}
982 Sets the handler type.
984 \wxheading{Parameters
}
986 \docparam{name
}{Handler type.
}