fixed converting BI_BITFIELDS bitmaps to DIBs (fixes 589416)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19780 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2003-03-24 22:08:53 +00:00
parent a6b4ff2e62
commit a8beba7230

View File

@ -288,13 +288,31 @@ HBITMAP wxDIB::ConvertToBitmap(const BITMAPINFO *pbmi, HDC hdc, void *bits)
if ( !bits ) if ( !bits )
{ {
// we must skip over the colour table to get to the image data // we must skip over the colour table to get to the image data
//
// biClrUsed has the number of colors but it may be not initialized at // colour table either has the real colour data in which case its
// all // number of entries is given by biClrUsed or is used for masks to be
int numColors = pbmih->biClrUsed; // used for extracting colour information from true colour bitmaps in
if ( !numColors ) // which case it always have exactly 3 DWORDs
int numColors;
switch ( pbmih->biCompression )
{ {
numColors = wxGetNumOfBitmapColors(pbmih->biBitCount); case BI_BITFIELDS:
numColors = 3;
break;
case BI_RGB:
// biClrUsed has the number of colors but it may be not initialized at
// all
numColors = pbmih->biClrUsed;
if ( !numColors )
{
numColors = wxGetNumOfBitmapColors(pbmih->biBitCount);
}
break;
default:
// no idea how it should be calculated for the other cases
numColors = 0;
} }
bits = (char *)pbmih + sizeof(*pbmih) + numColors*sizeof(RGBQUAD); bits = (char *)pbmih + sizeof(*pbmih) + numColors*sizeof(RGBQUAD);