[4/5] gdiplus: Use reference device to determine created metafile resolution.

Vincent Povirk madewokherd at gmail.com
Fri Oct 30 15:08:09 CDT 2015


-------------- next part --------------
From 7353884ea38664d6c33ee149f2a7cfe74acd5ba0 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Fri, 30 Oct 2015 14:28:12 -0500
Subject: [PATCH 4/5] gdiplus: Use reference device to determine created
 metafile resolution.

Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
---
 dlls/gdiplus/metafile.c       | 12 ++++++++----
 dlls/gdiplus/tests/metafile.c | 24 ++++++++++++------------
 2 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c
index 20b8e20..ca9889b 100644
--- a/dlls/gdiplus/metafile.c
+++ b/dlls/gdiplus/metafile.c
@@ -193,6 +193,7 @@ GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF
                                        MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
 {
     HDC record_dc;
+    REAL dpix, dpiy;
     REAL framerect_factor_x, framerect_factor_y;
     RECT rc;
     GpStatus stat;
@@ -208,11 +209,14 @@ GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF
         return NotImplemented;
     }
 
+    dpix = (REAL)GetDeviceCaps(hdc, HORZRES) / GetDeviceCaps(hdc, HORZSIZE) * 25.4;
+    dpiy = (REAL)GetDeviceCaps(hdc, VERTRES) / GetDeviceCaps(hdc, VERTSIZE) * 25.4;
+
     switch (frameUnit)
     {
     case MetafileFrameUnitPixel:
-        framerect_factor_x = 2540.0 / GetDeviceCaps(hdc, LOGPIXELSX);
-        framerect_factor_y = 2540.0 / GetDeviceCaps(hdc, LOGPIXELSY);
+        framerect_factor_x = 2540.0 / dpix;
+        framerect_factor_y = 2540.0 / dpiy;
         break;
     case MetafileFrameUnitPoint:
         framerect_factor_x = framerect_factor_y = 2540.0 / 72.0;
@@ -254,8 +258,8 @@ GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF
     (*metafile)->image.picture = NULL;
     (*metafile)->image.flags   = ImageFlagsNone;
     (*metafile)->image.palette = NULL;
-    (*metafile)->image.xres = 72.0;
-    (*metafile)->image.yres = 72.0;
+    (*metafile)->image.xres = dpix;
+    (*metafile)->image.yres = dpiy;
     (*metafile)->bounds = *frameRect;
     (*metafile)->unit = frameUnit;
     (*metafile)->metafile_type = type;
diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c
index 82e803d..5a7d037 100644
--- a/dlls/gdiplus/tests/metafile.c
+++ b/dlls/gdiplus/tests/metafile.c
@@ -373,10 +373,10 @@ static void test_empty(void)
     expect(U(header).EmfHeader.nBytes, header.Size);
     ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "Unexpected version %x\n", header.Version);
     expect(1, header.EmfPlusFlags); /* reference device was display, not printer */
-    todo_wine expectf(xres, header.DpiX);
-    todo_wine expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
-    todo_wine expectf(yres, header.DpiY);
-    todo_wine expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
+    expectf(xres, header.DpiX);
+    expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
+    expectf(yres, header.DpiY);
+    expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
     expect(0, header.X);
     expect(0, header.Y);
     expect(100, header.Width);
@@ -391,8 +391,8 @@ static void test_empty(void)
     expect(-1, U(header).EmfHeader.rclBounds.bottom);
     expect(0, U(header).EmfHeader.rclFrame.left);
     expect(0, U(header).EmfHeader.rclFrame.top);
-    todo_wine expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
-    todo_wine expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
+    expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
+    expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
 
     stat = GdipCreateMetafileFromEmf(hemf, TRUE, &metafile);
     expect(Ok, stat);
@@ -720,10 +720,10 @@ static void test_emfonly(void)
     expect(U(header).EmfHeader.nBytes, header.Size);
     expect(0x10000, header.Version);
     expect(0, header.EmfPlusFlags);
-    todo_wine expectf(xres, header.DpiX);
-    todo_wine expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
-    todo_wine expectf(yres, header.DpiY);
-    todo_wine expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
+    expectf(xres, header.DpiX);
+    expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
+    expectf(yres, header.DpiY);
+    expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
     expect(0, header.X);
     expect(0, header.Y);
     expect(100, header.Width);
@@ -738,8 +738,8 @@ static void test_emfonly(void)
     expect(74, U(header).EmfHeader.rclBounds.bottom);
     expect(0, U(header).EmfHeader.rclFrame.left);
     expect(0, U(header).EmfHeader.rclFrame.top);
-    todo_wine expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
-    todo_wine expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
+    expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
+    expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
 
     stat = GdipCreateMetafileFromEmf(hemf, TRUE, &metafile);
     expect(Ok, stat);
-- 
2.1.4



More information about the wine-patches mailing list