From 6e7b5347e362544ce4555636c4584cfecb2a3b83 Mon Sep 17 00:00:00 2001 From: Royal Chan Date: Fri, 29 Feb 2008 04:58:39 -0800 Subject: [PATCH] gdiplus: Implement GdipDrawLinesI based on GdipDrawLines. --- dlls/gdiplus/gdiplus.spec | 2 +- dlls/gdiplus/graphics.c | 29 +++++++++++++++++++ dlls/gdiplus/tests/graphics.c | 53 +++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index a2d3183e118..ce4640f1873 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -188,7 +188,7 @@ @ stdcall GdipDrawLine(ptr ptr long long long long) @ stdcall GdipDrawLineI(ptr ptr long long long long) @ stdcall GdipDrawLines(ptr ptr ptr long) -@ stub GdipDrawLinesI +@ stdcall GdipDrawLinesI(ptr ptr ptr long) @ stdcall GdipDrawPath(ptr ptr ptr) @ stdcall GdipDrawPie(ptr ptr long long long long long long) @ stub GdipDrawPieI diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 123da48970b..ab8733d3dc5 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -1224,6 +1224,35 @@ GpStatus WINGDIPAPI GdipDrawLines(GpGraphics *graphics, GpPen *pen, GDIPCONST return retval; } +GpStatus WINGDIPAPI GdipDrawLinesI(GpGraphics *graphics, GpPen *pen, GDIPCONST + GpPoint *points, INT count) +{ + INT save_state; + GpStatus retval; + GpPointF *ptf = NULL; + int i; + + if(!pen || !graphics || (count < 2)) + return InvalidParameter; + + ptf = GdipAlloc(count * sizeof(GpPointF)); + if(!ptf) return OutOfMemory; + + for(i = 0; i < count; i ++){ + ptf[i].X = (REAL) points[i].X; + ptf[i].Y = (REAL) points[i].Y; + } + + save_state = prepare_dc(graphics, pen); + + retval = draw_polyline(graphics, pen, ptf, count, TRUE); + + restore_dc(graphics, save_state); + + GdipFree(ptf); + return retval; +} + GpStatus WINGDIPAPI GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *path) { INT save_state; diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index c3a3315ff62..6a6bc3dcd21 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -384,6 +384,58 @@ static void test_GdipDrawLineI(void) ReleaseDC(0, hdc); } +static void test_GdipDrawLinesI(void) +{ + GpStatus status; + GpGraphics *graphics = NULL; + GpPen *pen = NULL; + GpPoint *ptf = 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"); + + /* make some arbitrary valid points*/ + ptf = GdipAlloc(2 * sizeof(GpPointF)); + + ptf[0].X = 1; + ptf[0].Y = 1; + + ptf[1].X = 2; + ptf[1].Y = 2; + + /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/ + status = GdipDrawLinesI(NULL, NULL, NULL, 0); + expect(InvalidParameter, status); + + status = GdipDrawLinesI(graphics, pen, ptf, 0); + expect(InvalidParameter, status); + + status = GdipDrawLinesI(graphics, NULL, ptf, 2); + expect(InvalidParameter, status); + + status = GdipDrawLinesI(NULL, pen, ptf, 2); + expect(InvalidParameter, status); + + /* successful case */ + status = GdipDrawLinesI(graphics, pen, ptf, 2); + expect(Ok, status); + + GdipFree(ptf); + GdipDeletePen(pen); + ReleaseDC(0, hdc); +} + START_TEST(graphics) { struct GdiplusStartupInput gdiplusStartupInput; @@ -402,6 +454,7 @@ START_TEST(graphics) test_GdipDrawArc(); test_GdipDrawArcI(); test_GdipDrawLineI(); + test_GdipDrawLinesI(); GdiplusShutdown(gdiplusToken); }