Export (0) Print
Expand All

Graphics.TransformPoints Method (CoordinateSpace, CoordinateSpace, PointF())

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

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

'Declaration
Public Sub TransformPoints ( _
	destSpace As CoordinateSpace, _
	srcSpace As CoordinateSpace, _
	pts As PointF() _
)

Parameters

destSpace
Type: System.Drawing.Drawing2D.CoordinateSpace

Member of the CoordinateSpace enumeration that specifies the destination coordinate space.

srcSpace
Type: System.Drawing.Drawing2D.CoordinateSpace

Member of the CoordinateSpace enumeration that specifies the source coordinate space.

pts
Type: System.Drawing.PointF()

Array of PointF structures that represent the points to transform.

The following code 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 (World) to page coordinates (Page).

  • Resets the world transformation to the identity and draws a red line between the transformed points.

The result is a blue line and a translated red line below it.

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft