mirror of
https://github.com/reactos/reactos.git
synced 2024-06-29 01:12:06 +00:00
Display icons/cursors correctly without hungup. CORE-16287
This commit is contained in:
parent
974a0f03df
commit
0360abb796
|
@ -508,12 +508,29 @@ static UINT ICO_ExtractIconExW(
|
||||||
HICON icon;
|
HICON icon;
|
||||||
WORD *cursorData = NULL;
|
WORD *cursorData = NULL;
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
BITMAPINFOHEADER bmih;
|
BITMAPINFOHEADER bi;
|
||||||
|
DWORD cbColorTable = 0, cbTotal;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
imageData = peimage + dataOffset;
|
imageData = peimage + dataOffset;
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
memcpy(&bmih, imageData, sizeof(BITMAPINFOHEADER));
|
/* Calculate the size of color table */
|
||||||
|
CopyMemory(&bi, imageData, sizeof(BITMAPCOREHEADER));
|
||||||
|
if (bi.biBitCount <= 8)
|
||||||
|
{
|
||||||
|
if (bi.biSize >= sizeof(BITMAPINFOHEADER))
|
||||||
|
{
|
||||||
|
CopyMemory(&bi, imageData, sizeof(BITMAPINFOHEADER));
|
||||||
|
if (bi.biClrUsed)
|
||||||
|
cbColorTable = bi.biClrUsed * sizeof(RGBQUAD);
|
||||||
|
else
|
||||||
|
cbColorTable = (1 << bi.biBitCount) * sizeof(RGBQUAD);
|
||||||
|
}
|
||||||
|
else if (bi.biSize == sizeof(BITMAPCOREHEADER))
|
||||||
|
{
|
||||||
|
cbColorTable = (1 << bi.biBitCount) * sizeof(RGBTRIPLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
entry = (LPICONIMAGE)(imageData);
|
entry = (LPICONIMAGE)(imageData);
|
||||||
#endif
|
#endif
|
||||||
|
@ -521,18 +538,23 @@ static UINT ICO_ExtractIconExW(
|
||||||
if(sig == 2)
|
if(sig == 2)
|
||||||
{
|
{
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
/* biSizeImage is the size of the raw bitmap data.
|
/* biSizeImage is the size of the raw bitmap data.
|
||||||
* A dummy 0 can be given for BI_RGB bitmaps.
|
* A dummy 0 can be given for BI_RGB bitmaps.
|
||||||
* https://en.wikipedia.org/wiki/BMP_file_format */
|
* https://en.wikipedia.org/wiki/BMP_file_format */
|
||||||
if ((bmih.biCompression == BI_RGB) && (bmih.biSizeImage == 0))
|
if (bi.biSizeImage == 0 || bi.biSize == sizeof(BITMAPCOREHEADER))
|
||||||
{
|
{
|
||||||
bmih.biSizeImage = ((bmih.biWidth * bmih.biBitCount + 31) / 32) * 4 *
|
/* Calculate image size */
|
||||||
(bmih.biHeight / 2);
|
#define WIDTHBYTES(width, bits) (((width) * (bits) + 31) / 32 * 4)
|
||||||
}
|
bi.biSizeImage = WIDTHBYTES(bi.biWidth, bi.biBitCount) * (bi.biHeight / 2);
|
||||||
|
bi.biSizeImage += WIDTHBYTES(bi.biWidth, 1) * (bi.biHeight / 2);
|
||||||
|
#undef WIDTHBYTES
|
||||||
|
}
|
||||||
|
/* Calculate total size */
|
||||||
|
cbTotal = bi.biSize + cbColorTable + bi.biSizeImage;
|
||||||
#endif
|
#endif
|
||||||
/* we need to prepend the bitmap data with hot spots for CreateIconFromResourceEx */
|
/* we need to prepend the bitmap data with hot spots for CreateIconFromResourceEx */
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
cursorData = HeapAlloc(GetProcessHeap(), 0, bmih.biSizeImage + 2 * sizeof(WORD));
|
cursorData = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(WORD) + cbTotal);
|
||||||
#else
|
#else
|
||||||
cursorData = HeapAlloc(GetProcessHeap(), 0, entry->icHeader.biSizeImage + 2 * sizeof(WORD));
|
cursorData = HeapAlloc(GetProcessHeap(), 0, entry->icHeader.biSizeImage + 2 * sizeof(WORD));
|
||||||
#endif
|
#endif
|
||||||
|
@ -544,7 +566,7 @@ static UINT ICO_ExtractIconExW(
|
||||||
cursorData[1] = hotSpot.y;
|
cursorData[1] = hotSpot.y;
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
memcpy(cursorData + 2, imageData, bmih.biSizeImage);
|
CopyMemory(cursorData + 2, imageData, cbTotal);
|
||||||
#else
|
#else
|
||||||
memcpy(cursorData + 2, imageData, entry->icHeader.biSizeImage);
|
memcpy(cursorData + 2, imageData, entry->icHeader.biSizeImage);
|
||||||
#endif
|
#endif
|
||||||
|
@ -553,7 +575,7 @@ static UINT ICO_ExtractIconExW(
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
icon = CreateIconFromResourceEx(imageData, bmih.biSizeImage, sig == 1, 0x00030000, cx[index], cy[index], flags);
|
icon = CreateIconFromResourceEx(imageData, cbTotal, sig == 1, 0x00030000, cx[index], cy[index], flags);
|
||||||
#else
|
#else
|
||||||
icon = CreateIconFromResourceEx(imageData, entry->icHeader.biSizeImage, sig == 1, 0x00030000, cx[index], cy[index], flags);
|
icon = CreateIconFromResourceEx(imageData, entry->icHeader.biSizeImage, sig == 1, 0x00030000, cx[index], cy[index], flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue