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; }
Dmitry Timoshkov dmitry@baikal.ru writes:
@@ -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);
If the test succeeds both before and after this change, doesn't it mean that 2bpp is never actually tested? What's the point of this test?
Alexandre Julliard julliard@winehq.org wrote:
@@ -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);
If the test succeeds both before and after this change, doesn't it mean that 2bpp is never actually tested? What's the point of this test?
It means that the original test is broken, and I had to fix it after adding actual support for it in Wine. That also means that since 2bpp is not supported under Windows I missed that the test is broken while running the test under Windows.
Dmitry Timoshkov dmitry@baikal.ru writes:
Alexandre Julliard julliard@winehq.org wrote:
@@ -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);
If the test succeeds both before and after this change, doesn't it mean that 2bpp is never actually tested? What's the point of this test?
It means that the original test is broken, and I had to fix it after adding actual support for it in Wine.
Well, the broken test is added in your 1/9 patch...
That also means that since 2bpp is not supported under Windows I missed that the test is broken while running the test under Windows.
Which is my point, if 2bpp is not supported on Windows what's the point of supporting it in Wine? And having a test for it?
It seems to me that the correct test would be to verify that 2bpp doesn't work, and then Wine should conform to that.
Alexandre Julliard julliard@winehq.org wrote:
@@ -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);
If the test succeeds both before and after this change, doesn't it mean that 2bpp is never actually tested? What's the point of this test?
It means that the original test is broken, and I had to fix it after adding actual support for it in Wine.
Well, the broken test is added in your 1/9 patch...
That's correct, and I didn't notice that until I've spotted it.
That also means that since 2bpp is not supported under Windows I missed that the test is broken while running the test under Windows.
Which is my point, if 2bpp is not supported on Windows what's the point of supporting it in Wine? And having a test for it?
It seems to me that the correct test would be to verify that 2bpp doesn't work, and then Wine should conform to that.
The thing is that I first added support for palette formats in Wine, and only after that added the tests and discovered that 2bpp format is not supported under Windows. Then I just decided to leave the implementation and mark the tests as broken. The reasoning that since there is an official GUID for 2bpp format then nothing prevents it to be implemented in the codec: even if Microsoft codecs don't support it other codecs may have this format supported.
Dmitry Timoshkov dmitry@baikal.ru wrote:
Well, the broken test is added in your 1/9 patch...
That's correct, and I didn't notice that until I've spotted it.
s/until I've spotted it/until you've spotted it/
Dmitry Timoshkov dmitry@baikal.ru writes:
The thing is that I first added support for palette formats in Wine, and only after that added the tests and discovered that 2bpp format is not supported under Windows. Then I just decided to leave the implementation and mark the tests as broken. The reasoning that since there is an official GUID for 2bpp format then nothing prevents it to be implemented in the codec: even if Microsoft codecs don't support it other codecs may have this format supported.
I suggest we leave it out until we find something that actually depends on this, and in the meantime we make the test conform to the Windows behavior.