From fb6aa772cde44c68699a788b3a4a1cf7e633ec91 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 21 Jul 2004 21:19:08 +0000 Subject: [PATCH] Fix CreateMappedBitmap for palette-less bitmaps. --- dlls/comctl32/commctrl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dlls/comctl32/commctrl.c b/dlls/comctl32/commctrl.c index 2eb5436b445..9ebd479afe1 100644 --- a/dlls/comctl32/commctrl.c +++ b/dlls/comctl32/commctrl.c @@ -862,7 +862,12 @@ CreateMappedBitmap (HINSTANCE hInstance, INT idBitmap, UINT wFlags, if (lpBitmap == NULL) return 0; - nColorTableSize = (1 << lpBitmap->biBitCount); + if (lpBitmap->biSize >= sizeof(BITMAPINFOHEADER) && lpBitmap->biClrUsed) + nColorTableSize = lpBitmap->biClrUsed; + else if (lpBitmap->biBitCount <= 8) + nColorTableSize = (1 << lpBitmap->biBitCount); + else + nColorTableSize = 0; nSize = lpBitmap->biSize + nColorTableSize * sizeof(RGBQUAD); lpBitmapInfo = (LPBITMAPINFOHEADER)GlobalAlloc (GMEM_FIXED, nSize); if (lpBitmapInfo == NULL) @@ -899,7 +904,7 @@ CreateMappedBitmap (HINSTANCE hInstance, INT idBitmap, UINT wFlags, HDC hdcDst = CreateCompatibleDC (hdcScreen); HBITMAP hbmOld = SelectObject (hdcDst, hbm); LPBYTE lpBits = (LPBYTE)(lpBitmap + 1); - lpBits += (1 << (lpBitmapInfo->biBitCount)) * sizeof(RGBQUAD); + lpBits += nColorTableSize * sizeof(RGBQUAD); StretchDIBits (hdcDst, 0, 0, nWidth, nHeight, 0, 0, nWidth, nHeight, lpBits, (LPBITMAPINFO)lpBitmapInfo, DIB_RGB_COLORS, SRCCOPY);