GraphicsPath::GetPathPoints (Point*,INT) 方法 (gdipluspath.h)
GraphicsPath::GetPathPoints 方法获取此路径的点数组。 数组包含用于绘制路径的线条和贝塞尔样条的端点和控制点。
语法
Status GetPathPoints(
[out] Point *points,
[in] INT count
);
parameters
[out] points
类型: 点*
指向接收数据点的 Point 对象的数组的指针。 必须为此数组分配内存。 可以调用 GraphicsPath::GetPointCount 方法来确定数组的所需大小。 大小(以字节为单位)应是 GraphicsPath::GetPointCount 的返回值乘以 size of (Point) 。
[in] count
类型: INT
指定 点 数组中的元素数的整数。 将此参数设置为等于 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;
Point points[] = {
Point(200, 200),
Point(250, 240),
Point(200, 300),
Point(300, 310),
Point(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();
Point* dataPoints = new Point[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)
要求
最低受支持的客户端 | Windows XP、Windows 2000 Professional [仅限桌面应用] |
最低受支持的服务器 | Windows 2000 Server [仅限桌面应用] |
目标平台 | Windows |
标头 | gdipluspath.h (包括 Gdiplus.h) |
Library | Gdiplus.lib |
DLL | Gdiplus.dll |
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈