WxBitmap
From WxWiki
Contents |
[edit] wxBitmap
wxBitmap::SetWidth() cannot be used to resize a bitmap: is is only used by wx itself to construct a new Bitmap. You might want to use wxImage::Rescale() instead.
See also WxIcon, wxImage
[edit] gotcha's
[edit] Working with bitmaps before the first wxApp object is created
It is said working with Bitmap objects before you've created your first wxApp object will cause segfaults on some systems.
In other words, don't use things like 'wxBitmap myBm("foo.bmp");' as globals. Instead, create them in the context of a member function (Frame or View level works fine, but not App).
This is because if the underlying code encounters an error, it tries to log it; the default place to log to (if you don't have a LogWindow up) is a MessageBox; if there's no Frame object in memory space yet, the MessageBox ctor fails, throwing; systems catches, and seg-faults.
[edit] Win32 bmp LoadFile() vs wxIcon
Note also that a Win32 .bmp will *not* correctly '.LoadFile()' into a wxBitmap ('unrecognized file format'), but *will* correctly load into a wxIcon (v 2.4.x). And, of course, that wxICON(xxx) only works on .xpm files.
[edit] Drawing transparent bitmaps to a DC
If you want to wxDC::DrawBitmap a bitmap with transparent pixels, remember to set the 4th argument ('transparent') to TRUE (the default is FALSE). Bitmaps suitable for alpha-blending during wxDC::DrawBitmap must be in RGBA format.
[edit] High-colour bitmaps
If you're using high-colour bitmaps, you'll need to call wxSystemOptions::SetOption(wxT("msw.remap"), 0); to switch off the remapping that wxWidgets does to make the tool colours match the current system colours. This remapping is only relevant for 16-colour tools, and messes up high-colour tools.
You'll need to include wx/sysopt.h to access wxSystemOptions.
[edit] can't find wxBITMAP_STD_COLOURS in .rc
If your compiler complains that it can't find wxBITMAP_STD_COLOURS in your .rc files, include wx/msw/wx.rc in your project. When using bakefiles, make sure you specify <win32-res> E.G. <win32-res>toolbar.rc</win32-res>
