Vincent Povirk : gdiplus: Fix graphics bounds for memory DC's.

Alexandre Julliard julliard at winehq.org
Thu Dec 6 16:25:09 CST 2012


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Wed Dec  5 14:11:25 2012 -0600

gdiplus: Fix graphics bounds for memory DC's.

---

 dlls/gdiplus/graphics.c       |   19 +++++++++++++++++++
 dlls/gdiplus/tests/graphics.c |    8 ++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 4474db6..8cec80d 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -2113,6 +2113,25 @@ static GpStatus get_graphics_bounds(GpGraphics* graphics, GpRectF* rect)
         stat = GdipGetImageBounds(graphics->image, rect, &unit);
         if (stat == Ok && unit != UnitPixel)
             FIXME("need to convert from unit %i\n", unit);
+    }else if (GetObjectType(graphics->hdc) == OBJ_MEMDC){
+        HBITMAP hbmp;
+        BITMAP bmp;
+
+        rect->X = 0;
+        rect->Y = 0;
+
+        hbmp = GetCurrentObject(graphics->hdc, OBJ_BITMAP);
+        if (hbmp && GetObjectW(hbmp, sizeof(bmp), &bmp))
+        {
+            rect->Width = bmp.bmWidth;
+            rect->Height = bmp.bmHeight;
+        }
+        else
+        {
+            /* FIXME: ??? */
+            rect->Width = 1;
+            rect->Height = 1;
+        }
     }else{
         rect->X = 0;
         rect->Y = 0;
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index f4e7ffa..42612dd 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -4091,6 +4091,7 @@ static void test_alpha_hdc(void)
     GpGraphics *graphics;
     ULONG *bits;
     BITMAPINFO bmi;
+    GpRectF bounds;
 
     hdc = CreateCompatibleDC(0);
     ok(hdc != NULL, "CreateCompatibleDC failed\n");
@@ -4110,6 +4111,13 @@ static void test_alpha_hdc(void)
     status = GdipCreateFromHDC(hdc, &graphics);
     expect(Ok, status);
 
+    status = GdipGetVisibleClipBounds(graphics, &bounds);
+    expect(Ok, status);
+    expectf(0.0, bounds.X);
+    expectf(0.0, bounds.Y);
+    expectf(5.0, bounds.Width);
+    expectf(5.0, bounds.Height);
+
     bits[0] = 0xdeadbeef;
 
     status = GdipGraphicsClear(graphics, 0xffaaaaaa);




More information about the wine-cvs mailing list