GraphicsPath::GetPathPoints (PointF*,INT) 方法 (gdipluspath.h)

GraphicsPath::GetPathPoints 方法获取此路径的点数组。 数组包含用于绘制路径的线条和贝塞尔样条的端点和控制点。

语法

Status GetPathPoints(
  PointF *points,
  INT    count
);

参数

points

指向接收数据点的 PointF 对象数组的指针。 必须为此数组分配内存。 可以调用 GraphicsPath::GetPointCount 方法来确定数组的所需大小。 大小(以字节为单位)应为 GraphicsPath::GetPointCount 乘以 sizeof(PointF)的返回值。

count

指定点数组中的元素数的整数。 将此参数设置为等于 GraphicsPath::GetPointCount 方法的返回值。

返回值

类型:状态

如果该方法成功,则返回 Ok,这是 Status 枚举的元素。

如果方法失败,它将返回 Status 枚举的其他元素之一。

注解

GraphicsPath 对象具有点数组和类型数组。 类型数组中的每个元素都是一个字节,用于指定点类型和点数组中相应元素的一组标志。 PathPointType 枚举中列出了可能的点类型和标志。

示例

以下示例创建并绘制一个包含线条、矩形、椭圆形和曲线的路径。 代码调用路径的 GraphicsPath::GetPointCount 方法来确定路径中存储的数据点数。 代码分配一个足够大的缓冲区来接收数据点数组,并将该缓冲区的地址传递给 GraphicsPath::GetPathPoints 方法。 最后,代码绘制路径的每个数据点。

VOID GetPathPointsExample(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 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)
   {
      graphics.FillEllipse(
         &brush, 
         dataPoints[j].X - 3.0f, 
         dataPoints[j].Y - 3.0f,
         6.0f,
         6.0f);
   }
   delete [] dataPoints; 
}
Color(255, 255, 0,  0)

要求

要求
Header gdipluspath.h

另请参阅

GraphicsPath

GraphicsPath::GetPathData

GraphicsPath::GetPathTypes

GraphicsPath::GetPointCount

PathData

PathPointType

PointF

使用区域进行剪裁

构造并绘制轨迹

创建路径渐变

路径