RESEND comctl32:toolbar: [2/2] CopyBitmap function modification

Oleg Krylov oleg.krylov at gmail.com
Tue Aug 1 06:38:00 CDT 2006


RESEND: fixed patch line wraps, sorry

Modifies CopyBitmap (introduced in previous patch) to support DIB bitmaps
Behavior got tracing windows implementation.
FIXES Bug#: 1715

-------------- next part --------------
diff -urN wine/dlls/comctl32/toolbar.c wineNew/dlls/comctl32/toolbar.c
--- wine/dlls/comctl32/toolbar.c	2006-07-27 13:45:36.000000000 +0300
+++ wineNew/dlls/comctl32/toolbar.c	2006-07-27 13:47:16.000000000 +0300
@@ -2577,16 +2577,45 @@
     BITMAP  bmp;
     HBITMAP hOldBitmapBitmap, hOldBitmapLoad, hbmLoad;
     HDC     hdcImage, hdcBitmap;
-
-    GetObjectW (hbm, sizeof(BITMAP), (LPVOID)&bmp);
+
+    if (!GetObjectW (hbm, sizeof(BITMAP), (LPVOID)&bmp))
+        return NULL;
 
     hdcImage  = CreateCompatibleDC(0);
     hdcBitmap = CreateCompatibleDC(0);
 
     /* create new bitmap */
-    hbmLoad = CreateBitmap (bmp.bmWidth, bmp.bmHeight, bmp.bmPlanes, bmp.bmBitsPixel, NULL);
-    hOldBitmapBitmap = SelectObject(hdcBitmap, hbm);
+    if(bmp.bmBits != NULL && bmp.bmBitsPixel <= 8)
+    {
+        struct
+        {
+            BITMAPINFOHEADER bmiHeader;
+            RGBQUAD bmiColors[256];
+        } bmi;
+        VOID *bits;
+
+        ZeroMemory (&bmi, sizeof(bmi));
+        bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+        bmi.bmiHeader.biWidth = bmp.bmWidth;
+        bmi.bmiHeader.biHeight = bmp.bmHeight;
+        bmi.bmiHeader.biPlanes = 1;
+        bmi.bmiHeader.biBitCount = bmp.bmBitsPixel;
+        if(bmp.bmBitsPixel<=1)
+            bmi.bmiHeader.biBitCount=1;
+        else if(bmp.bmBitsPixel<=4)
+            bmi.bmiHeader.biBitCount=4;
+        else
+            bmi.bmiHeader.biBitCount=8;
+        bmi.bmiHeader.biCompression = BI_RGB;
+
+        bmi.bmiHeader.biClrUsed = GetDIBColorTable (hdcBitmap, 0, 1<<bmi.bmiHeader.biBitCount, bmi.bmiColors);
+        hbmLoad = CreateDIBSection (hdcImage, (BITMAPINFO*)&bmi, DIB_RGB_COLORS, &bits, 0, 0);
+    }
+    else
+        hbmLoad = CreateBitmapIndirect(&bmp);
+
     hOldBitmapLoad = SelectObject(hdcImage, hbmLoad);
+    hOldBitmapBitmap = SelectObject (hdcBitmap, hbm);
 
     /* Copy the user's image */
     BitBlt (hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight,




More information about the wine-patches mailing list