user32: Fix drawing of 1-bpp icons in DrawIconEx.

This commit is contained in:
Alexandre Julliard 2010-05-07 12:08:29 +02:00
parent 2e96abd0d4
commit a59d79c9a6
1 changed files with 26 additions and 15 deletions

View File

@ -2294,28 +2294,40 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon,
if (flags & DI_IMAGE) if (flags & DI_IMAGE)
{ {
BITMAPINFOHEADER bmih; if (ptr->bPlanes * ptr->bBitsPerPixel == 1)
unsigned char *dibBits; {
hXorBits = CreateBitmap( ptr->nWidth, ptr->nHeight, 1, 1, xorBitmapBits );
}
else
{
unsigned char *dibBits;
BITMAPINFO *bmi = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
FIELD_OFFSET( BITMAPINFO, bmiColors[256] ));
bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi->bmiHeader.biWidth = ptr->nWidth;
bmi->bmiHeader.biHeight = -ptr->nHeight;
bmi->bmiHeader.biPlanes = ptr->bPlanes;
bmi->bmiHeader.biBitCount = ptr->bBitsPerPixel;
bmi->bmiHeader.biCompression = BI_RGB;
/* FIXME: color table */
memset(&bmih, 0, sizeof(BITMAPINFOHEADER)); hXorBits = CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, (void*)&dibBits, NULL, 0);
bmih.biSize = sizeof(BITMAPINFOHEADER); if (hXorBits)
bmih.biWidth = ptr->nWidth; {
bmih.biHeight = -ptr->nHeight; if(has_alpha)
bmih.biPlanes = ptr->bPlanes; premultiply_alpha_channel(dibBits, xorBitmapBits, xorLength);
bmih.biBitCount = ptr->bBitsPerPixel; else
bmih.biCompression = BI_RGB; memcpy(dibBits, xorBitmapBits, xorLength);
}
}
hXorBits = CreateDIBSection(hdc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, if (hXorBits)
(void*)&dibBits, NULL, 0);
if (hXorBits && dibBits)
{ {
if(has_alpha) if(has_alpha)
{ {
BLENDFUNCTION pixelblend = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; BLENDFUNCTION pixelblend = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
/* Do the alpha blending render */ /* Do the alpha blending render */
premultiply_alpha_channel(dibBits, xorBitmapBits, xorLength);
hBitTemp = SelectObject( hMemDC, hXorBits ); hBitTemp = SelectObject( hMemDC, hXorBits );
if (DoOffscreen) if (DoOffscreen)
@ -2329,7 +2341,6 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon,
} }
else else
{ {
memcpy(dibBits, xorBitmapBits, xorLength);
hBitTemp = SelectObject( hMemDC, hXorBits ); hBitTemp = SelectObject( hMemDC, hXorBits );
if (DoOffscreen) if (DoOffscreen)
StretchBlt (hDC_off, 0, 0, cxWidth, cyWidth, StretchBlt (hDC_off, 0, 0, cxWidth, cyWidth,