Module: wine Branch: master Commit: 5d7cd195566e2c5b489ed8650a8dcf7ec0a76c8c URL: http://source.winehq.org/git/wine.git/?a=commit;h=5d7cd195566e2c5b489ed8650a...
Author: Vincent Povirk vincent@codeweavers.com Date: Thu Aug 20 14:28:04 2009 -0500
windowscodecs: Implement CopyPixels for 24-bit ICO icons.
---
dlls/windowscodecs/icoformat.c | 51 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/dlls/windowscodecs/icoformat.c b/dlls/windowscodecs/icoformat.c index cb545a1..a6c7af3 100644 --- a/dlls/windowscodecs/icoformat.c +++ b/dlls/windowscodecs/icoformat.c @@ -249,6 +249,57 @@ static HRESULT IcoFrameDecode_ReadPixels(IcoFrameDecode *This) HeapFree(GetProcessHeap(), 0, tempdata); break; } + case 24: + { + UINT xorBytesPerRow = (width*3+3)/4*4; + UINT xorBytes = xorBytesPerRow * height; + INT xorStride; + BYTE *xorRow; + BYTE *bitsRow; + UINT x, y; + + tempdata = HeapAlloc(GetProcessHeap(), 0, xorBytes); + if (!tempdata) + { + hr = E_OUTOFMEMORY; + goto fail; + } + + hr = IStream_Read(This->parent->stream, tempdata, xorBytes, &bytesread); + if (FAILED(hr) || bytesread != xorBytes) goto fail; + + if (bih.biHeight > 0) /* bottom-up DIB */ + { + xorStride = -xorBytesPerRow; + xorRow = tempdata + (height-1)*xorBytesPerRow; + } + else /* top-down DIB */ + { + xorStride = xorBytesPerRow; + xorRow = tempdata; + } + + bits = HeapAlloc(GetProcessHeap(), 0, bitsSize); + + /* copy BGR->BGRA */ + bitsRow = bits; + for (y=0; y<height; y++) { + BYTE *xorByte=xorRow; + BYTE *bitsByte=bitsRow; + for (x=0; x<width; x++) + { + *bitsByte++ = *xorByte++; /* blue */ + *bitsByte++ = *xorByte++; /* green */ + *bitsByte++ = *xorByte++; /* red */ + bitsByte++; /* alpha */ + } + xorRow += xorStride; + bitsRow += bitsStride; + } + + HeapFree(GetProcessHeap(), 0, tempdata); + break; + } default: FIXME("unsupported bitcount: %u\n", This->entry.wBitCount); goto fail;