GraphicsPath::GetPathData method (gdipluspath.h)

The GraphicsPath::GetPathData method gets an array of points and an array of point types from this path. Together, these two arrays define the lines, curves, figures, and markers of this path.

Syntax

Status GetPathData(
  [out] PathData *pathData
);

Parameters

[out] pathData

Type: PathData*

Pointer to a PathData object that receives the path data. The Points data member of the PathData object receives a pointer to an array of PointF objects that contains the path points. The Types data member of the PathData object receives a pointer to an array of bytes that contains the point types. The Count data member of the PathData object receives an integer that indicates the number of elements in the Points array.

Return value

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

Remarks

A 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 do not have to allocate or deallocate memory for the array of points or the array of types. The GraphicsPath::GetPathData method allocates memory for the arrays (points and types) that it returns. The PathData destructor deallocates the memory for those arrays.

Examples

The following example creates and draws a path that has a line, a rectangle, an ellipse, and a curve. The code gets the path's points and types by passing the address of a PathData object to the GraphicsPath::GetPathData method. Then the code draws each of the path's data points.

VOID GetPathDataExample(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a path that has a line, a rectangle, an ellipse, and a curve.
   GraphicsPath path;
   
   PointF points[] = {
      PointF(200, 200),
      PointF(250, 240),
      PointF(200, 300),
      PointF(300, 310),
      PointF(250, 350)};

   path.AddLine(20, 100, 150, 200);
   path.AddRectangle(Rect(40, 30, 80, 60));
   path.AddEllipse(Rect(200, 30, 200, 100));
   path.AddCurve(points, 5);

   // Draw the path.
   Pen pen(Color(255, 0, 0, 255));
   graphics.DrawPath(&pen, &path);

   // Get the path data.
   PathData pathData;
   path.GetPathData(&pathData);

   // Draw the path's data points.
   SolidBrush brush(Color(255, 255, 0, 0));
   for(INT j = 0; j < pathData.Count; ++j)
   {
      graphics.FillEllipse(
         &brush, 
         pathData.Points[j].X - 3.0f, 
         pathData.Points[j].Y - 3.0f,
         6.0f,
         6.0f);
   }
}

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

Clipping with a Region

Constructing and Drawing Paths

Creating a Path Gradient

GetPathPoints Methods

GraphicsPath

GraphicsPath::GetPathTypes

GraphicsPath::GetPointCount

PathData

PathPointType

Paths

PointF