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:
Vadim Zeitlin
2000-01-19 23:53:18 +00:00
parent 7ddef9ed7a
commit 0765adca2b
2 changed files with 25 additions and 12 deletions

View File

@@ -42,22 +42,29 @@ Copy constructor.
\func{}{wxBitmap}{\param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}} \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. Creates a bitmap from the given data which is interpreted in platform-dependent
Windows only, I think. manner.
\func{}{wxBitmap}{\param{const char}{ bits[]}, \param{int}{ width}, \param{int}{ height}\\ \func{}{wxBitmap}{\param{const char}{ bits[]}, \param{int}{ width}, \param{int}{ height}\\
\param{int}{ depth = 1}} \param{int}{ depth = 1}}
Creates a bitmap from an array of bits. 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 You should only use this function for monochrome bitmaps ({\it depth} 1) in
from something else than a 1-bit data array, use the \helpref{wxImage}{wximage} class. 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}} \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 Creates a new bitmap. A depth of -1 indicates the depth of the current screen
visual. Some platforms only support 1 for monochrome and -1 for the current colour or visual. Some platforms only support 1 for monochrome and -1 for the current
setting. colour setting.
\func{}{wxBitmap}{\param{const char**}{ bits}} \func{}{wxBitmap}{\param{const char**}{ bits}}

View File

@@ -255,16 +255,22 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
for ( int rows = 0; rows < height; rows++ ) for ( int rows = 0; rows < height; rows++ )
{ {
// note that offset cannot be size_t due to >= 0 test! for ( size_t cols = 0; cols < bytesPerLine; cols++ )
for ( int offset = bytesPerLine - 1; offset >= 0; offset-- )
{ {
*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 ) if ( padding )
*dst++ = 0; *dst++ = 0;
src += bytesPerLine;
} }
} }
else else