From 3bacdaf664593b720afeb55a94225aab5aa04c80 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 18 Jun 2008 11:33:06 +0400 Subject: [PATCH] gdiplus: Implemented GdipGetPathData with test. --- dlls/gdiplus/gdiplus.spec | 2 +- dlls/gdiplus/graphicspath.c | 22 ++++++++++++++++++++++ dlls/gdiplus/tests/graphicspath.c | 23 +++++++++++++++++++++++ include/gdiplusflat.h | 1 + 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 3d01c1665a0..23346fc02bf 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -323,7 +323,7 @@ @ stub GdipGetNearestColor @ stdcall GdipGetPageScale(ptr ptr) @ stdcall GdipGetPageUnit(ptr ptr) -@ stub GdipGetPathData +@ stdcall GdipGetPathData(ptr ptr) @ stdcall GdipGetPathFillMode(ptr ptr) @ stub GdipGetPathGradientBlend @ stub GdipGetPathGradientBlendCount diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index 3782ca71aff..24f25e1ebf2 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -479,6 +479,28 @@ GpStatus WINGDIPAPI GdipDeletePath(GpPath *path) return Ok; } +GpStatus WINGDIPAPI GdipGetPathData(GpPath *path, GpPathData* pathData) +{ + if(!path || !pathData) + return InvalidParameter; + + pathData->Count = path->pathdata.Count; + + pathData->Points = GdipAlloc(sizeof(PointF) * pathData->Count); + if(!pathData->Points) + return OutOfMemory; + + pathData->Types = GdipAlloc(pathData->Count); + if(!pathData->Points) + return OutOfMemory; + + /* copy data */ + memcpy(pathData->Points, path->pathdata.Points, sizeof(PointF) * pathData->Count); + memcpy(pathData->Types , path->pathdata.Types , pathData->Count); + + return Ok; +} + GpStatus WINGDIPAPI GdipGetPathFillMode(GpPath *path, GpFillMode *fillmode) { if(!path || !fillmode) diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index 6436b1ab9c7..672f6da497b 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -149,6 +149,28 @@ static void test_constructor_destructor(void) expect(Ok, status); } +static void test_getpathdata(void) +{ + GpPath *path; + GpPathData data; + GpStatus status; + + GdipCreatePath(FillModeAlternate, &path); + status = GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0); + expect(Ok, status); + + status = GdipGetPathData(path, &data); + expect(Ok, status); + expect((data.Count == 2), TRUE); + expect((data.Points[0].X == 5.0) && (data.Points[0].Y == 5.0) && + (data.Points[1].X == 100.0) && (data.Points[1].Y == 50.0), TRUE); + expect((data.Types[0] == PathPointTypeStart) && (data.Types[1] == PathPointTypeLine), TRUE); + + GdipFree(data.Points); + GdipFree(data.Types); + GdipDeletePath(path); +} + static path_test_t line2_path[] = { {0.0, 50.0, PathPointTypeStart, 0, 0}, /*0*/ {5.0, 45.0, PathPointTypeLine, 0, 0}, /*1*/ @@ -605,6 +627,7 @@ START_TEST(graphicspath) GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); test_constructor_destructor(); + test_getpathdata(); test_line2(); test_arc(); test_worldbounds(); diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index 152b6da0ab4..58659fedb27 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -225,6 +225,7 @@ GpStatus WINGDIPAPI GdipCreatePath2(GDIPCONST GpPointF*,GDIPCONST BYTE*,INT, GpFillMode,GpPath**); GpStatus WINGDIPAPI GdipCreatePath2I(GDIPCONST GpPoint*,GDIPCONST BYTE*,INT,GpFillMode,GpPath**); GpStatus WINGDIPAPI GdipDeletePath(GpPath*); +GpStatus WINGDIPAPI GdipGetPathData(GpPath*,GpPathData*); GpStatus WINGDIPAPI GdipGetPathFillMode(GpPath*,GpFillMode*); GpStatus WINGDIPAPI GdipGetPathPoints(GpPath*,GpPointF*,INT); GpStatus WINGDIPAPI GdipGetPathPointsI(GpPath*,GpPoint*,INT); -- 2.11.4.GIT