Added patch to forward GIF encoder requests to windowscodecs.

This commit is contained in:
Sebastian Lackner
2015-06-09 05:49:04 +02:00
parent 7a6fec3740
commit 5fc6371a97
5 changed files with 212 additions and 37 deletions

View File

@@ -0,0 +1,151 @@
From 5a9241dd76874080df0938618a2fbbb022250791 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Tue, 9 Jun 2015 05:46:41 +0200
Subject: gdiplus: Forward GIF encoder requests to windowscodecs.
---
dlls/gdiplus/image.c | 10 ++++--
dlls/gdiplus/tests/image.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 94 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index 86802a5..1d2d6fa 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -4401,6 +4401,12 @@ static GpStatus encode_image_jpeg(GpImage *image, IStream* stream,
return encode_image_wic(image, stream, &GUID_ContainerFormatJpeg, params);
}
+static GpStatus encode_image_gif(GpImage *image, IStream* stream,
+ GDIPCONST CLSID* clsid, GDIPCONST EncoderParameters* params)
+{
+ return encode_image_wic(image, stream, &CLSID_WICGifEncoder, params);
+}
+
/*****************************************************************************
* GdipSaveImageToStream [GDIPLUS.@]
*/
@@ -4611,14 +4617,14 @@ static const struct image_codec codecs[NUM_CODECS] = {
/* FormatDescription */ gif_format,
/* FilenameExtension */ gif_extension,
/* MimeType */ gif_mimetype,
- /* Flags */ ImageCodecFlagsDecoder | ImageCodecFlagsSupportBitmap | ImageCodecFlagsBuiltin,
+ /* Flags */ ImageCodecFlagsDecoder | ImageCodecFlagsEncoder | ImageCodecFlagsSupportBitmap | ImageCodecFlagsBuiltin,
/* Version */ 1,
/* SigCount */ 2,
/* SigSize */ 6,
/* SigPattern */ gif_sig_pattern,
/* SigMask */ gif_sig_mask,
},
- NULL,
+ encode_image_gif,
decode_image_gif,
select_frame_gif
},
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index 63fc96e..8a85828 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -4544,6 +4544,91 @@ static void test_CloneBitmapArea(void)
GdipDisposeImage((GpImage *)bitmap);
}
+static BOOL get_encoder_clsid(LPCWSTR mime, GUID *format, CLSID *clsid)
+{
+ GpStatus status;
+ UINT n_codecs, info_size, i;
+ ImageCodecInfo *info;
+ BOOL ret = FALSE;
+
+ status = GdipGetImageEncodersSize(&n_codecs, &info_size);
+ expect(Ok, status);
+
+ info = GdipAlloc(info_size);
+
+ status = GdipGetImageEncoders(n_codecs, info_size, info);
+ expect(Ok, status);
+
+ for (i = 0; i < n_codecs; i++)
+ {
+ if (!lstrcmpW(info[i].MimeType, mime))
+ {
+ *format = info[i].FormatID;
+ *clsid = info[i].Clsid;
+ ret = TRUE;
+ break;
+ }
+ }
+
+ GdipFree(info);
+ return ret;
+}
+
+static void test_supported_encoders(void)
+{
+ static const WCHAR bmp_mimetype[] = {'i', 'm', 'a','g', 'e', '/', 'b', 'm', 'p', 0};
+ static const WCHAR jpeg_mimetype[] = {'i','m','a','g','e','/','j','p','e','g', 0};
+ static const WCHAR gif_mimetype[] = {'i','m','a','g','e','/','g','i','f', 0};
+ static const WCHAR tiff_mimetype[] = {'i','m','a','g','e','/','t','i','f','f', 0};
+ static const WCHAR png_mimetype[] = {'i','m','a','g','e','/','p','n','g', 0};
+ static const struct test_data
+ {
+ LPCWSTR mime;
+ const GUID *format;
+ BOOL todo;
+ } td[] =
+ {
+ { bmp_mimetype, &ImageFormatBMP, FALSE },
+ { jpeg_mimetype, &ImageFormatJPEG, FALSE },
+ { gif_mimetype, &ImageFormatGIF, TRUE },
+ { tiff_mimetype, &ImageFormatTIFF, FALSE },
+ { png_mimetype, &ImageFormatPNG, FALSE }
+ };
+ GUID format, clsid;
+ BOOL ret;
+ HRESULT hr;
+ GpStatus status;
+ GpBitmap *bm;
+ IStream *stream;
+ HGLOBAL hmem;
+ int i;
+
+ status = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat24bppRGB, NULL, &bm);
+ ok(status == Ok, "GdipCreateBitmapFromScan0 error %d\n", status);
+
+ for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
+ {
+ ret = get_encoder_clsid(td[i].mime, &format, &clsid);
+ ok(ret, "%s encoder is not in the list\n", wine_dbgstr_w(td[i].mime));
+ expect_guid(td[i].format, &format, __LINE__, FALSE);
+
+ hmem = GlobalAlloc(GMEM_MOVEABLE | GMEM_NODISCARD, 16);
+
+ hr = CreateStreamOnHGlobal(hmem, TRUE, &stream);
+ ok(hr == S_OK, "CreateStreamOnHGlobal error %#x\n", hr);
+
+ status = GdipSaveImageToStream((GpImage *)bm, stream, &clsid, NULL);
+ if (td[i].todo)
+ todo_wine ok(status == Ok, "GdipSaveImageToStream error %d\n", status);
+ else
+ ok(status == Ok, "GdipSaveImageToStream error %d\n", status);
+
+ IStream_Release(stream);
+ }
+
+ GdipDisposeImage((GpImage *)bm);
+}
+
START_TEST(image)
{
struct GdiplusStartupInput gdiplusStartupInput;
@@ -4556,6 +4641,7 @@ START_TEST(image)
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
+ test_supported_encoders();
test_CloneBitmapArea();
test_ARGB_conversion();
test_DrawImage_scale();
--
2.4.2

View File

@@ -0,0 +1 @@
Fixes: [34356] Forward GIF encoder requests to windowscodecs