gdiplus: Force conversion of 8 bpp grayscale PNG images to 32 bpp BGRA.
Vincent Povirk
vincent at codeweavers.com
Thu Aug 24 11:19:01 CDT 2017
From: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
---
dlls/gdiplus/image.c | 32 +++++++++++++++++++++++++++++++-
dlls/gdiplus/tests/image.c | 1 -
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index 0821658..e3bc70e 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -3961,7 +3961,37 @@ static GpStatus decode_image_jpeg(IStream* stream, GpImage **image)
static GpStatus decode_image_png(IStream* stream, GpImage **image)
{
- return decode_image_wic(stream, &GUID_ContainerFormatPng, png_metadata_reader, image);
+ IWICBitmapDecoder *decoder;
+ IWICBitmapFrameDecode *frame;
+ GpStatus status;
+ HRESULT hr;
+ GUID format;
+ BOOL force_conversion = FALSE;
+
+ status = initialize_decoder_wic(stream, &GUID_ContainerFormatPng, &decoder);
+ if (status != Ok)
+ return status;
+
+ hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
+ if (hr == S_OK)
+ {
+ hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
+ if (hr == S_OK)
+ {
+ if (IsEqualGUID(&format, &GUID_WICPixelFormat8bppGray))
+ force_conversion = TRUE;
+ status = decode_frame_wic(decoder, force_conversion, 0, png_metadata_reader, image);
+ }
+ else
+ status = hresult_to_status(hr);
+
+ IWICBitmapFrameDecode_Release(frame);
+ }
+ else
+ status = hresult_to_status(hr);
+
+ IWICBitmapDecoder_Release(decoder);
+ return status;
}
static GpStatus decode_image_gif(IStream* stream, GpImage **image)
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index 989c217..b9685c3 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -5014,7 +5014,6 @@ static void test_png_color_formats(void)
status = GdipGetImagePixelFormat(image, &format);
expect(Ok, status);
-todo_wine_if(td[i].bit_depth == 8 && td[i].color_type == 0)
ok(format == td[i].format ||
broken(td[i].bit_depth == 1 && td[i].color_type == 0 && format == PixelFormat32bppARGB), /* XP */
"%d: expected %#x, got %#x\n", i, td[i].format, format);
--
2.7.4
More information about the wine-patches
mailing list