user32: Fix some problems with the previous CreateIconIndirect patch

Dmitry Timoshkov dmitry at codeweavers.com
Fri Jan 19 08:48:39 CST 2007


Hello,

in order to investigate why my previous patch didn't completely fix the bug
written the helpers that dump passed in to CreateIconIndirect bitmaps (and
as well a resulting b/w bitmap) to BMP files. It appeared that the b/w mask
and the color images were reversed: one bottom-top, another top-down. Looks
like we need to tell GetDIBits to mirror the image. Also I didn't allocate
enough space for the DIB color table.

This patch completely fixes all remaining artifacts on the toolbar bitmaps,
now they are perfect.

Changelog:
    user32: Fix some problems with the previous CreateIconIndirect patch.

---
 dlls/user32/cursoricon.c |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index 26adfde..5dfa120 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -1847,7 +1847,8 @@ HICON WINAPI CreateIconIndirect(PICONINFO iconinfo)
     if (hObj)
     {
         HDC hdc;
-        BITMAPINFO bi;
+        char bi_buf[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 2];
+        BITMAPINFO *bi = (BITMAPINFO *)bi_buf;
         CURSORICONINFO *info;
 
         info = (CURSORICONINFO *)GlobalLock16( hObj );
@@ -1885,15 +1886,23 @@ HICON WINAPI CreateIconIndirect(PICONINFO iconinfo)
 
         /* Some apps pass a color bitmap as a mask, convert it to b/w */
         hdc = GetDC( 0 );
-        memset(&bi, 0, sizeof(bi) );
-        bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
-        bi.bmiHeader.biWidth = bmpAnd.bmWidth;
-        bi.bmiHeader.biHeight = bmpAnd.bmHeight;
-        bi.bmiHeader.biPlanes = 1;
-        bi.bmiHeader.biBitCount = 1;
-        bi.bmiHeader.biCompression = BI_RGB;
-        bi.bmiHeader.biSizeImage = sizeAnd;
-        GetDIBits( hdc, iconinfo->hbmMask, 0, bmpAnd.bmHeight, (char*)(info + 1), &bi, DIB_RGB_COLORS );
+        memset( bi, 0, sizeof(*bi) );
+        bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+        bi->bmiHeader.biWidth = bmpAnd.bmWidth;
+        bi->bmiHeader.biHeight = -bmpAnd.bmHeight;
+        bi->bmiHeader.biPlanes = 1;
+        bi->bmiHeader.biBitCount = 1;
+        bi->bmiHeader.biCompression = BI_RGB;
+        bi->bmiHeader.biSizeImage = sizeAnd;
+        bi->bmiColors[0].rgbRed = 0;
+        bi->bmiColors[0].rgbGreen = 0;
+        bi->bmiColors[0].rgbBlue = 0;
+        bi->bmiColors[0].rgbReserved = 0;
+        bi->bmiColors[1].rgbRed = 0xff;
+        bi->bmiColors[1].rgbGreen = 0xff;
+        bi->bmiColors[1].rgbBlue = 0xff;
+        bi->bmiColors[1].rgbReserved = 0;
+        GetDIBits( hdc, iconinfo->hbmMask, 0, bmpAnd.bmHeight, (char*)(info + 1), bi, DIB_RGB_COLORS );
         ReleaseDC( 0, hdc );
 
         if (iconinfo->hbmColor) GetBitmapBits( iconinfo->hbmColor, sizeXor, (char*)(info + 1) + sizeAnd );
-- 
1.4.4.4






More information about the wine-patches mailing list