gdiplus: Fix GdipGetPathData implementation and test.
Previous version (commit 3bacdaf664
) was totally incorrect.
Thanks to Paul Vriens for pointing this out.
This commit is contained in:
parent
c42d937402
commit
991e785f50
|
@ -484,17 +484,8 @@ 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 */
|
||||
/* Only copy data. pathData allocation/freeing controlled by wrapper class.
|
||||
Assumed that pathData is enough wide to get all data - controlled by wrapper too. */
|
||||
memcpy(pathData->Points, path->pathdata.Points, sizeof(PointF) * pathData->Count);
|
||||
memcpy(pathData->Types , path->pathdata.Types , pathData->Count);
|
||||
|
||||
|
|
|
@ -154,14 +154,22 @@ static void test_getpathdata(void)
|
|||
GpPath *path;
|
||||
GpPathData data;
|
||||
GpStatus status;
|
||||
INT count;
|
||||
|
||||
GdipCreatePath(FillModeAlternate, &path);
|
||||
status = GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0);
|
||||
expect(Ok, status);
|
||||
|
||||
/* Prepare storage. Made by wrapper class. */
|
||||
status = GdipGetPointCount(path, &count);
|
||||
expect(Ok, status);
|
||||
|
||||
data.Count = 2;
|
||||
data.Types = GdipAlloc(sizeof(BYTE) * count);
|
||||
data.Points = GdipAlloc(sizeof(PointF) * count);
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue