[1/3] windowscodecs/tests: Make create_decoder() return an error code in PNG tests.
Vincent Povirk
vincent at codeweavers.com
Thu Sep 7 15:52:03 CDT 2017
From: Dmitry Timoshkov <dmitry at baikal.ru>
These tests are from the staging patchset windowscodecs-Palette_Images.
I found that patch 4 in that series breaks display of images with color-key
transparency (http://www.schaik.com/pngsuite/pngsuite_trn_png.html), but
we still have to return a paletted format for grayscale images with a tRNS
chunk, instead of RGBA as we do now.
Since those images don't have a palette, but Windows is able to display
them correctly, Windows must be generating a grayscale palette for them
with a transparent color inserted.
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
---
dlls/windowscodecs/tests/pngformat.c | 63 ++++++++++++++++++------------------
1 file changed, 32 insertions(+), 31 deletions(-)
diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c
index d266910..7fb9abf 100644
--- a/dlls/windowscodecs/tests/pngformat.c
+++ b/dlls/windowscodecs/tests/pngformat.c
@@ -276,37 +276,38 @@ static const char png_color_profile[] = {
static IWICImagingFactory *factory;
-static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size)
+static HRESULT create_decoder(const void *image_data, UINT image_size, IWICBitmapDecoder **decoder)
{
HRESULT hr;
- IWICBitmapDecoder *decoder = NULL;
IStream *stream;
GUID format;
LONG refcount;
ULARGE_INTEGER pos;
LARGE_INTEGER zero;
+ *decoder = NULL;
+
stream = SHCreateMemStream (image_data, image_size);
ok(stream != NULL, "SHCreateMemStream error\n");
- hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder);
- ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr);
- if (FAILED(hr)) return NULL;
-
- hr = IWICBitmapDecoder_GetContainerFormat(decoder, &format);
- ok(hr == S_OK, "GetContainerFormat error %#x\n", hr);
- ok(IsEqualGUID(&format, &GUID_ContainerFormatPng),
- "wrong container format %s\n", wine_dbgstr_guid(&format));
-
- zero.QuadPart = 0;
- IStream_Seek (stream, zero, STREAM_SEEK_CUR, &pos);
- ok(pos.QuadPart < image_size, "seek beyond the end of stream: %x%08x >= %x\n",
- (UINT)(pos.QuadPart >> 32), (UINT)pos.QuadPart, image_size);
-
- refcount = IStream_Release(stream);
- ok(refcount > 0, "expected stream refcount > 0\n");
+ hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, decoder);
+ if (hr == S_OK)
+ {
+ hr = IWICBitmapDecoder_GetContainerFormat(*decoder, &format);
+ ok(hr == S_OK, "GetContainerFormat error %#x\n", hr);
+ ok(IsEqualGUID(&format, &GUID_ContainerFormatPng),
+ "wrong container format %s\n", wine_dbgstr_guid(&format));
+
+ zero.QuadPart = 0;
+ IStream_Seek (stream, zero, STREAM_SEEK_CUR, &pos);
+ ok(pos.QuadPart < image_size, "seek beyond the end of stream: %x%08x >= %x\n",
+ (UINT)(pos.QuadPart >> 32), (UINT)pos.QuadPart, image_size);
+
+ refcount = IStream_Release(stream);
+ ok(refcount > 0, "expected stream refcount > 0\n");
+ }
- return decoder;
+ return hr;
}
static WCHAR *save_profile( BYTE *buffer, UINT size )
@@ -342,9 +343,9 @@ static void test_color_contexts(void)
BYTE *buffer;
BOOL ret;
- decoder = create_decoder(png_no_color_profile, sizeof(png_no_color_profile));
- ok(decoder != 0, "Failed to load PNG image data\n");
- if (!decoder) return;
+ hr = create_decoder(png_no_color_profile, sizeof(png_no_color_profile), &decoder);
+ ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr);
+ if (hr != S_OK) return;
/* global color context */
hr = IWICBitmapDecoder_GetColorContexts(decoder, 0, NULL, NULL);
@@ -370,9 +371,9 @@ static void test_color_contexts(void)
IWICBitmapFrameDecode_Release(frame);
IWICBitmapDecoder_Release(decoder);
- decoder = create_decoder(png_color_profile, sizeof(png_color_profile));
- ok(decoder != 0, "Failed to load PNG image data\n");
- if (!decoder) return;
+ hr = create_decoder(png_color_profile, sizeof(png_color_profile), &decoder);
+ ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr);
+ if (hr != S_OK) return;
/* global color context */
count = 0xdeadbeef;
@@ -548,9 +549,9 @@ static void test_png_palette(void)
UINT count, ret;
WICColor color[256];
- decoder = create_decoder(png_PLTE_tRNS, sizeof(png_PLTE_tRNS));
- ok(decoder != 0, "Failed to load PNG image data\n");
- if (!decoder) return;
+ hr = create_decoder(png_PLTE_tRNS, sizeof(png_PLTE_tRNS), &decoder);
+ ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr);
+ if (hr != S_OK) return;
hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
ok(hr == S_OK, "GetFrame error %#x\n", hr);
@@ -618,9 +619,9 @@ static void test_color_formats(void)
buf[24] = td[i].bit_depth;
buf[25] = td[i].color_type;
- decoder = create_decoder(buf, sizeof(buf));
- ok(decoder != NULL, "Failed to load PNG image data\n");
- if (!decoder) continue;
+ hr = create_decoder(buf, sizeof(buf), &decoder);
+ ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr);
+ if (hr != S_OK) return;
hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
ok(hr == S_OK, "GetFrame error %#x\n", hr);
--
2.7.4
More information about the wine-patches
mailing list