The following example creates a
path and adds a sequence of three connected lines to the
path. The code calls the
GdipGetPointCount method to determine the number of bytes in the
path's array of point types and then allocates a buffer large enough to hold that array. Then the code calls the
GdipGetPathTypes method to fill the buffer with the array of point types.
C++
GraphicsPath path;
Point pts[] = {Point(0, 0), Point(2, 2), Point(3, 3), Point(0, 5)};
path.AddLines(pts, 4);
INT num = path.GetPointCount();
BYTE* pTypes = new BYTE[num];
path.GetPathTypes(pTypes, num);
PowerBASIC
SUB GDIP_GetPathTypes (BYVAL hdc AS DWORD)
LOCAL hStatus AS LONG
LOCAL pGraphics AS DWORD
LOCAL pPath AS DWORD
LOCAL i AS LONG
LOCAL count AS LONG
DIM pts(3) AS POINTF
DIM Types(0) AS BYTE
hStatus = GdipCreateFromHDC(hdc, pGraphics)
hStatus = GdipCreatePath(%FillModeAlternate, pPath)
pts(0).x = 0 : pts(0).y = 0
pts(1).x = 2 : pts(1).y = 2
pts(2).x = 3 : pts(2).y = 3
pts(3).x = 0 : pts(3).y = 5
hStatus = GdipAddPathLine2(pPath, pts(0), 4)
hStatus = GdipGetPointCount(pPath, count)
Outputdebugstring "Count = " & STR$(count)
IF count THEN
REDIM Types(count - 1)
hStatus = GdipGetPathTypes(pPath, Types(0), count)
FOR i = 0 TO count - 1
OutputDebugString "Type" & STR$(i) & " =" & STR$(Types(i))
NEXT
END IF
' // Cleanup
IF pPath THEN GdipDeletePath(pPath)
IF pGraphics THEN GdipDeleteGraphics(pGraphics)
END SUB