Graphics.TransformPoints 方法

定义

使用此 Graphics的当前世界和页面转换,将一组点从一个坐标空间转换为另一个坐标空间。

重载

TransformPoints(CoordinateSpace, CoordinateSpace, Point[])

使用此 Graphics的当前世界和页面转换,将一组点从一个坐标空间转换为另一个坐标空间。

TransformPoints(CoordinateSpace, CoordinateSpace, PointF[])

使用此 Graphics的当前世界和页面转换,将一组点从一个坐标空间转换为另一个坐标空间。

TransformPoints(CoordinateSpace, CoordinateSpace, ReadOnlySpan<Point>)
TransformPoints(CoordinateSpace, CoordinateSpace, ReadOnlySpan<PointF>)

TransformPoints(CoordinateSpace, CoordinateSpace, Point[])

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

使用此 Graphics的当前世界和页面转换,将一组点从一个坐标空间转换为另一个坐标空间。

public:
 void TransformPoints(System::Drawing::Drawing2D::CoordinateSpace destSpace, System::Drawing::Drawing2D::CoordinateSpace srcSpace, cli::array <System::Drawing::Point> ^ pts);
public:
 void TransformPoints(System::Drawing::Drawing2D::CoordinateSpace destSpace, System::Drawing::Drawing2D::CoordinateSpace srcSpace, ... cli::array <System::Drawing::Point> ^ pts);
public void TransformPoints (System.Drawing.Drawing2D.CoordinateSpace destSpace, System.Drawing.Drawing2D.CoordinateSpace srcSpace, System.Drawing.Point[] pts);
public void TransformPoints (System.Drawing.Drawing2D.CoordinateSpace destSpace, System.Drawing.Drawing2D.CoordinateSpace srcSpace, params System.Drawing.Point[] pts);
member this.TransformPoints : System.Drawing.Drawing2D.CoordinateSpace * System.Drawing.Drawing2D.CoordinateSpace * System.Drawing.Point[] -> unit
Public Sub TransformPoints (destSpace As CoordinateSpace, srcSpace As CoordinateSpace, pts As Point())
Public Sub TransformPoints (destSpace As CoordinateSpace, srcSpace As CoordinateSpace, ParamArray pts As Point())

参数

destSpace
CoordinateSpace

指定目标坐标空间的 CoordinateSpace 枚举的成员。

srcSpace
CoordinateSpace

指定源坐标空间的 CoordinateSpace 枚举的成员。

pts
Point[]

表示要转换的点的 Point 结构的数组。

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 创建两个点,并在两个点之间绘制一条蓝色线条。

  • 将世界转换设置为按 x 方向的 40 个量进行转换,30 个方向为 y 方向。

  • 将点从世界坐标(World)转换为页面坐标(Page)。

  • 将世界转换重置为标识。

  • 在转换的点之间绘制一条红线。

结果是一条蓝线,其下方是一条已转换的红线。

public:
   void TransformPointsPoint( PaintEventArgs^ e )
   {
      // Create array of two points.
      array<Point>^ points = {Point(0,0),Point(100,50)};

      // Draw line connecting two untransformed points.
      e->Graphics->DrawLine( gcnew Pen( Color::Blue,3.0f ), points[ 0 ], points[ 1 ] );

      // Set world transformation of Graphics object to translate.
      e->Graphics->TranslateTransform( 40, 30 );

      // Transform points in array from world to page coordinates.
      e->Graphics->TransformPoints( CoordinateSpace::Page, CoordinateSpace::World, points );

      // Reset world transformation.
      e->Graphics->ResetTransform();

      // Draw line that connects transformed points.
      e->Graphics->DrawLine( gcnew Pen( Color::Red,3.0f ), points[ 0 ], points[ 1 ] );
   }
private void TransformPointsPoint(PaintEventArgs e)
{

    // Create array of two points.
    Point[] points = { new Point(0, 0), new Point(100, 50) };

    // Draw line connecting two untransformed points.
    e.Graphics.DrawLine(new Pen(Color.Blue, 3), points[0], points[1]);

    // Set world transformation of Graphics object to translate.
    e.Graphics.TranslateTransform(40, 30);

    // Transform points in array from world to page coordinates.
    e.Graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.World, points);

    // Reset world transformation.
    e.Graphics.ResetTransform();

    // Draw line that connects transformed points.
    e.Graphics.DrawLine(new Pen(Color.Red, 3), points[0], points[1]);
}
Private Sub TransformPointsPoint(ByVal e As PaintEventArgs)

    ' Create array of two points.
    Dim points As Point() = {New Point(0, 0), New Point(100, 50)}

    ' Draw line connecting two untransformed points.
    e.Graphics.DrawLine(New Pen(Color.Blue, 3), points(0), points(1))

    ' Set world transformation of Graphics object to translate.
    e.Graphics.TranslateTransform(40, 30)

    ' Transform points in array from world to page coordinates.
    e.Graphics.TransformPoints(CoordinateSpace.Page, _
    CoordinateSpace.World, points)

    ' Reset world transformation.
    e.Graphics.ResetTransform()

    ' Draw line that connects transformed points.
    e.Graphics.DrawLine(New Pen(Color.Red, 3), points(0), points(1))
End Sub

适用于

TransformPoints(CoordinateSpace, CoordinateSpace, PointF[])

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

使用此 Graphics的当前世界和页面转换,将一组点从一个坐标空间转换为另一个坐标空间。

public:
 void TransformPoints(System::Drawing::Drawing2D::CoordinateSpace destSpace, System::Drawing::Drawing2D::CoordinateSpace srcSpace, cli::array <System::Drawing::PointF> ^ pts);
public:
 void TransformPoints(System::Drawing::Drawing2D::CoordinateSpace destSpace, System::Drawing::Drawing2D::CoordinateSpace srcSpace, ... cli::array <System::Drawing::PointF> ^ pts);
public void TransformPoints (System.Drawing.Drawing2D.CoordinateSpace destSpace, System.Drawing.Drawing2D.CoordinateSpace srcSpace, System.Drawing.PointF[] pts);
public void TransformPoints (System.Drawing.Drawing2D.CoordinateSpace destSpace, System.Drawing.Drawing2D.CoordinateSpace srcSpace, params System.Drawing.PointF[] pts);
member this.TransformPoints : System.Drawing.Drawing2D.CoordinateSpace * System.Drawing.Drawing2D.CoordinateSpace * System.Drawing.PointF[] -> unit
Public Sub TransformPoints (destSpace As CoordinateSpace, srcSpace As CoordinateSpace, pts As PointF())
Public Sub TransformPoints (destSpace As CoordinateSpace, srcSpace As CoordinateSpace, ParamArray pts As PointF())

参数

destSpace
CoordinateSpace

指定目标坐标空间的 CoordinateSpace 枚举的成员。

srcSpace
CoordinateSpace

指定源坐标空间的 CoordinateSpace 枚举的成员。

pts
PointF[]

表示要转换的点的 PointF 结构的数组。

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 创建两个点,并在两个点之间绘制一条蓝色线条。

  • 将世界转换设置为按 x 方向的 40 个量进行转换,30 个方向为 y 方向。

  • 将点从世界坐标(World)转换为页面坐标(Page)。

  • 将世界转换重置为标识,并在转换的点之间绘制一条红线。

结果是一条蓝线,其下方是一条已转换的红线。

public:
   void TransformPointsPointF( PaintEventArgs^ e )
   {
      // Create array of two points.
      array<PointF>^ points = {PointF(0.0F,0.0F),PointF(100.0F,50.0F)};

      // Draw line connecting two untransformed points.
      e->Graphics->DrawLine( gcnew Pen( Color::Blue,3.0f ), points[ 0 ], points[ 1 ] );

      // Set world transformation of Graphics object to translate.
      e->Graphics->TranslateTransform( 40.0F, 30.0F );

      // Transform points in array from world to page coordinates.
      e->Graphics->TransformPoints( CoordinateSpace::Page, CoordinateSpace::World, points );

      // Reset world transformation.
      e->Graphics->ResetTransform();

      // Draw line that connects transformed points.
      e->Graphics->DrawLine( gcnew Pen( Color::Red,3.0f ), points[ 0 ], points[ 1 ] );
   }
private void TransformPointsPointF(PaintEventArgs e)
{

    // Create array of two points.
    PointF[] points = { new PointF(0.0F, 0.0F), new PointF(100.0F, 50.0F) };

    // Draw line connecting two untransformed points.
    e.Graphics.DrawLine(new Pen(Color.Blue, 3), points[0], points[1]);

    // Set world transformation of Graphics object to translate.
    e.Graphics.TranslateTransform(40.0F, 30.0F);

    // Transform points in array from world to page coordinates.
    e.Graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.World, points);

    // Reset world transformation.
    e.Graphics.ResetTransform();

    // Draw line that connects transformed points.
    e.Graphics.DrawLine(new Pen(Color.Red, 3), points[0], points[1]);
}
Private Sub TransformPointsPointF(ByVal e As PaintEventArgs)

    ' Create array of two points.
    Dim points As PointF() = {New PointF(0.0F, 0.0F), New PointF(100.0F, _
    50.0F)}

    ' Draw line connecting two untransformed points.
    e.Graphics.DrawLine(New Pen(Color.Blue, 3), points(0), points(1))

    ' Set world transformation of Graphics object to translate.
    e.Graphics.TranslateTransform(40.0F, 30.0F)

    ' Transform points in array from world to page coordinates.
    e.Graphics.TransformPoints(CoordinateSpace.Page, _
    CoordinateSpace.World, points)

    ' Reset world transformation.
    e.Graphics.ResetTransform()

    ' Draw line that connects transformed points.
    e.Graphics.DrawLine(New Pen(Color.Red, 3), points(0), points(1))
End Sub

适用于

TransformPoints(CoordinateSpace, CoordinateSpace, ReadOnlySpan<Point>)

Source:
Graphics.cs
public:
 void TransformPoints(System::Drawing::Drawing2D::CoordinateSpace destSpace, System::Drawing::Drawing2D::CoordinateSpace srcSpace, ReadOnlySpan<System::Drawing::Point> pts);
public void TransformPoints (System.Drawing.Drawing2D.CoordinateSpace destSpace, System.Drawing.Drawing2D.CoordinateSpace srcSpace, scoped ReadOnlySpan<System.Drawing.Point> pts);
member this.TransformPoints : System.Drawing.Drawing2D.CoordinateSpace * System.Drawing.Drawing2D.CoordinateSpace * ReadOnlySpan<System.Drawing.Point> -> unit
Public Sub TransformPoints (destSpace As CoordinateSpace, srcSpace As CoordinateSpace, pts As ReadOnlySpan(Of Point))

参数

destSpace
CoordinateSpace
srcSpace
CoordinateSpace

适用于

TransformPoints(CoordinateSpace, CoordinateSpace, ReadOnlySpan<PointF>)

Source:
Graphics.cs
public:
 void TransformPoints(System::Drawing::Drawing2D::CoordinateSpace destSpace, System::Drawing::Drawing2D::CoordinateSpace srcSpace, ReadOnlySpan<System::Drawing::PointF> pts);
public void TransformPoints (System.Drawing.Drawing2D.CoordinateSpace destSpace, System.Drawing.Drawing2D.CoordinateSpace srcSpace, scoped ReadOnlySpan<System.Drawing.PointF> pts);
member this.TransformPoints : System.Drawing.Drawing2D.CoordinateSpace * System.Drawing.Drawing2D.CoordinateSpace * ReadOnlySpan<System.Drawing.PointF> -> unit
Public Sub TransformPoints (destSpace As CoordinateSpace, srcSpace As CoordinateSpace, pts As ReadOnlySpan(Of PointF))

参数

destSpace
CoordinateSpace
srcSpace
CoordinateSpace

适用于