This topic has not yet been rated - Rate this topic

GraphicsPath.GetPathData method

Applies to: desktop apps only

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

pathData [out]

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:

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

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdipluspath.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

GraphicsPath
GetPathPoints Methods
GraphicsPath::GetPathTypes
GraphicsPath::GetPointCount
PathData
PathPointType
PointF
Clipping with a Region
Constructing and Drawing Paths
Creating a Path Gradient
Paths

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.