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.
}
37 When saving in PCX format,
{\bf wxPCXHandler
} will count the number of
38 different colours in the image; if there are
256 or less colours, it will
39 save as
8 bit, else it will save as
24 bit.
41 Loading PNMs only works for ASCII or raw RGB images. When saving in
42 PNM format,
{\bf wxPNMHandler
} will always save as raw RGB.
44 \wxheading{Derived from
}
46 \helpref{wxObject
}{wxobject
}
48 \wxheading{Include files
}
54 \helpref{wxBitmap
}{wxbitmap
},
55 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}
57 \latexignore{\rtfignore{\wxheading{Members
}}}
59 \membersection{wxImage::wxImage
}\label{wximageconstr
}
61 \func{}{wxImage
}{\void}
65 \func{}{wxImage
}{\param{const wxImage\&
}{image
}}
69 \func{}{wxImage
}{\param{const wxBitmap\&
}{ bitmap
}}
71 (Deprecated form, use
\helpref{wxBitmap::ConvertToImage
}{wxbitmapconverttoimage
}
72 instead.) Constructs an image from a platform-dependent bitmap. This preserves
73 mask information so that bitmaps and images can be converted back
74 and forth without loss in that respect.
76 \func{}{wxImage
}{\param{int
}{ width
},
\param{int
}{ height
}}
78 Creates an image with the given width and height.
80 \func{}{wxImage
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{unsigned char*
}{ data
},
\param{bool
}{ static_data=FALSE
}}
82 Creates an image from given data with the given width and height. If
83 {\it static_data
} is TRUE, then wxImage will not delete the actual
84 image data in its destructor, otherwise it will free it by calling
87 \func{}{wxImage
}{\param{const wxString\&
}{name
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY}}
89 \func{}{wxImage
}{\param{const wxString\&
}{name
},
\param{const wxString\&
}{ mimetype
}}
91 Loads an image from a file.
93 \func{}{wxImage
}{\param{wxInputStream\&
}{stream
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY}}
95 \func{}{wxImage
}{\param{wxInputStream\&
}{stream
},
\param{const wxString\&
}{ mimetype
}}
97 Loads an image from an input stream.
99 \wxheading{Parameters
}
101 \docparam{width
}{Specifies the width of the image.
}
103 \docparam{height
}{Specifies the height of the image.
}
105 \docparam{name
}{Name of the file from which to load the image.
}
107 \docparam{stream
}{Opened input stream from which to load the image. Currently, the stream must support seeking.
}
109 \docparam{type
}{May be one of the following:
113 \twocolitem{\indexit{wxBITMAP
\_TYPE\_BMP}}{Load a Windows bitmap file.
}
114 \twocolitem{\indexit{wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
115 \twocolitem{\indexit{wxBITMAP
\_TYPE\_JPEG}}{Load a JPEG bitmap file.
}
116 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PNG}}{Load a PNG bitmap file.
}
117 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PCX}}{Load a PCX bitmap file.
}
118 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PNM}}{Load a PNM bitmap file.
}
119 \twocolitem{\indexit{wxBITMAP
\_TYPE\_TIF}}{Load a TIFF bitmap file.
}
120 \twocolitem{\indexit{wxBITMAP
\_TYPE\_XPM}}{Load a XPM bitmap file.
}
121 \twocolitem{\indexit{wxBITMAP
\_TYPE\_ANY}}{Will try to autodetect the format.
}
124 \docparam{mimetype
}{MIME type string (for example 'image/jpeg')
}
128 Depending on how wxWindows has been configured, not all formats may be available.
130 Note: any handler other than BMP must be previously
131 initialized with
\helpref{wxImage::AddHandler
}{wximageaddhandler
} or
132 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}.
136 \helpref{wxImage::LoadFile
}{wximageloadfile
}
138 \pythonnote{Constructors supported by wxPython are:
\par
139 \indented{2cm
}{\begin{twocollist
}
140 \twocolitem{{\bf wxImage(name, flag)
}}{Loads an image from a file
}
141 \twocolitem{{\bf wxNullImage()
}}{Create a null image (has no size or
143 \twocolitem{{\bf wxEmptyImage(width, height)
}}{Creates an empty image
145 \twocolitem{{\bf wxImageFromMime(name, mimetype
}}{Creates an image from
146 the given file of the given mimetype
}
147 \twocolitem{{\bf wxImageFromBitmap(bitmap)
}}{Creates an image from a
148 platform-dependent bitmap
}
152 \perlnote{Constructors supported by wxPerl are:
\par
154 \item{Wx::Image->new( bitmap )
}
155 \item{Wx::Image->new( width, height )
}
156 \item{Wx::Image->new( name, type )
}
157 \item{Wx::Image->new( name, mimetype )
}
161 \membersection{wxImage::
\destruct{wxImage
}}
163 \func{}{\destruct{wxImage
}}{\void}
167 \membersection{wxImage::AddHandler
}\label{wximageaddhandler
}
169 \func{static void
}{AddHandler
}{\param{wxImageHandler*
}{ handler
}}
171 Adds a handler to the end of the static list of format handlers.
173 \docparam{handler
}{A new image format handler object. There is usually only one instance
174 of a given handler class in an application session.
}
178 \helpref{wxImageHandler
}{wximagehandler
}
180 \pythonnote{In wxPython this static method is named
{\tt wxImage_AddHandler
}.
}
181 \membersection{wxImage::CleanUpHandlers
}
183 \func{static void
}{CleanUpHandlers
}{\void}
185 Deletes all image handlers.
187 This function is called by wxWindows on exit.
189 \membersection{wxImage::ConvertToBitmap
}\label{wximageconverttobitmap
}
191 \constfunc{wxBitmap
}{ConvertToBitmap
}{\void}
193 Deprecated, use equivalent
\helpref{wxBitmap constructor
}{wxbitmapconstr
}
194 (which takes wxImage and depth as its arguments) instead.
196 \membersection{wxImage::ConvertToMono
}\label{wxbitmapconverttomono
}
198 \constfunc{wxImage
}{ConvertToMono
}{\param{unsigned char
}{ r
},
\param{unsigned char
}{ g
},
\param{unsigned char
}{ b
}}
200 Returns monochromatic version of the image. The returned image has white
201 colour where the original has
{\it (r,g,b)
} colour and black colour
204 \membersection{wxImage::Copy
}\label{wximagecopy
}
206 \constfunc{wxImage
}{Copy
}{\void}
208 Returns an identical copy of the image.
210 \membersection{wxImage::Create
}\label{wximagecreate
}
212 \func{bool
}{Create
}{\param{int
}{ width
},
\param{int
}{ height
}}
214 Creates a fresh image.
216 \wxheading{Parameters
}
218 \docparam{width
}{The width of the image in pixels.
}
220 \docparam{height
}{The height of the image in pixels.
}
222 \wxheading{Return value
}
224 TRUE if the call succeeded, FALSE otherwise.
226 \membersection{wxImage::Destroy
}\label{wximagedestroy
}
228 \func{bool
}{Destroy
}{\void}
230 Destroys the image data.
232 \membersection{wxImage::FindHandler
}
234 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{name
}}
236 Finds the handler with the given name.
238 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{extension
},
\param{long
}{ imageType
}}
240 Finds the handler associated with the given extension and type.
242 \func{static wxImageHandler*
}{FindHandler
}{\param{long
}{imageType
}}
244 Finds the handler associated with the given image type.
246 \func{static wxImageHandler*
}{FindHandlerMime
}{\param{const wxString\&
}{mimetype
}}
248 Finds the handler associated with the given MIME type.
250 \docparam{name
}{The handler name.
}
252 \docparam{extension
}{The file extension, such as ``bmp".
}
254 \docparam{imageType
}{The image type, such as wxBITMAP
\_TYPE\_BMP.
}
256 \docparam{mimetype
}{MIME type.
}
258 \wxheading{Return value
}
260 A pointer to the handler if found, NULL otherwise.
264 \helpref{wxImageHandler
}{wximagehandler
}
266 \membersection{wxImage::GetBlue
}\label{wximagegetblue
}
268 \constfunc{unsigned char
}{GetBlue
}{\param{int
}{ x
},
\param{int
}{ y
}}
270 Returns the blue intensity at the given coordinate.
272 \membersection{wxImage::GetData
}\label{wximagegetdata
}
274 \constfunc{unsigned char*
}{GetData
}{\void}
276 Returns the image data as an array. This is most often used when doing
277 direct image manipulation. The return value points to an array of
278 chararcters in RGBGBRGB... format.
280 \membersection{wxImage::GetGreen
}\label{wximagegetgreen
}
282 \constfunc{unsigned char
}{GetGreen
}{\param{int
}{ x
},
\param{int
}{ y
}}
284 Returns the green intensity at the given coordinate.
286 \membersection{wxImage::GetRed
}\label{wximagegetred
}
288 \constfunc{unsigned char
}{GetRed
}{\param{int
}{ x
},
\param{int
}{ y
}}
290 Returns the red intensity at the given coordinate.
292 \membersection{wxImage::GetHandlers
}
294 \func{static wxList\&
}{GetHandlers
}{\void}
296 Returns the static list of image format handlers.
300 \helpref{wxImageHandler
}{wximagehandler
}
302 \membersection{wxImage::GetHeight
}\label{wximagegetheight
}
304 \constfunc{int
}{GetHeight
}{\void}
306 Gets the height of the image in pixels.
308 \membersection{wxImage::GetMaskBlue
}\label{wximagegetmaskblue
}
310 \constfunc{unsigned char
}{GetMaskBlue
}{\void}
312 Gets the blue value of the mask colour.
314 \membersection{wxImage::GetMaskGreen
}\label{wximagegetmaskgreen
}
316 \constfunc{unsigned char
}{GetMaskGreen
}{\void}
318 Gets the green value of the mask colour.
320 \membersection{wxImage::GetMaskRed
}\label{wximagegetmaskred
}
322 \constfunc{unsigned char
}{GetMaskRed
}{\void}
324 Gets the red value of the mask colour.
326 \membersection{wxImage::GetPalette
}\label{wximagegetpalette
}
328 \constfunc{const wxPalette\&
}{GetPalette
}{\void}
330 Returns the palette associated with the image. Currently the palette is only
331 used when converting to wxBitmap under Windows.
333 Eventually wxImage handlers will set the palette if one exists in the image file.
335 \membersection{wxImage::GetSubImage
}\label{wximagegetsubimage
}
337 \constfunc{wxImage
}{GetSubImage
}{\param{const wxRect\&
}{ rect
}}
339 Returns a sub image of the current one as long as the rect belongs entirely to
342 \membersection{wxImage::GetWidth
}\label{wximagegetwidth
}
344 \constfunc{int
}{GetWidth
}{\void}
346 Gets the width of the image in pixels.
350 \helpref{wxImage::GetHeight
}{wximagegetheight
}
352 \membersection{wxImage::HasMask
}\label{wximagehasmask
}
354 \constfunc{bool
}{HasMask
}{\void}
356 Returns TRUE if there is a mask active, FALSE otherwise.
358 \membersection{wxImage::GetOption
}\label{wximagegetoption
}
360 \constfunc{wxString
}{GetOption
}{\param{const wxString\&
}{ name
}}
362 Gets a user-defined option. The function is case-insensitive to
{\it name
}.
364 For example, when saving as a JPEG file, the option
{\bf quality
} is
365 used, which is a number between
0 and
100 (
0 is terrible,
100 is very good).
369 \helpref{wxImage::SetOption
}{wximagesetoption
},
\rtfsp
370 \helpref{wxImage::GetOptionInt
}{wximagegetoptionint
},
\rtfsp
371 \helpref{wxImage::HasOption
}{wximagehasoption
}
373 \membersection{wxImage::GetOptionInt
}\label{wximagegetoptionint
}
375 \constfunc{int
}{GetOptionInt
}{\param{const wxString\&
}{ name
}}
377 Gets a user-defined option as an integer. The function is case-insensitive to
{\it name
}.
381 \helpref{wxImage::SetOption
}{wximagesetoption
},
\rtfsp
382 \helpref{wxImage::GetOption
}{wximagegetoption
},
\rtfsp
383 \helpref{wxImage::HasOption
}{wximagehasoption
}
385 \membersection{wxImage::HasOption
}\label{wximagehasoption
}
387 \constfunc{bool
}{HasOption
}{\param{const wxString\&
}{ name
}}
389 Returns TRUE if the given option is present. The function is case-insensitive to
{\it name
}.
393 \helpref{wxImage::SetOption
}{wximagesetoption
},
\rtfsp
394 \helpref{wxImage::GetOption
}{wximagegetoption
},
\rtfsp
395 \helpref{wxImage::GetOptionInt
}{wximagegetoptionint
}
397 \membersection{wxImage::InitStandardHandlers
}
399 \func{static void
}{InitStandardHandlers
}{\void}
401 Internal use only. Adds standard image format handlers. It only install BMP
402 for the time being, which is used by wxBitmap.
404 This function is called by wxWindows on startup, and shouldn't be called by
409 \helpref{wxImageHandler
}{wximagehandler
},
410 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}
412 \membersection{wxImage::InsertHandler
}
414 \func{static void
}{InsertHandler
}{\param{wxImageHandler*
}{ handler
}}
416 Adds a handler at the start of the static list of format handlers.
418 \docparam{handler
}{A new image format handler object. There is usually only one instance
419 of a given handler class in an application session.
}
423 \helpref{wxImageHandler
}{wximagehandler
}
425 \membersection{wxImage::LoadFile
}\label{wximageloadfile
}
427 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY}}
429 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{const wxString\&
}{ mimetype
}}
431 Loads an image from a file. If no handler type is provided, the library will
432 try to autodetect the format.
434 \func{bool
}{LoadFile
}{\param{wxInputStream\&
}{ stream
},
\param{long
}{ type
}}
436 \func{bool
}{LoadFile
}{\param{wxInputStream\&
}{ stream
},
\param{const wxString\&
}{ mimetype
}}
438 Loads an image from an input stream.
440 \wxheading{Parameters
}
442 \docparam{name
}{Name of the file from which to load the image.
}
444 \docparam{stream
}{Opened input stream from which to load the image. Currently, the stream must support seeking.
}
446 \docparam{type
}{One of the following values:
450 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Load a Windows image file.
}
451 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Load a GIF image file.
}
452 \twocolitem{{\bf wxBITMAP
\_TYPE\_JPEG}}{Load a JPEG image file.
}
453 \twocolitem{{\bf wxBITMAP
\_TYPE\_PCX}}{Load a PCX image file.
}
454 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNG}}{Load a PNG image file.
}
455 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNM}}{Load a PNM image file.
}
456 \twocolitem{{\bf wxBITMAP
\_TYPE\_TIF}}{Load a TIFF image file.
}
457 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Load a XPM image file.
}
458 \twocolitem{{\bf wxBITMAP
\_TYPE\_ANY}}{Will try to autodetect the format.
}
461 \docparam{mimetype
}{MIME type string (for example 'image/jpeg')
}
465 Depending on how wxWindows has been configured, not all formats may be available.
467 \wxheading{Return value
}
469 TRUE if the operation succeeded, FALSE otherwise.
473 \helpref{wxImage::SaveFile
}{wximagesavefile
}
475 \pythonnote{In place of a single overloaded method name, wxPython
476 implements the following methods:
\par
477 \indented{2cm
}{\begin{twocollist
}
478 \twocolitem{{\bf LoadFile(filename, type)
}}{Loads an image of the given
480 \twocolitem{{\bf LoadMimeFile(filename, mimetype)
}}{Loads an image of the given
481 mimetype from a file
}
485 \perlnote{Methods supported by wxPerl are:
\par
487 \item{bitmap->LoadFile( name, type )
}
488 \item{bitmap->LoadFile( name, mimetype )
}
493 \membersection{wxImage::Ok
}\label{wximageok
}
495 \constfunc{bool
}{Ok
}{\void}
497 Returns TRUE if image data is present.
499 \membersection{wxImage::RemoveHandler
}
501 \func{static bool
}{RemoveHandler
}{\param{const wxString\&
}{name
}}
503 Finds the handler with the given name, and removes it. The handler
506 \docparam{name
}{The handler name.
}
508 \wxheading{Return value
}
510 TRUE if the handler was found and removed, FALSE otherwise.
514 \helpref{wxImageHandler
}{wximagehandler
}
516 \membersection{wxImage::SaveFile
}\label{wximagesavefile
}
518 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{int
}{ type
}}
520 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{const wxString\&
}{ mimetype
}}
522 Saves a image in the named file.
524 \func{bool
}{SaveFile
}{\param{wxOutputStream\&
}{stream
},
\param{int
}{ type
}}
526 \func{bool
}{SaveFile
}{\param{wxOutputStream\&
}{stream
},
\param{const wxString\&
}{ mimetype
}}
528 Saves a image in the given stream.
530 \wxheading{Parameters
}
532 \docparam{name
}{Name of the file to save the image to.
}
534 \docparam{stream
}{Opened output stream to save the image to.
}
536 \docparam{type
}{Currently three types can be used:
540 \twocolitem{{\bf wxBITMAP
\_TYPE\_JPEG}}{Save a JPEG image file.
}
541 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNG}}{Save a PNG image file.
}
542 \twocolitem{{\bf wxBITMAP
\_TYPE\_PCX}}{Save a PCX image file (tries to save as
8-bit if possible, falls back to
24-bit otherwise).
}
543 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNM}}{Save a PNM image file (as raw RGB always).
}
544 \twocolitem{{\bf wxBITMAP
\_TYPE\_TIFF}}{Save a TIFF image file.
}
545 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Save a XPM image file.
}
548 \docparam{mimetype
}{MIME type.
}
550 \wxheading{Return value
}
552 TRUE if the operation succeeded, FALSE otherwise.
556 Depending on how wxWindows has been configured, not all formats may be available.
560 \helpref{wxImage::LoadFile
}{wximageloadfile
}
562 \pythonnote{In place of a single overloaded method name, wxPython
563 implements the following methods:
\par
564 \indented{2cm
}{\begin{twocollist
}
565 \twocolitem{{\bf SaveFile(filename, type)
}}{Saves the image using the given
566 type to the named file
}
567 \twocolitem{{\bf SaveMimeFile(filename, mimetype)
}}{Saves the image using the given
568 mimetype to the named file
}
572 \perlnote{Methods supported by wxPerl are:
\par
574 \item{bitmap->SaveFile( name, type )
}
575 \item{bitmap->SaveFile( name, mimetype )
}
579 \membersection{wxImage::Mirror
}\label{wximagemirror
}
581 \constfunc{wxImage
}{Mirror
}{\param{bool
}{ horizontally = TRUE
}}
583 Returns a mirrored copy of the image. The parameter
{\it horizontally
}
584 indicates the orientation.
586 \membersection{wxImage::Replace
}\label{wximagereplace
}
588 \func{void
}{Replace
}{\param{unsigned char
}{ r1
},
\param{unsigned char
}{ g1
},
\param{unsigned char
}{ b1
},
589 \param{unsigned char
}{ r2
},
\param{unsigned char
}{ g2
},
\param{unsigned char
}{ b2
}}
591 Replaces the colour specified by
{\it r1,g1,b1
} by the colour
{\it r2,g2,b2
}.
593 \membersection{wxImage::Rescale
}\label{wximagerescale
}
595 \func{wxImage \&
}{Rescale
}{\param{int
}{ width
},
\param{int
}{ height
}}
597 Changes the size of the image in-place: after a call to this function, the
598 image will have the given width and height.
600 Returns the (modified) image itself.
604 \helpref{Scale
}{wximagescale
}
606 \membersection{wxImage::Rotate
}\label{wximagerotate
}
608 \func{wxImage
}{Rotate
}{\param{double
}{ angle
},
\param{const wxPoint\&
}{rotationCentre
},
609 \param{bool
}{ interpolating = TRUE
},
\param{wxPoint*
}{ offsetAfterRotation = NULL
}}
611 Rotates the image about the given point, by
{\it angle
} radians. Passing TRUE
612 to
{\it interpolating
} results in better image quality, but is slower. If the
613 image has a mask, then the mask colour is used for the uncovered pixels in the
614 rotated image background. Else, black (rgb
0,
0,
0) will be used.
616 Returns the rotated image, leaving this image intact.
618 \membersection{wxImage::Rotate90
}\label{wximagerotate90
}
620 \constfunc{wxImage
}{Rotate90
}{\param{bool
}{ clockwise = TRUE
}}
622 Returns a copy of the image rotated
90 degrees in the direction
623 indicated by
{\it clockwise
}.
625 \membersection{wxImage::Scale
}\label{wximagescale
}
627 \constfunc{wxImage
}{Scale
}{\param{int
}{ width
},
\param{int
}{ height
}}
629 Returns a scaled version of the image. This is also useful for
630 scaling bitmaps in general as the only other way to scale bitmaps
631 is to blit a wxMemoryDC into another wxMemoryDC.
633 It may be mentioned that the GTK port uses this function internally
634 to scale bitmaps when using mapping modes in wxDC.
639 // get the bitmap from somewhere
642 // rescale it to have size of
32*
32
643 if ( bmp.GetWidth() !=
32 || bmp.GetHeight() !=
32 )
646 bmp = wxBitmap(image.Scale(
32,
32));
648 // another possibility:
649 image.Rescale(
32,
32);
657 \helpref{Rescale
}{wximagerescale
}
659 \membersection{wxImage::SetData
}\label{wximagesetdata
}
661 \func{void
}{SetData
}{\param{unsigned char*
}{data
}}
663 Sets the image data without performing checks. The data given must have
664 the size (width*height*
3) or results will be unexpected. Don't use this
665 method if you aren't sure you know what you are doing.
667 \membersection{wxImage::SetMask
}\label{wximagesetmask
}
669 \func{void
}{SetMask
}{\param{bool
}{ hasMask = TRUE
}}
671 Specifies whether there is a mask or not. The area of the mask is determined by the current mask colour.
673 \membersection{wxImage::SetMaskColour
}\label{wximagesetmaskcolour
}
675 \func{void
}{SetMaskColour
}{\param{unsigned char
}{red
},
\param{unsigned char
}{blue
},
\param{unsigned char
}{green
}}
677 Sets the mask colour for this image (and tells the image to use the mask).
679 \membersection{wxImage::SetOption
}\label{wximagesetoption
}
681 \func{void
}{SetOption
}{\param{const wxString\&
}{ name
},
\param{const wxString\&
}{ value
}}
683 \func{void
}{SetOption
}{\param{const wxString\&
}{ name
},
\param{int
}{ value
}}
685 Sets a user-defined option. The function is case-insensitive to
{\it name
}.
687 For example, when saving as a JPEG file, the option
{\bf quality
} is
688 used, which is a number between
0 and
100 (
0 is terrible,
100 is very good).
692 \helpref{wxImage::GetOption
}{wximagegetoption
},
\rtfsp
693 \helpref{wxImage::GetOptionInt
}{wximagegetoptionint
},
\rtfsp
694 \helpref{wxImage::HasOption
}{wximagehasoption
}
696 \membersection{wxImage::SetPalette
}\label{wximagesetpalette
}
698 \func{void
}{SetPalette
}{\param{const wxPalette\&
}{ palette
}}
700 Associates a palette with the image. The palette may be used when converting
701 wxImage to wxBitmap (MSW only at present) or in file save operations (none as yet).
703 \membersection{wxImage::SetRGB
}\label{wximagesetrgb
}
705 \func{void
}{SetRGB
}{\param{int
}{x
},
\param{int
}{y
},
\param{unsigned char
}{red
},
\param{unsigned char
}{green
},
\param{unsigned char
}{blue
}}
707 Sets the pixel at the given coordinate. This routine performs bounds-checks
708 for the coordinate so it can be considered a safe way to manipulate the
709 data, but in some cases this might be too slow so that the data will have to
710 be set directly. In that case you will have to get access to the image data
711 using the
\helpref{GetData
}{wximagegetdata
} method.
713 \membersection{wxImage::operator $=$
}
715 \func{wxImage\&
}{operator $=$
}{\param{const wxImage\&
}{image
}}
717 Assignment operator. This operator does not copy any data, but instead
718 passes a pointer to the data in
{\it image
} and increments a reference
719 counter. It is a fast operation.
721 \wxheading{Parameters
}
723 \docparam{image
}{Image to assign.
}
725 \wxheading{Return value
}
727 Returns 'this' object.
729 \membersection{wxImage::operator $==$
}
731 \func{bool
}{operator $==$
}{\param{const wxImage\&
}{image
}}
733 Equality operator. This operator tests whether the internal data pointers are
736 \wxheading{Parameters
}
738 \docparam{image
}{Image to compare with 'this'
}
740 \wxheading{Return value
}
742 Returns TRUE if the images were effectively equal, FALSE otherwise.
744 \membersection{wxImage::operator $!=$
}
746 \func{bool
}{operator $!=$
}{\param{const wxImage\&
}{image
}}
748 Inequality operator. This operator tests whether the internal data pointers are
749 unequal (a fast test).
751 \wxheading{Parameters
}
753 \docparam{image
}{Image to compare with 'this'
}
755 \wxheading{Return value
}
757 Returns TRUE if the images were unequal, FALSE otherwise.
759 \section{\class{wxImageHandler
}}\label{wximagehandler
}
761 This is the base class for implementing image file loading/saving, and image creation from data.
762 It is used within wxImage and is not normally seen by the application.
764 If you wish to extend the capabilities of wxImage, derive a class from wxImageHandler
765 and add the handler using
\helpref{wxImage::AddHandler
}{wximageaddhandler
} in your
766 application initialisation.
768 \wxheading{Note (Legal Issue)
}
770 This software is based in part on the work of the Independent JPEG Group.
772 (Applies when wxWindows is linked with JPEG support. wxJPEGHandler uses libjpeg
775 \wxheading{Derived from
}
777 \helpref{wxObject
}{wxobject
}
779 \wxheading{Include files
}
785 \helpref{wxImage
}{wximage
},
786 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}
788 \latexignore{\rtfignore{\wxheading{Members
}}}
790 \membersection{wxImageHandler::wxImageHandler
}\label{wximagehandlerconstr
}
792 \func{}{wxImageHandler
}{\void}
794 Default constructor. In your own default constructor, initialise the members
795 m
\_name, m
\_extension and m
\_type.
797 \membersection{wxImageHandler::
\destruct{wxImageHandler
}}
799 \func{}{\destruct{wxImageHandler
}}{\void}
801 Destroys the wxImageHandler object.
803 \membersection{wxImageHandler::GetName
}
805 \constfunc{wxString
}{GetName
}{\void}
807 Gets the name of this handler.
809 \membersection{wxImageHandler::GetExtension
}
811 \constfunc{wxString
}{GetExtension
}{\void}
813 Gets the file extension associated with this handler.
815 \membersection{wxImageHandler::GetImageCount
}\label{wximagehandlergetimagecount
}
817 \func{int
}{GetImageCount
}{\param{wxInputStream\&
}{ stream
}}
819 If the image file contains more than one image and the image handler is capable
820 of retrieving these individually, this function will return the number of
823 \docparam{stream
}{Opened input stream for reading image data. Currently, the stream must support seeking.
}
825 \wxheading{Return value
}
827 Number of available images. For most image handles, this defaults to
1.
829 \membersection{wxImageHandler::GetType
}
831 \constfunc{long
}{GetType
}{\void}
833 Gets the image type associated with this handler.
835 \membersection{wxImageHandler::GetMimeType
}
837 \constfunc{wxString
}{GetMimeType
}{\void}
839 Gets the MIME type associated with this handler.
841 \membersection{wxImageHandler::LoadFile
}\label{wximagehandlerloadfile
}
843 \func{bool
}{LoadFile
}{\param{wxImage*
}{image
},
\param{wxInputStream\&
}{ stream
},
\param{bool
}{ verbose=TRUE
},
\param{int
}{ index=
0}}
845 Loads a image from a stream, putting the resulting data into
{\it image
}. If the image file contains
846 more than one image and the image handler is capable of retrieving these individually,
{\it index
}
847 indicates which image to read from the stream.
849 \wxheading{Parameters
}
851 \docparam{image
}{The image object which is to be affected by this operation.
}
853 \docparam{stream
}{Opened input stream for reading image data.
}
855 \docparam{verbose
}{If set to TRUE, errors reported by the image handler will produce wxLogMessages.
}
857 \docparam{index
}{The index of the image in the file (starting from zero).
}
859 \wxheading{Return value
}
861 TRUE if the operation succeeded, FALSE otherwise.
865 \helpref{wxImage::LoadFile
}{wximageloadfile
},
866 \helpref{wxImage::SaveFile
}{wximagesavefile
},
867 \helpref{wxImageHandler::SaveFile
}{wximagehandlersavefile
}
869 \membersection{wxImageHandler::SaveFile
}\label{wximagehandlersavefile
}
871 \func{bool
}{SaveFile
}{\param{wxImage*
}{image
},
\param{wxOutputStream\&
}{stream
}}
873 Saves a image in the output stream.
875 \wxheading{Parameters
}
877 \docparam{image
}{The image object which is to be affected by this operation.
}
879 \docparam{stream
}{Opened output stream for writing the data.
}
881 \wxheading{Return value
}
883 TRUE if the operation succeeded, FALSE otherwise.
887 \helpref{wxImage::LoadFile
}{wximageloadfile
},
888 \helpref{wxImage::SaveFile
}{wximagesavefile
},
889 \helpref{wxImageHandler::LoadFile
}{wximagehandlerloadfile
}
891 \membersection{wxImageHandler::SetName
}
893 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
895 Sets the handler name.
897 \wxheading{Parameters
}
899 \docparam{name
}{Handler name.
}
901 \membersection{wxImageHandler::SetExtension
}
903 \func{void
}{SetExtension
}{\param{const wxString\&
}{extension
}}
905 Sets the handler extension.
907 \wxheading{Parameters
}
909 \docparam{extension
}{Handler extension.
}
911 \membersection{wxImageHandler::SetMimeType
}\label{wximagehandlersetmimetype
}
913 \func{void
}{SetMimeType
}{\param{const wxString\&
}{mimetype
}}
915 Sets the handler MIME type.
917 \wxheading{Parameters
}
919 \docparam{mimename
}{Handler MIME type.
}
921 \membersection{wxImageHandler::SetType
}
923 \func{void
}{SetType
}{\param{long
}{type
}}
925 Sets the handler type.
927 \wxheading{Parameters
}
929 \docparam{name
}{Handler type.
}