Vincent Povirk : gdiplus: Fix bounds of recorded Metafile objects.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Apr 7 11:42:52 CDT 2016


Module: wine
Branch: master
Commit: 18e65a95a7e294af04a62696a8181a72860c561f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=18e65a95a7e294af04a62696a8181a72860c561f

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Wed Apr  6 14:36:55 2016 -0500

gdiplus: Fix bounds of recorded Metafile objects.

Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdiplus/metafile.c       | 19 +++++++++++--
 dlls/gdiplus/tests/metafile.c | 63 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 2 deletions(-)

diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c
index 922c101..79bf5c3 100644
--- a/dlls/gdiplus/metafile.c
+++ b/dlls/gdiplus/metafile.c
@@ -260,8 +260,9 @@ GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF
     (*metafile)->image.palette = NULL;
     (*metafile)->image.xres = dpix;
     (*metafile)->image.yres = dpiy;
-    (*metafile)->bounds = *frameRect;
-    (*metafile)->unit = frameUnit;
+    (*metafile)->bounds.X = (*metafile)->bounds.Y = 0.0;
+    (*metafile)->bounds.Width = (*metafile)->bounds.Height = 1.0;
+    (*metafile)->unit = UnitPixel;
     (*metafile)->metafile_type = type;
     (*metafile)->record_dc = record_dc;
     (*metafile)->comment_data = NULL;
@@ -471,6 +472,20 @@ GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile)
     metafile->comment_data = NULL;
     metafile->comment_data_size = 0;
 
+    if (stat == Ok)
+    {
+        MetafileHeader header;
+
+        stat = GdipGetMetafileHeaderFromEmf(metafile->hemf, &header);
+        if (stat == Ok)
+        {
+            metafile->bounds.X = header.X;
+            metafile->bounds.Y = header.Y;
+            metafile->bounds.Width = header.Width;
+            metafile->bounds.Height = header.Height;
+        }
+    }
+
     return stat;
 }
 
diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c
index 0c52718..086a261 100644
--- a/dlls/gdiplus/tests/metafile.c
+++ b/dlls/gdiplus/tests/metafile.c
@@ -1141,6 +1141,68 @@ static void test_converttoemfplus(void)
     expect(Ok, stat);
 }
 
+static void test_frameunit(void)
+{
+    GpStatus stat;
+    GpMetafile *metafile;
+    GpGraphics *graphics;
+    HDC hdc;
+    static const GpRectF frame = {0.0, 0.0, 5.0, 5.0};
+    static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
+    GpUnit unit;
+    REAL dpix, dpiy;
+    GpRectF bounds;
+
+    hdc = CreateCompatibleDC(0);
+
+    stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitInch, description, &metafile);
+    expect(Ok, stat);
+
+    DeleteDC(hdc);
+
+    if (stat != Ok)
+        return;
+
+    stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
+    expect(Ok, stat);
+    expect(UnitPixel, unit);
+    expectf(0.0, bounds.X);
+    expectf(0.0, bounds.Y);
+    expectf(1.0, bounds.Width);
+    expectf(1.0, bounds.Height);
+
+    stat = GdipGetImageGraphicsContext((GpImage*)metafile, &graphics);
+    expect(Ok, stat);
+
+    stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
+    expect(Ok, stat);
+    expect(UnitPixel, unit);
+    expectf(0.0, bounds.X);
+    expectf(0.0, bounds.Y);
+    expectf(1.0, bounds.Width);
+    expectf(1.0, bounds.Height);
+
+    stat = GdipDeleteGraphics(graphics);
+    expect(Ok, stat);
+
+    stat = GdipGetImageHorizontalResolution((GpImage*)metafile, &dpix);
+    expect(Ok, stat);
+
+    stat = GdipGetImageVerticalResolution((GpImage*)metafile, &dpiy);
+    expect(Ok, stat);
+
+    stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
+    expect(Ok, stat);
+    expect(UnitPixel, unit);
+    expectf(0.0, bounds.X);
+    expectf(0.0, bounds.Y);
+    expectf_(5.0 * dpix, bounds.Width, 1.0);
+    expectf_(5.0 * dpiy, bounds.Height, 1.0);
+
+    stat = GdipDisposeImage((GpImage*)metafile);
+    expect(Ok, stat);
+}
+
 START_TEST(metafile)
 {
     struct GdiplusStartupInput gdiplusStartupInput;
@@ -1166,6 +1228,7 @@ START_TEST(metafile)
     test_fillrect();
     test_pagetransform();
     test_converttoemfplus();
+    test_frameunit();
 
     GdiplusShutdown(gdiplusToken);
 }




More information about the wine-cvs mailing list