Fix CreateMappedBitmap for palette-less bitmaps.
This commit is contained in:
parent
c846f88fa2
commit
fb6aa772cd
@ -862,7 +862,12 @@ CreateMappedBitmap (HINSTANCE hInstance, INT idBitmap, UINT wFlags,
|
|||||||
if (lpBitmap == NULL)
|
if (lpBitmap == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (lpBitmap->biSize >= sizeof(BITMAPINFOHEADER) && lpBitmap->biClrUsed)
|
||||||
|
nColorTableSize = lpBitmap->biClrUsed;
|
||||||
|
else if (lpBitmap->biBitCount <= 8)
|
||||||
nColorTableSize = (1 << lpBitmap->biBitCount);
|
nColorTableSize = (1 << lpBitmap->biBitCount);
|
||||||
|
else
|
||||||
|
nColorTableSize = 0;
|
||||||
nSize = lpBitmap->biSize + nColorTableSize * sizeof(RGBQUAD);
|
nSize = lpBitmap->biSize + nColorTableSize * sizeof(RGBQUAD);
|
||||||
lpBitmapInfo = (LPBITMAPINFOHEADER)GlobalAlloc (GMEM_FIXED, nSize);
|
lpBitmapInfo = (LPBITMAPINFOHEADER)GlobalAlloc (GMEM_FIXED, nSize);
|
||||||
if (lpBitmapInfo == NULL)
|
if (lpBitmapInfo == NULL)
|
||||||
@ -899,7 +904,7 @@ CreateMappedBitmap (HINSTANCE hInstance, INT idBitmap, UINT wFlags,
|
|||||||
HDC hdcDst = CreateCompatibleDC (hdcScreen);
|
HDC hdcDst = CreateCompatibleDC (hdcScreen);
|
||||||
HBITMAP hbmOld = SelectObject (hdcDst, hbm);
|
HBITMAP hbmOld = SelectObject (hdcDst, hbm);
|
||||||
LPBYTE lpBits = (LPBYTE)(lpBitmap + 1);
|
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,
|
StretchDIBits (hdcDst, 0, 0, nWidth, nHeight, 0, 0, nWidth, nHeight,
|
||||||
lpBits, (LPBITMAPINFO)lpBitmapInfo, DIB_RGB_COLORS,
|
lpBits, (LPBITMAPINFO)lpBitmapInfo, DIB_RGB_COLORS,
|
||||||
SRCCOPY);
|
SRCCOPY);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user