mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-01-28 22:04:43 -08:00
windowscodecs-Palette_Images: Add some more tests and fixes for loading PNG images in various color formats.
This commit is contained in:
parent
92510a34ed
commit
84612d7ffd
@ -2037,9 +2037,13 @@ if test "$enable_wined3d_CSMT_Helper" -eq 1; then
|
||||
fi
|
||||
|
||||
if test "$enable_windowscodecs_Palette_Images" -eq 1; then
|
||||
if test "$enable_gdiplus_Grayscale_PNG" -gt 1; then
|
||||
abort "Patchset gdiplus-Grayscale_PNG disabled, but windowscodecs-Palette_Images depends on that."
|
||||
fi
|
||||
if test "$enable_windowscodecs_32bppGrayFloat" -gt 1; then
|
||||
abort "Patchset windowscodecs-32bppGrayFloat disabled, but windowscodecs-Palette_Images depends on that."
|
||||
fi
|
||||
enable_gdiplus_Grayscale_PNG=1
|
||||
enable_windowscodecs_32bppGrayFloat=1
|
||||
fi
|
||||
|
||||
@ -7187,11 +7191,12 @@ fi
|
||||
# Patchset windowscodecs-Palette_Images
|
||||
# |
|
||||
# | This patchset has the following (direct or indirect) dependencies:
|
||||
# | * windowscodecs-32bppGrayFloat
|
||||
# | * gdiplus-Grayscale_PNG, windowscodecs-32bppGrayFloat
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/windowscodecs/bmpdecode.c, dlls/windowscodecs/bmpencode.c, dlls/windowscodecs/main.c,
|
||||
# | dlls/windowscodecs/pngformat.c, dlls/windowscodecs/tests/converter.c, dlls/windowscodecs/tiffformat.c
|
||||
# | * dlls/windowscodecs/bmpdecode.c, dlls/windowscodecs/bmpencode.c, dlls/windowscodecs/imgfactory.c,
|
||||
# | dlls/windowscodecs/main.c, dlls/windowscodecs/pngformat.c, dlls/windowscodecs/tests/converter.c,
|
||||
# | dlls/windowscodecs/tests/pngformat.c, dlls/windowscodecs/tiffformat.c
|
||||
# |
|
||||
if test "$enable_windowscodecs_Palette_Images" -eq 1; then
|
||||
patch_apply windowscodecs-Palette_Images/0001-windowscodecs-Implement-IWICBitmapDecoder-CopyPalett.patch
|
||||
@ -7211,6 +7216,11 @@ if test "$enable_windowscodecs_Palette_Images" -eq 1; then
|
||||
patch_apply windowscodecs-Palette_Images/0015-windowscodecs-Write-the-image-bits-as-a-bottom-top-a.patch
|
||||
patch_apply windowscodecs-Palette_Images/0016-windowscodecs-Limit-number-of-colors-in-a-palette-in.patch
|
||||
patch_apply windowscodecs-Palette_Images/0017-windowscodecs-Add-support-for-palette-image-formats-.patch
|
||||
patch_apply windowscodecs-Palette_Images/0018-windowscodecs-tests-Make-create_decoder-return-an-er.patch
|
||||
patch_apply windowscodecs-Palette_Images/0019-windowscodecs-tests-Add-more-tests-for-loading-PNG-i.patch
|
||||
patch_apply windowscodecs-Palette_Images/0020-windowscodecs-find_decoder-should-return-an-error-it.patch
|
||||
patch_apply windowscodecs-Palette_Images/0021-windowscodecs-PNG-decoder-should-return-WINCODEC_ERR.patch
|
||||
patch_apply windowscodecs-Palette_Images/0022-windowscodecs-PNG-decoder-should-use-indexed-formats.patch
|
||||
(
|
||||
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapDecoder::CopyPalette in PNG decoder.", 1 },';
|
||||
echo '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapFrameEncode::SetPalette in PNG encoder.", 1 },';
|
||||
@ -7229,6 +7239,11 @@ if test "$enable_windowscodecs_Palette_Images" -eq 1; then
|
||||
echo '+ { "Dmitry Timoshkov", "windowscodecs: Write the image bits as a bottom-top array in BMP encoder.", 1 },';
|
||||
echo '+ { "Dmitry Timoshkov", "windowscodecs: Limit number of colors in a palette in BMP decoder.", 1 },';
|
||||
echo '+ { "Dmitry Timoshkov", "windowscodecs: Add support for palette image formats to BMP encoder.", 1 },';
|
||||
echo '+ { "Dmitry Timoshkov", "windowscodecs/tests: Make create_decoder() return an error code in PNG tests.", 1 },';
|
||||
echo '+ { "Dmitry Timoshkov", "windowscodecs/tests: Add more tests for loading PNG images in various color formats.", 1 },';
|
||||
echo '+ { "Dmitry Timoshkov", "windowscodecs: Find_decoder() should return an error it received from the decoder.", 1 },';
|
||||
echo '+ { "Dmitry Timoshkov", "windowscodecs: PNG decoder should return WINCODEC_ERR_UNKNOWNIMAGEFORMAT when image loading fails.", 1 },';
|
||||
echo '+ { "Dmitry Timoshkov", "windowscodecs: PNG decoder should use indexed formats for grayscale images when a PLTE chunk exists.", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 1f1114e95a0ae40ca396b6612b46de78a4e4a676 Mon Sep 17 00:00:00 2001
|
||||
From 9fb318f61a9b336397e74cab3e602cba54cab2a5 Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Tue, 20 Sep 2016 14:28:49 +0800
|
||||
Subject: windowscodecs: Add support for palette image formats to PNG encoder.
|
||||
@ -8,7 +8,7 @@ Subject: windowscodecs: Add support for palette image formats to PNG encoder.
|
||||
1 file changed, 45 insertions(+)
|
||||
|
||||
diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c
|
||||
index 4473b98..870240a 100644
|
||||
index 4473b98..d8b4e2f 100644
|
||||
--- a/dlls/windowscodecs/pngformat.c
|
||||
+++ b/dlls/windowscodecs/pngformat.c
|
||||
@@ -1,5 +1,6 @@
|
||||
@ -40,17 +40,17 @@ index 4473b98..870240a 100644
|
||||
LOAD_FUNCPTR(png_set_tRNS_to_alpha);
|
||||
LOAD_FUNCPTR(png_set_write_fn);
|
||||
LOAD_FUNCPTR(png_read_end);
|
||||
@@ -1305,6 +1310,10 @@ struct png_pixelformat {
|
||||
static const struct png_pixelformat formats[] = {
|
||||
{&GUID_WICPixelFormat24bppBGR, 24, 8, PNG_COLOR_TYPE_RGB, 0, 1},
|
||||
{&GUID_WICPixelFormatBlackWhite, 1, 1, PNG_COLOR_TYPE_GRAY, 0, 0},
|
||||
@@ -1313,6 +1318,10 @@ static const struct png_pixelformat formats[] = {
|
||||
{&GUID_WICPixelFormat32bppBGRA, 32, 8, PNG_COLOR_TYPE_RGB_ALPHA, 0, 1},
|
||||
{&GUID_WICPixelFormat48bppRGB, 48, 16, PNG_COLOR_TYPE_RGB, 0, 0},
|
||||
{&GUID_WICPixelFormat64bppRGBA, 64, 16, PNG_COLOR_TYPE_RGB_ALPHA, 0, 0},
|
||||
+ {&GUID_WICPixelFormat1bppIndexed, 1, 1, PNG_COLOR_TYPE_PALETTE, 0, 0},
|
||||
+ {&GUID_WICPixelFormat2bppIndexed, 2, 2, PNG_COLOR_TYPE_PALETTE, 0, 0},
|
||||
+ {&GUID_WICPixelFormat4bppIndexed, 4, 4, PNG_COLOR_TYPE_PALETTE, 0, 0},
|
||||
+ {&GUID_WICPixelFormat8bppIndexed, 8, 8, PNG_COLOR_TYPE_PALETTE, 0, 0},
|
||||
{&GUID_WICPixelFormat2bppGray, 2, 2, PNG_COLOR_TYPE_GRAY, 0, 0},
|
||||
{&GUID_WICPixelFormat4bppGray, 4, 4, PNG_COLOR_TYPE_GRAY, 0, 0},
|
||||
{&GUID_WICPixelFormat8bppGray, 8, 8, PNG_COLOR_TYPE_GRAY, 0, 0},
|
||||
{NULL},
|
||||
};
|
||||
|
||||
@@ -1600,6 +1609,42 @@ static HRESULT WINAPI PngFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
|
||||
(This->yres+0.0127) / 0.0254, PNG_RESOLUTION_METER);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 133eeb6996e3f60f346de05a968508ae60178736 Mon Sep 17 00:00:00 2001
|
||||
From d68de6ad4c3d41a3b6b879ee24e1775e67763310 Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Fri, 23 Sep 2016 16:36:50 +0800
|
||||
Subject: windowscodecs: Add support for palette image formats to TIFF encoder.
|
||||
@ -93,7 +93,7 @@ index 78bc8f5..e7b9ba9 100644
|
||||
&testdata_24bppBGR, &CLSID_WICTiffDecoder, "TIFF encoder 24bppBGR");
|
||||
|
||||
diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c
|
||||
index 1f757d8..cb2faaa 100644
|
||||
index 1f757d8..350590d 100644
|
||||
--- a/dlls/windowscodecs/tiffformat.c
|
||||
+++ b/dlls/windowscodecs/tiffformat.c
|
||||
@@ -1,5 +1,6 @@
|
||||
@ -116,17 +116,17 @@ index 1f757d8..cb2faaa 100644
|
||||
case 4:
|
||||
decode_info->format = &GUID_WICPixelFormat4bppIndexed;
|
||||
break;
|
||||
@@ -1402,6 +1409,10 @@ static const struct tiff_encode_format formats[] = {
|
||||
{&GUID_WICPixelFormat24bppBGR, 2, 8, 3, 24, 0, 0, 1},
|
||||
{&GUID_WICPixelFormat24bppRGB, 2, 8, 3, 24, 0, 0, 0},
|
||||
{&GUID_WICPixelFormatBlackWhite, 1, 1, 1, 1, 0, 0, 0},
|
||||
@@ -1409,6 +1416,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},
|
||||
{&GUID_WICPixelFormat4bppGray, 1, 4, 1, 4, 0, 0, 0},
|
||||
{&GUID_WICPixelFormat8bppGray, 1, 8, 1, 8, 0, 0, 0},
|
||||
{&GUID_WICPixelFormat32bppBGRA, 2, 8, 4, 32, 1, 2, 1},
|
||||
{0}
|
||||
};
|
||||
|
||||
@@ -1691,6 +1702,21 @@ static HRESULT WINAPI TiffFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
|
||||
pTIFFSetField(This->parent->tiff, TIFFTAG_YRESOLUTION, (float)This->yres);
|
||||
}
|
||||
|
@ -0,0 +1,120 @@
|
||||
From ea8d7d6e5661a0cf96ca5a224a60474535ff8157 Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Tue, 4 Oct 2016 18:20:31 +0800
|
||||
Subject: windowscodecs/tests: Make create_decoder() return an error code in
|
||||
PNG tests.
|
||||
|
||||
---
|
||||
dlls/windowscodecs/tests/pngformat.c | 51 ++++++++++++++++++------------------
|
||||
1 file changed, 26 insertions(+), 25 deletions(-)
|
||||
|
||||
diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c
|
||||
index 296866f..95393c9 100644
|
||||
--- a/dlls/windowscodecs/tests/pngformat.c
|
||||
+++ b/dlls/windowscodecs/tests/pngformat.c
|
||||
@@ -275,16 +275,17 @@ 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)
|
||||
{
|
||||
HGLOBAL hmem;
|
||||
BYTE *data;
|
||||
HRESULT hr;
|
||||
- IWICBitmapDecoder *decoder = NULL;
|
||||
IStream *stream;
|
||||
GUID format;
|
||||
LONG refcount;
|
||||
|
||||
+ *decoder = NULL;
|
||||
+
|
||||
hmem = GlobalAlloc(0, image_size);
|
||||
data = GlobalLock(hmem);
|
||||
memcpy(data, image_data, image_size);
|
||||
@@ -293,19 +294,19 @@ static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size
|
||||
hr = CreateStreamOnHGlobal(hmem, TRUE, &stream);
|
||||
ok(hr == S_OK, "CreateStreamOnHGlobal error %#x\n", hr);
|
||||
|
||||
- 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));
|
||||
+ 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));
|
||||
|
||||
- refcount = IStream_Release(stream);
|
||||
- ok(refcount > 0, "expected stream refcount > 0\n");
|
||||
+ refcount = IStream_Release(stream);
|
||||
+ ok(refcount > 0, "expected stream refcount > 0\n");
|
||||
+ }
|
||||
|
||||
- return decoder;
|
||||
+ return hr;
|
||||
}
|
||||
|
||||
static WCHAR *save_profile( BYTE *buffer, UINT size )
|
||||
@@ -341,9 +342,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);
|
||||
@@ -369,9 +370,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;
|
||||
@@ -547,9 +548,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);
|
||||
@@ -617,9 +618,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.9.0
|
||||
|
@ -0,0 +1,277 @@
|
||||
From a11b0ed49b0de9622408c44d82196b1d18d36715 Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Tue, 4 Oct 2016 18:26:22 +0800
|
||||
Subject: windowscodecs/tests: Add more tests for loading PNG images in various
|
||||
color formats.
|
||||
|
||||
---
|
||||
dlls/windowscodecs/tests/pngformat.c | 218 +++++++++++++++++++++++++++++++++--
|
||||
1 file changed, 208 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c
|
||||
index 95393c9..aee8e4e 100644
|
||||
--- a/dlls/windowscodecs/tests/pngformat.c
|
||||
+++ b/dlls/windowscodecs/tests/pngformat.c
|
||||
@@ -584,43 +584,211 @@ static void test_png_palette(void)
|
||||
static const char png_1x1_data[] = {
|
||||
0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,
|
||||
0x00,0x00,0x00,0x0d,'I','H','D','R',0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53,0xde,
|
||||
+ 0x00,0x00,0x03,0x00,'P','L','T','E',
|
||||
+ 0x01,0x01,0x01,0x02,0x02,0x02,0x03,0x03,0x03,0x04,0x04,0x04,0x05,0x05,0x05,0x06,0x06,0x06,0x07,0x07,0x07,0x08,0x08,0x08,
|
||||
+ 0x09,0x09,0x09,0x0a,0x0a,0x0a,0x0b,0x0b,0x0b,0x0c,0x0c,0x0c,0x0d,0x0d,0x0d,0x0e,0x0e,0x0e,0x0f,0x0f,0x0f,0x10,0x10,0x10,
|
||||
+ 0x11,0x11,0x11,0x12,0x12,0x12,0x13,0x13,0x13,0x14,0x14,0x14,0x15,0x15,0x15,0x16,0x16,0x16,0x17,0x17,0x17,0x18,0x18,0x18,
|
||||
+ 0x19,0x19,0x19,0x1a,0x1a,0x1a,0x1b,0x1b,0x1b,0x1c,0x1c,0x1c,0x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x1f,0x1f,0x1f,0x20,0x20,0x20,
|
||||
+ 0x21,0x21,0x21,0x22,0x22,0x22,0x23,0x23,0x23,0x24,0x24,0x24,0x25,0x25,0x25,0x26,0x26,0x26,0x27,0x27,0x27,0x28,0x28,0x28,
|
||||
+ 0x29,0x29,0x29,0x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2c,0x2c,0x2c,0x2d,0x2d,0x2d,0x2e,0x2e,0x2e,0x2f,0x2f,0x2f,0x30,0x30,0x30,
|
||||
+ 0x31,0x31,0x31,0x32,0x32,0x32,0x33,0x33,0x33,0x34,0x34,0x34,0x35,0x35,0x35,0x36,0x36,0x36,0x37,0x37,0x37,0x38,0x38,0x38,
|
||||
+ 0x39,0x39,0x39,0x3a,0x3a,0x3a,0x3b,0x3b,0x3b,0x3c,0x3c,0x3c,0x3d,0x3d,0x3d,0x3e,0x3e,0x3e,0x3f,0x3f,0x3f,0x40,0x40,0x40,
|
||||
+ 0x41,0x41,0x41,0x42,0x42,0x42,0x43,0x43,0x43,0x44,0x44,0x44,0x45,0x45,0x45,0x46,0x46,0x46,0x47,0x47,0x47,0x48,0x48,0x48,
|
||||
+ 0x49,0x49,0x49,0x4a,0x4a,0x4a,0x4b,0x4b,0x4b,0x4c,0x4c,0x4c,0x4d,0x4d,0x4d,0x4e,0x4e,0x4e,0x4f,0x4f,0x4f,0x50,0x50,0x50,
|
||||
+ 0x51,0x51,0x51,0x52,0x52,0x52,0x53,0x53,0x53,0x54,0x54,0x54,0x55,0x55,0x55,0x56,0x56,0x56,0x57,0x57,0x57,0x58,0x58,0x58,
|
||||
+ 0x59,0x59,0x59,0x5a,0x5a,0x5a,0x5b,0x5b,0x5b,0x5c,0x5c,0x5c,0x5d,0x5d,0x5d,0x5e,0x5e,0x5e,0x5f,0x5f,0x5f,0x60,0x60,0x60,
|
||||
+ 0x61,0x61,0x61,0x62,0x62,0x62,0x63,0x63,0x63,0x64,0x64,0x64,0x65,0x65,0x65,0x66,0x66,0x66,0x67,0x67,0x67,0x68,0x68,0x68,
|
||||
+ 0x69,0x69,0x69,0x6a,0x6a,0x6a,0x6b,0x6b,0x6b,0x6c,0x6c,0x6c,0x6d,0x6d,0x6d,0x6e,0x6e,0x6e,0x6f,0x6f,0x6f,0x70,0x70,0x70,
|
||||
+ 0x71,0x71,0x71,0x72,0x72,0x72,0x73,0x73,0x73,0x74,0x74,0x74,0x75,0x75,0x75,0x76,0x76,0x76,0x77,0x77,0x77,0x78,0x78,0x78,
|
||||
+ 0x79,0x79,0x79,0x7a,0x7a,0x7a,0x7b,0x7b,0x7b,0x7c,0x7c,0x7c,0x7d,0x7d,0x7d,0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x80,0x80,0x80,
|
||||
+ 0x01,0x01,0x01,0x02,0x02,0x02,0x03,0x03,0x03,0x04,0x04,0x04,0x05,0x05,0x05,0x06,0x06,0x06,0x07,0x07,0x07,0x08,0x08,0x08,
|
||||
+ 0x09,0x09,0x09,0x0a,0x0a,0x0a,0x0b,0x0b,0x0b,0x0c,0x0c,0x0c,0x0d,0x0d,0x0d,0x0e,0x0e,0x0e,0x0f,0x0f,0x0f,0x10,0x10,0x10,
|
||||
+ 0x11,0x11,0x11,0x12,0x12,0x12,0x13,0x13,0x13,0x14,0x14,0x14,0x15,0x15,0x15,0x16,0x16,0x16,0x17,0x17,0x17,0x18,0x18,0x18,
|
||||
+ 0x19,0x19,0x19,0x1a,0x1a,0x1a,0x1b,0x1b,0x1b,0x1c,0x1c,0x1c,0x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x1f,0x1f,0x1f,0x20,0x20,0x20,
|
||||
+ 0x21,0x21,0x21,0x22,0x22,0x22,0x23,0x23,0x23,0x24,0x24,0x24,0x25,0x25,0x25,0x26,0x26,0x26,0x27,0x27,0x27,0x28,0x28,0x28,
|
||||
+ 0x29,0x29,0x29,0x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2c,0x2c,0x2c,0x2d,0x2d,0x2d,0x2e,0x2e,0x2e,0x2f,0x2f,0x2f,0x30,0x30,0x30,
|
||||
+ 0x31,0x31,0x31,0x32,0x32,0x32,0x33,0x33,0x33,0x34,0x34,0x34,0x35,0x35,0x35,0x36,0x36,0x36,0x37,0x37,0x37,0x38,0x38,0x38,
|
||||
+ 0x39,0x39,0x39,0x3a,0x3a,0x3a,0x3b,0x3b,0x3b,0x3c,0x3c,0x3c,0x3d,0x3d,0x3d,0x3e,0x3e,0x3e,0x3f,0x3f,0x3f,0x40,0x40,0x40,
|
||||
+ 0x41,0x41,0x41,0x42,0x42,0x42,0x43,0x43,0x43,0x44,0x44,0x44,0x45,0x45,0x45,0x46,0x46,0x46,0x47,0x47,0x47,0x48,0x48,0x48,
|
||||
+ 0x49,0x49,0x49,0x4a,0x4a,0x4a,0x4b,0x4b,0x4b,0x4c,0x4c,0x4c,0x4d,0x4d,0x4d,0x4e,0x4e,0x4e,0x4f,0x4f,0x4f,0x50,0x50,0x50,
|
||||
+ 0x51,0x51,0x51,0x52,0x52,0x52,0x53,0x53,0x53,0x54,0x54,0x54,0x55,0x55,0x55,0x56,0x56,0x56,0x57,0x57,0x57,0x58,0x58,0x58,
|
||||
+ 0x59,0x59,0x59,0x5a,0x5a,0x5a,0x5b,0x5b,0x5b,0x5c,0x5c,0x5c,0x5d,0x5d,0x5d,0x5e,0x5e,0x5e,0x5f,0x5f,0x5f,0x60,0x60,0x60,
|
||||
+ 0x61,0x61,0x61,0x62,0x62,0x62,0x63,0x63,0x63,0x64,0x64,0x64,0x65,0x65,0x65,0x66,0x66,0x66,0x67,0x67,0x67,0x68,0x68,0x68,
|
||||
+ 0x69,0x69,0x69,0x6a,0x6a,0x6a,0x6b,0x6b,0x6b,0x6c,0x6c,0x6c,0x6d,0x6d,0x6d,0x6e,0x6e,0x6e,0x6f,0x6f,0x6f,0x70,0x70,0x70,
|
||||
+ 0x71,0x71,0x71,0x72,0x72,0x72,0x73,0x73,0x73,0x74,0x74,0x74,0x75,0x75,0x75,0x76,0x76,0x76,0x77,0x77,0x77,0x78,0x78,0x78,
|
||||
+ 0x79,0x79,0x79,0x7a,0x7a,0x7a,0x7b,0x7b,0x7b,0x7c,0x7c,0x7c,0x7d,0x7d,0x7d,0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x80,0x80,0x80,
|
||||
+ 0x76,0xb6,0x24,0x31,
|
||||
+ 0x00,0x00,0x00,0x02,'t','R','N','S',0xff,0x00,0xe5,0xb7,0x30,0x4a,
|
||||
0x00,0x00,0x00,0x0c,'I','D','A','T',0x08,0xd7,0x63,0xf8,0xff,0xff,0x3f,0x00,0x05,0xfe,0x02,0xfe,0xdc,0xcc,0x59,0xe7,
|
||||
0x00,0x00,0x00,0x00,'I','E','N','D',0xae,0x42,0x60,0x82
|
||||
};
|
||||
|
||||
+static BOOL is_valid_png_type_depth(int color_type, int bit_depth, BOOL plte)
|
||||
+{
|
||||
+ switch (color_type)
|
||||
+ {
|
||||
+ case 0: /* Grayscale */
|
||||
+ return bit_depth == 1 || bit_depth == 2 || bit_depth == 4 || bit_depth == 8 || bit_depth == 16;
|
||||
+
|
||||
+ case 2: /* True Color */
|
||||
+ return bit_depth == 8 || bit_depth == 16;
|
||||
+
|
||||
+ case 3: /* Indexed Color */
|
||||
+ return (bit_depth == 1 || bit_depth == 2 || bit_depth == 4 || bit_depth == 8) && plte;
|
||||
+
|
||||
+ case 4: /* Grayscale with alpha */
|
||||
+ return bit_depth == 8 || bit_depth == 16;
|
||||
+
|
||||
+ case 6: /* True Color with alpha */
|
||||
+ return bit_depth == 8 || bit_depth == 16;
|
||||
+
|
||||
+ default:
|
||||
+ ok(0, "unknown PNG type %d, depth %d\n", color_type, bit_depth);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void test_color_formats(void)
|
||||
{
|
||||
static const struct
|
||||
{
|
||||
char bit_depth, color_type;
|
||||
const GUID *format;
|
||||
+ const GUID *format_PLTE;
|
||||
+ const GUID *format_PLTE_tRNS;
|
||||
+ BOOL todo;
|
||||
+ BOOL todo_load;
|
||||
} td[] =
|
||||
{
|
||||
/* 2 - PNG_COLOR_TYPE_RGB */
|
||||
- { 8, 2, &GUID_WICPixelFormat24bppBGR },
|
||||
+ { 1, 2, NULL, NULL, NULL },
|
||||
+ { 2, 2, NULL, NULL, NULL },
|
||||
+ { 4, 2, NULL, NULL, NULL },
|
||||
+ { 8, 2, &GUID_WICPixelFormat24bppBGR, &GUID_WICPixelFormat24bppBGR, &GUID_WICPixelFormat24bppBGR },
|
||||
+ /* libpng refuses to load our test image complaining about extra compressed data,
|
||||
+ * but libpng is still able to load the image with other combination of type/depth
|
||||
+ * making RGB 16 bpp case special for some reason. Therefore todo = TRUE.
|
||||
+ */
|
||||
+ { 16, 2, &GUID_WICPixelFormat48bppRGB, &GUID_WICPixelFormat48bppRGB, &GUID_WICPixelFormat48bppRGB, TRUE, TRUE },
|
||||
+ { 24, 2, NULL, NULL, NULL },
|
||||
+ { 32, 2, NULL, NULL, NULL },
|
||||
/* 0 - PNG_COLOR_TYPE_GRAY */
|
||||
- { 1, 0, &GUID_WICPixelFormatBlackWhite },
|
||||
- { 2, 0, &GUID_WICPixelFormat2bppGray },
|
||||
- { 4, 0, &GUID_WICPixelFormat4bppGray },
|
||||
- { 8, 0, &GUID_WICPixelFormat8bppGray },
|
||||
- { 16, 0, &GUID_WICPixelFormat16bppGray },
|
||||
+ { 1, 0, &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormat1bppIndexed, TRUE },
|
||||
+ { 2, 0, &GUID_WICPixelFormat2bppGray, &GUID_WICPixelFormat2bppGray, &GUID_WICPixelFormat2bppIndexed, TRUE },
|
||||
+ { 4, 0, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat4bppIndexed, TRUE },
|
||||
+ { 8, 0, &GUID_WICPixelFormat8bppGray, &GUID_WICPixelFormat8bppGray, &GUID_WICPixelFormat8bppIndexed, TRUE },
|
||||
+ { 16, 0, &GUID_WICPixelFormat16bppGray, &GUID_WICPixelFormat16bppGray, &GUID_WICPixelFormat64bppRGBA, TRUE },
|
||||
+ { 24, 0, NULL, NULL, NULL },
|
||||
+ { 32, 0, NULL, NULL, NULL },
|
||||
+ /* 3 - PNG_COLOR_TYPE_PALETTE */
|
||||
+ { 1, 3, &GUID_WICPixelFormat1bppIndexed, &GUID_WICPixelFormat1bppIndexed, &GUID_WICPixelFormat1bppIndexed },
|
||||
+ { 2, 3, &GUID_WICPixelFormat2bppIndexed, &GUID_WICPixelFormat2bppIndexed, &GUID_WICPixelFormat2bppIndexed },
|
||||
+ { 4, 3, &GUID_WICPixelFormat4bppIndexed, &GUID_WICPixelFormat4bppIndexed, &GUID_WICPixelFormat4bppIndexed },
|
||||
+ { 8, 3, &GUID_WICPixelFormat8bppIndexed, &GUID_WICPixelFormat8bppIndexed, &GUID_WICPixelFormat8bppIndexed },
|
||||
+ { 16, 3, NULL, NULL, NULL },
|
||||
+ { 24, 3, NULL, NULL, NULL },
|
||||
+ { 32, 3, NULL, NULL, NULL },
|
||||
};
|
||||
char buf[sizeof(png_1x1_data)];
|
||||
HRESULT hr;
|
||||
IWICBitmapDecoder *decoder;
|
||||
IWICBitmapFrameDecode *frame;
|
||||
GUID format;
|
||||
- int i;
|
||||
+ int i, PLTE_off = 0, tRNS_off = 0;
|
||||
+
|
||||
+ memcpy(buf, png_1x1_data, sizeof(png_1x1_data));
|
||||
+ for (i = 0; i < sizeof(png_1x1_data) - 4; i++)
|
||||
+ {
|
||||
+ if (!memcmp(buf + i, "tRNS", 4))
|
||||
+ tRNS_off = i;
|
||||
+ else if (!memcmp(buf + i, "PLTE", 4))
|
||||
+ PLTE_off = i;
|
||||
+ }
|
||||
+
|
||||
+ ok(PLTE_off && tRNS_off, "PLTE offset %d, tRNS offset %d\n", PLTE_off, tRNS_off);
|
||||
+ if (!PLTE_off || !tRNS_off) return;
|
||||
+
|
||||
+ /* In order to test the image data with and without PLTE and tRNS chunks
|
||||
+ * it's been decided to simply sero out the chunk id for testing puposes,
|
||||
+ * and under Windows such images get loaded just fine. But unfortunately
|
||||
+ * libpng refuses to load such images complaining about unknown chunk type.
|
||||
+ * A workaround for this libpng limitation is to mark the "disabled" chunks
|
||||
+ * with tEXt id.
|
||||
+ */
|
||||
|
||||
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
|
||||
{
|
||||
+ /* with the tRNS and PLTE chunks */
|
||||
+ memcpy(buf, png_1x1_data, sizeof(png_1x1_data));
|
||||
+ buf[24] = td[i].bit_depth;
|
||||
+ buf[25] = td[i].color_type;
|
||||
+
|
||||
+ hr = create_decoder(buf, sizeof(buf), &decoder);
|
||||
+ if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, TRUE))
|
||||
+todo_wine
|
||||
+ ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr);
|
||||
+ else
|
||||
+todo_wine_if(td[i].todo_load)
|
||||
+ ok(hr == S_OK, "%d: Failed to load PNG image data (type %d, bpp %d) %#x\n", i, td[i].color_type, td[i].bit_depth, hr);
|
||||
+ if (hr != S_OK) goto next_1;
|
||||
+
|
||||
+ hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
|
||||
+ ok(hr == S_OK, "GetFrame error %#x\n", hr);
|
||||
+
|
||||
+ hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
|
||||
+ ok(hr == S_OK, "GetPixelFormat error %#x\n", hr);
|
||||
+todo_wine_if(td[i].todo)
|
||||
+ ok(IsEqualGUID(&format, td[i].format_PLTE_tRNS),
|
||||
+ "PLTE+tRNS: expected %s, got %s (type %d, bpp %d)\n",
|
||||
+ wine_dbgstr_guid(td[i].format_PLTE_tRNS), wine_dbgstr_guid(&format), td[i].color_type, td[i].bit_depth);
|
||||
+
|
||||
+ IWICBitmapFrameDecode_Release(frame);
|
||||
+ IWICBitmapDecoder_Release(decoder);
|
||||
+
|
||||
+next_1:
|
||||
+ /* without the tRNS chunk */
|
||||
memcpy(buf, png_1x1_data, sizeof(png_1x1_data));
|
||||
buf[24] = td[i].bit_depth;
|
||||
buf[25] = td[i].color_type;
|
||||
+ memcpy(buf + tRNS_off, "tEXt", 4);
|
||||
|
||||
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;
|
||||
+ if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, TRUE))
|
||||
+todo_wine
|
||||
+ ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr);
|
||||
+ else
|
||||
+todo_wine_if(td[i].todo_load)
|
||||
+ ok(hr == S_OK, "%d: Failed to load PNG image data (type %d, bpp %d) %#x\n", i, td[i].color_type, td[i].bit_depth, hr);
|
||||
+ if (hr != S_OK) goto next_2;
|
||||
+
|
||||
+ hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
|
||||
+ ok(hr == S_OK, "GetFrame error %#x\n", hr);
|
||||
+
|
||||
+ hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
|
||||
+ ok(hr == S_OK, "GetPixelFormat error %#x\n", hr);
|
||||
+ ok(IsEqualGUID(&format, td[i].format_PLTE),
|
||||
+ "PLTE: expected %s, got %s (type %d, bpp %d)\n",
|
||||
+ wine_dbgstr_guid(td[i].format_PLTE), wine_dbgstr_guid(&format), td[i].color_type, td[i].bit_depth);
|
||||
+
|
||||
+ IWICBitmapFrameDecode_Release(frame);
|
||||
+ IWICBitmapDecoder_Release(decoder);
|
||||
+
|
||||
+next_2:
|
||||
+ /* without the tRNS and PLTE chunks */
|
||||
+ memcpy(buf, png_1x1_data, sizeof(png_1x1_data));
|
||||
+ buf[24] = td[i].bit_depth;
|
||||
+ buf[25] = td[i].color_type;
|
||||
+ memcpy(buf + PLTE_off, "tEXt", 4);
|
||||
+ memcpy(buf + tRNS_off, "tEXt", 4);
|
||||
+
|
||||
+ hr = create_decoder(buf, sizeof(buf), &decoder);
|
||||
+ if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, FALSE))
|
||||
+todo_wine
|
||||
+ ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr);
|
||||
+ else
|
||||
+todo_wine_if(td[i].todo_load)
|
||||
+ ok(hr == S_OK, "%d: Failed to load PNG image data (type %d, bpp %d) %#x\n", i, td[i].color_type, td[i].bit_depth, hr);
|
||||
+ if (hr != S_OK) goto next_3;
|
||||
|
||||
hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
|
||||
ok(hr == S_OK, "GetFrame error %#x\n", hr);
|
||||
@@ -628,7 +796,37 @@ static void test_color_formats(void)
|
||||
hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
|
||||
ok(hr == S_OK, "GetPixelFormat error %#x\n", hr);
|
||||
ok(IsEqualGUID(&format, td[i].format),
|
||||
- "expected %s, got %s\n", wine_dbgstr_guid(td[i].format), wine_dbgstr_guid(&format));
|
||||
+ "expected %s, got %s (type %d, bpp %d)\n",
|
||||
+ wine_dbgstr_guid(td[i].format), wine_dbgstr_guid(&format), td[i].color_type, td[i].bit_depth);
|
||||
+
|
||||
+ IWICBitmapFrameDecode_Release(frame);
|
||||
+ IWICBitmapDecoder_Release(decoder);
|
||||
+
|
||||
+next_3:
|
||||
+ /* without the PLTE chunk */
|
||||
+ memcpy(buf, png_1x1_data, sizeof(png_1x1_data));
|
||||
+ buf[24] = td[i].bit_depth;
|
||||
+ buf[25] = td[i].color_type;
|
||||
+ memcpy(buf + PLTE_off, "tEXt", 4);
|
||||
+
|
||||
+ hr = create_decoder(buf, sizeof(buf), &decoder);
|
||||
+ if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, FALSE))
|
||||
+todo_wine
|
||||
+ ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr);
|
||||
+ else
|
||||
+todo_wine_if(td[i].todo_load)
|
||||
+ ok(hr == S_OK, "%d: Failed to load PNG image data (type %d, bpp %d) %#x\n", i, td[i].color_type, td[i].bit_depth, hr);
|
||||
+ if (hr != S_OK) continue;
|
||||
+
|
||||
+ hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
|
||||
+ ok(hr == S_OK, "GetFrame error %#x\n", hr);
|
||||
+
|
||||
+ hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
|
||||
+ ok(hr == S_OK, "GetPixelFormat error %#x\n", hr);
|
||||
+todo_wine_if(td[i].todo)
|
||||
+ ok(IsEqualGUID(&format, td[i].format_PLTE_tRNS),
|
||||
+ "tRNS: expected %s, got %s (type %d, bpp %d)\n",
|
||||
+ wine_dbgstr_guid(td[i].format_PLTE_tRNS), wine_dbgstr_guid(&format), td[i].color_type, td[i].bit_depth);
|
||||
|
||||
IWICBitmapFrameDecode_Release(frame);
|
||||
IWICBitmapDecoder_Release(decoder);
|
||||
--
|
||||
2.9.0
|
||||
|
@ -0,0 +1,122 @@
|
||||
From 6838f692cc7e41dfcae4ee8cf3ee63307a93dd8c Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Tue, 4 Oct 2016 18:33:40 +0800
|
||||
Subject: windowscodecs: find_decoder() should return an error it received from
|
||||
the decoder.
|
||||
|
||||
If IWICBitmapDecoderInfo::MatchesPattern() has recognized the decoder by the pattern,
|
||||
and the called IWICBitmapDecoder::Initialize() has failed, an error should be returned
|
||||
right away instead of trying next codec. This allows report image format related errors
|
||||
instead of WINCODEC_ERR_COMPONENTNOTFOUND.
|
||||
---
|
||||
dlls/windowscodecs/imgfactory.c | 42 ++++++++++++++++++++++-------------------
|
||||
1 file changed, 23 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/dlls/windowscodecs/imgfactory.c b/dlls/windowscodecs/imgfactory.c
|
||||
index 659aa7e..8c37e3d 100644
|
||||
--- a/dlls/windowscodecs/imgfactory.c
|
||||
+++ b/dlls/windowscodecs/imgfactory.c
|
||||
@@ -120,22 +120,23 @@ static HRESULT WINAPI ComponentFactory_CreateDecoderFromFilename(
|
||||
return hr;
|
||||
}
|
||||
|
||||
-static IWICBitmapDecoder *find_decoder(IStream *pIStream, const GUID *pguidVendor,
|
||||
- WICDecodeOptions metadataOptions)
|
||||
+static HRESULT find_decoder(IStream *pIStream, const GUID *pguidVendor,
|
||||
+ WICDecodeOptions metadataOptions, IWICBitmapDecoder **decoder)
|
||||
{
|
||||
IEnumUnknown *enumdecoders;
|
||||
IUnknown *unkdecoderinfo;
|
||||
IWICBitmapDecoderInfo *decoderinfo;
|
||||
- IWICBitmapDecoder *decoder = NULL;
|
||||
GUID vendor;
|
||||
HRESULT res;
|
||||
ULONG num_fetched;
|
||||
BOOL matches;
|
||||
|
||||
+ *decoder = NULL;
|
||||
+
|
||||
res = CreateComponentEnumerator(WICDecoder, WICComponentEnumerateDefault, &enumdecoders);
|
||||
- if (FAILED(res)) return NULL;
|
||||
+ if (FAILED(res)) return res;
|
||||
|
||||
- while (!decoder)
|
||||
+ while (!*decoder)
|
||||
{
|
||||
res = IEnumUnknown_Next(enumdecoders, 1, &unkdecoderinfo, &num_fetched);
|
||||
|
||||
@@ -160,18 +161,21 @@ static IWICBitmapDecoder *find_decoder(IStream *pIStream, const GUID *pguidVendo
|
||||
|
||||
if (SUCCEEDED(res) && matches)
|
||||
{
|
||||
- res = IWICBitmapDecoderInfo_CreateInstance(decoderinfo, &decoder);
|
||||
+ res = IWICBitmapDecoderInfo_CreateInstance(decoderinfo, decoder);
|
||||
|
||||
/* FIXME: should use QueryCapability to choose a decoder */
|
||||
|
||||
if (SUCCEEDED(res))
|
||||
{
|
||||
- res = IWICBitmapDecoder_Initialize(decoder, pIStream, metadataOptions);
|
||||
+ res = IWICBitmapDecoder_Initialize(*decoder, pIStream, metadataOptions);
|
||||
|
||||
if (FAILED(res))
|
||||
{
|
||||
- IWICBitmapDecoder_Release(decoder);
|
||||
- decoder = NULL;
|
||||
+ IWICBitmapDecoder_Release(*decoder);
|
||||
+ IWICBitmapDecoderInfo_Release(decoderinfo);
|
||||
+ IUnknown_Release(unkdecoderinfo);
|
||||
+ *decoder = NULL;
|
||||
+ return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,7 +191,7 @@ static IWICBitmapDecoder *find_decoder(IStream *pIStream, const GUID *pguidVendo
|
||||
|
||||
IEnumUnknown_Release(enumdecoders);
|
||||
|
||||
- return decoder;
|
||||
+ return WINCODEC_ERR_COMPONENTNOTFOUND;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ComponentFactory_CreateDecoderFromStream(
|
||||
@@ -201,9 +205,9 @@ static HRESULT WINAPI ComponentFactory_CreateDecoderFromStream(
|
||||
metadataOptions, ppIDecoder);
|
||||
|
||||
if (pguidVendor)
|
||||
- decoder = find_decoder(pIStream, pguidVendor, metadataOptions);
|
||||
+ res = find_decoder(pIStream, pguidVendor, metadataOptions, &decoder);
|
||||
if (!decoder)
|
||||
- decoder = find_decoder(pIStream, NULL, metadataOptions);
|
||||
+ res = find_decoder(pIStream, NULL, metadataOptions, &decoder);
|
||||
|
||||
if (decoder)
|
||||
{
|
||||
@@ -218,17 +222,17 @@ static HRESULT WINAPI ComponentFactory_CreateDecoderFromStream(
|
||||
BYTE data[4];
|
||||
ULONG bytesread;
|
||||
|
||||
- WARN("failed to load from a stream\n");
|
||||
+ WARN("failed to load from a stream %#x\n", res);
|
||||
|
||||
seek.QuadPart = 0;
|
||||
- res = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, NULL);
|
||||
- if (SUCCEEDED(res))
|
||||
- res = IStream_Read(pIStream, data, 4, &bytesread);
|
||||
- if (SUCCEEDED(res))
|
||||
- WARN("first %i bytes of stream=%x %x %x %x\n", bytesread, data[0], data[1], data[2], data[3]);
|
||||
+ if (IStream_Seek(pIStream, seek, STREAM_SEEK_SET, NULL) == S_OK)
|
||||
+ {
|
||||
+ if (IStream_Read(pIStream, data, 4, &bytesread) == S_OK)
|
||||
+ WARN("first %i bytes of stream=%x %x %x %x\n", bytesread, data[0], data[1], data[2], data[3]);
|
||||
+ }
|
||||
}
|
||||
*ppIDecoder = NULL;
|
||||
- return WINCODEC_ERR_COMPONENTNOTFOUND;
|
||||
+ return res;
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.9.0
|
||||
|
@ -0,0 +1,63 @@
|
||||
From 0d54c3163edd87ef50d4808b4ba5c708f12d1ddd Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Tue, 4 Oct 2016 18:39:40 +0800
|
||||
Subject: windowscodecs: PNG decoder should return
|
||||
WINCODEC_ERR_UNKNOWNIMAGEFORMAT when image loading fails.
|
||||
|
||||
---
|
||||
dlls/windowscodecs/pngformat.c | 2 +-
|
||||
dlls/windowscodecs/tests/pngformat.c | 4 ----
|
||||
2 files changed, 1 insertion(+), 5 deletions(-)
|
||||
|
||||
diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c
|
||||
index d8b4e2f..9cce735 100644
|
||||
--- a/dlls/windowscodecs/pngformat.c
|
||||
+++ b/dlls/windowscodecs/pngformat.c
|
||||
@@ -621,7 +621,7 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
|
||||
ppng_destroy_read_struct(&This->png_ptr, &This->info_ptr, &This->end_info);
|
||||
HeapFree(GetProcessHeap(), 0, row_pointers);
|
||||
This->png_ptr = NULL;
|
||||
- hr = E_FAIL;
|
||||
+ hr = WINCODEC_ERR_UNKNOWNIMAGEFORMAT;
|
||||
goto end;
|
||||
}
|
||||
ppng_set_error_fn(This->png_ptr, jmpbuf, user_error_fn, user_warning_fn);
|
||||
diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c
|
||||
index aee8e4e..3747244 100644
|
||||
--- a/dlls/windowscodecs/tests/pngformat.c
|
||||
+++ b/dlls/windowscodecs/tests/pngformat.c
|
||||
@@ -725,7 +725,6 @@ static void test_color_formats(void)
|
||||
|
||||
hr = create_decoder(buf, sizeof(buf), &decoder);
|
||||
if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, TRUE))
|
||||
-todo_wine
|
||||
ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr);
|
||||
else
|
||||
todo_wine_if(td[i].todo_load)
|
||||
@@ -754,7 +753,6 @@ next_1:
|
||||
|
||||
hr = create_decoder(buf, sizeof(buf), &decoder);
|
||||
if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, TRUE))
|
||||
-todo_wine
|
||||
ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr);
|
||||
else
|
||||
todo_wine_if(td[i].todo_load)
|
||||
@@ -783,7 +781,6 @@ next_2:
|
||||
|
||||
hr = create_decoder(buf, sizeof(buf), &decoder);
|
||||
if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, FALSE))
|
||||
-todo_wine
|
||||
ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr);
|
||||
else
|
||||
todo_wine_if(td[i].todo_load)
|
||||
@@ -811,7 +808,6 @@ next_3:
|
||||
|
||||
hr = create_decoder(buf, sizeof(buf), &decoder);
|
||||
if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, FALSE))
|
||||
-todo_wine
|
||||
ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr);
|
||||
else
|
||||
todo_wine_if(td[i].todo_load)
|
||||
--
|
||||
2.9.0
|
||||
|
@ -0,0 +1,48 @@
|
||||
From 7ea6ea9c3538448255f6c14047cdbb88e9d73336 Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Tue, 4 Oct 2016 19:04:34 +0800
|
||||
Subject: windowscodecs: PNG decoder should use indexed formats for grayscale
|
||||
images when a PLTE chunk exists.
|
||||
|
||||
todo_wine statements in the tests can't be removed because libpng refuses to
|
||||
return a PLTE chunk for grayscale images even though the chunk does exist in
|
||||
the data stream, and issues a warning: "ignoring PLTE chunk in grayscale PNG".
|
||||
---
|
||||
dlls/windowscodecs/pngformat.c | 18 +++++++++++++-----
|
||||
1 file changed, 13 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c
|
||||
index 9cce735..1a409ae 100644
|
||||
--- a/dlls/windowscodecs/pngformat.c
|
||||
+++ b/dlls/windowscodecs/pngformat.c
|
||||
@@ -657,14 +657,22 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
|
||||
This->bpp = bit_depth;
|
||||
switch (bit_depth)
|
||||
{
|
||||
- case 1: This->format = &GUID_WICPixelFormatBlackWhite; break;
|
||||
- case 2: This->format = &GUID_WICPixelFormat2bppGray; break;
|
||||
- case 4: This->format = &GUID_WICPixelFormat4bppGray; break;
|
||||
- case 8: This->format = &GUID_WICPixelFormat8bppGray; break;
|
||||
+ case 1:
|
||||
+ This->format = num_palette ? &GUID_WICPixelFormat1bppIndexed : &GUID_WICPixelFormatBlackWhite;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ This->format = num_palette ? &GUID_WICPixelFormat2bppIndexed : &GUID_WICPixelFormat2bppGray;
|
||||
+ break;
|
||||
+ case 4:
|
||||
+ This->format = num_palette ? &GUID_WICPixelFormat4bppIndexed : &GUID_WICPixelFormat4bppGray;
|
||||
+ break;
|
||||
+ case 8:
|
||||
+ This->format = num_palette ? &GUID_WICPixelFormat8bppIndexed : &GUID_WICPixelFormat8bppGray;
|
||||
+ break;
|
||||
case 16: This->format = &GUID_WICPixelFormat16bppGray; break;
|
||||
default:
|
||||
ERR("invalid grayscale bit depth: %i\n", bit_depth);
|
||||
- hr = E_FAIL;
|
||||
+ hr = WINCODEC_ERR_UNKNOWNIMAGEFORMAT;
|
||||
goto end;
|
||||
}
|
||||
break;
|
||||
--
|
||||
2.9.0
|
||||
|
@ -1,2 +1,3 @@
|
||||
Fixes: Improve palette support in windowscodecs.dll
|
||||
Depends: windowscodecs-32bppGrayFloat
|
||||
Depends: gdiplus-Grayscale_PNG
|
||||
|
Loading…
x
Reference in New Issue
Block a user