Contents Up Previous Next

What bitmap loading facilities are available for wxWindows?

There is Windows .BMP code that compiles under Windows distributed with wxWindows 1.50k (utils/dib directory). wxWindows 1.60 will allow proper colourmap setting with this code. DIB allows loading and saving BMP files. The contributed Windows wxImage library (utils/wximage/win) enables GIF loading (and other formats such as JPEG if extra graphics libraries are installed).

For X, the utils/image directory contains code to load GIFS, Windows bitmaps and X bitmaps into a canvas (and optionally, into a wxBitmap). The code has been taken from a pre-shareware version of the excellent image viewer XV; it cannot be guaranteed that the code is free from copyright issues. See the file test.cpp for a scanty explanation of how to use it.

XPM (colour X Pixmap) files are supported by the wxXPM package now bundled with wxWindows, from 1.61. The package is in contrib/wxxpm, and includes a utility XPMShow which allows conversion between XPM and BMP files under Windows (only, at present).

For the maximum bitmap facilities, wx_setup.h should be edited and the following settings made:

Then recompile the wxWindows, image (X), DIB (Windows) and XPM (X and Windows) libraries and link in with your application. You can now load and save XPMs (X and Windows), load BMP files (X and Windows), save BMP bitmaps (Windows), and load GIFs (X), all through the wxBitmap interface.

It is recommended that you use XPMs for colour bitmap buttons, at least under X. Note that colour buttons will not display correctly on X terminals whose display depth does not match the bitmap depth, so checking will need to be done in the application.