XBM loading finally works (thanks Guillermo)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5543 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -42,22 +42,29 @@ Copy constructor.
|
||||
|
||||
\func{}{wxBitmap}{\param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
|
||||
|
||||
Creates a bitmap from the given data, which can be of arbitrary type.
|
||||
Windows only, I think.
|
||||
Creates a bitmap from the given data which is interpreted in platform-dependent
|
||||
manner.
|
||||
|
||||
\func{}{wxBitmap}{\param{const char}{ bits[]}, \param{int}{ width}, \param{int}{ height}\\
|
||||
\param{int}{ depth = 1}}
|
||||
|
||||
Creates a bitmap from an array of bits.
|
||||
|
||||
Note that the bit depth is ignored on GTK+ and Motif. If you want to create a bitmap
|
||||
from something else than a 1-bit data array, use the \helpref{wxImage}{wximage} class.
|
||||
You should only use this function for monochrome bitmaps ({\it depth} 1) in
|
||||
portable programs: in this case the {\it bits} parameter should contain an XBM
|
||||
image.
|
||||
|
||||
For other bit depths, the behaviour is platform dependent: under Windows, the
|
||||
data is passed withotu any changes to the underlying {\tt CreateBitmap()} API.
|
||||
Under other platforms, only monochrome bitmaps may be created using this
|
||||
constructor and \helpref{wxImage}{wximage} should be used for creating colour
|
||||
bitmaps from static data.
|
||||
|
||||
\func{}{wxBitmap}{\param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
|
||||
|
||||
Creates a new bitmap. A depth of -1 indicates the depth of the current screen or
|
||||
visual. Some platforms only support 1 for monochrome and -1 for the current colour
|
||||
setting.
|
||||
Creates a new bitmap. A depth of -1 indicates the depth of the current screen
|
||||
or visual. Some platforms only support 1 for monochrome and -1 for the current
|
||||
colour setting.
|
||||
|
||||
\func{}{wxBitmap}{\param{const char**}{ bits}}
|
||||
|
||||
|
@@ -255,16 +255,22 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
|
||||
|
||||
for ( int rows = 0; rows < height; rows++ )
|
||||
{
|
||||
// note that offset cannot be size_t due to >= 0 test!
|
||||
for ( int offset = bytesPerLine - 1; offset >= 0; offset-- )
|
||||
for ( size_t cols = 0; cols < bytesPerLine; cols++ )
|
||||
{
|
||||
*dst++ = *(src + offset);
|
||||
unsigned char val = *src++;
|
||||
unsigned char reversed = 0;
|
||||
|
||||
for ( int bits = 0; bits < 8; bits++)
|
||||
{
|
||||
reversed <<= 1;
|
||||
reversed |= (val & 0x01);
|
||||
val >>= 1;
|
||||
}
|
||||
*dst++ = reversed;
|
||||
}
|
||||
|
||||
if ( padding )
|
||||
*dst++ = 0;
|
||||
|
||||
src += bytesPerLine;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user