From: Vadim Zeitlin Date: Mon, 24 Mar 2003 22:08:53 +0000 (+0000) Subject: fixed converting BI_BITFIELDS bitmaps to DIBs (fixes 589416) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a8beba7230ae19c06f7c0d4e0f785a0bf64bb984 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 --- diff --git a/src/msw/dib.cpp b/src/msw/dib.cpp index 92db7b427d..a3e9b49a45 100644 --- a/src/msw/dib.cpp +++ b/src/msw/dib.cpp @@ -288,13 +288,31 @@ HBITMAP wxDIB::ConvertToBitmap(const BITMAPINFO *pbmi, HDC hdc, void *bits) if ( !bits ) { // 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 - // all - int numColors = pbmih->biClrUsed; - if ( !numColors ) + // + // colour table either has the real colour data in which case its + // number of entries is given by biClrUsed or is used for masks to be + // used for extracting colour information from true colour bitmaps in + // 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);