This documentation is archived and is not being maintained.

Graphics.TransformPoints Method

Transforms an array of points from one coordinate space to another using the current world and page transformations of this Graphics object.

Overload List

Transforms an array of points from one coordinate space to another using the current world and page transformations of this Graphics object.

[Visual Basic] Overloads Public Sub TransformPoints(CoordinateSpace, CoordinateSpace, Point())
[C#] public void TransformPoints(CoordinateSpace, CoordinateSpace, Point[]);
[C++] public: void TransformPoints(CoordinateSpace, CoordinateSpace, Point[]);
[JScript] public function TransformPoints(CoordinateSpace, CoordinateSpace, Point[]);

Transforms an array of points from one coordinate space to another using the current world and page transformations of this Graphics object.

[Visual Basic] Overloads Public Sub TransformPoints(CoordinateSpace, CoordinateSpace, PointF())
[C#] public void TransformPoints(CoordinateSpace, CoordinateSpace, PointF[]);
[C++] public: void TransformPoints(CoordinateSpace, CoordinateSpace, PointF[]);
[JScript] public function TransformPoints(CoordinateSpace, CoordinateSpace, PointF[]);

Example

[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Creates two points and draws a blue line between them.
  • Sets the world transform to translate by amounts 40 in the x direction and 30 in the y direction.
  • Transforms the points from world coordinates (CoordinateSpace.World) to page coordinates (CoordinateSpace.Page).
  • Resets the world transformation to the identity and draws a red line between the transformed points.

[Visual Basic, C#] The result is a blue line and a translated red line below it.

[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of TransformPoints. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub TransformPointsPointF(e As PaintEventArgs)
' Create array of two points.
Dim points As PointF() =  {New PointF(0F, 0F), New PointF(100F, _
50F)}
' 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(40F, 30F)
' 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
        
[C#] 
public 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]);
}
        

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Graphics Class | Graphics Members | System.Drawing Namespace

Show: