Dmitry Timoshkov : windowscodecs/tests: Add a test for copying pixels of a 24bpp TIFF format.

Alexandre Julliard julliard at winehq.org
Wed Jan 9 16:57:10 CST 2019


Module: wine
Branch: master
Commit: 8cdef63178ab5375bc7b15dca57c72434c47b8f3
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=8cdef63178ab5375bc7b15dca57c72434c47b8f3

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Wed Jan  9 14:51:09 2019 +0800

windowscodecs/tests: Add a test for copying pixels of a 24bpp TIFF format.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/windowscodecs/tests/tiffformat.c | 103 ++++++++++++++++++++++++++++++++++
 1 file changed, 103 insertions(+)

diff --git a/dlls/windowscodecs/tests/tiffformat.c b/dlls/windowscodecs/tests/tiffformat.c
index 36de69e..8da843b 100644
--- a/dlls/windowscodecs/tests/tiffformat.c
+++ b/dlls/windowscodecs/tests/tiffformat.c
@@ -219,6 +219,46 @@ static struct tiff_resolution_image_data
     { 72, 1 }, /* value will be filled with test data */
     { 0x11, 0x22, 0x33, 0 }
 };
+
+static const struct
+{
+    USHORT byte_order;
+    USHORT version;
+    ULONG  dir_offset;
+    USHORT number_of_entries;
+    struct IFD_entry entry[13];
+    ULONG next_IFD;
+    struct IFD_rational res;
+    BYTE pixel_data[3];
+} tiff_24bpp_data =
+{
+#ifdef WORDS_BIGENDIAN
+    'M' | 'M' << 8,
+#else
+    'I' | 'I' << 8,
+#endif
+    42,
+    FIELD_OFFSET(struct tiff_1bpp_data, number_of_entries),
+    13,
+    {
+        { 0xff, IFD_SHORT, 1, 0 }, /* SUBFILETYPE */
+        { 0x100, IFD_LONG, 1, 1 }, /* IMAGEWIDTH */
+        { 0x101, IFD_LONG, 1, 1 }, /* IMAGELENGTH */
+        { 0x102, IFD_SHORT, 1, 8 }, /* BITSPERSAMPLE */
+        { 0x103, IFD_SHORT, 1, 1 }, /* COMPRESSION: XP doesn't accept IFD_LONG here */
+        { 0x106, IFD_SHORT, 1, 2 }, /* PHOTOMETRIC */
+        { 0x111, IFD_LONG, 1, FIELD_OFFSET(struct tiff_1bpp_data, pixel_data) }, /* STRIPOFFSETS */
+        { 0x115, IFD_SHORT, 1, 3 }, /* SAMPLESPERPIXEL */
+        { 0x116, IFD_LONG, 1, 1 }, /* ROWSPERSTRIP */
+        { 0x117, IFD_LONG, 1, 1 }, /* STRIPBYTECOUNT */
+        { 0x11a, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_1bpp_data, res) }, /* XRESOLUTION */
+        { 0x11b, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_1bpp_data, res) }, /* YRESOLUTION */
+        { 0x128, IFD_SHORT, 1, 2 }, /* RESOLUTIONUNIT */
+    },
+    0,
+    { 900, 3 },
+    { 0x11, 0x22, 0x33 }
+};
 #include "poppack.h"
 
 static IWICImagingFactory *factory;
@@ -509,6 +549,68 @@ static void test_tiff_resolution(void)
     }
 }
 
+static void test_tiff_24bpp(void)
+{
+    HRESULT hr;
+    IWICBitmapDecoder *decoder;
+    IWICBitmapFrameDecode *frame;
+    UINT count, width, height, i, stride;
+    double dpi_x, dpi_y;
+    GUID format;
+    WICRect rc;
+    BYTE data[3];
+    static const BYTE expected_data[] = { 0x33,0x22,0x11 };
+
+    decoder = create_decoder(&tiff_24bpp_data, sizeof(tiff_24bpp_data));
+    ok(decoder != NULL, "Failed to load TIFF image data\n");
+
+    hr = IWICBitmapDecoder_GetFrameCount(decoder, &count);
+    ok(hr == S_OK, "GetFrameCount error %#x\n", hr);
+    ok(count == 1, "got %u\n", count);
+
+    hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
+    ok(hr == S_OK, "GetFrame error %#x\n", hr);
+
+    hr = IWICBitmapFrameDecode_GetSize(frame, &width, &height);
+    ok(hr == S_OK, "GetSize error %#x\n", hr);
+    ok(width == 1, "got %u\n", width);
+    ok(height == 1, "got %u\n", height);
+
+    hr = IWICBitmapFrameDecode_GetResolution(frame, &dpi_x, &dpi_y);
+    ok(hr == S_OK, "GetResolution error %#x\n", hr);
+    ok(dpi_x == 300.0, "got %f\n", dpi_x);
+    ok(dpi_y == 300.0, "got %f\n", dpi_y);
+
+    hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
+    ok(hr == S_OK, "GetPixelFormat error %#x\n", hr);
+    ok(IsEqualGUID(&format, &GUID_WICPixelFormat24bppBGR),
+       "got wrong format %s\n", wine_dbgstr_guid(&format));
+
+    for (stride = 0; stride <= 32; stride++)
+    {
+        memset(data, 0, sizeof(data));
+        rc.X = 0;
+        rc.Y = 0;
+        rc.Width = 1;
+        rc.Height = 1;
+        hr = IWICBitmapFrameDecode_CopyPixels(frame, &rc, stride, sizeof(data), data);
+        if (stride < 3)
+            ok(hr == E_INVALIDARG, "CopyPixels(%u) should fail: %#x\n", stride, hr);
+        else
+        {
+todo_wine_if(stride > 3)
+            ok(hr == S_OK, "CopyPixels(%u) error %#x\n", stride, hr);
+
+            for (i = 0; i < sizeof(data); i++)
+todo_wine_if(stride > 3)
+                ok(data[i] == expected_data[i], "%u: expected %02x, got %02x\n", i, expected_data[i], data[i]);
+        }
+    }
+
+    IWICBitmapFrameDecode_Release(frame);
+    IWICBitmapDecoder_Release(decoder);
+}
+
 START_TEST(tiffformat)
 {
     HRESULT hr;
@@ -524,6 +626,7 @@ START_TEST(tiffformat)
     test_QueryCapability();
     test_tiff_8bpp_alpha();
     test_tiff_resolution();
+    test_tiff_24bpp();
 
     IWICImagingFactory_Release(factory);
     CoUninitialize();




More information about the wine-cvs mailing list