[3/4] gdiplus: Load EMF images directly instead of through olepicture.
Vincent Povirk
madewokherd at gmail.com
Tue Aug 16 16:00:28 CDT 2016
From: Vincent Povirk <vincent at codeweavers.com>
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
---
dlls/gdiplus/image.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 47 insertions(+), 1 deletion(-)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index c3f6a5e..cc5e8c8 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -4037,6 +4037,52 @@ static GpStatus decode_image_tiff(IStream* stream, GpImage **image)
return decode_image_wic(stream, &GUID_ContainerFormatTiff, NULL, image);
}
+static GpStatus decode_image_emf(IStream* stream, GpImage **image)
+{
+ HENHMETAFILE hemf;
+ STATSTG statstg;
+ DWORD size, bytesread;
+ BYTE *buffer;
+ HRESULT hr;
+ GpStatus status;
+
+ TRACE("%p %p\n", stream, image);
+
+ if(!stream || !image)
+ return InvalidParameter;
+
+ hr = IStream_Stat(stream, &statstg, STATFLAG_NONAME);
+ if (FAILED(hr))
+ return hresult_to_status(hr);
+
+ size = statstg.cbSize.u.LowPart;
+
+ buffer = heap_alloc(size);
+ if (!buffer)
+ return OutOfMemory;
+
+ hr = IStream_Read(stream, buffer, size, &bytesread);
+ if (FAILED(hr) || bytesread != size)
+ {
+ heap_free(buffer);
+ return FAILED(hr) ? hresult_to_status(hr) : GenericError;
+ }
+
+ hemf = SetEnhMetaFileBits(size, buffer);
+
+ heap_free(buffer);
+
+ if (!hemf)
+ return GenericError;
+
+ status = GdipCreateMetafileFromEmf(hemf, TRUE, (GpMetafile**)image);
+
+ if (status != Ok)
+ DeleteEnhMetaFile(hemf);
+
+ return status;
+}
+
static GpStatus decode_image_olepicture_metafile(IStream* stream, GpImage **image)
{
IPicture *pic;
@@ -4721,7 +4767,7 @@ static const struct image_codec codecs[NUM_CODECS] = {
/* SigMask */ emf_sig_mask,
},
NULL,
- decode_image_olepicture_metafile,
+ decode_image_emf,
NULL
},
{
--
2.7.4
More information about the wine-patches
mailing list