Add wxBITMAP_PNG() macro similar to wxBITMAP() but for PNG images.

Just as wxBITMAP() provides a portable way of loading bitmaps from either
Windows BMP resources or embedded XPM data depending on the platform,
wxBITMAP_PNG() hides the difference between loading bitmaps from PNG resources
under Windows and embedded PNG data elsewhere.

Also add wxBITMAP_PNG_FROM_DATA() macro which always loads PNG data from
memory: it's needed anyhow as part of wxBITMAP_PNG() implementation and some
people may prefer to always use it under all platforms.

Finally modify the image sample to demonstrate loading PNG images from both
resources and memory. This involved creation of a new Windows .rc file for it
and copying its data files to Resources bundle directory under OS X.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72477 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-09-13 17:15:25 +00:00
parent 20e6714a67
commit c3f641cb5e
20 changed files with 328 additions and 36 deletions

View File

@@ -78,8 +78,17 @@ wxBitmap bmp(wxBITMAP(bmpname));
You should always use wxICON() and wxBITMAP() macros because they work for any
platform (unlike the code above which doesn't deal with wxMac, wxX11, ...) and
are shorter and more clear than versions with many @ifdef_ blocks. Even better,
use the same XPMs on all platforms.
are shorter and more clear than versions with many @ifdef_ blocks.
Alternatively, you could use the same XPMs on all platforms and avoid dealing
with Windows resource files.
If you'd like to embed bitmaps with alpha transparency in your program, neither
XPM nor BMP formats are appropriate as they don't have support for alpha and
another format, typically PNG, should be used. wxWidgets provides a similar
helper for PNG bitmaps called wxBITMAP_PNG() that can be used to either load
PNG files embedded in resources (meaning either Windows resource section of the
executable file or OS X "Resource" subdirectory of the application bundle) or
arrays containing PNG data included into the program code itself.
@li @ref overview_bitmap_supportedformats
@li @ref overview_bitmap_handlers