CGpGraphicsPathIterator.Enumeratemethod
Copies the path's data points to a **GpPointF** array and copies the path's point types to a byte array.
Syntax
FUNCTION Enumerate (BYVAL pts AS GpPointF PTR, BYVAL types AS BYTE PTR, BYVAL count AS INT_) AS INT
Parameters
| Name | Description | |
|---|---|---|
pts | Pointer to an array that receives the path's data points. | |
types | Pointer to an array that receives the path's point types. | |
count | Integer that specifies the number of elements in the points array. This is the same as the number of elements in the types array. |
Return value
This method returns the number of points retrieved.
Description
Copies the path's data points to a GpPointF array and copies the path's point types to a byte array.
Remarks
This GraphicsPathIterator object is associated with a GraphicsPath object. That GraphicsPath object has an array of points and an array of types. Each element in the array of types is a byte that specifies the point type and a set of flags for the corresponding element in the array of points. Possible point types and flags are listed in the PathPointType enumeration.
You can call the GetCount method to determine the number of data points in the path. The points parameter points to a buffer that receives the data points, and the types parameter points to a buffer that receives the types. Before you call the Enumerate method, you must allocate memory for those buffers. The size of the points buffer should be the return value of GetCount multiplied by SIZEOF(GpPointF). The size of the types buffer should be the return value of GetCount.
Example
' ======================================================================================== ' Using GdipPathIterEnumerate to Extract All Path Data. ' Builds a path with two figures. ' Uses GdipPathIterEnumerate to extract all points and types. ' Draws the path and overlays each point’s coordinates and type. ' ======================================================================================== SUB Example_PathIterEnumerate (BYVAL hdc AS HDC)
' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale transform graphics.ScaleTransformForDpi
' // Create a GraphicsPath with two figures DIM path AS CGpGraphicsPath path.AddLine(20, 20, 120, 20) path.AddLine(120, 20, 70, 100) path.CloseFigure
path.StartFigure path.AddLine(150, 30, 200, 80) path.AddLine(200, 80, 150, 130)
' // Create a GraphicsPathIterator DIM iterator AS CGpGraphicsPathIterator = CGpGraphicsPathIterator(@path)
' // Get total number of points in the path DIM totalCount AS LONG = iterator.GetCount
' // Allocate arrays for points and types DIM points(0 TO totalCount - 1) AS GpPointF DIM types(0 TO totalCount - 1) AS BYTE
' // Enumerate all path data DIM resultCount AS LONG = iterator.Enumerate(@points(0), @types(0), totalCount)
' Draw the path using a blue pen DIM pen AS CGpPen = CGpPen(ARGB_BLUE, 2.0) graphics.DrawPath(@pen, @path)
' Create font and brush for text output DIM fontFamily AS CGpFontFamily = CGpFontFamily("Arial") DIM font AS CGpFont = CGpFont(@fontFamily, AfxGdipPointsToPixels(9, TRUE), FontStyleRegular) DIM brush AS CGpSolidBrush = ARGB_BLACK
' Display point coordinates and type below the drawing DIM yOffset AS SINGLE = 150 FOR i AS LONG = 0 TO resultCount - 1
DIM info AS STRING = "Point " & i & ": (" & points(i).x & ", " & points(i).y & ") Type=" & types(i)
DIM layout AS GpRectF = (10.0, yOffset, 300.0, 20.0)
graphics.DrawString(info, -1, @font, @layout, @brush)
yOffset += 20.0
NEXT
END SUB ' ========================================================================================
Reference
- Include file
CGpGraphics.inc - Defined in AfxNova/CGpPath.inc:744
- Documented in Graphics/GdiPlus Classes/CGpGraphics Classes.md
- Topic: CGpGraphics Class