windowscodecs: fix ICO palette size calculation
Damjan Jovanovic
damjan.jov at gmail.com
Sat May 22 00:57:54 CDT 2010
Changelog:
* fix ICO palette size calculation
The current code works out the ICO palette size using the
ICONDIRENTRY's bColorCount, which can apparently be wrong, resulting
in too few colours read -> wrong offset to pixels and wrong AND mask
-> badly corrupted image. Rather use the BITMAPINFOHEADER's biClrUsed
the way winemenubuilder does.
Damjan Jovanovic
-------------- next part --------------
diff --git a/dlls/windowscodecs/icoformat.c b/dlls/windowscodecs/icoformat.c
index 180dbb3..8012b4e 100644
--- a/dlls/windowscodecs/icoformat.c
+++ b/dlls/windowscodecs/icoformat.c
@@ -192,7 +192,7 @@ static HRESULT IcoFrameDecode_ReadPixels(IcoFrameDecode *This)
if (bih.biBitCount <= 8)
{
/* read the palette */
- colorcount = This->entry.bColorCount ? This->entry.bColorCount : 256;
+ colorcount = bih.biClrUsed ? bih.biClrUsed : 1 << bih.biBitCount;
hr = IStream_Read(This->parent->stream, colors, sizeof(RGBQUAD)*colorcount, &bytesread);
if (FAILED(hr) || bytesread != sizeof(RGBQUAD)*colorcount) goto fail;
More information about the wine-patches
mailing list