[1/3] user32/cursoricon.c: Multiple Fixes/Improvements for DrawIconEx (try 2)
Wilfried Pasquazzo
wilfried.pasquazzo at gmail.com
Sun Sep 27 01:00:48 CDT 2009
Resending my previous patches with minor changes:
[1/3] Fix for Bug http://bugs.winehq.org/show_bug.cgi?id=20145
Only changed hierarchy of if statements to get monochrome 1 bpp icons
into the "correct"
branch which doesn't compute alpha blending.
What changed?
Removed some whitespaces on an empty line that would issue a warning
when patching.
[2/3] Small change to make all "wine todo" tests of DrawIconEx pass
Changed rendering flag to depend on DI_MASK flag
Removed "wine todo" from both corresponding tests
What changed?
This is a new version of the [2/4] and [3/4] I sent before, as
suggested by Vitaliy Margolen
(http://www.winehq.org/pipermail/wine-devel/2009-September/078825.html)
now respecting the limitations of C89, as pointed out by Juan Lang
http://www.winehq.org/pipermail/wine-devel/2009-September/078823.html
[3/3] Replacing the DrawIcon implementation with now equivalent call
to DrawIconEx
(as suggested by http://msdn.microsoft.com/en-us/library/ms648065(VS.85).aspx ),
therefore eliminating lots of duplicated code.
What changed?
Nothing, this is essentially the old [4/4].
Wilfried Pasquazzo
-------------- next part --------------
From 81c6952d5fbdedbe71f14cb838775d80489d2784 Mon Sep 17 00:00:00 2001
From: Wilfried Pasquazzo <wilfried.pasquazzo at gmail.com>
Date: Sun, 27 Sep 2009 07:16:03 +0000
Subject: Fixed handling of 1 bpp monochrome icons Bug 20145
---
dlls/user32/cursoricon.c | 55 +++++++++++++++++++++++----------------------
1 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index 23de6a5..df12c54 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -2371,23 +2371,23 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon,
if (flags & DI_IMAGE)
{
- BITMAPINFOHEADER bmih;
- unsigned char *dibBits;
+ if (has_alpha)
+ {
+ 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 = ptr->bBitsPerPixel;
- bmih.biCompression = BI_RGB;
+ memset(&bmih, 0, sizeof(BITMAPINFOHEADER));
+ bmih.biSize = sizeof(BITMAPINFOHEADER);
+ bmih.biWidth = ptr->nWidth;
+ bmih.biHeight = -ptr->nHeight;
+ bmih.biPlanes = ptr->bPlanes;
+ bmih.biBitCount = ptr->bBitsPerPixel;
+ bmih.biCompression = BI_RGB;
- hXorBits = CreateDIBSection(hdc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS,
- (void*)&dibBits, NULL, 0);
+ hXorBits = CreateDIBSection(hdc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS,
+ (void*)&dibBits, NULL, 0);
- if (hXorBits && dibBits)
- {
- if(has_alpha)
+ if(hXorBits && dibBits)
{
BLENDFUNCTION pixelblend = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
@@ -2403,20 +2403,21 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon,
0, 0, ptr->nWidth, ptr->nHeight, pixelblend);
SelectObject( hMemDC, hBitTemp );
- }
- else
- {
- memcpy(dibBits, xorBitmapBits, xorLength);
- hBitTemp = SelectObject( hMemDC, hXorBits );
- if (DoOffscreen)
- StretchBlt (hDC_off, 0, 0, cxWidth, cyWidth,
- hMemDC, 0, 0, ptr->nWidth, ptr->nHeight, SRCPAINT);
- else
- StretchBlt (hdc, x0, y0, cxWidth, cyWidth,
- hMemDC, 0, 0, ptr->nWidth, ptr->nHeight, SRCPAINT);
- SelectObject( hMemDC, hBitTemp );
- }
+ DeleteObject( hXorBits );
+ }
+ }
+ else
+ {
+ hXorBits = CreateBitmap( ptr->nWidth, ptr->nHeight, ptr->bPlanes, ptr->bBitsPerPixel, xorBitmapBits);
+ hBitTemp = SelectObject( hMemDC, hXorBits );
+ if (DoOffscreen)
+ StretchBlt (hDC_off, 0, 0, cxWidth, cyWidth,
+ hMemDC, 0, 0, ptr->nWidth, ptr->nHeight, SRCPAINT);
+ else
+ StretchBlt (hdc, x0, y0, cxWidth, cyWidth,
+ hMemDC, 0, 0, ptr->nWidth, ptr->nHeight, SRCPAINT);
+ SelectObject( hMemDC, hBitTemp );
DeleteObject( hXorBits );
}
}
--
1.6.3.3
More information about the wine-patches
mailing list