From 8ac531959a224be46364b5cc47023cbf4e4a4459 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Fri, 19 Mar 2010 17:11:50 -0500 Subject: [PATCH 08/11] windowscodecs: Add support for decoding RGB TIFF images. --- dlls/windowscodecs/tiffformat.c | 45 +++++++++++++++++++++++++++++++++++++- 1 files changed, 43 insertions(+), 2 deletions(-) diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c index a7ac25d..a13f90e 100644 --- a/dlls/windowscodecs/tiffformat.c +++ b/dlls/windowscodecs/tiffformat.c @@ -219,7 +219,7 @@ static const IWICBitmapFrameDecodeVtbl TiffFrameDecode_Vtbl; static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info) { - uint16 photometric, bps; + uint16 photometric, bps, samples, planar; int ret; decode_info->indexed = 0; @@ -255,6 +255,29 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info) return E_FAIL; } break; + case 2: /* RGB */ + if (bps != 8) + { + FIXME("unhandled RGB bit count %u\n", bps); + return E_FAIL; + } + ret = pTIFFGetField(tiff, TIFFTAG_SAMPLESPERPIXEL, &samples); + if (samples != 3) + { + FIXME("unhandled RGB sample count %u\n", samples); + return E_FAIL; + } + ret = pTIFFGetField(tiff, TIFFTAG_PLANARCONFIG, &planar); + if (!ret) planar = 1; + if (planar != 1) + { + FIXME("unhandled planar configuration %u\n", planar); + return E_FAIL; + } + decode_info->bpp = bps * samples; + decode_info->reverse_bgr = 1; + decode_info->format = &GUID_WICPixelFormat24bppBGR; + break; case 3: /* RGB Palette */ decode_info->indexed = 1; decode_info->bpp = bps; @@ -272,7 +295,6 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info) } break; case 0: /* WhiteIsZero */ - case 2: /* RGB */ case 4: /* Transparency mask */ case 5: /* CMYK */ case 6: /* YCbCr */ @@ -650,6 +672,25 @@ static HRESULT TiffFrameDecode_ReadTile(TiffFrameDecode *This, UINT tile_x, UINT hr = E_FAIL; } + if (hr == S_OK && This->decode_info.reverse_bgr) + { + if (This->decode_info.format == &GUID_WICPixelFormat24bppBGR) + { + UINT i, total_pixels; + BYTE *pixel, temp; + + total_pixels = This->decode_info.tile_width * This->decode_info.tile_height; + pixel = This->cached_tile; + for (i=0; icached_tile_x = tile_x; -- 1.6.3.3