Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/windowscodecs/regsvr.c | 6 ++++++ dlls/windowscodecs/tests/converter.c | 23 +++++++++++++++-------- dlls/windowscodecs/tiffformat.c | 26 ++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 8 deletions(-)
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c index b011d71645..b32b294d72 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 c221f3b99e..d859c8dda0 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)) { @@ -1151,8 +1151,9 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls memcpy(&pixelformat, srcs[i]->format, sizeof(GUID)); hr = IWICBitmapFrameEncode_SetPixelFormat(frameencode, &pixelformat); ok(SUCCEEDED(hr), "SetPixelFormat failed, hr=%x\n", hr); - ok(IsEqualGUID(&pixelformat, dsts[i]->format), "SetPixelFormat changed the format to %s (%s)\n", - wine_dbgstr_guid(&pixelformat), name); + ok(IsEqualGUID(&pixelformat, dsts[i]->format) || + broken(IsEqualGUID(clsid_encoder, &CLSID_WICTiffEncoder) && srcs[i]->bpp == 2 && IsEqualGUID(&pixelformat, &GUID_WICPixelFormat4bppIndexed)), + "SetPixelFormat changed the format to %s (%s)\n", wine_dbgstr_guid(&pixelformat), name);
hr = IWICBitmapFrameEncode_SetSize(frameencode, srcs[i]->width, srcs[i]->height); ok(SUCCEEDED(hr), "SetSize failed, hr=%x\n", hr); @@ -1315,6 +1316,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); @@ -1504,8 +1514,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, @@ -1514,7 +1522,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 f43b330547..ac98d7dcdb 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; }
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=45228
Your paranoid android.
=== wxppro (32 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== w2003std (32 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== wvistau64 (32 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== wvistau64_zh_CN (32 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== wvistau64_fr (32 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== wvistau64_he (32 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== w2008s64 (32 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== w7u (32 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== w7pro64 (32 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== w8 (32 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== w8adm (32 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== w864 (32 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== w1064 (32 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== wvistau64 (64 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== w2008s64 (64 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== w7pro64 (64 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== w864 (64 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)
=== w1064 (64 bit report) ===
windowscodecs: converter.c:1154: Test failed: SetPixelFormat changed the format to {6fddc324-4e03-4bfe-b185-3d77768dc903} (BMP encoder 2bppIndexed)