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.
}
36 When saving in PCX format,
{\bf wxPCXHandler
} will count the number of
37 different colours in the image; if there are
256 or less colours, it will
38 save as
8 bit, else it will save as
24 bit.
40 Loading PNMs only works for ASCII or raw RGB images. When saving in
41 PNM format,
{\bf wxPNMHandler
} will always save as raw RGB.
43 \wxheading{Derived from
}
45 \helpref{wxObject
}{wxobject
}
47 \wxheading{Include files
}
53 \helpref{wxBitmap
}{wxbitmap
},
54 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}
56 \latexignore{\rtfignore{\wxheading{Members
}}}
58 \membersection{wxImage::wxImage
}\label{wximageconstr
}
60 \func{}{wxImage
}{\void}
64 \func{}{wxImage
}{\param{const wxImage\&
}{image
}}
68 \func{}{wxImage
}{\param{const wxBitmap\&
}{ bitmap
}}
70 (Deprecated form, use
\helpref{wxBitmap::ConvertToImage
}{wxbitmapconverttoimage
}
71 instead.) Constructs an image from a platform-dependent bitmap. This preserves
72 mask information so that bitmaps and images can be converted back
73 and forth without loss in that respect.
75 \func{}{wxImage
}{\param{int
}{ width
},
\param{int
}{ height
}}
77 Creates an image with the given width and height.
79 \func{}{wxImage
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{unsigned char*
}{ data
},
\param{bool
}{ static_data=FALSE
}}
81 Creates an image from given data with the given width and height. If
82 {\it static_data
} is TRUE, then wxImage will not delete the actual
83 image data in its destructor, otherwise it will free it by calling
86 \func{}{wxImage
}{\param{const wxString\&
}{name
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY}}
88 \func{}{wxImage
}{\param{const wxString\&
}{name
},
\param{const wxString\&
}{ mimetype
}}
90 Loads an image from a file.
92 \func{}{wxImage
}{\param{wxInputStream\&
}{stream
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY}}
94 \func{}{wxImage
}{\param{wxInputStream\&
}{stream
},
\param{const wxString\&
}{ mimetype
}}
96 Loads an image from an input stream.
98 \wxheading{Parameters
}
100 \docparam{width
}{Specifies the width of the image.
}
102 \docparam{height
}{Specifies the height of the image.
}
104 \docparam{name
}{Name of the file from which to load the image.
}
106 \docparam{stream
}{Opened input stream from which to load the image. Currently, the stream must support seeking.
}
108 \docparam{type
}{May be one of the following:
112 \twocolitem{\indexit{wxBITMAP
\_TYPE\_BMP}}{Load a Windows bitmap file.
}
113 \twocolitem{\indexit{wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
114 \twocolitem{\indexit{wxBITMAP
\_TYPE\_JPEG}}{Load a JPEG bitmap file.
}
115 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PNG}}{Load a PNG bitmap file.
}
116 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PCX}}{Load a PCX bitmap file.
}
117 \twocolitem{\indexit{wxBITMAP
\_TYPE\_PNM}}{Load a PNM bitmap file.
}
118 \twocolitem{\indexit{wxBITMAP
\_TYPE\_TIF}}{Load a TIFF bitmap file.
}
119 \twocolitem{\indexit{wxBITMAP
\_TYPE\_ANY}}{Will try to autodetect the format.
}
122 \docparam{mimetype
}{MIME type string (for example 'image/jpeg')
}
126 Depending on how wxWindows has been configured, not all formats may be available.
128 Note: any handler other than BMP must be previously
129 initialized with
\helpref{wxImage::AddHandler
}{wximageaddhandler
} or
130 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}.
134 \helpref{wxImage::LoadFile
}{wximageloadfile
}
136 \pythonnote{Constructors supported by wxPython are:
\par
137 \indented{2cm
}{\begin{twocollist
}
138 \twocolitem{{\bf wxImage(name, flag)
}}{Loads an image from a file
}
139 \twocolitem{{\bf wxNullImage()
}}{Create a null image (has no size or
141 \twocolitem{{\bf wxEmptyImage(width, height)
}}{Creates an empty image
143 \twocolitem{{\bf wxImageFromMime(name, mimetype
}}{Creates an image from
144 the given file of the given mimetype
}
145 \twocolitem{{\bf wxImageFromBitmap(bitmap)
}}{Creates an image from a
146 platform-dependent bitmap
}
150 \perlnote{Constructors supported by wxPerl are:
\par
152 \item{Wx::Image->new( bitmap )
}
153 \item{Wx::Image->new( width, height )
}
154 \item{Wx::Image->new( name, type )
}
155 \item{Wx::Image->new( name, mimetype )
}
159 \membersection{wxImage::
\destruct{wxImage
}}
161 \func{}{\destruct{wxImage
}}{\void}
165 \membersection{wxImage::AddHandler
}\label{wximageaddhandler
}
167 \func{static void
}{AddHandler
}{\param{wxImageHandler*
}{ handler
}}
169 Adds a handler to the end of the static list of format handlers.
171 \docparam{handler
}{A new image format handler object. There is usually only one instance
172 of a given handler class in an application session.
}
176 \helpref{wxImageHandler
}{wximagehandler
}
178 \pythonnote{In wxPython this static method is named
{\tt wxImage_AddHandler
}.
}
179 \membersection{wxImage::CleanUpHandlers
}
181 \func{static void
}{CleanUpHandlers
}{\void}
183 Deletes all image handlers.
185 This function is called by wxWindows on exit.
187 \membersection{wxImage::ConvertToBitmap
}\label{wximageconverttobitmap
}
189 \constfunc{wxBitmap
}{ConvertToBitmap
}{\void}
191 Deprecated, use equivalent
\helpref{wxBitmap constructor
}{wxbitmapconstr
}
192 (which takes wxImage and depth as its arguments) instead.
194 \membersection{wxImage::ConvertToMono
}\label{wxbitmapconverttomono
}
196 \constfunc{wxImage
}{ConvertToMono
}{\param{unsigned char
}{ r
},
\param{unsigned char
}{ g
},
\param{unsigned char
}{ b
}}
198 Returns monochromatic version of the image. The returned image has white
199 colour where the original has
{\it (r,g,b)
} colour and black colour
202 \membersection{wxImage::Copy
}\label{wximagecopy
}
204 \constfunc{wxImage
}{Copy
}{\void}
206 Returns an identical copy of the image.
208 \membersection{wxImage::Create
}\label{wximagecreate
}
210 \func{bool
}{Create
}{\param{int
}{ width
},
\param{int
}{ height
}}
212 Creates a fresh image.
214 \wxheading{Parameters
}
216 \docparam{width
}{The width of the image in pixels.
}
218 \docparam{height
}{The height of the image in pixels.
}
220 \wxheading{Return value
}
222 TRUE if the call succeeded, FALSE otherwise.
224 \membersection{wxImage::Destroy
}\label{wximagedestroy
}
226 \func{bool
}{Destroy
}{\void}
228 Destroys the image data.
230 \membersection{wxImage::FindHandler
}
232 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{name
}}
234 Finds the handler with the given name.
236 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{extension
},
\param{long
}{ imageType
}}
238 Finds the handler associated with the given extension and type.
240 \func{static wxImageHandler*
}{FindHandler
}{\param{long
}{imageType
}}
242 Finds the handler associated with the given image type.
244 \func{static wxImageHandler*
}{FindHandlerMime
}{\param{const wxString\&
}{mimetype
}}
246 Finds the handler associated with the given MIME type.
248 \docparam{name
}{The handler name.
}
250 \docparam{extension
}{The file extension, such as ``bmp".
}
252 \docparam{imageType
}{The image type, such as wxBITMAP
\_TYPE\_BMP.
}
254 \docparam{mimetype
}{MIME type.
}
256 \wxheading{Return value
}
258 A pointer to the handler if found, NULL otherwise.
262 \helpref{wxImageHandler
}{wximagehandler
}
264 \membersection{wxImage::GetBlue
}\label{wximagegetblue
}
266 \constfunc{unsigned char
}{GetBlue
}{\param{int
}{ x
},
\param{int
}{ y
}}
268 Returns the blue intensity at the given coordinate.
270 \membersection{wxImage::GetData
}\label{wximagegetdata
}
272 \constfunc{unsigned char*
}{GetData
}{\void}
274 Returns the image data as an array. This is most often used when doing
275 direct image manipulation. The return value points to an array of
276 chararcters in RGBGBRGB... format.
278 \membersection{wxImage::GetGreen
}\label{wximagegetgreen
}
280 \constfunc{unsigned char
}{GetGreen
}{\param{int
}{ x
},
\param{int
}{ y
}}
282 Returns the green intensity at the given coordinate.
284 \membersection{wxImage::GetRed
}\label{wximagegetred
}
286 \constfunc{unsigned char
}{GetRed
}{\param{int
}{ x
},
\param{int
}{ y
}}
288 Returns the red intensity at the given coordinate.
290 \membersection{wxImage::GetHandlers
}
292 \func{static wxList\&
}{GetHandlers
}{\void}
294 Returns the static list of image format handlers.
298 \helpref{wxImageHandler
}{wximagehandler
}
300 \membersection{wxImage::GetHeight
}\label{wximagegetheight
}
302 \constfunc{int
}{GetHeight
}{\void}
304 Gets the height of the image in pixels.
306 \membersection{wxImage::GetMaskBlue
}\label{wximagegetmaskblue
}
308 \constfunc{unsigned char
}{GetMaskBlue
}{\void}
310 Gets the blue value of the mask colour.
312 \membersection{wxImage::GetMaskGreen
}\label{wximagegetmaskgreen
}
314 \constfunc{unsigned char
}{GetMaskGreen
}{\void}
316 Gets the green value of the mask colour.
318 \membersection{wxImage::GetMaskRed
}\label{wximagegetmaskred
}
320 \constfunc{unsigned char
}{GetMaskRed
}{\void}
322 Gets the red value of the mask colour.
324 \membersection{wxImage::GetPalette
}\label{wximagegetpalette
}
326 \constfunc{const wxPalette\&
}{GetPalette
}{\void}
328 Returns the palette associated with the image. Currently the palette is only
329 used when converting to wxBitmap under Windows.
331 Eventually wxImage handlers will set the palette if one exists in the image file.
333 \membersection{wxImage::GetSubImage
}\label{wximagegetsubimage
}
335 \constfunc{wxImage
}{GetSubImage
}{\param{const wxRect\&
}{ rect
}}
337 Returns a sub image of the current one as long as the rect belongs entirely to
340 \membersection{wxImage::GetWidth
}\label{wximagegetwidth
}
342 \constfunc{int
}{GetWidth
}{\void}
344 Gets the width of the image in pixels.
348 \helpref{wxImage::GetHeight
}{wximagegetheight
}
350 \membersection{wxImage::HasMask
}\label{wximagehasmask
}
352 \constfunc{bool
}{HasMask
}{\void}
354 Returns TRUE if there is a mask active, FALSE otherwise.
356 \membersection{wxImage::GetOption
}\label{wximagegetoption
}
358 \constfunc{wxString
}{GetOption
}{\param{const wxString\&
}{ name
}}
360 Gets a user-defined option. The function is case-insensitive to
{\it name
}.
362 For example, when saving as a JPEG file, the option
{\bf quality
} is
363 used, which is a number between
0 and
100 (
0 is terrible,
100 is very good).
367 \helpref{wxImage::SetOption
}{wximagesetoption
},
\rtfsp
368 \helpref{wxImage::GetOptionInt
}{wximagegetoptionint
},
\rtfsp
369 \helpref{wxImage::HasOption
}{wximagehasoption
}
371 \membersection{wxImage::GetOptionInt
}\label{wximagegetoptionint
}
373 \constfunc{int
}{GetOptionInt
}{\param{const wxString\&
}{ name
}}
375 Gets a user-defined option as an integer. The function is case-insensitive to
{\it name
}.
379 \helpref{wxImage::SetOption
}{wximagesetoption
},
\rtfsp
380 \helpref{wxImage::GetOption
}{wximagegetoption
},
\rtfsp
381 \helpref{wxImage::HasOption
}{wximagehasoption
}
383 \membersection{wxImage::HasOption
}\label{wximagehasoption
}
385 \constfunc{bool
}{HasOption
}{\param{const wxString\&
}{ name
}}
387 Returns TRUE if the given option is present. The function is case-insensitive to
{\it name
}.
391 \helpref{wxImage::SetOption
}{wximagesetoption
},
\rtfsp
392 \helpref{wxImage::GetOption
}{wximagegetoption
},
\rtfsp
393 \helpref{wxImage::GetOptionInt
}{wximagegetoptionint
}
395 \membersection{wxImage::InitStandardHandlers
}
397 \func{static void
}{InitStandardHandlers
}{\void}
399 Internal use only. Adds standard image format handlers. It only install BMP
400 for the time being, which is used by wxBitmap.
402 This function is called by wxWindows on startup, and shouldn't be called by
407 \helpref{wxImageHandler
}{wximagehandler
},
408 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}
410 \membersection{wxImage::InsertHandler
}
412 \func{static void
}{InsertHandler
}{\param{wxImageHandler*
}{ handler
}}
414 Adds a handler at the start of the static list of format handlers.
416 \docparam{handler
}{A new image format handler object. There is usually only one instance
417 of a given handler class in an application session.
}
421 \helpref{wxImageHandler
}{wximagehandler
}
423 \membersection{wxImage::LoadFile
}\label{wximageloadfile
}
425 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY}}
427 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{const wxString\&
}{ mimetype
}}
429 Loads an image from a file. If no handler type is provided, the library will
430 try to autodetect the format.
432 \func{bool
}{LoadFile
}{\param{wxInputStream\&
}{ stream
},
\param{long
}{ type
}}
434 \func{bool
}{LoadFile
}{\param{wxInputStream\&
}{ stream
},
\param{const wxString\&
}{ mimetype
}}
436 Loads an image from an input stream.
438 \wxheading{Parameters
}
440 \docparam{name
}{Name of the file from which to load the image.
}
442 \docparam{stream
}{Opened input stream from which to load the image. Currently, the stream must support seeking.
}
444 \docparam{type
}{One of the following values:
448 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Load a Windows image file.
}
449 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Load a GIF image file.
}
450 \twocolitem{{\bf wxBITMAP
\_TYPE\_JPEG}}{Load a JPEG image file.
}
451 \twocolitem{{\bf wxBITMAP
\_TYPE\_PCX}}{Load a PCX image file.
}
452 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNG}}{Load a PNG image file.
}
453 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNM}}{Load a PNM image file.
}
454 \twocolitem{{\bf wxBITMAP
\_TYPE\_TIF}}{Load a TIFF image file.
}
455 \twocolitem{{\bf wxBITMAP
\_TYPE\_ANY}}{Will try to autodetect the format.
}
458 \docparam{mimetype
}{MIME type string (for example 'image/jpeg')
}
462 Depending on how wxWindows has been configured, not all formats may be available.
464 \wxheading{Return value
}
466 TRUE if the operation succeeded, FALSE otherwise.
470 \helpref{wxImage::SaveFile
}{wximagesavefile
}
472 \pythonnote{In place of a single overloaded method name, wxPython
473 implements the following methods:
\par
474 \indented{2cm
}{\begin{twocollist
}
475 \twocolitem{{\bf LoadFile(filename, type)
}}{Loads an image of the given
477 \twocolitem{{\bf LoadMimeFile(filename, mimetype)
}}{Loads an image of the given
478 mimetype from a file
}
482 \perlnote{Methods supported by wxPerl are:
\par
484 \item{bitmap->LoadFile( name, type )
}
485 \item{bitmap->LoadFile( name, mimetype )
}
490 \membersection{wxImage::Ok
}\label{wximageok
}
492 \constfunc{bool
}{Ok
}{\void}
494 Returns TRUE if image data is present.
496 \membersection{wxImage::RemoveHandler
}
498 \func{static bool
}{RemoveHandler
}{\param{const wxString\&
}{name
}}
500 Finds the handler with the given name, and removes it. The handler
503 \docparam{name
}{The handler name.
}
505 \wxheading{Return value
}
507 TRUE if the handler was found and removed, FALSE otherwise.
511 \helpref{wxImageHandler
}{wximagehandler
}
513 \membersection{wxImage::SaveFile
}\label{wximagesavefile
}
515 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{int
}{ type
}}
517 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{const wxString\&
}{ mimetype
}}
519 Saves a image in the named file.
521 \func{bool
}{SaveFile
}{\param{wxOutputStream\&
}{stream
},
\param{int
}{ type
}}
523 \func{bool
}{SaveFile
}{\param{wxOutputStream\&
}{stream
},
\param{const wxString\&
}{ mimetype
}}
525 Saves a image in the given stream.
527 \wxheading{Parameters
}
529 \docparam{name
}{Name of the file to save the image to.
}
531 \docparam{stream
}{Opened output stream to save the image to.
}
533 \docparam{type
}{Currently three types can be used:
537 \twocolitem{{\bf wxBITMAP
\_TYPE\_JPEG}}{Save a JPEG image file.
}
538 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNG}}{Save a PNG image file.
}
539 \twocolitem{{\bf wxBITMAP
\_TYPE\_PCX}}{Save a PCX image file (tries to save as
8-bit if possible, falls back to
24-bit otherwise).
}
540 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNM}}{Save a PNM image file (as raw RGB always).
}
543 \docparam{mimetype
}{MIME type.
}
545 \wxheading{Return value
}
547 TRUE if the operation succeeded, FALSE otherwise.
551 Depending on how wxWindows has been configured, not all formats may be available.
555 \helpref{wxImage::LoadFile
}{wximageloadfile
}
557 \pythonnote{In place of a single overloaded method name, wxPython
558 implements the following methods:
\par
559 \indented{2cm
}{\begin{twocollist
}
560 \twocolitem{{\bf SaveFile(filename, type)
}}{Saves the image using the given
561 type to the named file
}
562 \twocolitem{{\bf SaveMimeFile(filename, mimetype)
}}{Saves the image using the given
563 mimetype to the named file
}
567 \perlnote{Methods supported by wxPerl are:
\par
569 \item{bitmap->SaveFile( name, type )
}
570 \item{bitmap->SaveFile( name, mimetype )
}
574 \membersection{wxImage::Mirror
}\label{wximagemirror
}
576 \constfunc{wxImage
}{Mirror
}{\param{bool
}{ horizontally = TRUE
}}
578 Returns a mirrored copy of the image. The parameter
{\it horizontally
}
579 indicates the orientation.
581 \membersection{wxImage::Replace
}\label{wximagereplace
}
583 \func{void
}{Replace
}{\param{unsigned char
}{ r1
},
\param{unsigned char
}{ g1
},
\param{unsigned char
}{ b1
},
584 \param{unsigned char
}{ r2
},
\param{unsigned char
}{ g2
},
\param{unsigned char
}{ b2
}}
586 Replaces the colour specified by
{\it r1,g1,b1
} by the colour
{\it r2,g2,b2
}.
588 \membersection{wxImage::Rescale
}\label{wximagerescale
}
590 \func{wxImage \&
}{Rescale
}{\param{int
}{ width
},
\param{int
}{ height
}}
592 Changes the size of the image in-place: after a call to this function, the
593 image will have the given width and height.
595 Returns the (modified) image itself.
599 \helpref{Scale
}{wximagescale
}
601 \membersection{wxImage::Rotate
}\label{wximagerotate
}
603 \func{wxImage
}{Rotate
}{\param{double
}{ angle
},
\param{const wxPoint\&
}{rotationCentre
},
604 \param{bool
}{ interpolating = TRUE
},
\param{wxPoint*
}{ offsetAfterRotation = NULL
}}
606 Rotates the image about the given point, by
{\it angle
} radians. Passing TRUE
607 to
{\it interpolating
} results in better image quality, but is slower. If the
608 image has a mask, then the mask colour is used for the uncovered pixels in the
609 rotated image background. Else, black (rgb
0,
0,
0) will be used.
611 Returns the rotated image, leaving this image intact.
613 \membersection{wxImage::Rotate90
}\label{wximagerotate90
}
615 \constfunc{wxImage
}{Rotate90
}{\param{bool
}{ clockwise = TRUE
}}
617 Returns a copy of the image rotated
90 degrees in the direction
618 indicated by
{\it clockwise
}.
620 \membersection{wxImage::Scale
}\label{wximagescale
}
622 \constfunc{wxImage
}{Scale
}{\param{int
}{ width
},
\param{int
}{ height
}}
624 Returns a scaled version of the image. This is also useful for
625 scaling bitmaps in general as the only other way to scale bitmaps
626 is to blit a wxMemoryDC into another wxMemoryDC.
628 It may be mentioned that the GTK port uses this function internally
629 to scale bitmaps when using mapping modes in wxDC.
634 // get the bitmap from somewhere
637 // rescale it to have size of
32*
32
638 if ( bmp.GetWidth() !=
32 || bmp.GetHeight() !=
32 )
641 bmp = wxBitmap(image.Scale(
32,
32));
643 // another possibility:
644 image.Rescale(
32,
32);
652 \helpref{Rescale
}{wximagerescale
}
654 \membersection{wxImage::SetData
}\label{wximagesetdata
}
656 \func{void
}{SetData
}{\param{unsigned char*
}{data
}}
658 Sets the image data without performing checks. The data given must have
659 the size (width*height*
3) or results will be unexpected. Don't use this
660 method if you aren't sure you know what you are doing.
662 \membersection{wxImage::SetMask
}\label{wximagesetmask
}
664 \func{void
}{SetMask
}{\param{bool
}{ hasMask = TRUE
}}
666 Specifies whether there is a mask or not. The area of the mask is determined by the current mask colour.
668 \membersection{wxImage::SetMaskColour
}\label{wximagesetmaskcolour
}
670 \func{void
}{SetMaskColour
}{\param{unsigned char
}{red
},
\param{unsigned char
}{blue
},
\param{unsigned char
}{green
}}
672 Sets the mask colour for this image (and tells the image to use the mask).
674 \membersection{wxImage::SetOption
}\label{wximagesetoption
}
676 \func{void
}{SetOption
}{\param{const wxString\&
}{ name
},
\param{const wxString\&
}{ value
}}
678 \func{void
}{SetOption
}{\param{const wxString\&
}{ name
},
\param{int
}{ value
}}
680 Sets a user-defined option. The function is case-insensitive to
{\it name
}.
682 For example, when saving as a JPEG file, the option
{\bf quality
} is
683 used, which is a number between
0 and
100 (
0 is terrible,
100 is very good).
687 \helpref{wxImage::GetOption
}{wximagegetoption
},
\rtfsp
688 \helpref{wxImage::GetOptionInt
}{wximagegetoptionint
},
\rtfsp
689 \helpref{wxImage::HasOption
}{wximagehasoption
}
691 \membersection{wxImage::SetPalette
}\label{wximagesetpalette
}
693 \func{void
}{SetPalette
}{\param{const wxPalette\&
}{ palette
}}
695 Associates a palette with the image. The palette may be used when converting
696 wxImage to wxBitmap (MSW only at present) or in file save operations (none as yet).
698 \membersection{wxImage::SetRGB
}\label{wximagesetrgb
}
700 \func{void
}{SetRGB
}{\param{int
}{x
},
\param{int
}{y
},
\param{unsigned char
}{red
},
\param{unsigned char
}{green
},
\param{unsigned char
}{blue
}}
702 Sets the pixel at the given coordinate. This routine performs bounds-checks
703 for the coordinate so it can be considered a safe way to manipulate the
704 data, but in some cases this might be too slow so that the data will have to
705 be set directly. In that case you will have to get access to the image data
706 using the
\helpref{GetData
}{wximagegetdata
} method.
708 \membersection{wxImage::operator $=$
}
710 \func{wxImage\&
}{operator $=$
}{\param{const wxImage\&
}{image
}}
712 Assignment operator. This operator does not copy any data, but instead
713 passes a pointer to the data in
{\it image
} and increments a reference
714 counter. It is a fast operation.
716 \wxheading{Parameters
}
718 \docparam{image
}{Image to assign.
}
720 \wxheading{Return value
}
722 Returns 'this' object.
724 \membersection{wxImage::operator $==$
}
726 \func{bool
}{operator $==$
}{\param{const wxImage\&
}{image
}}
728 Equality operator. This operator tests whether the internal data pointers are
731 \wxheading{Parameters
}
733 \docparam{image
}{Image to compare with 'this'
}
735 \wxheading{Return value
}
737 Returns TRUE if the images were effectively equal, FALSE otherwise.
739 \membersection{wxImage::operator $!=$
}
741 \func{bool
}{operator $!=$
}{\param{const wxImage\&
}{image
}}
743 Inequality operator. This operator tests whether the internal data pointers are
744 unequal (a fast test).
746 \wxheading{Parameters
}
748 \docparam{image
}{Image to compare with 'this'
}
750 \wxheading{Return value
}
752 Returns TRUE if the images were unequal, FALSE otherwise.
754 \section{\class{wxImageHandler
}}\label{wximagehandler
}
756 This is the base class for implementing image file loading/saving, and image creation from data.
757 It is used within wxImage and is not normally seen by the application.
759 If you wish to extend the capabilities of wxImage, derive a class from wxImageHandler
760 and add the handler using
\helpref{wxImage::AddHandler
}{wximageaddhandler
} in your
761 application initialisation.
763 \wxheading{Note (Legal Issue)
}
765 This software is based in part on the work of the Independent JPEG Group.
767 (Applies when wxWindows is linked with JPEG support. wxJPEGHandler uses libjpeg
770 \wxheading{Derived from
}
772 \helpref{wxObject
}{wxobject
}
774 \wxheading{Include files
}
780 \helpref{wxImage
}{wximage
},
781 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}
783 \latexignore{\rtfignore{\wxheading{Members
}}}
785 \membersection{wxImageHandler::wxImageHandler
}\label{wximagehandlerconstr
}
787 \func{}{wxImageHandler
}{\void}
789 Default constructor. In your own default constructor, initialise the members
790 m
\_name, m
\_extension and m
\_type.
792 \membersection{wxImageHandler::
\destruct{wxImageHandler
}}
794 \func{}{\destruct{wxImageHandler
}}{\void}
796 Destroys the wxImageHandler object.
798 \membersection{wxImageHandler::GetName
}
800 \constfunc{wxString
}{GetName
}{\void}
802 Gets the name of this handler.
804 \membersection{wxImageHandler::GetExtension
}
806 \constfunc{wxString
}{GetExtension
}{\void}
808 Gets the file extension associated with this handler.
810 \membersection{wxImageHandler::GetImageCount
}\label{wximagehandlergetimagecount
}
812 \func{int
}{GetImageCount
}{\param{wxInputStream\&
}{ stream
}}
814 If the image file contains more than one image and the image handler is capable
815 of retrieving these individually, this function will return the number of
818 \docparam{stream
}{Opened input stream for reading image data. Currently, the stream must support seeking.
}
820 \wxheading{Return value
}
822 Number of available images. For most image handles, this defaults to
1.
824 \membersection{wxImageHandler::GetType
}
826 \constfunc{long
}{GetType
}{\void}
828 Gets the image type associated with this handler.
830 \membersection{wxImageHandler::GetMimeType
}
832 \constfunc{wxString
}{GetMimeType
}{\void}
834 Gets the MIME type associated with this handler.
836 \membersection{wxImageHandler::LoadFile
}\label{wximagehandlerloadfile
}
838 \func{bool
}{LoadFile
}{\param{wxImage*
}{image
},
\param{wxInputStream\&
}{ stream
},
\param{bool
}{ verbose=TRUE
},
\param{int
}{ index=
0}}
840 Loads a image from a stream, putting the resulting data into
{\it image
}. If the image file contains
841 more than one image and the image handler is capable of retrieving these individually,
{\it index
}
842 indicates which image to read from the stream.
844 \wxheading{Parameters
}
846 \docparam{image
}{The image object which is to be affected by this operation.
}
848 \docparam{stream
}{Opened input stream for reading image data.
}
850 \docparam{verbose
}{If set to TRUE, errors reported by the image handler will produce wxLogMessages.
}
852 \docparam{index
}{The index of the image in the file (starting from zero).
}
854 \wxheading{Return value
}
856 TRUE if the operation succeeded, FALSE otherwise.
860 \helpref{wxImage::LoadFile
}{wximageloadfile
},
861 \helpref{wxImage::SaveFile
}{wximagesavefile
},
862 \helpref{wxImageHandler::SaveFile
}{wximagehandlersavefile
}
864 \membersection{wxImageHandler::SaveFile
}\label{wximagehandlersavefile
}
866 \func{bool
}{SaveFile
}{\param{wxImage*
}{image
},
\param{wxOutputStream\&
}{stream
}}
868 Saves a image in the output stream.
870 \wxheading{Parameters
}
872 \docparam{image
}{The image object which is to be affected by this operation.
}
874 \docparam{stream
}{Opened output stream for writing the data.
}
876 \wxheading{Return value
}
878 TRUE if the operation succeeded, FALSE otherwise.
882 \helpref{wxImage::LoadFile
}{wximageloadfile
},
883 \helpref{wxImage::SaveFile
}{wximagesavefile
},
884 \helpref{wxImageHandler::LoadFile
}{wximagehandlerloadfile
}
886 \membersection{wxImageHandler::SetName
}
888 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
890 Sets the handler name.
892 \wxheading{Parameters
}
894 \docparam{name
}{Handler name.
}
896 \membersection{wxImageHandler::SetExtension
}
898 \func{void
}{SetExtension
}{\param{const wxString\&
}{extension
}}
900 Sets the handler extension.
902 \wxheading{Parameters
}
904 \docparam{extension
}{Handler extension.
}
906 \membersection{wxImageHandler::SetMimeType
}\label{wximagehandlersetmimetype
}
908 \func{void
}{SetMimeType
}{\param{const wxString\&
}{mimetype
}}
910 Sets the handler MIME type.
912 \wxheading{Parameters
}
914 \docparam{mimename
}{Handler MIME type.
}
916 \membersection{wxImageHandler::SetType
}
918 \func{void
}{SetType
}{\param{long
}{type
}}
920 Sets the handler type.
922 \wxheading{Parameters
}
924 \docparam{name
}{Handler type.
}