Vincent Povirk : gdiplus: Implement drawing metafiles with an emf handle.

Alexandre Julliard julliard at winehq.org
Thu Nov 1 14:42:58 CDT 2012


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Wed Oct 31 13:36:00 2012 -0500

gdiplus: Implement drawing metafiles with an emf handle.

---

 dlls/gdiplus/graphics.c       |   23 +++++++++++++++++++++--
 dlls/gdiplus/tests/metafile.c |    8 ++++----
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index c428b6b..7380c5d 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -3085,6 +3085,13 @@ GpStatus WINGDIPAPI GdipDrawImagePointsI(GpGraphics *graphics, GpImage *image,
     return GdipDrawImagePoints(graphics, image, ptf, count);
 }
 
+static BOOL CALLBACK play_metafile_proc(EmfPlusRecordType record_type, unsigned int flags,
+    unsigned int dataSize, const unsigned char *pStr, void *userdata)
+{
+    GdipPlayMetafileRecord(userdata, record_type, flags, dataSize, pStr);
+    return TRUE;
+}
+
 GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image,
      GDIPCONST GpPointF *points, INT count, REAL srcx, REAL srcy, REAL srcwidth,
      REAL srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes* imageAttributes,
@@ -3379,10 +3386,22 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
                 DeleteObject(hbitmap);
         }
     }
+    else if (image->type == ImageTypeMetafile && ((GpMetafile*)image)->hemf)
+    {
+        GpRectF rc;
+
+        rc.X = srcx;
+        rc.Y = srcy;
+        rc.Width = srcwidth;
+        rc.Height = srcheight;
+
+        return GdipEnumerateMetafileSrcRectDestPoints(graphics, (GpMetafile*)image,
+            points, count, &rc, srcUnit, play_metafile_proc, image, imageAttributes);
+    }
     else
     {
-        ERR("GpImage with no IPicture or HBITMAP?!\n");
-        return NotImplemented;
+        WARN("GpImage with nothing we can draw (metafile in wrong state?)\n");
+        return InvalidParameter;
     }
 
     return Ok;
diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c
index 31374a5..f283c06 100644
--- a/dlls/gdiplus/tests/metafile.c
+++ b/dlls/gdiplus/tests/metafile.c
@@ -431,7 +431,7 @@ static void test_getdc(void)
 
     stat = GdipDrawImagePointsRect(graphics, (GpImage*)metafile, dst_points, 3,
         0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
-    todo_wine expect(Ok, stat);
+    expect(Ok, stat);
 
     stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
     expect(Ok, stat);
@@ -439,7 +439,7 @@ static void test_getdc(void)
 
     stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
     expect(Ok, stat);
-    todo_wine expect(0xff0000ff, color);
+    expect(0xff0000ff, color);
 
     stat = GdipDeleteGraphics(graphics);
     expect(Ok, stat);
@@ -550,7 +550,7 @@ static void test_emfonly(void)
 
     stat = GdipDrawImagePointsRect(graphics, (GpImage*)metafile, dst_points, 3,
         0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
-    todo_wine expect(Ok, stat);
+    expect(Ok, stat);
 
     stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
     expect(Ok, stat);
@@ -558,7 +558,7 @@ static void test_emfonly(void)
 
     stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
     expect(Ok, stat);
-    todo_wine expect(0xff0000ff, color);
+    expect(0xff0000ff, color);
 
     stat = GdipDeleteGraphics(graphics);
     expect(Ok, stat);




More information about the wine-cvs mailing list