This class encapsulates the concept of a platform-dependent bitmap, either monochrome or colour. Platform-specific methods for creating a wxBitmap structure 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.
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); #endifwxBitmap::wxBitmap