https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5c8ae0d76697c28b850e8…
commit 5c8ae0d76697c28b850e8914680a95e5327d616f
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sat Dec 25 21:40:08 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Sat Dec 25 21:40:08 2021 +0900
[GDIPLUS] GdipCreateBitmapFromStream should accept metafiles (#4181)
- Add hbitmap_from_emf helper function.
- GdipCreateBitmapFromStream accepts the metafiles.
CORE-17814
---
dll/win32/gdiplus/image.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/dll/win32/gdiplus/image.c b/dll/win32/gdiplus/image.c
index 8425bcb54b3..e9fd781a1be 100644
--- a/dll/win32/gdiplus/image.c
+++ b/dll/win32/gdiplus/image.c
@@ -1897,6 +1897,41 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT
height, INT stride,
return Ok;
}
+#ifdef __REACTOS__
+static HBITMAP hbitmap_from_emf(HENHMETAFILE hemf)
+{
+ BITMAPINFO bmi;
+ HBITMAP hbm;
+ SIZE size;
+ ENHMETAHEADER header;
+ HGDIOBJ hbmOld;
+ RECT rc;
+ HDC hdc;
+
+ GetEnhMetaFileHeader(hemf, sizeof(header), &header);
+ size.cx = header.rclBounds.right - header.rclBounds.left + 1;
+ size.cy = header.rclBounds.bottom - header.rclBounds.top + 1;
+
+ ZeroMemory(&bmi, sizeof(bmi));
+ bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
+ bmi.bmiHeader.biWidth = size.cx;
+ bmi.bmiHeader.biHeight = size.cy;
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = 24;
+
+ hdc = CreateCompatibleDC(NULL);
+ hbm = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, NULL, NULL, 0);
+
+ hbmOld = SelectObject(hdc, hbm);
+ SetRect(&rc, 0, 0, size.cx, size.cy);
+ PlayEnhMetaFile(hdc, hemf, &rc);
+ SelectObject(hdc, hbmOld);
+
+ DeleteDC(hdc);
+ return hbm;
+}
+
+#endif
GpStatus WINGDIPAPI GdipCreateBitmapFromStream(IStream* stream,
GpBitmap **bitmap)
{
@@ -1909,6 +1944,19 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromStream(IStream* stream,
if(stat != Ok)
return stat;
+#ifdef __REACTOS__
+ if ((*bitmap)->image.type == ImageTypeMetafile)
+ {
+ HBITMAP hbm = hbitmap_from_emf(((GpMetafile*)*bitmap)->hemf);
+ GdipDisposeImage(&(*bitmap)->image);
+ if (!hbm)
+ return GenericError; /* FIXME: what error to return? */
+
+ GdipCreateBitmapFromHBITMAP(hbm, NULL, bitmap);
+ DeleteObject(hbm);
+ }
+ else
+#endif
if((*bitmap)->image.type != ImageTypeBitmap){
GdipDisposeImage(&(*bitmap)->image);
*bitmap = NULL;