GraphicsPathIterator::CopyData method (gdipluspath.h)

The GraphicsPathIterator::CopyData method copies a subset of the path's data points to a PointF array and copies a subset of the path's point types to a BYTE array.

Syntax

INT CopyData(
  [out] PointF *points,
  [out] BYTE   *types,
  [in]  INT    startIndex,
  [in]  INT    endIndex
);

Parameters

[out] points

Type: PointF*

Pointer to an array that receives a subset of the path's data points.

[out] types

Type: BYTE*

Pointer to an array that receives a subset of the path's point types.

[in] startIndex

Type: INT

Integer that specifies the starting index of the points and types to be copied.

[in] endIndex

Type: INT

Integer that specifies the ending index of the points and types to be copied.

Return value

Type: INT

This method returns the number of points copied. This is the same as the number of types copied.

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 GraphicsPathIterator::GetCount method to determine the number of data points in the path.

Examples

The following example creates a GraphicsPath object and adds three lines to the path. The code creates a GraphicsPathIterator> object and calls its GraphicsPathIterator::CopyData method to retrieve the path's points and point types. Then the code displays the count returned by the GraphicsPathIterator::CopyData method.


#define BUFFER_SIZE 30
TCHAR numPointsCopied[BUFFER_SIZE];

// Create the points for three lines in a path.
Point pts[] = { Point(20, 20), 
                Point(100, 20), 
                Point(100, 50), 
                Point(20, 50) };
GraphicsPath path;
path.AddLines(pts, 4); // Add the lines to the path.

// Create a GraphicsPathIterator object and associate it with the path. 
GraphicsPathIterator pathIterator(&path);

// Create destination arrays, and copy the path data to them.
PointF* pCopiedPoints = new PointF[4]; 
BYTE* pTypes = new BYTE[4];
INT count = pathIterator.CopyData(pCopiedPoints, pTypes, 0, 3);

// Confirm that the points copied.
StringCchPrintf(
   numPointsCopied, BUFFER_SIZE, TEXT("%d points were copied."), count);

MessageBox(hWnd, numPointsCopied, TEXT("CopyData"), NULL);

delete[] pCopiedPoints;
delete[] pTypes;

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdipluspath.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Constructing and Drawing Paths

GetPathData

GetPathPoints Methods

GetPathTypes

GetPointCount

GraphicsPath

GraphicsPathIterator

GraphicsPathIterator::Enumerate

GraphicsPathIterator::GetCount

Paths