Classes: wxBitmap, wxIcon, wxCursor.
The wxBitmap class encapsulates the concept of a platform-dependent bitmap, either monochrome or colour. Platform-specific methods for creating a wxBitmap object from an existing file are catered for, and this is an occasion where conditional compilation will probably be required.
A bitmap created dynamically or loaded from a file can be selected into a memory device context (instance of wxMemoryDC). This enables the bitmap to be copied to a canvas or memory device context using wxDC::Blit, or to be used as a drawing surface. The wxToolBar class was implemented using bitmaps, and the toolbar demo shows one of the toolbar bitmaps being used for drawing a miniature version of the graphic which appears on the main canvas.
wxWindows contains code to 'grey out' a bitmap when used in an insensitive panel item. Under X, this code is contained in the wxBitmap class. Under Windows, the user-contributed Fafa library is responsible for this.
See wxMemoryDC for an example of drawing onto a bitmap.
The following shows the conditional compilation required to load a bitmap in X and in Windows 3. The alternative is to use the string version of the bitmap constructor, which loads a file under X and a resource under Windows 3, but has the disadvantage of requiring the X icon file to be available at run-time.
#ifdef wx_x #include "aiai.xbm" #endif #ifdef wx_msw wxIcon *icon = new wxBitmap("aiai"); #endif #ifdef wx_x wxIcon *icon = new wxBitmap(aiai_bits, aiai_width, aiai_height); #endifLoading bitmaps: further information
See also the DIB and wxImage libraries distributed with wxWindows. DIB allows loading of .BMP files under Windows, and wxImage allows loading of a variety of bitmap formats under X. wxBuilder makes use of both of these packages: search for wxLoadBitmap for example of usage.
There is now (from version 1.61) extra provision for a number of bitmap formats via the standard wxBitmap class. These extra facilities can be enabled using settings in wx_setup.h; by default they are switched off.
XPM colour pixmaps may be loaded and saved under Windows and X, with some restrictions imposed by the lack of colourmap facility when using XPM files. The user may elect to use XPM files as a cross-platform stabdard, or translate between XPM and BMP files using a suitable utility (one is under preparation for wxWindows users).
Also, under Windows, DIBs (device independent bitmaps with extension BMP) may be dynamically loaded and saved. Under X, GIF and BMP files may be loaded but not saved.