GraphicsPath::GetPathPoints method

The GraphicsPath::GetPathPoints method gets this path's array of points. The array contains the endpoints and control points of the lines and Bézier splines that are used to draw the path.


Status GetPathPoints(
  OUT PointF *points,
  IN INT     count



Pointer to an array of PointF objects that receives the data points. You must allocate memory for this array. You can call the GraphicsPath::GetPointCount method to determine the required size of the array. The size, in bytes, should be the return value of GraphicsPath::GetPointCount multiplied by sizeof(PointF).


Integer that specifies the number of elements in the points array. Set this parameter equal to the return value of the GraphicsPath::GetPointCount method.

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.


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.


The following example creates and draws a path that has a line, a rectangle, an ellipse, and a curve. The code calls the path's GraphicsPath::GetPointCount method to determine the number of data points that are stored in the path. The code allocates a buffer large enough to receive the array of data points and passes the address of that buffer to the GraphicsPath::GetPathPoints method. Finally, the code draws each of the path's data points.

VOID GetPathPointsExample(HDC hdc)
   Graphics graphics(hdc);

   // Create a path that has a line, a rectangle, an ellipse, and a curve.
   GraphicsPath path;

   PointF[] = {
      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 points.
   INT count = path.GetPointCount();
   PointF* dataPoints = new PointF[count];  
   path.GetPathPoints(dataPoints, count);

   // Draw the path's data points.
   SolidBrush brush(Color(255, 255, 0, 0));
   for(INT j = 0; j < count; ++j)
         dataPoints[j].X - 3.0f, 
         dataPoints[j].Y - 3.0f,
   delete [] dataPoints; 
Color(255, 255, 0,  0)


Header gdipluspath.h

See Also








Clipping with a Region

Constructing and Drawing Paths

Creating a Path Gradient