Royal Chan : diplus: Implement GdipDrawBezierI based on GdipDrawBezier.

Alexandre Julliard julliard at winehq.org
Tue Feb 26 05:45:19 CST 2008


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

Author: Royal Chan <chanroyal at gmail.com>
Date:   Mon Feb 25 21:00:43 2008 -0800

diplus: Implement GdipDrawBezierI based on GdipDrawBezier.

---

 dlls/gdiplus/gdiplus.spec     |    2 +-
 dlls/gdiplus/graphics.c       |   28 ++++++++++++++++++++++++++++
 dlls/gdiplus/tests/graphics.c |   39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+), 1 deletions(-)

diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 33b474d..d28de1e 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -155,7 +155,7 @@
 @ stdcall GdipDrawArc(ptr ptr long long long long long long)
 @ stub GdipDrawArcI
 @ stdcall GdipDrawBezier(ptr ptr long long long long long long long long)
-@ stub GdipDrawBezierI
+@ stdcall GdipDrawBezierI(ptr ptr long long long long long long long long)
 @ stub GdipDrawBeziers
 @ stub GdipDrawBeziersI
 @ stub GdipDrawCachedBitmap
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index aed61c5..ebd46aa 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -957,6 +957,34 @@ GpStatus WINGDIPAPI GdipDrawBezier(GpGraphics *graphics, GpPen *pen, REAL x1,
     return retval;
 }
 
+GpStatus WINGDIPAPI GdipDrawBezierI(GpGraphics *graphics, GpPen *pen, INT x1,
+    INT y1, INT x2, INT y2, INT x3, INT y3, INT x4, INT y4)
+{
+    INT save_state;
+    GpPointF pt[4];
+    GpStatus retval;
+
+    if(!graphics || !pen)
+        return InvalidParameter;
+
+    pt[0].X = x1;
+    pt[0].Y = y1;
+    pt[1].X = x2;
+    pt[1].Y = y2;
+    pt[2].X = x3;
+    pt[2].Y = y3;
+    pt[3].X = x4;
+    pt[3].Y = y4;
+
+    save_state = prepare_dc(graphics, pen);
+
+    retval = draw_polybezier(graphics, pen, pt, 4, TRUE);
+
+    restore_dc(graphics, save_state);
+
+    return retval;
+}
+
 /* Approximates cardinal spline with Bezier curves. */
 GpStatus WINGDIPAPI GdipDrawCurve2(GpGraphics *graphics, GpPen *pen,
     GDIPCONST GpPointF *points, INT count, REAL tension)
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index de29bfb..826ab67 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -220,6 +220,44 @@ static void test_save_restore(void)
     ReleaseDC(0, hdc);
 }
 
+static void test_GdipDrawBezierI(void)
+{
+    GpStatus status;
+    GpGraphics *graphics = NULL;
+    GpPen *pen = NULL;
+    HDC hdc = GetDC(0);
+
+    /* make a graphics object and pen object */
+    status = GdipCreateFromHDC(hdc, &graphics);
+    expect(Ok, status);
+    ok(hdc != NULL, "Expected HDC to be initialized\n");
+
+    status = GdipCreateFromHDC(hdc, &graphics);
+    expect(Ok, status);
+    ok(graphics != NULL, "Expected graphics to be initialized\n");
+
+    status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
+    expect(Ok, status);
+    ok(pen != NULL, "Expected pen to be initialized\n");
+
+    /* InvalidParameter cases: null graphics, null pen */
+    status = GdipDrawBezierI(NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
+    expect(InvalidParameter, status);
+
+    status = GdipDrawBezierI(graphics, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
+    expect(InvalidParameter, status);
+
+    status = GdipDrawBezierI(NULL, pen, 0, 0, 0, 0, 0, 0, 0, 0);
+    expect(InvalidParameter, status);
+
+    /* successful case */
+    status = GdipDrawBezierI(graphics, pen, 0, 0, 0, 0, 0, 0, 0, 0);
+    expect(Ok, status);
+
+    GdipDeletePen(pen);
+    ReleaseDC(0, hdc);
+}
+
 START_TEST(graphics)
 {
     struct GdiplusStartupInput gdiplusStartupInput;
@@ -234,6 +272,7 @@ START_TEST(graphics)
 
     test_constructor_destructor();
     test_save_restore();
+    test_GdipDrawBezierI();
 
     GdiplusShutdown(gdiplusToken);
 }




More information about the wine-cvs mailing list