]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed bug in wxConvertDIBToBitmap (contributed)
authorJulian Smart <julian@anthemion.co.uk>
Fri, 30 Nov 2001 07:34:40 +0000 (07:34 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 30 Nov 2001 07:34:40 +0000 (07:34 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12760 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/app.cpp
src/msw/ole/dataobj.cpp

index fd8d8e723a94a032c003c09bb55c4949545865c6..f29afe759c0c4f46e6339c07220c1095ce2dcbbe 100644 (file)
@@ -779,7 +779,7 @@ int wxEntry(WXHINSTANCE hInstance,
         wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
 
         // save the WinMain() parameters
-        if (lpCmdLine) // MicroWindows pass NULL for this
+        if (lpCmdLine) // MicroWindows passes NULL
             wxTheApp->ConvertToStandardCommandArgs(lpCmdLine);
         wxTheApp->m_nCmdShow = nCmdShow;
 
index 29c0d6f8e52a58371b1260f1042b963cc75bed7f..65151fbf5e73e43dd6906bb44c53f14f98335f2b 100644 (file)
@@ -1260,8 +1260,15 @@ wxBitmap wxConvertDIBToBitmap(const LPBITMAPINFO pbmi)
     // BITMAPINFO starts with BITMAPINFOHEADER followed by colour info
     const BITMAPINFOHEADER *pbmih = &pbmi->bmiHeader;
 
+    // biClrUsed has the number of colors, unless it's 0
+    int numColors = pbmih->biClrUsed;
+    if (numColors==0)
+    {
+        numColors = wxGetNumOfBitmapColors(pbmih->biBitCount);
+    }
+
     // offset of image from the beginning of the header
-    DWORD ofs = wxGetNumOfBitmapColors(pbmih->biBitCount) * sizeof(RGBQUAD);
+    DWORD ofs = numColors * sizeof(RGBQUAD);
     void *image = (char *)pbmih + sizeof(BITMAPINFOHEADER) + ofs;
 
     ScreenHDC hdc;