[3/3] user32/cursoricon.c: Multiple Fixes/Improvements for DrawIconEx (try 2)

Wilfried Pasquazzo wilfried.pasquazzo at gmail.com
Sun Sep 27 01:01:59 CDT 2009


Wilfried Pasquazzo
-------------- next part --------------
From c11fad372155e6d2e1fc44da81644bef40abd651 Mon Sep 17 00:00:00 2001
From: Wilfried Pasquazzo <wilfried.pasquazzo at gmail.com>
Date: Sun, 27 Sep 2009 07:41:49 +0000
Subject: Optional Relpace 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 7ab9424..4eb2bf6 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_DEFAULTSIZE | DI_NORMAL | DI_COMPAT ));
 }
 
 /***********************************************************************
-- 
1.6.3.3


More information about the wine-patches mailing list