Module: wine Branch: master Commit: 0cd8502b493e7a93df7aad08bc2fdfe3fd73b5cc URL: https://source.winehq.org/git/wine.git/?a=commit;h=0cd8502b493e7a93df7aad08b...
Author: Dmitry Timoshkov dmitry@baikal.ru Date: Tue Apr 21 12:02:15 2020 +0800
windowscodecs: Add support for 4bps RGBA format to TIFF decoder.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru Signed-off-by: Vincent Povirk vincent@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/windowscodecs/tiffformat.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c index b0c422a440..33d3a3c992 100644 --- a/dlls/windowscodecs/tiffformat.c +++ b/dlls/windowscodecs/tiffformat.c @@ -1147,6 +1147,45 @@ static HRESULT TiffFrameDecode_ReadTile(TiffFrameDecode *This, UINT tile_x, UINT
HeapFree(GetProcessHeap(), 0, srcdata); } + /* 4bps RGBA */ + else if (This->decode_info.source_bpp == 4 && This->decode_info.samples == 4 && This->decode_info.bpp == 32) + { + BYTE *srcdata, *src, *dst; + DWORD x, y, count, width_bytes = (This->decode_info.tile_width * 3 + 7) / 8; + + count = width_bytes * This->decode_info.tile_height; + + srcdata = HeapAlloc(GetProcessHeap(), 0, count); + if (!srcdata) return E_OUTOFMEMORY; + memcpy(srcdata, This->cached_tile, count); + + for (y = 0; y < This->decode_info.tile_height; y++) + { + src = srcdata + y * width_bytes; + dst = This->cached_tile + y * This->decode_info.tile_width * 4; + + /* 1 source byte expands to 2 BGRA samples */ + + for (x = 0; x < This->decode_info.tile_width; x += 2) + { + dst[0] = (src[0] & 0x20) ? 0xff : 0; /* B */ + dst[1] = (src[0] & 0x40) ? 0xff : 0; /* G */ + dst[2] = (src[0] & 0x80) ? 0xff : 0; /* R */ + dst[3] = (src[0] & 0x10) ? 0xff : 0; /* A */ + if (x + 1 < This->decode_info.tile_width) + { + dst[4] = (src[0] & 0x02) ? 0xff : 0; /* B */ + dst[5] = (src[0] & 0x04) ? 0xff : 0; /* G */ + dst[6] = (src[0] & 0x08) ? 0xff : 0; /* R */ + dst[7] = (src[0] & 0x01) ? 0xff : 0; /* A */ + } + src++; + dst += 8; + } + } + + HeapFree(GetProcessHeap(), 0, srcdata); + } /* 8bpp grayscale with extra alpha */ else if (This->decode_info.source_bpp == 16 && This->decode_info.samples == 2 && This->decode_info.bpp == 32) {