[4/4] user32/cursoricon.c: Multiple Fixes/Improvements for DrawIconEx

Wilfried Pasquazzo wilfried.pasquazzo at gmail.com
Fri Sep 25 12:15:04 CDT 2009


Best regards,


Wilfried Pasquazzo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20090925/d0f5ea2d/attachment-0001.htm>
-------------- next part --------------
From 5d9cbaab712591a67d1055e01e8c36acd3ad735c Mon Sep 17 00:00:00 2001
From: Wilfried Pasquazzo <wilfried.pasquazzo at gmail.com>
Date: Fri, 25 Sep 2009 18:23:23 +0000
Subject: Optional: Replace DrawIcon with equivalent call to
 DrawIconEx

---
 dlls/user32/cursoricon.c |   80 +--------------------------------------------
 1 files changed, 2 insertions(+), 78 deletions(-)

diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index 8ffe600..5c321b8 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -1671,84 +1671,8 @@ static void premultiply_alpha_channel( unsigned char *destBitmap,
  */
 BOOL WINAPI DrawIcon( HDC hdc, INT x, INT y, HICON hIcon )
 {
-    CURSORICONINFO *ptr;
-    HDC hMemDC;
-    HBITMAP hXorBits = NULL, hAndBits = NULL, hBitTemp = NULL;
-    COLORREF oldFg, oldBg;
-    unsigned char *xorBitmapBits;
-    unsigned int dibLength;
-
-    TRACE("%p, (%d,%d), %p\n", hdc, x, y, hIcon);
-
-    if (!(ptr = GlobalLock16(HICON_16(hIcon)))) return FALSE;
-    if (!(hMemDC = CreateCompatibleDC( hdc ))) return FALSE;
-
-    dibLength = ptr->nHeight * get_bitmap_width_bytes(
-        ptr->nWidth, ptr->bBitsPerPixel);
-
-    xorBitmapBits = (unsigned char *)(ptr + 1) + ptr->nHeight *
-                    get_bitmap_width_bytes(ptr->nWidth, 1);
-
-    oldFg = SetTextColor( hdc, RGB(0,0,0) );
-    oldBg = SetBkColor( hdc, RGB(255,255,255) );
-
-    if(bitmap_has_alpha_channel(ptr->bBitsPerPixel, xorBitmapBits, dibLength))
-    {
-        BITMAPINFOHEADER bmih;
-        unsigned char *dibBits;
-
-        memset(&bmih, 0, sizeof(BITMAPINFOHEADER));
-        bmih.biSize = sizeof(BITMAPINFOHEADER);
-        bmih.biWidth = ptr->nWidth;
-        bmih.biHeight = -ptr->nHeight;
-        bmih.biPlanes = ptr->bPlanes;
-        bmih.biBitCount = 32;
-        bmih.biCompression = BI_RGB;
-
-        hXorBits = CreateDIBSection(hdc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS,
-                                    (void*)&dibBits, NULL, 0);
-
-        if (hXorBits && dibBits)
-        {
-            BLENDFUNCTION pixelblend = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
-
-            /* Do the alpha blending render */
-            premultiply_alpha_channel(dibBits, xorBitmapBits, dibLength);
-            hBitTemp = SelectObject( hMemDC, hXorBits );
-	    /* Destination width/height has to be "System Large" size */
-            GdiAlphaBlend(hdc, x, y, GetSystemMetrics(SM_CXICON),
-	                    GetSystemMetrics(SM_CYICON), hMemDC,
-                            0, 0, ptr->nWidth, ptr->nHeight, pixelblend);
-            SelectObject( hMemDC, hBitTemp );
-        }
-    }
-    else
-    {
-        hAndBits = CreateBitmap( ptr->nWidth, ptr->nHeight, 1, 1, ptr + 1 );
-        hXorBits = CreateBitmap( ptr->nWidth, ptr->nHeight, ptr->bPlanes,
-                               ptr->bBitsPerPixel, xorBitmapBits);
-
-        if (hXorBits && hAndBits)
-        {
-            hBitTemp = SelectObject( hMemDC, hAndBits );
-            StretchBlt( hdc, x, y, GetSystemMetrics(SM_CXICON),
-	                    GetSystemMetrics(SM_CYICON), hMemDC, 0, 0,
-			    ptr->nWidth, ptr->nHeight, SRCAND );
-            SelectObject( hMemDC, hXorBits );
-            StretchBlt( hdc, x, y, GetSystemMetrics(SM_CXICON),
-	                    GetSystemMetrics(SM_CYICON), hMemDC, 0, 0,
-			    ptr->nWidth, ptr->nHeight, SRCINVERT );
-            SelectObject( hMemDC, hBitTemp );
-        }
-    }
-
-    DeleteDC( hMemDC );
-    if (hXorBits) DeleteObject( hXorBits );
-    if (hAndBits) DeleteObject( hAndBits );
-    GlobalUnlock16(HICON_16(hIcon));
-    SetTextColor( hdc, oldFg );
-    SetBkColor( hdc, oldBg );
-    return TRUE;
+    return DrawIconEx( hdc, x, y, hIcon, 0, 0, 0, NULL, 
+                         ( DI_NORMAL | DI_DEFAULTSIZE | DI_COMPAT ));
 }
 
 /***********************************************************************
-- 
1.6.3.3


More information about the wine-patches mailing list