Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/windowscodecs/regsvr.c | 6 ++++++ dlls/windowscodecs/tests/converter.c | 18 ++++++++++++------ dlls/windowscodecs/tiffformat.c | 26 ++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c index 3f53591552..05c8f03a3d 100644 --- a/dlls/windowscodecs/regsvr.c +++ b/dlls/windowscodecs/regsvr.c @@ -1211,6 +1211,8 @@ static GUID const * const tiff_decode_formats[] = { &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat8bppGray, + &GUID_WICPixelFormat1bppIndexed, + &GUID_WICPixelFormat2bppIndexed, &GUID_WICPixelFormat4bppIndexed, &GUID_WICPixelFormat8bppIndexed, &GUID_WICPixelFormat24bppBGR, @@ -1370,6 +1372,10 @@ static GUID const * const tiff_encode_formats[] = { &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat8bppGray, + &GUID_WICPixelFormat1bppIndexed, + &GUID_WICPixelFormat2bppIndexed, + &GUID_WICPixelFormat4bppIndexed, + &GUID_WICPixelFormat8bppIndexed, &GUID_WICPixelFormat24bppBGR, &GUID_WICPixelFormat32bppBGRA, &GUID_WICPixelFormat32bppPBGRA, diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c index 8072064b48..13c50d7dff 100644 --- a/dlls/windowscodecs/tests/converter.c +++ b/dlls/windowscodecs/tests/converter.c @@ -752,13 +752,13 @@ static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format) } else if (IsEqualGUID(format, &GUID_WICPixelFormat2bppIndexed)) { - ok(width == 32, "wrong width %u\n", width); + ok(width == 16, "wrong width %u\n", width); ok(height == 2, "wrong height %u\n", height);
- ok(bps == 1, "wrong bps %d\n", bps); + ok(bps == 2, "wrong bps %d\n", bps); ok(photo == 3, "wrong photometric %d\n", photo); ok(samples == 1, "wrong samples %d\n", samples); - ok(colormap == 6, "wrong colormap %d\n", colormap); + ok(colormap == 12, "wrong colormap %d\n", colormap); } else if (IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed)) { @@ -1341,6 +1341,15 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls ok(colors[4] == 0xff555555, "got %08x (%s)\n", colors[4], name); ok(colors[5] == 0xff000000, "got %08x (%s)\n", colors[5], name); } + else if (IsEqualGUID(dsts[i]->format, &GUID_WICPixelFormat2bppIndexed)) + { + ok(count == 4, "expected 4, got %u (%s)\n", count, name); + + ok(colors[0] == 0xff111111, "got %08x (%s)\n", colors[0], name); + ok(colors[1] == 0xff222222, "got %08x (%s)\n", colors[1], name); + ok(colors[2] == 0xff333333, "got %08x (%s)\n", colors[2], name); + ok(colors[3] == 0xff444444, "got %08x (%s)\n", colors[3], name); + } else if (IsEqualGUID(dsts[i]->format, &GUID_WICPixelFormat4bppIndexed)) { ok(count == 16, "expected 16, got %u (%s)\n", count, name); @@ -1530,8 +1539,6 @@ if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in
test_encoder(&testdata_BlackWhite, &CLSID_WICTiffEncoder, &testdata_BlackWhite, &CLSID_WICTiffDecoder, "TIFF encoder BlackWhite"); -if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in Wine */ -{ test_encoder(&testdata_1bppIndexed, &CLSID_WICTiffEncoder, &testdata_1bppIndexed, &CLSID_WICTiffDecoder, "TIFF encoder 1bppIndexed"); test_encoder(&testdata_2bppIndexed, &CLSID_WICTiffEncoder, @@ -1540,7 +1547,6 @@ if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in &testdata_4bppIndexed, &CLSID_WICTiffDecoder, "TIFF encoder 4bppIndexed"); test_encoder(&testdata_8bppIndexed, &CLSID_WICTiffEncoder, &testdata_8bppIndexed, &CLSID_WICTiffDecoder, "TIFF encoder 8bppIndexed"); -} test_encoder(&testdata_24bppBGR, &CLSID_WICTiffEncoder, &testdata_24bppBGR, &CLSID_WICTiffDecoder, "TIFF encoder 24bppBGR");
diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c index 81c6394a52..62476a9bb9 100644 --- a/dlls/windowscodecs/tiffformat.c +++ b/dlls/windowscodecs/tiffformat.c @@ -1,5 +1,6 @@ /* * Copyright 2010 Vincent Povirk for CodeWeavers + * Copyright 2016 Dmitry Timoshkov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -461,6 +462,12 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info) decode_info->bpp = bps; switch (bps) { + case 1: + decode_info->format = &GUID_WICPixelFormat1bppIndexed; + break; + case 2: + decode_info->format = &GUID_WICPixelFormat2bppIndexed; + break; case 4: decode_info->format = &GUID_WICPixelFormat4bppIndexed; break; @@ -1408,6 +1415,10 @@ static const struct tiff_encode_format formats[] = { {&GUID_WICPixelFormat48bppRGB, 2, 16, 3, 48, 0, 0, 0}, {&GUID_WICPixelFormat64bppRGBA, 2, 16, 4, 64, 1, 2, 0}, {&GUID_WICPixelFormat64bppPRGBA, 2, 16, 4, 64, 1, 1, 0}, + {&GUID_WICPixelFormat1bppIndexed, 3, 1, 1, 1, 0, 0, 0}, + {&GUID_WICPixelFormat2bppIndexed, 3, 2, 1, 2, 0, 0, 0}, + {&GUID_WICPixelFormat4bppIndexed, 3, 4, 1, 4, 0, 0, 0}, + {&GUID_WICPixelFormat8bppIndexed, 3, 8, 1, 8, 0, 0, 0}, {0} };
@@ -1690,6 +1701,21 @@ static HRESULT WINAPI TiffFrameEncode_WritePixels(IWICBitmapFrameEncode *iface, pTIFFSetField(This->parent->tiff, TIFFTAG_YRESOLUTION, (float)This->yres); }
+ if (This->format->bpp <= 8 && This->colors && !IsEqualGUID(This->format->guid, &GUID_WICPixelFormatBlackWhite)) + { + uint16 red[256], green[256], blue[256]; + UINT i; + + for (i = 0; i < This->colors; i++) + { + red[i] = (This->palette[i] >> 8) & 0xff00; + green[i] = This->palette[i] & 0xff00; + blue[i] = (This->palette[i] << 8) & 0xff00; + } + + pTIFFSetField(This->parent->tiff, TIFFTAG_COLORMAP, red, green, blue); + } + This->info_written = TRUE; }