]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed converting BI_BITFIELDS bitmaps to DIBs (fixes 589416)
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 24 Mar 2003 22:08:53 +0000 (22:08 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 24 Mar 2003 22:08:53 +0000 (22:08 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19780 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/dib.cpp

index 92db7b427d40dd307bec4330d81feea3b58ac336..a3e9b49a45406a70110b3a2b5179d63b7b8d74e9 100644 (file)
@@ -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);