From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/tests/tiffformat.c | 90 ++++++++++++++++++++++++--- 1 file changed, 81 insertions(+), 9 deletions(-)
diff --git a/dlls/windowscodecs/tests/tiffformat.c b/dlls/windowscodecs/tests/tiffformat.c index 152a02b9edf..2cf232429b7 100644 --- a/dlls/windowscodecs/tests/tiffformat.c +++ b/dlls/windowscodecs/tests/tiffformat.c @@ -292,8 +292,9 @@ static const struct tiff_4bps_bgra struct IFD_entry entry[14]; ULONG next_IFD; struct IFD_rational res; - BYTE pixel_data[4]; -} tiff_4bps_bgra = + BYTE pixel_data[6]; +} tiff_4bps_bgra[2] = +{ { 'I' | 'I' << 8, 42, @@ -318,6 +319,32 @@ static const struct tiff_4bps_bgra 0, { 96, 1 }, { 0x12,0x30, 0x47,0xe0 } +}, +{ + 'I' | 'I' << 8, + 42, + FIELD_OFFSET(struct tiff_4bps_bgra, number_of_entries), + 14, + { + { 0xff, IFD_SHORT, 1, 0 }, /* SUBFILETYPE */ + { 0x100, IFD_LONG, 1, 5 }, /* IMAGEWIDTH */ + { 0x101, IFD_LONG, 1, 2 }, /* IMAGELENGTH */ + { 0x102, IFD_SHORT, 1, 1 }, /* BITSPERSAMPLE */ + { 0x103, IFD_SHORT, 1, 1 }, /* COMPRESSION */ + { 0x106, IFD_SHORT, 1, 2 }, /* PHOTOMETRIC */ + { 0x111, IFD_LONG, 1, FIELD_OFFSET(struct tiff_4bps_bgra, pixel_data) }, /* STRIPOFFSETS */ + { 0x115, IFD_SHORT, 1, 4 }, /* SAMPLESPERPIXEL */ + { 0x116, IFD_LONG, 1, 2 }, /* ROWSPERSTRIP */ + { 0x117, IFD_LONG, 1, 4 }, /* STRIPBYTECOUNT */ + { 0x11a, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_4bps_bgra, res) }, /* XRESOLUTION */ + { 0x11b, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_4bps_bgra, res) }, /* YRESOLUTION */ + { 0x11c, IFD_SHORT, 1, 1 }, /* PLANARCONFIGURATION */ + { 0x128, IFD_SHORT, 1, 2 } /* RESOLUTIONUNIT */ + }, + 0, + { 96, 1 }, + { 0x12,0x34,0x70, 0xe8,0xf0,0xa0 } +}, }; #include "poppack.h"
@@ -1244,11 +1271,22 @@ static void test_tiff_4bps_bgra(void) IWICPalette *palette; GUID format; WICRect rc; - BYTE data[24]; - static const BYTE expected_data[24] = { 0,0,0,0xff, 0xff,0,0,0, 0xff,0,0,0xff, - 0,0xff,0,0, 0xff,0xff,0,0xff, 0xff,0xff,0xff,0 }; + DWORD data[10]; + + static const DWORD expected_data_3x2[6] = + { + 0xff000000, 0x000000ff, 0xff0000ff, + 0x0000ff00, 0xff00ffff, 0x00ffffff, + }; + + static const DWORD expected_data_5x2[10] = + { + 0xff000000, 0x000000ff, 0xff0000ff, 0x0000ff00, 0xff00ffff, + 0x00ffffff, 0x00ff0000, 0xffffffff, 0x00000000, 0x00ff00ff, + };
- hr = create_decoder(&tiff_4bps_bgra, sizeof(tiff_4bps_bgra), &decoder); + /* 3x2 */ + hr = create_decoder(&tiff_4bps_bgra[0], sizeof(tiff_4bps_bgra[0]), &decoder); ok(hr == S_OK, "Failed to load TIFF image data %#lx\n", hr); if (hr != S_OK) return;
@@ -1286,11 +1324,45 @@ static void test_tiff_4bps_bgra(void) rc.Y = 0; rc.Width = 3; rc.Height = 2; - hr = IWICBitmapFrameDecode_CopyPixels(frame, &rc, 12, sizeof(data), data); + hr = IWICBitmapFrameDecode_CopyPixels(frame, &rc, 12, sizeof(data), (BYTE *)data); ok(hr == S_OK, "CopyPixels error %#lx\n", hr);
- for (i = 0; i < sizeof(data); i++) - ok(data[i] == expected_data[i], "%u: expected %02x, got %02x\n", i, expected_data[i], data[i]); + for (i = 0; i < 6; i++) + ok(data[i] == expected_data_3x2[i], "%u: expected %08lx, got %08lx\n", i, expected_data_3x2[i], data[i]); + + IWICBitmapFrameDecode_Release(frame); + IWICBitmapDecoder_Release(decoder); + + /* 5x2 */ + hr = create_decoder(&tiff_4bps_bgra[1], sizeof(tiff_4bps_bgra[1]), &decoder); + ok(hr == S_OK, "Failed to load TIFF image data %#lx\n", hr); + + hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); + ok(hr == S_OK, "GetFrame error %#lx\n", hr); + + hr = IWICBitmapFrameDecode_GetSize(frame, &width, &height); + ok(hr == S_OK, "GetSize error %#lx\n", hr); + ok(width == 5, "got %u\n", width); + ok(height == 2, "got %u\n", height); + + hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format); + ok(hr == S_OK, "GetPixelFormat error %#lx\n", hr); + ok(IsEqualGUID(&format, &GUID_WICPixelFormat32bppBGRA), + "got wrong format %s\n", wine_dbgstr_guid(&format)); + + memset(data, 0xaa, sizeof(data)); + rc.X = 0; + rc.Y = 0; + rc.Width = 5; + rc.Height = 2; + hr = IWICBitmapFrameDecode_CopyPixels(frame, &rc, 20, sizeof(data), (BYTE *)data); + ok(hr == S_OK, "CopyPixels error %#lx\n", hr); + + for (i = 0; i < 10; i++) + { + todo_wine_if(i >= 5 && i <= 9) + ok(data[i] == expected_data_5x2[i], "%u: expected %08lx, got %08lx\n", i, expected_data_5x2[i], data[i]); + }
IWICBitmapFrameDecode_Release(frame); IWICBitmapDecoder_Release(decoder);
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/libtiff.c | 2 +- dlls/windowscodecs/tests/tiffformat.c | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/dlls/windowscodecs/libtiff.c b/dlls/windowscodecs/libtiff.c index b88ccb68b62..98ad376f431 100644 --- a/dlls/windowscodecs/libtiff.c +++ b/dlls/windowscodecs/libtiff.c @@ -782,7 +782,7 @@ static HRESULT tiff_decoder_read_tile(struct tiff_decoder *This, UINT tile_x, UI else if (info->source_bpp == 4 && info->samples == 4 && info->frame.bpp == 32) { BYTE *srcdata, *src, *dst; - DWORD x, y, count, width_bytes = (info->tile_width * 3 + 7) / 8; + DWORD x, y, count, width_bytes = (info->tile_width * 4 + 7) / 8;
count = width_bytes * info->tile_height;
diff --git a/dlls/windowscodecs/tests/tiffformat.c b/dlls/windowscodecs/tests/tiffformat.c index 2cf232429b7..e483e68ceea 100644 --- a/dlls/windowscodecs/tests/tiffformat.c +++ b/dlls/windowscodecs/tests/tiffformat.c @@ -1359,10 +1359,7 @@ static void test_tiff_4bps_bgra(void) ok(hr == S_OK, "CopyPixels error %#lx\n", hr);
for (i = 0; i < 10; i++) - { - todo_wine_if(i >= 5 && i <= 9) ok(data[i] == expected_data_5x2[i], "%u: expected %08lx, got %08lx\n", i, expected_data_5x2[i], data[i]); - }
IWICBitmapFrameDecode_Release(frame); IWICBitmapDecoder_Release(decoder);
This merge request was approved by Esme Povirk.