mirror of
https://github.com/reactos/reactos.git
synced 2025-04-25 16:10:29 +00:00
LoadBitmapImage: - add space for 3 RGBQUADs to BITMAPINFO when biCompression is BI_BITFIELDS. Based on patch by Evgeniy Boltik <bstsoft at narod dot ru>, modified by me.
- Take into account BITMAPV4/V5HEADER sizes. See issue #3708 for more details. svn path=/trunk/; revision=39987
This commit is contained in:
parent
9c84f62cd4
commit
004cc56ed5
1 changed files with 14 additions and 6 deletions
|
@ -449,18 +449,26 @@ LoadBitmapImage(HINSTANCE hInstance, LPCWSTR lpszName, UINT fuLoad)
|
|||
BitmapInfo = (LPBITMAPINFO)((ULONG_PTR)BitmapInfo + sizeof(BITMAPFILEHEADER));
|
||||
}
|
||||
|
||||
if (BitmapInfo->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
|
||||
HeaderSize = BitmapInfo->bmiHeader.biSize;
|
||||
if (HeaderSize == sizeof(BITMAPCOREHEADER))
|
||||
{
|
||||
BITMAPCOREHEADER* Core = (BITMAPCOREHEADER*)BitmapInfo;
|
||||
ColorCount = (Core->bcBitCount <= 8) ? (1 << Core->bcBitCount) : 0;
|
||||
HeaderSize = sizeof(BITMAPCOREHEADER) + ColorCount * sizeof(RGBTRIPLE);
|
||||
HeaderSize += ColorCount * sizeof(RGBTRIPLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
ColorCount = BitmapInfo->bmiHeader.biClrUsed;
|
||||
if (ColorCount == 0 && BitmapInfo->bmiHeader.biBitCount <= 8)
|
||||
ColorCount = 1 << BitmapInfo->bmiHeader.biBitCount;
|
||||
HeaderSize = sizeof(BITMAPINFOHEADER) + ColorCount * sizeof(RGBQUAD);
|
||||
if (BitmapInfo->bmiHeader.biCompression == BI_BITFIELDS)
|
||||
{
|
||||
HeaderSize += 3 * sizeof(RGBQUAD);
|
||||
}
|
||||
else
|
||||
{
|
||||
ColorCount = BitmapInfo->bmiHeader.biClrUsed;
|
||||
if (ColorCount == 0 && BitmapInfo->bmiHeader.biBitCount <= 8)
|
||||
ColorCount = 1 << BitmapInfo->bmiHeader.biBitCount;
|
||||
HeaderSize += ColorCount * sizeof(RGBQUAD);
|
||||
}
|
||||
}
|
||||
Data = (PVOID)((ULONG_PTR)BitmapInfo + HeaderSize);
|
||||
|
||||
|
|
Loading…
Reference in a new issue