[USER] Fix cursor icon

Christian Costa titan.costa at wanadoo.fr
Sat Nov 5 08:58:15 CST 2005


Hi,

This patch fixes crash in Railroad tycoon 2.

Changelog:
When creating black & white cursor icon, handle special case where 
hbmColor is null and
hbmMask specify a bitmap having twice the height and formatted so the 
upper half is the
icon AND bitmask and the lower one is the OR bitmask.

Christian Costa   titan.costa at wanadoo.fr

-------------- next part --------------
Index: dlls/user/cursoricon.c
===================================================================
RCS file: /home/wine/wine/dlls/user/cursoricon.c,v
retrieving revision 1.17
diff -u -r1.17 cursoricon.c
--- dlls/user/cursoricon.c	12 Sep 2005 10:30:06 -0000	1.17
+++ dlls/user/cursoricon.c	5 Nov 2005 13:36:44 -0000
@@ -1807,10 +1807,10 @@
     HICON16 hObj;
     int	sizeXor,sizeAnd;
 
-    GetObjectA( iconinfo->hbmColor, sizeof(bmpXor), &bmpXor );
+    if (iconinfo->hbmColor) GetObjectA( iconinfo->hbmColor, sizeof(bmpXor), &bmpXor );
     GetObjectA( iconinfo->hbmMask, sizeof(bmpAnd), &bmpAnd );
 
-    sizeXor = bmpXor.bmHeight * bmpXor.bmWidthBytes;
+    sizeXor = iconinfo->hbmColor ? (bmpXor.bmHeight * bmpXor.bmWidthBytes) : 0;
     sizeAnd = bmpAnd.bmHeight * bmpAnd.bmWidthBytes;
 
     hObj = GlobalAlloc16( GMEM_MOVEABLE,
@@ -1833,16 +1833,16 @@
           info->ptHotSpot.y   = iconinfo->yHotspot;
         }
 
-        info->nWidth        = bmpXor.bmWidth;
-        info->nHeight       = bmpXor.bmHeight;
-        info->nWidthBytes   = bmpXor.bmWidthBytes;
-        info->bPlanes       = bmpXor.bmPlanes;
-        info->bBitsPerPixel = bmpXor.bmBitsPixel;
+        info->nWidth        = bmpAnd.bmWidth;
+        info->nHeight       = iconinfo->hbmColor ? bmpAnd.bmHeight : (bmpAnd.bmHeight / 2);
+        info->nWidthBytes   = bmpAnd.bmWidthBytes;
+        info->bPlanes       = bmpAnd.bmPlanes;
+        info->bBitsPerPixel = bmpAnd.bmBitsPixel;
 
         /* Transfer the bitmap bits to the CURSORICONINFO structure */
 
-        GetBitmapBits( iconinfo->hbmMask ,sizeAnd,(char*)(info + 1) );
-        GetBitmapBits( iconinfo->hbmColor,sizeXor,(char*)(info + 1) +sizeAnd);
+        GetBitmapBits( iconinfo->hbmMask, sizeAnd, (char*)(info + 1) );
+        if (iconinfo->hbmColor) GetBitmapBits( iconinfo->hbmColor, sizeXor, (char*)(info + 1) + sizeAnd );
         GlobalUnlock16( hObj );
     }
     return HICON_32(hObj);


More information about the wine-patches mailing list