[Gdiplus 11/15] Implement GdipCreateRegionRect

Adam Petaccia adam at tpetaccia.com
Wed Jul 9 02:34:01 CDT 2008


---
 dlls/gdiplus/region.c       |   28 ++++++++++++++++++++++++----
 dlls/gdiplus/tests/region.c |    8 ++++----
 2 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/dlls/gdiplus/region.c b/dlls/gdiplus/region.c
index 59e2fa6..de86ce1 100644
--- a/dlls/gdiplus/region.c
+++ b/dlls/gdiplus/region.c
@@ -129,12 +129,32 @@ GpStatus WINGDIPAPI GdipCreateRegionPath(GpPath *path, GpRegion **region)
     return Ok;
 }
 
-GpStatus WINGDIPAPI GdipCreateRegionRect(GDIPCONST GpRectF *rect, GpRegion **region)
+GpStatus WINGDIPAPI GdipCreateRegionRect(GDIPCONST GpRectF *rect,
+        GpRegion **region)
 {
-    FIXME("(%p, %p): stub\n", rect, region);
+    GpPath *path;
+    GpStatus stat;
 
-    *region = NULL;
-    return NotImplemented;
+    if (!(rect && region))
+        return InvalidParameter;
+
+    TRACE("%p, %p\n", rect, region);
+
+    *region = GdipAlloc(sizeof(GpRegion*));
+    if(!*region)
+        return OutOfMemory;
+
+    stat = GdipCreatePath(FillModeAlternate, &path);
+    if (stat != Ok) { GdipDeleteRegion(*region); return stat;}
+    stat = GdipAddPathRectangle(path, rect->X, rect->Y,
+            rect->Width, rect->Height);
+    if (stat != Ok) { GdipDeleteRegion(*region); return stat;}
+    stat = GdipCreateRegionPath(path, region);
+    if (stat != Ok) { GdipDeleteRegion(*region); return stat;}
+
+    GdipDeletePath(path);
+
+    return Ok;
 }
 
 GpStatus WINGDIPAPI GdipCreateRegionRectI(GDIPCONST GpRect *rect, GpRegion **region)
diff --git a/dlls/gdiplus/tests/region.c b/dlls/gdiplus/tests/region.c
index d4c3ddc..cfe3106 100644
--- a/dlls/gdiplus/tests/region.c
+++ b/dlls/gdiplus/tests/region.c
@@ -222,13 +222,13 @@ static void test_regionbounds(void)
     rect.Y = 7;
     rect.Width  = 10;
     rect.Height = 20;
-todo_wine
-{
     stat = GdipCreateRegionRect(&rect, &region);
     expect(Ok, stat);
 
     /* Clear the rect to make sure what we get isn't stale data */
     ZeroMemory(&rect, sizeof(RectF));
+todo_wine
+{
     stat = GdipGetRegionBounds(region, graphics, &rect);
     ok(rect.X == 5, "Expected 5 for X, got %f\n", rect.X);
     ok(rect.Y == 7, "Expected 7 for Y, got %f\n", rect.Y);
@@ -246,10 +246,10 @@ todo_wine
     expect(Ok, stat);
     stat = GdipAddPathLine(path, 1, 4, 5, 1);
     expect(Ok, stat);
-todo_wine
-{
     stat = GdipCreateRegionPath(path, &region);
     expect(Ok, stat);
+todo_wine
+{
     stat = GdipGetRegionBounds(region, graphics, &rect);
     expect(Ok, stat);
     ok(rect.X == 1, "Expected 0 for X, got %f\n", rect.X);
-- 
1.5.4.3




More information about the wine-patches mailing list