|
wxWidgets supports four kinds of bitmap images: wxBitmap, wxIcon, wxCursor, and wxImage. wxBitmap represents a platform-dependent bitmap, with an optional wxMask to support drawing with transparency. On Windows, wxBitmap is implemented using device-independent bitmaps (DIBs). On GTK+ and X11, each wxBitmap contains the pixmap object of GDK and X11, respectively. On Mac, a PICT is used. A wxBitmap can be converted to and from a wxImage. wxIcon represents the platform's concept of an icon, a small image with transparency that can be used for giving frames and dialogs a recognizable visual cue, among other things. On GTK+, X11, and Mac, an icon is simply a bitmap that always has a wxMask. On Windows, an icon is represented by an HICON object. wxCursor represents the mouse pointer image; this is a GdkCursor on GTK+, a Cursor on X11, an HCURSOR in Windows, and a Cursor on Mac. It has the notion of a hotspot (the pixel in the cursor image that is considered to be the exact mouse pointer location) and a mask. wxImage is the only class of the four with a platform-independent implementation, supporting 24-bit images with an optional alpha channel. A wxImage can be created from data or by using wxBitmap::ConvertToImage. A wxImage can be loaded from a file in a variety of formats, and it is extensible to new formats via image format handlers. Functions are available to set and get image bits, so it can be used for basic image manipulation. Unlike a wxBitmap, a wxImage cannot be drawn directly to a wxDC. Instead, a wxBitmap object must be created from the wxImage. This bitmap can then be drawn in a device context by using wxDC:: DrawBitmap. wxImage supports a mask color indicating transparent areas, and it also supports alpha channel data to allow for more sophisticated transparency effects. You can convert between these bitmap objects, though there are platform dependencies on some conversion operations. Note that all image classes are reference-counted, so assignment and copying are very cheap operations because the image data itself is not copied. However, you need to be aware that if you change an image, other image objects that refer to the same image data will also be changed. All image classes use standard wxBitmapType identifiers for loading and saving bitmap data, as described in Table 10-1.
|
|