]> git.saurik.com Git - wxWidgets.git/blame - docs/doxygen/overviews/bitmap.h
Removed some remaining '#' references.
[wxWidgets.git] / docs / doxygen / overviews / bitmap.h
CommitLineData
15b6757b 1/////////////////////////////////////////////////////////////////////////////
e0a47918 2// Name: bitmap.h
15b6757b
FM
3// Purpose: topic overview
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/*!
36c9828f 10
59c0db6a 11 @page overview_bitmap Bitmaps and icons overview
36c9828f 12
98ba1eee 13 Classes: wxBitmap, wxBitmapHandler, wxIcon, wxCursor.
59c0db6a 14
15b6757b
FM
15 The wxBitmap class encapsulates the concept of a platform-dependent bitmap,
16 either monochrome or colour. Platform-specific methods for creating a
17 wxBitmap object from an existing file are catered for, and
18 this is an occasion where conditional compilation will sometimes be
19 required.
59c0db6a 20
15b6757b 21 A bitmap created dynamically or loaded from a file can be selected
98ba1eee 22 into a memory device context (instance of wxMemoryDC). This
15b6757b
FM
23 enables the bitmap to be copied to a window or memory device context
24 using wxDC::Blit, or to be used as a drawing surface.
59c0db6a 25
98ba1eee 26 See wxMemoryDC for an example of drawing onto a bitmap.
59c0db6a 27
15b6757b
FM
28 All wxWidgets platforms support XPMs for small bitmaps and icons.
29 You may include the XPM inline as below, since it's C code, or you
30 can load it at run-time.
36c9828f 31
15b6757b
FM
32 @code
33 #include "mondrian.xpm"
34 @endcode
36c9828f 35
15b6757b 36 Sometimes you wish to use a .ico resource on Windows, and XPMs on
59c0db6a
FM
37 other platforms (for example to take advantage of Windows' support for
38 multiple icon resolutions).
39
15b6757b
FM
40 A macro, #wxICON, is available which creates an icon using an XPM
41 on the appropriate platform, or an icon resource on Windows.
36c9828f 42
15b6757b
FM
43 @code
44 wxIcon icon(wxICON(mondrian));
36c9828f 45
15b6757b 46 // Equivalent to:
36c9828f 47
15b6757b
FM
48 #if defined(__WXGTK__) || defined(__WXMOTIF__)
49 wxIcon icon(mondrian_xpm);
50 #endif
36c9828f 51
15b6757b
FM
52 #if defined(__WXMSW__)
53 wxIcon icon("mondrian");
54 #endif
55 @endcode
36c9828f 56
15b6757b
FM
57 There is also a corresponding #wxBITMAP macro which allows
58 to create the bitmaps in much the same way as #wxICON creates
59 icons. It assumes that bitmaps live in resources under Windows or OS2 and XPM
60 files under all other platforms (for XPMs, the corresponding file must be
61 included before this macro is used, of course, and the name of the bitmap
62 should be the same as the resource name under Windows with @c _xpm
63 suffix). For example:
36c9828f 64
15b6757b
FM
65 @code
66 // an easy and portable way to create a bitmap
67 wxBitmap bmp(wxBITMAP(bmpname));
36c9828f 68
15b6757b
FM
69 // which is roughly equivalent to the following
70 #if defined(__WXMSW__) || defined(__WXPM__)
71 wxBitmap bmp("bmpname", wxBITMAP_TYPE_RESOURCE);
72 #else // Unix
73 wxBitmap bmp(bmpname_xpm, wxBITMAP_TYPE_XPM);
74 #endif
75 @endcode
36c9828f 76
15b6757b
FM
77 You should always use wxICON and wxBITMAP macros because they work for any
78 platform (unlike the code above which doesn't deal with wxMac, wxX11, ...) and
79 are more short and clear than versions with @c #ifdefs. Even better,
80 use the same XPMs on all platforms.
36c9828f 81
59c0db6a
FM
82 @li @ref overview_bitmap_supportedformats
83 @li @ref overview_bitmap_handlers
84
85
86 <hr>
36c9828f 87
59c0db6a
FM
88
89 @section overview_bitmap_supportedformats Supported bitmap file formats
36c9828f 90
15b6757b
FM
91 The following lists the formats handled on different platforms. Note
92 that missing or partially-implemented formats are automatically supplemented
98ba1eee 93 by the wxImage to load the data, and then converting
15b6757b
FM
94 it to wxBitmap form. Note that using wxImage is the preferred way to
95 load images in wxWidgets, with the exception of resources (XPM-files or
59c0db6a 96 native Windows resources).
36c9828f 97
59c0db6a
FM
98 Writing an image format handler for wxImage is also far easier than writing
99 one for wxBitmap, because wxImage has exactly one format on all platforms
100 whereas wxBitmap can store pixel data very differently, depending on colour
101 depths and platform.
36c9828f 102
98ba1eee
FM
103 @subsection overview_bitmap_supportedformats_bmp wxBitmap
104
59c0db6a 105 Under Windows, wxBitmap may load the following formats:
36c9828f 106
59c0db6a
FM
107 @li Windows bitmap resource (wxBITMAP_TYPE_BMP_RESOURCE)
108 @li Windows bitmap file (wxBITMAP_TYPE_BMP)
109 @li XPM data and file (wxBITMAP_TYPE_XPM)
98ba1eee 110 @li All formats that are supported by the wxImage class.
36c9828f 111
15b6757b 112 Under wxGTK, wxBitmap may load the following formats:
36c9828f 113
59c0db6a 114 @li XPM data and file (wxBITMAP_TYPE_XPM)
98ba1eee 115 @li All formats that are supported by the wxImage class.
36c9828f 116
15b6757b 117 Under wxMotif and wxX11, wxBitmap may load the following formats:
36c9828f 118
59c0db6a
FM
119 @li XBM data and file (wxBITMAP_TYPE_XBM)
120 @li XPM data and file (wxBITMAP_TYPE_XPM)
98ba1eee
FM
121 @li All formats that are supported by the wxImage class.
122
36c9828f 123
98ba1eee 124 @subsection overview_bitmap_supportedformats_icon wxIcon
36c9828f 125
15b6757b 126 Under Windows, wxIcon may load the following formats:
36c9828f 127
59c0db6a
FM
128 @li Windows icon resource (wxBITMAP_TYPE_ICO_RESOURCE)
129 @li Windows icon file (wxBITMAP_TYPE_ICO)
130 @li XPM data and file (wxBITMAP_TYPE_XPM)
36c9828f 131
15b6757b 132 Under wxGTK, wxIcon may load the following formats:
36c9828f 133
59c0db6a 134 @li XPM data and file (wxBITMAP_TYPE_XPM)
98ba1eee 135 @li All formats that are supported by the wxImage class.
36c9828f 136
15b6757b 137 Under wxMotif and wxX11, wxIcon may load the following formats:
36c9828f 138
59c0db6a
FM
139 @li XBM data and file (wxBITMAP_TYPE_XBM)
140 @li XPM data and file (wxBITMAP_TYPE_XPM)
98ba1eee
FM
141 @li All formats that are supported by the wxImage class.
142
36c9828f 143
98ba1eee 144 @subsection overview_bitmap_supportedformats_cursor wxCursor
36c9828f 145
15b6757b 146 Under Windows, wxCursor may load the following formats:
36c9828f 147
59c0db6a
FM
148 @li Windows cursor resource (wxBITMAP_TYPE_CUR_RESOURCE)
149 @li Windows cursor file (wxBITMAP_TYPE_CUR)
150 @li Windows icon file (wxBITMAP_TYPE_ICO)
151 @li Windows bitmap file (wxBITMAP_TYPE_BMP)
36c9828f 152
15b6757b
FM
153 Under wxGTK, wxCursor may load the following formats (in additional
154 to stock cursors):
36c9828f 155
59c0db6a 156 @li None (stock cursors only).
36c9828f 157
15b6757b 158 Under wxMotif and wxX11, wxCursor may load the following formats:
36c9828f 159
59c0db6a 160 @li XBM data and file (wxBITMAP_TYPE_XBM)
36c9828f
FM
161
162
163
59c0db6a 164 @section overview_bitmap_handlers Bitmap format handlers
36c9828f 165
15b6757b
FM
166 To provide extensibility, the functionality for loading and saving bitmap formats
167 is not implemented in the wxBitmap class, but in a number of handler classes,
168 derived from wxBitmapHandler. There is a static list of handlers which wxBitmap
59c0db6a
FM
169 examines when a file load/save operation is requested.
170
171 Some handlers are provided as standard, but if you
15b6757b
FM
172 have special requirements, you may wish to initialise the wxBitmap class with
173 some extra handlers which you write yourself or receive from a third party.
59c0db6a
FM
174
175 To add a handler object to wxBitmap, your application needs to include the header
176 which implements it, and then call the static function wxBitmap::AddHandler.
177
98ba1eee
FM
178 @note bitmap handlers are not implemented on all platforms, and new ones rarely need
179 to be implemented since wxImage can be used for loading most formats, as noted
180 earlier.
36c9828f 181
e0a47918 182*/
36c9828f 183