[1/1] user32: Don't memcpy 16bit-aligned icon into 32bit-aligned DIBSection
Wilfried Pasquazzo
wilfried.pasquazzo at gmail.com
Sat Nov 21 09:32:20 CST 2009
modified file: dlls/user32/cursoricon.c
In DrawIconEx() at one point the content of 16-bit aligned icons
is memcopied directly into 32-bit aligned DIBSections, which may lead
to loss of information when the DIBSection is immediatly afterwards
used as a source for blitting.
Instead temporarily create a 16-bit aligned bitmap and use that as source
for blitting, like the similar DrawIcon() does.
This fixes Bug 20145 (http://bugs.winehq.org/show_bug.cgi?id=20145):
"DrawIconEx() doesn't draw 1 bpp monochrome Icons correctly"
Wilfried Pasquazzo
-------------- next part --------------
From 18cc4a336187c864c623964f27f4011901ec5c03 Mon Sep 17 00:00:00 2001
From: Wilfried Pasquazzo <wilfried.pasquazzo at gmail.com>
Date: Sat, 21 Nov 2009 16:26:08 +0100
Subject: [PATCH] Don't use 32-bit-aligned DIBSection for drawing of 16-bit-aligned icons
---
dlls/user32/cursoricon.c | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index 248f3a0..442f724 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -2445,15 +2445,21 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon,
}
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 );
+ HBITMAP hXor = CreateBitmap( ptr->nWidth, ptr->nHeight, ptr->bPlanes,
+ ptr->bBitsPerPixel, xorBitmapBits );
+
+ if(hXor) {
+ hBitTemp = SelectObject( hMemDC, hXor );
+ 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( hXor );
+ }
}
DeleteObject( hXorBits );
--
1.6.5.3
More information about the wine-patches
mailing list