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 wxDC. Instead, a platform-specific
10 wxBitmap object must be created from it, and that bitmap drawn on the wxDC.
12 \wxheading{Derived from
}
14 \helpref{wxObject
}{wxobject
}
18 \helpref{wxBitmap
}{wxbitmap
}
20 \latexignore{\rtfignore{\wxheading{Members
}}}
22 \membersection{wxImage::wxImage
}\label{wximageconstr
}
24 \func{}{wxImage
}{\void}
28 \func{}{wxImage
}{\param{const wxImage\&
}{image
}}
32 \func{}{wxImage
}{\param{const wxBitmap\&
}{ bitmap
}}
34 Constructs an image from a platform-dependent bitmap.
36 \func{}{wxImage
}{\param{int
}{ width
},
\param{int
}{ height
}}
38 Creates an image with the given width and height.
40 \func{}{wxImage
}{\param{const wxString\&
}{name
},
\param{long
}{ type = wxBITMAP
\_TYPE\_PNG}}
42 Loads an image from a file.
44 \wxheading{Parameters
}
46 \docparam{width
}{Specifies the width of the image.
}
48 \docparam{height
}{Specifies the height of the image.
}
50 \docparam{name
}{This refers to an image filename. Its meaning is determined by the
{\it type
} parameter.
}
52 \docparam{type
}{May be one of the following:
56 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_BMP}}}{Load a Windows bitmap file.
}
57 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_GIF}}}{Load a GIF bitmap file.
}
58 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XBM}}}{Load an X bitmap file.
}
59 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XPM}}}{Load an XPM bitmap file.
}
60 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_PNG}}}{Load a PNG bitmap file.
}
63 The validity of these flags depends on the platform and wxWindows configuration.
64 If all possible wxWindows settings are used, the Windows platform supports BMP, BMP
\_RESOURCE,
65 XPM
\_DATA, and XPM. Under X, the available formats are BMP, GIF, XBM, and XPM.
}
69 \helpref{wxImage::LoadFile
}{wximageloadfile
}
71 \membersection{wxImage::
\destruct{wxImage
}}
73 \func{}{\destruct{wxImage
}}{\void}
77 \membersection{wxImage::AddHandler
}\label{wximageaddhandler
}
79 \func{static void
}{AddHandler
}{\param{wxImageHandler*
}{ handler
}}
81 Adds a handler to the end of the static list of format handlers.
83 \docparam{handler
}{A new image format handler object. There is usually only one instance
84 of a given handler class in an application session.
}
88 \helpref{wxImageHandler
}{wximagehandler
}
90 \membersection{wxImage::CleanUpHandlers
}
92 \func{static void
}{CleanUpHandlers
}{\void}
94 Deletes all image handlers.
96 This function is called by wxWindows on exit.
98 \membersection{wxImage::ConvertToBitmap
}\label{wximageconverttobitmap
}
100 \constfunc{wxBitmap
}{ConvertToBitmap
}{\void}
102 Converts the image to a platform-specific bitmap object.
104 \membersection{wxImage::Create
}\label{wximagecreate
}
106 \func{bool
}{Create
}{\param{int
}{ width
},
\param{int
}{ height
}}
108 Creates a fresh image.
110 \wxheading{Parameters
}
112 \docparam{width
}{The width of the image in pixels.
}
114 \docparam{height
}{The height of the image in pixels.
}
116 \wxheading{Return value
}
118 TRUE if the call succeeded, FALSE otherwise.
120 \membersection{wxImage::Destroy
}\label{wximagedestroy
}
122 \func{bool
}{Destroy
}{\void}
124 Destroys the image data.
126 \membersection{wxImage::FindHandler
}
128 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{name
}}
130 Finds the handler with the given name.
132 \func{static wxImageHandler*
}{FindHandler
}{\param{const wxString\&
}{extension
},
\param{long
}{ imageType
}}
134 Finds the handler associated with the given extension and type.
136 \func{static wxImageHandler*
}{FindHandler
}{\param{long
}{imageType
}}
138 Finds the handler associated with the given image type.
140 \docparam{name
}{The handler name.
}
142 \docparam{extension
}{The file extension, such as ``bmp".
}
144 \docparam{imageType
}{The image type, such as wxBITMAP
\_TYPE\_BMP.
}
146 \wxheading{Return value
}
148 A pointer to the handler if found, NULL otherwise.
152 \helpref{wxImageHandler
}{wximagehandler
}
154 \membersection{wxImage::GetBlue
}\label{wximagegetblue
}
156 \constfunc{unsigned char
}{GetBlue
}{\param{int
}{ x
},
\param{int
}{ y
}}
158 Returns the blue intensity at the given coordinate.
160 \membersection{wxImage::GetData
}\label{wximagegetdata
}
162 \constfunc{unsigned char*
}{GetData
}{\void}
164 Returns the image data as an array.
166 \membersection{wxImage::GetGreen
}\label{wximagegetgreen
}
168 \constfunc{unsigned char
}{GetGreen
}{\param{int
}{ x
},
\param{int
}{ y
}}
170 Returns the green intensity at the given coordinate.
172 \membersection{wxImage::GetRed
}\label{wximagegetred
}
174 \constfunc{unsigned char
}{GetRed
}{\param{int
}{ x
},
\param{int
}{ y
}}
176 Returns the red intensity at the given coordinate.
178 \membersection{wxImage::GetHandlers
}
180 \func{static wxList\&
}{GetHandlers
}{\void}
182 Returns the static list of image format handlers.
186 \helpref{wxImageHandler
}{wximagehandler
}
188 \membersection{wxImage::GetHeight
}\label{wximagegetheight
}
190 \constfunc{int
}{GetHeight
}{\void}
192 Gets the height of the image in pixels.
194 \membersection{wxImage::GetMaskBlue
}\label{wximagegetmaskblue
}
196 \constfunc{unsigned char
}{GetMaskBlue
}{\void}
198 Gets the blue value of the mask colour.
200 \membersection{wxImage::GetMaskGreen
}\label{wximagegetmaskgreen
}
202 \constfunc{unsigned char
}{GetMaskGreen
}{\void}
204 Gets the green value of the mask colour.
206 \membersection{wxImage::GetMaskRed
}\label{wximagegetmaskred
}
208 \constfunc{unsigned char
}{GetMaskRed
}{\void}
210 Gets the red value of the mask colour.
212 \membersection{wxImage::GetWidth
}\label{wximagegetwidth
}
214 \constfunc{int
}{GetWidth
}{\void}
216 Gets the width of the image in pixels.
220 \helpref{wxImage::GetHeight
}{wximagegetheight
}
222 \membersection{wxImage::HasMask
}\label{wximagehasmask
}
224 \constfunc{bool
}{HasMask
}{\void}
226 Returns TRUE if there is a mask active, FALSE otherwise.
228 \membersection{wxImage::InitStandardHandlers
}
230 \func{static void
}{InitStandardHandlers
}{\void}
232 Adds the standard image format handlers, which, depending on wxWindows
233 configuration, can be handlers for Windows image, Windows image resource, and XPM.
235 This function is called by wxWindows on startup.
239 \helpref{wxImageHandler
}{wximagehandler
}
241 \membersection{wxImage::InsertHandler
}
243 \func{static void
}{InsertHandler
}{\param{wxImageHandler*
}{ handler
}}
245 Adds a handler at the start of the static list of format handlers.
247 \docparam{handler
}{A new image format handler object. There is usually only one instance
248 of a given handler class in an application session.
}
252 \helpref{wxImageHandler
}{wximagehandler
}
254 \membersection{wxImage::LoadFile
}\label{wximageloadfile
}
256 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{long
}{ type
}}
258 Loads an image from a file.
260 \wxheading{Parameters
}
262 \docparam{name
}{A filename.
263 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
265 \docparam{type
}{One of the following values:
269 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Load a Windows image file.
}
270 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Load a GIF image file.
}
271 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Load an X image file.
}
272 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Load an XPM image file.
}
273 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNG}}{Load a PNG image file.
}
276 The validity of these flags depends on the platform and wxWindows configuration.
}
278 \wxheading{Return value
}
280 TRUE if the operation succeeded, FALSE otherwise.
284 \helpref{wxImage::SaveFile
}{wximagesavefile
}
286 \membersection{wxImage::Ok
}\label{wximageok
}
288 \constfunc{bool
}{Ok
}{\void}
290 Returns TRUE if image data is present.
292 \membersection{wxImage::RemoveHandler
}
294 \func{static bool
}{RemoveHandler
}{\param{const wxString\&
}{name
}}
296 Finds the handler with the given name, and removes it. The handler
299 \docparam{name
}{The handler name.
}
301 \wxheading{Return value
}
303 TRUE if the handler was found and removed, FALSE otherwise.
307 \helpref{wxImageHandler
}{wximagehandler
}
309 \membersection{wxImage::SaveFile
}\label{wximagesavefile
}
311 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{int
}{ type
}}
313 Saves a image in the named file.
315 \wxheading{Parameters
}
317 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
319 \docparam{type
}{One of the following values:
323 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Save a Windows image file.
}
324 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Save a GIF image file.
}
325 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Save an X image file.
}
326 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Save an XPM image file.
}
327 \twocolitem{{\bf wxBITMAP
\_TYPE\_PNG}}{Save a PNG image file.
}
330 The validity of these flags depends on the platform and wxWindows configuration.
}
332 \wxheading{Return value
}
334 TRUE if the operation succeeded, FALSE otherwise.
338 Depending on how wxWindows has been configured, not all formats may be available.
342 \helpref{wxImage::LoadFile
}{wximageloadfile
}
344 \membersection{wxImage::Scale
}\label{wximagescale
}
346 \func{wxImage
}{Scale
}{\param{int
}{ width
},
\param{int
}{ height
}}
348 Returns a scaled version of the image.
350 \membersection{wxImage::SetData
}\label{wximagesetdata
}
352 \func{void
}{SetData
}{\param{unsigned char*
}{data
}}
356 \membersection{wxImage::SetMask
}\label{wximagesetmask
}
358 \func{void
}{SetMask
}{\param{bool
}{ hasMask = TRUE
}}
360 Specifies whether there is a mask or not. The area of the mask is determined by the current mask colour.
362 \membersection{wxImage::SetMaskColour
}\label{wximagesetmaskcolour
}
364 \func{void
}{SetMaskColour
}{\param{unsigned char
}{red
},
\param{unsigned char
}{blue
},
\param{unsigned char
}{green
}}
366 Sets the mask colour for this image.
368 \membersection{wxImage::SetRGB
}\label{wximagesetrgb
}
370 \func{void
}{SetRGB
}{\param{int
}{x
},
\param{int
}{y
},
\param{unsigned char
}{red
},
\param{unsigned char
}{blue
},
\param{unsigned char
}{green
}}
372 Sets the pixel at the given coordinate.
374 \membersection{wxImage::operator $=$
}
376 \func{wxImage\&
}{operator $=$
}{\param{const wxImage\&
}{image
}}
378 Assignment operator. This operator does not copy any data, but instead
379 passes a pointer to the data in
{\it image
} and increments a reference
380 counter. It is a fast operation.
382 \wxheading{Parameters
}
384 \docparam{image
}{Image to assign.
}
386 \wxheading{Return value
}
388 Returns 'this' object.
390 \membersection{wxImage::operator $==$
}
392 \func{bool
}{operator $==$
}{\param{const wxImage\&
}{image
}}
394 Equality operator. This operator tests whether the internal data pointers are
397 \wxheading{Parameters
}
399 \docparam{image
}{Image to compare with 'this'
}
401 \wxheading{Return value
}
403 Returns TRUE if the images were effectively equal, FALSE otherwise.
405 \membersection{wxImage::operator $!=$
}
407 \func{bool
}{operator $!=$
}{\param{const wxImage\&
}{image
}}
409 Inequality operator. This operator tests whether the internal data pointers are
410 unequal (a fast test).
412 \wxheading{Parameters
}
414 \docparam{image
}{Image to compare with 'this'
}
416 \wxheading{Return value
}
418 Returns TRUE if the images were unequal, FALSE otherwise.
420 \section{\class{wxImageHandler
}}\label{wximagehandler
}
422 This is the base class for implementing image file loading/saving, and image creation from data.
423 It is used within wxImage and is not normally seen by the application.
425 If you wish to extend the capabilities of wxImage, derive a class from wxImageHandler
426 and add the handler using
\helpref{wxImage::AddHandler
}{wximageaddhandler
} in your
427 application initialisation.
429 \wxheading{Derived from
}
431 \helpref{wxObject
}{wxobject
}
435 \helpref{wxImage
}{wximage
}
437 \latexignore{\rtfignore{\wxheading{Members
}}}
439 \membersection{wxImageHandler::wxImageHandler
}\label{wximagehandlerconstr
}
441 \func{}{wxImageHandler
}{\void}
443 Default constructor. In your own default constructor, initialise the members
444 m
\_name, m
\_extension and m
\_type.
446 \membersection{wxImageHandler::
\destruct{wxImageHandler
}}
448 \func{}{\destruct{wxImageHandler
}}{\void}
450 Destroys the wxImageHandler object.
452 \membersection{wxImageHandler::GetName
}
454 \constfunc{wxString
}{GetName
}{\void}
456 Gets the name of this handler.
458 \membersection{wxImageHandler::GetExtension
}
460 \constfunc{wxString
}{GetExtension
}{\void}
462 Gets the file extension associated with this handler.
464 \membersection{wxImageHandler::GetType
}
466 \constfunc{long
}{GetType
}{\void}
468 Gets the image type associated with this handler.
470 \membersection{wxImageHandler::LoadFile
}\label{wximagehandlerloadfile
}
472 \func{bool
}{LoadFile
}{\param{wxImage*
}{image
},
\param{const wxString\&
}{ name
}}
474 Loads a image from a file or resource, putting the resulting data into
{\it image
}.
476 \wxheading{Parameters
}
478 \docparam{image
}{The image object which is to be affected by this operation.
}
480 \docparam{name
}{Either a filename or a Windows resource name.
481 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
483 \wxheading{Return value
}
485 TRUE if the operation succeeded, FALSE otherwise.
489 \helpref{wxImage::LoadFile
}{wximageloadfile
}\\
490 \helpref{wxImage::SaveFile
}{wximagesavefile
}\\
491 \helpref{wxImageHandler::SaveFile
}{wximagehandlersavefile
}
493 \membersection{wxImageHandler::SaveFile
}\label{wximagehandlersavefile
}
495 \func{bool
}{SaveFile
}{\param{wxImage*
}{image
},
\param{const wxString\&
}{name
}}
497 Saves a image in the named file.
499 \wxheading{Parameters
}
501 \docparam{image
}{The image object which is to be affected by this operation.
}
503 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
505 \wxheading{Return value
}
507 TRUE if the operation succeeded, FALSE otherwise.
511 \helpref{wxImage::LoadFile
}{wximageloadfile
}\\
512 \helpref{wxImage::SaveFile
}{wximagesavefile
}\\
513 \helpref{wxImageHandler::LoadFile
}{wximagehandlerloadfile
}
515 \membersection{wxImageHandler::SetName
}
517 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
519 Sets the handler name.
521 \wxheading{Parameters
}
523 \docparam{name
}{Handler name.
}
525 \membersection{wxImageHandler::SetExtension
}
527 \func{void
}{SetExtension
}{\param{const wxString\&
}{extension
}}
529 Sets the handler extension.
531 \wxheading{Parameters
}
533 \docparam{extension
}{Handler extension.
}
535 \membersection{wxImageHandler::SetType
}
537 \func{void
}{SetType
}{\param{long
}{type
}}
539 Sets the handler type.
541 \wxheading{Parameters
}
543 \docparam{name
}{Handler type.
}