Graphics::TransformPoints 方法将点数组从一个坐标空间转换为另一个坐标空间。 转换基于此 Graphics 对象的当前世界和页面转换。
语法
Status TransformPoints(
  [in]      CoordinateSpace destSpace,
  [in]      CoordinateSpace srcSpace,
  [in, out] PointF          *pts,
  [in]      INT             count
);
parameters
[in] destSpace
类型: 坐标空间
指定目标坐标空间的 坐标空间 枚举的元素。
[in] srcSpace
类型: 坐标空间
指定源坐标空间的 坐标空间 枚举的元素。
[in, out] pts
类型: 点*
指向数组的指针,该数组在输入时保存要转换的点,在输出中保存转换的点。
[in] count
类型: INT
指定 pts 数组中的元素数的整数。
返回值
类型: 状态
如果方法成功,则返回 Ok,这是 Status 枚举的元素。
如果 方法失败,它将返回 Status 枚举的其他元素之一。
注解
世界转换将点从世界坐标空间转换为页面坐标空间。 页面转换将点从页面坐标空间转换为设备坐标空间。 有关坐标空间的详细信息,请参阅 坐标系的类型。
示例
以下示例创建 一个 Graphics 对象,并将其世界转换设置为右翻译 40 个单位,向下 30 个单位。 然后,代码创建一个点数组,并将该数组的地址传递给同一 Graphics 对象的 Graphics::TransformPoints 方法。 数组中的点由 Graphics 对象的世界转换进行转换。 该代码调用 Graphics::D rawLine 方法两次:一次用于连接转换前的两个点,一次用于在转换后连接两个点。
VOID Example_TransformPoints(HDC hdc)
{
   Graphics graphics(hdc);
   Pen pen(Color(255, 0, 0, 255));
   // Create an array of two Point objects.
   Point points[2] = {Point(0, 0), Point(100, 50)};
   // Draw a line that connects the two points.
   // No transformation has been performed yet.
   graphics.DrawLine(&pen, points[0], points[1]);
   // Set the world transformation of the Graphics object.
   graphics.TranslateTransform(40.0f, 30.0f);
   // Transform the points in the array from world to page coordinates.
   graphics.TransformPoints(
      CoordinateSpacePage, 
      CoordinateSpaceWorld, 
      points, 
      2);
   // It is the world transformation that takes points from world
   // space to page space. Because the world transformation is a
   // translation 40 to the right and 30 down, the
   // points in the array are now (40, 30) and (140, 80).
   // Draw a line that connects the transformed points.
   graphics.ResetTransform();
   graphics.DrawLine(&pen, points[0], points[1]);
}
要求
| 最低受支持的客户端 | Windows XP、Windows 2000 Professional [仅限桌面应用] | 
| 最低受支持的服务器 | Windows 2000 Server [仅限桌面应用] | 
| 目标平台 | Windows | 
| 标头 | gdiplusgraphics.h (包括 Gdiplus.h) | 
| Library | Gdiplus.lib | 
| DLL | Gdiplus.dll |