1 \section{\class{wxImage
}}\label{wximage
}
3 This class encapsulates a platform-independent image. An image can be created
4 from data, or using the constructor taking a wxBitmap object. 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{ConvertToBitmap
}{wximageconverttobitmap
} function. This bitmap can then
12 be drawn in a device context, using
\helpref{wxDC::DrawBitmap
}{wxdcdrawbitmap
}.
14 One colour value of the image may be used as a mask colour which will lead to the automatic
15 creation of a
\helpref{wxMask
}{wxmask
} object associated to the bitmap object.
17 \wxheading{Available image handlers
}
19 The following image handlers are available.
{\bf wxBMPHandler
} is always
20 installed by default. To use other image formats, install the appropiate
21 handler with
\helpref{wxImage::AddHandler
}{wximageaddhandler
} or
22 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}.
26 \twocolitem{{\bf \indexit{wxBMPHandler
}}}{Only for loading, always installed.
}
27 \twocolitem{{\bf \indexit{wxPNGHandler
}}}{For loading and saving.
}
28 \twocolitem{{\bf \indexit{wxJPEGHandler
}}}{For loading and saving.
}
29 \twocolitem{{\bf \indexit{wxGIFHandler
}}}{Only for loading, due to legal issues.
}
30 \twocolitem{{\bf \indexit{wxPCXHandler
}}}{For loading and saving (see below).
}
31 \twocolitem{{\bf \indexit{wxPNMHandler
}}}{For loading and saving (see below).
}
32 \twocolitem{{\bf \indexit{wxTIFFHandler
}}}{For loading.
}
35 When saving in PCX format,
{\bf wxPCXHandler
} will count the number of
36 different colours in the image; if there are
256 or less colours, it will
37 save as
8 bit, else it will save as
24 bit.
39 Loading PNMs only works for ASCII or raw RGB images. When saving in
40 PNM format,
{\bf wxPNMHandler
} will always save as raw RGB.
42 \wxheading{Derived from
}
44 \helpref{wxObject
}{wxobject
}
46 \wxheading{Include files
}
52 \helpref{wxBitmap
}{wxbitmap
},
53 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}
55 \latexignore{\rtfignore{\wxheading{Members
}}}
57 \membersection{wxImage::wxImage
}\label{wximageconstr
}
59 \func{}{wxImage
}{\void}
63 \func{}{wxImage
}{\param{const wxImage\&
}{image
}}
67 \func{}{wxImage
}{\param{const wxBitmap\&
}{ bitmap
}}
69 Constructs an image from a platform-dependent bitmap. This preserves
70 mask information so that bitmaps and images can be converted back
71 and forth without loss in that respect.
73 \func{}{wxImage
}{\param{int
}{ width
},
\param{int
}{ height
}}
75 Creates an image with the given width and height.
77 \func{}{wxImage
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{unsigned char*
}{ data
},
\param{bool
}{ static_data=FALSE
}}
79 Creates an image from given data with the given width and height. If
80 {\it static_data
} is TRUE, then wxImage will not delete the actual
81 image data in its destructor, otherwise it will free it by calling
84 \func{}{wxImage
}{\param{const wxString\&
}{name
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY}}
86 \func{}{wxImage
}{\param{const wxString\&
}{name
},
\param{const wxString\&
}{ mimetype
}}
88 Loads an image from a file.
90 \func{}{wxImage
}{\param{wxInputStream\&
}{stream
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY}}
92 \func{}{wxImage
}{\param{wxInputStream\&
}{stream
},
\param{const wxString\&
}{ mimetype
}}
94 Loads an image from an input stream.
96 \wxheading{Parameters
}
98 \docparam{width
}{Specifies the width of the image.
}
100 \docparam{height
}{Specifies the height of the image.
}
102 \docparam{name
}{Name of the file from which to load the image.
}
104 \docparam{stream
}{Opened input stream from which to load the image. Currently, the stream must support seeking.
}
106 \docparam{type
}{May be one of the following:
110 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_BMP}}}{Load a Windows bitmap file.
}
111 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_GIF}}}{Load a GIF bitmap file.
}
112 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_JPEG}}}{Load a JPEG bitmap file.
}
113 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_PNG}}}{Load a PNG bitmap file.
}
114 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_PCX}}}{Load a PCX bitmap file.
}
115 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_PNM}}}{Load a PNM bitmap file.
}
116 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_TIF}}}{Load a TIFF bitmap file.
}
117 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_ANY}}}{Will try to autodetect the format.
}
120 \docparam{mimetype
}{MIME type string (for example 'image/jpeg')
}
124 Depending on how wxWindows has been configured, not all formats may be available.
126 Note: any handler other than BMP must be previously
127 initialized with
\helpref{wxImage::AddHandler
}{wximageaddhandler
} or
128 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}.
132 \helpref{wxImage::LoadFile
}{wximageloadfile
}
134 \pythonnote{Constructors supported by wxPython are:
\par
135 \indented{2cm
}{\begin{twocollist
}
136 \twocolitem{{\bf wxImage(name, flag)
}}{Loads an image from a file
}
137 \twocolitem{{\bf wxNullImage()
}}{Create a null image (has no size or
139 \twocolitem{{\bf wxEmptyImage(width, height)
}}{Creates an empty image
141 \twocolitem{{\bf wxImageFromMime(name, mimetype
}}{Creates an image from
142 the given file of the given mimetype
}
143 \twocolitem{{\bf wxImageFromBitmap(bitmap)
}}{Creates an image from a
144 platform-dependent bitmap
}
148 \membersection{wxImage::
\destruct{wxImage
}}
150 \func{}{\destruct{wxImage
}}{\void}
154 \membersection{wxImage::AddHandler
}\label{wximageaddhandler
}
156 \func{static void
}{AddHandler
}{\param{wxImageHandler*
}{ handler
}}
158 Adds a handler to the end of the static list of format handlers.
160 \docparam{handler
}{A new image format handler object. There is usually only one instance
161 of a given handler class in an application session.
}
165 \helpref{wxImageHandler
}{wximagehandler
}
167 \pythonnote{In wxPython this static method is named
{\tt wxImage_AddHandler
}.
}
168 \membersection{wxImage::CleanUpHandlers
}
170 \func{static void
}{CleanUpHandlers
}{\void}
172 Deletes all image handlers.
174 This function is called by wxWindows on exit.
176 \membersection{wxImage::ConvertToBitmap
}\label{wximageconverttobitmap
}
178 \constfunc{wxBitmap
}{ConvertToBitmap
}{\void}
180 Converts the image to a platform-specific bitmap object. This has to be done
181 to actually display an image as you cannot draw an image directly on a window.
182 The resulting bitmap will use the colour depth of the current system which entails
183 that a colour reduction has to take place.
185 When in
8-bit mode (PseudoColour mode), the GTK port will use a
color cube created
186 on program start-up to look up colors. This ensures a very fast conversion, but
187 the image quality won't be perfect (and could be better for photo images using more
188 sophisticated dithering algorithms).
190 On Windows, if there is a palette present (set with SetPalette), it will be used when
191 creating the wxBitmap (most useful in
8-bit display mode). On other platforms,
192 the palette is currently ignored.
194 \membersection{wxImage::Copy
}\label{wximagecopy
}
196 \constfunc{wxImage
}{Copy
}{\void}
198 Returns an identical copy of the image.
200 \membersection{wxImage::Create
}\label{wximagecreate
}
202 \func{bool
}{Create
}{\param{int
}{ width
},
\param{int
}{ height
}}
204 Creates a fresh image.
206 \wxheading{Parameters
}
208 \docparam{width
}{The width of the image in pixels.
}
210 \docparam{height
}{The height of the image in pixels.
}
212 \wxheading{Return value
}
214 TRUE if the call succeeded, FALSE otherwise.
216 \membersection{wxImage::Destroy
}\label{wximagedestroy
}
218 \func{bool
}{Destroy
}{\void}
220 Destroys the image data.
222 \membersection{wxImage::FindHandler
}
224 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{name
}}
226 Finds the handler with the given name.
228 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{extension
},
\param{long
}{ imageType
}}
230 Finds the handler associated with the given extension and type.
232 \func{static wxImageHandler*
}{FindHandler
}{\param{long
}{imageType
}}
234 Finds the handler associated with the given image type.
236 \func{static wxImageHandler*
}{FindHandlerMime
}{\param{const wxString\&
}{mimetype
}}
238 Finds the handler associated with the given MIME type.
240 \docparam{name
}{The handler name.
}
242 \docparam{extension
}{The file extension, such as ``bmp".
}
244 \docparam{imageType
}{The image type, such as wxBITMAP
\_TYPE\_BMP.
}
246 \docparam{mimetype
}{MIME type.
}
248 \wxheading{Return value
}
250 A pointer to the handler if found, NULL otherwise.
254 \helpref{wxImageHandler
}{wximagehandler
}
256 \membersection{wxImage::GetBlue
}\label{wximagegetblue
}
258 \constfunc{unsigned char
}{GetBlue
}{\param{int
}{ x
},
\param{int
}{ y
}}
260 Returns the blue intensity at the given coordinate.
262 \membersection{wxImage::GetData
}\label{wximagegetdata
}
264 \constfunc{unsigned char*
}{GetData
}{\void}
266 Returns the image data as an array. This is most often used when doing
267 direct image manipulation. The return value points to an array of
268 chararcters in RGBGBRGB... format.
270 \membersection{wxImage::GetGreen
}\label{wximagegetgreen
}
272 \constfunc{unsigned char
}{GetGreen
}{\param{int
}{ x
},
\param{int
}{ y
}}
274 Returns the green intensity at the given coordinate.
276 \membersection{wxImage::GetRed
}\label{wximagegetred
}
278 \constfunc{unsigned char
}{GetRed
}{\param{int
}{ x
},
\param{int
}{ y
}}
280 Returns the red intensity at the given coordinate.
282 \membersection{wxImage::GetHandlers
}
284 \func{static wxList\&
}{GetHandlers
}{\void}
286 Returns the static list of image format handlers.
290 \helpref{wxImageHandler
}{wximagehandler
}
292 \membersection{wxImage::GetHeight
}\label{wximagegetheight
}
294 \constfunc{int
}{GetHeight
}{\void}
296 Gets the height of the image in pixels.
298 \membersection{wxImage::GetMaskBlue
}\label{wximagegetmaskblue
}
300 \constfunc{unsigned char
}{GetMaskBlue
}{\void}
302 Gets the blue value of the mask colour.
304 \membersection{wxImage::GetMaskGreen
}\label{wximagegetmaskgreen
}
306 \constfunc{unsigned char
}{GetMaskGreen
}{\void}
308 Gets the green value of the mask colour.
310 \membersection{wxImage::GetMaskRed
}\label{wximagegetmaskred
}
312 \constfunc{unsigned char
}{GetMaskRed
}{\void}
314 Gets the red value of the mask colour.
316 \membersection{wxImage::GetPalette
}\label{wximagegetpalette
}
318 \constfunc{const wxPalette\&
}{GetPalette
}{\void}
320 Returns the palette associated with the image. Currently the palette is only
321 used in ConvertToBitmap under Windows.
323 Eventually wxImage handlers will set the palette if one exists in the image file.
325 \membersection{wxImage::GetSubImage
}\label{wximagegetsubimage
}
327 \constfunc{wxImage
}{GetSubImage
}{\param{const wxRect\&
}{ rect
}}
329 Returns a sub image of the current one as long as the rect belongs entirely to
332 \membersection{wxImage::GetWidth
}\label{wximagegetwidth
}
334 \constfunc{int
}{GetWidth
}{\void}
336 Gets the width of the image in pixels.
340 \helpref{wxImage::GetHeight
}{wximagegetheight
}
342 \membersection{wxImage::HasMask
}\label{wximagehasmask
}
344 \constfunc{bool
}{HasMask
}{\void}
346 Returns TRUE if there is a mask active, FALSE otherwise.
348 \membersection{wxImage::GetOption
}\label{wximagegetoption
}
350 \constfunc{wxString
}{GetOption
}{\param{const wxString\&
}{ name
}}
352 Gets a user-defined option. The function is case-insensitive to
{\it name
}.
354 For example, when saving as a JPEG file, the option
{\bf quality
} is
355 used, which is a number between
0 and
100 (
0 is terrible,
100 is very good).
359 \helpref{wxImage::SetOption
}{wximagesetoption
},
\rtfsp
360 \helpref{wxImage::GetOptionInt
}{wximagegetoptionint
},
\rtfsp
361 \helpref{wxImage::HasOption
}{wximagehasoption
}
363 \membersection{wxImage::GetOptionInt
}\label{wximagegetoptionint
}
365 \constfunc{int
}{GetOptionInt
}{\param{const wxString\&
}{ name
}}
367 Gets a user-defined option as an integer. The function is case-insensitive to
{\it name
}.
371 \helpref{wxImage::SetOption
}{wximagesetoption
},
\rtfsp
372 \helpref{wxImage::GetOption
}{wximagegetoption
},
\rtfsp
373 \helpref{wxImage::HasOption
}{wximagehasoption
}
375 \membersection{wxImage::HasOption
}\label{wximagehasoption
}
377 \constfunc{bool
}{HasOption
}{\param{const wxString\&
}{ name
}}
379 Returns TRUE if the given option is present. The function is case-insensitive to
{\it name
}.
383 \helpref{wxImage::SetOption
}{wximagesetoption
},
\rtfsp
384 \helpref{wxImage::GetOption
}{wximagegetoption
},
\rtfsp
385 \helpref{wxImage::GetOptionInt
}{wximagegetoptionint
}
387 \membersection{wxImage::InitStandardHandlers
}
389 \func{static void
}{InitStandardHandlers
}{\void}
391 Internal use only. Adds standard image format handlers. It only install BMP
392 for the time being, which is used by wxBitmap.
394 This function is called by wxWindows on startup, and shouldn't be called by
399 \helpref{wxImageHandler
}{wximagehandler
},
400 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}
402 \membersection{wxImage::InsertHandler
}
404 \func{static void
}{InsertHandler
}{\param{wxImageHandler*
}{ handler
}}
406 Adds a handler at the start of the static list of format handlers.
408 \docparam{handler
}{A new image format handler object. There is usually only one instance
409 of a given handler class in an application session.
}
413 \helpref{wxImageHandler
}{wximagehandler
}
415 \membersection{wxImage::LoadFile
}\label{wximageloadfile
}
417 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{long
}{ type = wxBITMAP
\_TYPE\_ANY}}
419 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{const wxString\&
}{ mimetype
}}
421 Loads an image from a file. If no handler type is provided, the library will
422 try to autodetect the format.
424 \func{bool
}{LoadFile
}{\param{wxInputStream\&
}{ stream
},
\param{long
}{ type
}}
426 \func{bool
}{LoadFile
}{\param{wxInputStream\&
}{ stream
},
\param{const wxString\&
}{ mimetype
}}
428 Loads an image from an input stream.
430 \wxheading{Parameters
}
432 \docparam{name
}{Name of the file from which to load the image.
}
434 \docparam{stream
}{Opened input stream from which to load the image. Currently, the stream must support seeking.
}
436 \docparam{type
}{One of the following values:
440 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Load a Windows image file.
}
441 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Load a GIF image file.
}
442 \twocolitem{{\bf wxBITMAP
\_TYPE\_JPEG}}{Load a JPEG image file.
}
443 \twocolitem{{\bf wxBITMAP
\_TYPE\_PCX}}{Load a PCX image file.
}
444 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNG}}{Load a PNG image file.
}
445 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNM}}{Load a PNM image file.
}
446 \twocolitem{{\bf wxBITMAP
\_TYPE\_TIF}}{Load a TIFF image file.
}
447 \twocolitem{{\bf wxBITMAP
\_TYPE\_ANY}}{Will try to autodetect the format.
}
450 \docparam{mimetype
}{MIME type string (for example 'image/jpeg')
}
454 Depending on how wxWindows has been configured, not all formats may be available.
456 \wxheading{Return value
}
458 TRUE if the operation succeeded, FALSE otherwise.
462 \helpref{wxImage::SaveFile
}{wximagesavefile
}
464 \pythonnote{In place of a single overloaded method name, wxPython
465 implements the following methods:
\par
466 \indented{2cm
}{\begin{twocollist
}
467 \twocolitem{{\bf LoadFile(filename, type)
}}{Loads an image of the given
469 \twocolitem{{\bf LoadMimeFile(filename, mimetype)
}}{Loads an image of the given
470 mimetype from a file
}
475 \membersection{wxImage::Ok
}\label{wximageok
}
477 \constfunc{bool
}{Ok
}{\void}
479 Returns TRUE if image data is present.
481 \membersection{wxImage::RemoveHandler
}
483 \func{static bool
}{RemoveHandler
}{\param{const wxString\&
}{name
}}
485 Finds the handler with the given name, and removes it. The handler
488 \docparam{name
}{The handler name.
}
490 \wxheading{Return value
}
492 TRUE if the handler was found and removed, FALSE otherwise.
496 \helpref{wxImageHandler
}{wximagehandler
}
498 \membersection{wxImage::SaveFile
}\label{wximagesavefile
}
500 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{int
}{ type
}}
502 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{const wxString\&
}{ mimetype
}}
504 Saves a image in the named file.
506 \func{bool
}{SaveFile
}{\param{wxOutputStream\&
}{stream
},
\param{int
}{ type
}}
508 \func{bool
}{SaveFile
}{\param{wxOutputStream\&
}{stream
},
\param{const wxString\&
}{ mimetype
}}
510 Saves a image in the given stream.
512 \wxheading{Parameters
}
514 \docparam{name
}{Name of the file to save the image to.
}
516 \docparam{stream
}{Opened output stream to save the image to.
}
518 \docparam{type
}{Currently three types can be used:
522 \twocolitem{{\bf wxBITMAP
\_TYPE\_JPEG}}{Save a JPEG image file.
}
523 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNG}}{Save a PNG image file.
}
524 \twocolitem{{\bf wxBITMAP
\_TYPE\_PCX}}{Save a PCX image file (tries to save as
8-bit if possible, falls back to
24-bit otherwise).
}
525 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNM}}{Save a PNM image file (as raw RGB always).
}
528 \docparam{mimetype
}{MIME type.
}
530 \wxheading{Return value
}
532 TRUE if the operation succeeded, FALSE otherwise.
536 Depending on how wxWindows has been configured, not all formats may be available.
540 \helpref{wxImage::LoadFile
}{wximageloadfile
}
542 \pythonnote{In place of a single overloaded method name, wxPython
543 implements the following methods:
\par
544 \indented{2cm
}{\begin{twocollist
}
545 \twocolitem{{\bf SaveFile(filename, type)
}}{Saves the image using the given
546 type to the named file
}
547 \twocolitem{{\bf SaveMimeFile(filename, mimetype)
}}{Saves the image using the given
548 mimetype to the named file
}
552 \membersection{wxImage::Mirror
}\label{wximagemirror
}
554 \constfunc{wxImage
}{Mirror
}{\param{bool
}{ horizontally = TRUE
}}
556 Returns a mirrored copy of the image. The parameter
{\it horizontally
}
557 indicates the orientation.
559 \membersection{wxImage::Replace
}\label{wximagereplace
}
561 \func{void
}{Replace
}{\param{unsigned char
}{ r1
},
\param{unsigned char
}{ g1
},
\param{unsigned char
}{ b1
},
562 \param{unsigned char
}{ r2
},
\param{unsigned char
}{ g2
},
\param{unsigned char
}{ b2
}}
564 Replaces the colour specified by
{\it r1,g1,b1
} by the colour
{\it r2,g2,b2
}.
566 \membersection{wxImage::Rescale
}\label{wximagerescale
}
568 \func{wxImage \&
}{Rescale
}{\param{int
}{ width
},
\param{int
}{ height
}}
570 Changes the size of the image in-place: after a call to this function, the
571 image will have the given width and height.
573 Returns the (modified) image itself.
577 \helpref{Scale
}{wximagescale
}
579 \membersection{wxImage::Rotate
}\label{wximagerotate
}
581 \func{wxImage
}{Rotate
}{\param{double
}{ angle
},
\param{const wxPoint\&
}{rotationCentre
},
582 \param{bool
}{ interpolating = TRUE
},
\param{wxPoint*
}{ offsetAfterRotation = NULL
}}
584 Rotates the image about the given point, by
{\it angle
} radians. Passing TRUE
585 to
{\it interpolating
} results in better image quality, but is slower. If the
586 image has a mask, then the mask colour is used for the uncovered pixels in the
587 rotated image background. Else, black (rgb
0,
0,
0) will be used.
589 Returns the rotated image, leaving this image intact.
591 \membersection{wxImage::Rotate90
}\label{wximagerotate90
}
593 \constfunc{wxImage
}{Rotate90
}{\param{bool
}{ clockwise = TRUE
}}
595 Returns a copy of the image rotated
90 degrees in the direction
596 indicated by
{\it clockwise
}.
598 \membersection{wxImage::Scale
}\label{wximagescale
}
600 \constfunc{wxImage
}{Scale
}{\param{int
}{ width
},
\param{int
}{ height
}}
602 Returns a scaled version of the image. This is also useful for
603 scaling bitmaps in general as the only other way to scale bitmaps
604 is to blit a wxMemoryDC into another wxMemoryDC.
606 It may be mentioned that the GTK port uses this function internally
607 to scale bitmaps when using mapping modes in wxDC.
612 // get the bitmap from somewhere
615 // rescale it to have size of
32*
32
616 if ( bmp.GetWidth() !=
32 || bmp.GetHeight() !=
32 )
619 bmp = image.Scale(
32,
32).ConvertToBitmap();
621 // another possibility:
622 image.Rescale(
32,
32);
630 \helpref{Rescale
}{wximagerescale
}
632 \membersection{wxImage::SetData
}\label{wximagesetdata
}
634 \func{void
}{SetData
}{\param{unsigned char*
}{data
}}
636 Sets the image data without performing checks. The data given must have
637 the size (width*height*
3) or results will be unexpected. Don't use this
638 method if you aren't sure you know what you are doing.
640 \membersection{wxImage::SetMask
}\label{wximagesetmask
}
642 \func{void
}{SetMask
}{\param{bool
}{ hasMask = TRUE
}}
644 Specifies whether there is a mask or not. The area of the mask is determined by the current mask colour.
646 \membersection{wxImage::SetMaskColour
}\label{wximagesetmaskcolour
}
648 \func{void
}{SetMaskColour
}{\param{unsigned char
}{red
},
\param{unsigned char
}{blue
},
\param{unsigned char
}{green
}}
650 Sets the mask colour for this image (and tells the image to use the mask).
652 \membersection{wxImage::SetOption
}\label{wximagesetoption
}
654 \func{void
}{SetOption
}{\param{const wxString\&
}{ name
},
\param{const wxString\&
}{ value
}}
656 \func{void
}{SetOption
}{\param{const wxString\&
}{ name
},
\param{int
}{ value
}}
658 Sets a user-defined option. The function is case-insensitive to
{\it name
}.
660 For example, when saving as a JPEG file, the option
{\bf quality
} is
661 used, which is a number between
0 and
100 (
0 is terrible,
100 is very good).
665 \helpref{wxImage::GetOption
}{wximagegetoption
},
\rtfsp
666 \helpref{wxImage::GetOptionInt
}{wximagegetoptionint
},
\rtfsp
667 \helpref{wxImage::HasOption
}{wximagehasoption
}
669 \membersection{wxImage::SetPalette
}\label{wximagesetpalette
}
671 \func{void
}{SetPalette
}{\param{const wxPalette\&
}{ palette
}}
673 Associates a palette with the image. The palette may be used in ConvertToBitmap (MSW only at present)
674 or in file save operations (none as yet).
676 \membersection{wxImage::SetRGB
}\label{wximagesetrgb
}
678 \func{void
}{SetRGB
}{\param{int
}{x
},
\param{int
}{y
},
\param{unsigned char
}{red
},
\param{unsigned char
}{green
},
\param{unsigned char
}{blue
}}
680 Sets the pixel at the given coordinate. This routine performs bounds-checks
681 for the coordinate so it can be considered a safe way to manipulate the
682 data, but in some cases this might be too slow so that the data will have to
683 be set directly. In that case you will have to get access to the image data
684 using the
\helpref{GetData
}{wximagegetdata
} method.
686 \membersection{wxImage::operator $=$
}
688 \func{wxImage\&
}{operator $=$
}{\param{const wxImage\&
}{image
}}
690 Assignment operator. This operator does not copy any data, but instead
691 passes a pointer to the data in
{\it image
} and increments a reference
692 counter. It is a fast operation.
694 \wxheading{Parameters
}
696 \docparam{image
}{Image to assign.
}
698 \wxheading{Return value
}
700 Returns 'this' object.
702 \membersection{wxImage::operator $==$
}
704 \func{bool
}{operator $==$
}{\param{const wxImage\&
}{image
}}
706 Equality operator. This operator tests whether the internal data pointers are
709 \wxheading{Parameters
}
711 \docparam{image
}{Image to compare with 'this'
}
713 \wxheading{Return value
}
715 Returns TRUE if the images were effectively equal, FALSE otherwise.
717 \membersection{wxImage::operator $!=$
}
719 \func{bool
}{operator $!=$
}{\param{const wxImage\&
}{image
}}
721 Inequality operator. This operator tests whether the internal data pointers are
722 unequal (a fast test).
724 \wxheading{Parameters
}
726 \docparam{image
}{Image to compare with 'this'
}
728 \wxheading{Return value
}
730 Returns TRUE if the images were unequal, FALSE otherwise.
732 \section{\class{wxImageHandler
}}\label{wximagehandler
}
734 This is the base class for implementing image file loading/saving, and image creation from data.
735 It is used within wxImage and is not normally seen by the application.
737 If you wish to extend the capabilities of wxImage, derive a class from wxImageHandler
738 and add the handler using
\helpref{wxImage::AddHandler
}{wximageaddhandler
} in your
739 application initialisation.
741 \wxheading{Note (Legal Issue)
}
743 This software is based in part on the work of the Independent JPEG Group.
745 (Applies when wxWindows is linked with JPEG support. wxJPEGHandler uses libjpeg
748 \wxheading{Derived from
}
750 \helpref{wxObject
}{wxobject
}
752 \wxheading{Include files
}
758 \helpref{wxImage
}{wximage
},
759 \helpref{wxInitAllImageHandlers
}{wxinitallimagehandlers
}
761 \latexignore{\rtfignore{\wxheading{Members
}}}
763 \membersection{wxImageHandler::wxImageHandler
}\label{wximagehandlerconstr
}
765 \func{}{wxImageHandler
}{\void}
767 Default constructor. In your own default constructor, initialise the members
768 m
\_name, m
\_extension and m
\_type.
770 \membersection{wxImageHandler::
\destruct{wxImageHandler
}}
772 \func{}{\destruct{wxImageHandler
}}{\void}
774 Destroys the wxImageHandler object.
776 \membersection{wxImageHandler::GetName
}
778 \constfunc{wxString
}{GetName
}{\void}
780 Gets the name of this handler.
782 \membersection{wxImageHandler::GetExtension
}
784 \constfunc{wxString
}{GetExtension
}{\void}
786 Gets the file extension associated with this handler.
788 \membersection{wxImageHandler::GetImageCount
}\label{wximagehandlergetimagecount
}
790 \func{int
}{GetImageCount
}{\param{wxInputStream\&
}{ stream
}}
792 If the image file contains more than one image and the image handler is capable
793 of retrieving these individually, this function will return the number of
796 \docparam{stream
}{Opened input stream for reading image data. Currently, the stream must support seeking.
}
798 \wxheading{Return value
}
800 Number of available images. For most image handles, this defaults to
1.
802 \membersection{wxImageHandler::GetType
}
804 \constfunc{long
}{GetType
}{\void}
806 Gets the image type associated with this handler.
808 \membersection{wxImageHandler::GetMimeType
}
810 \constfunc{wxString
}{GetMimeType
}{\void}
812 Gets the MIME type associated with this handler.
814 \membersection{wxImageHandler::LoadFile
}\label{wximagehandlerloadfile
}
816 \func{bool
}{LoadFile
}{\param{wxImage*
}{image
},
\param{wxInputStream\&
}{ stream
},
\param{bool
}{ verbose=TRUE
},
\param{int
}{ index=
0}}
818 Loads a image from a stream, putting the resulting data into
{\it image
}. If the image file contains
819 more than one image and the image handler is capable of retrieving these individually,
{\it index
}
820 indicates which image to read from the stream.
822 \wxheading{Parameters
}
824 \docparam{image
}{The image object which is to be affected by this operation.
}
826 \docparam{stream
}{Opened input stream for reading image data.
}
828 \docparam{verbose
}{If set to TRUE, errors reported by the image handler will produce wxLogMessages.
}
830 \docparam{index
}{The index of the image in the file (starting from zero).
}
832 \wxheading{Return value
}
834 TRUE if the operation succeeded, FALSE otherwise.
838 \helpref{wxImage::LoadFile
}{wximageloadfile
},
839 \helpref{wxImage::SaveFile
}{wximagesavefile
},
840 \helpref{wxImageHandler::SaveFile
}{wximagehandlersavefile
}
842 \membersection{wxImageHandler::SaveFile
}\label{wximagehandlersavefile
}
844 \func{bool
}{SaveFile
}{\param{wxImage*
}{image
},
\param{wxOutputStream\&
}{stream
}}
846 Saves a image in the output stream.
848 \wxheading{Parameters
}
850 \docparam{image
}{The image object which is to be affected by this operation.
}
852 \docparam{stream
}{Opened output stream for writing the data.
}
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::LoadFile
}{wximagehandlerloadfile
}
864 \membersection{wxImageHandler::SetName
}
866 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
868 Sets the handler name.
870 \wxheading{Parameters
}
872 \docparam{name
}{Handler name.
}
874 \membersection{wxImageHandler::SetExtension
}
876 \func{void
}{SetExtension
}{\param{const wxString\&
}{extension
}}
878 Sets the handler extension.
880 \wxheading{Parameters
}
882 \docparam{extension
}{Handler extension.
}
884 \membersection{wxImageHandler::SetMimeType
}\label{wximagehandlersetmimetype
}
886 \func{void
}{SetMimeType
}{\param{const wxString\&
}{mimetype
}}
888 Sets the handler MIME type.
890 \wxheading{Parameters
}
892 \docparam{mimename
}{Handler MIME type.
}
894 \membersection{wxImageHandler::SetType
}
896 \func{void
}{SetType
}{\param{long
}{type
}}
898 Sets the handler type.
900 \wxheading{Parameters
}
902 \docparam{name
}{Handler type.
}