Graphics::TransformPoints(CoordinateSpace,CoordinateSpace,PointF*,INT) method (gdiplusgraphics.h)

The Graphics::TransformPoints method converts an array of points from one coordinate space to another. The conversion is based on the current world and page transformations of this Graphics object.

Syntax

Status TransformPoints(
  [in]      CoordinateSpace destSpace,
  [in]      CoordinateSpace srcSpace,
  [in, out] PointF          *pts,
  [in]      INT             count
);

Parameters

[in] destSpace

Type: CoordinateSpace

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

[in] srcSpace

Type: CoordinateSpace

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

[in, out] pts

Type: Point*

Pointer to an array that, on input, holds the points to be converted and, on output, holds the converted points.

[in] count

Type: INT

Integer that specifies the number of elements in the pts array.

Return value

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

Remarks

The world transformation converts points from the world coordinate space to the page coordinate space. The page transformation converts points from the page coordinate space to the device coordinate space. For more information about coordinate spaces, see Types of Coordinate Systems.

Examples

The following example creates a Graphics object and sets its world transformation to a translation 40 units right and 30 units down. Then the code creates an array of points and passes the address of that array to the Graphics::TransformPoints method of the same Graphics object. The points in the array are transformed by the world transformation of the Graphics object. The code calls the Graphics::DrawLine method twice: once to connect the two points before the transformation and once to connect the two points after the transformation.

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]);
}

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdiplusgraphics.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Graphics

Graphics::GetTransform

Graphics::MultiplyTransform

Graphics::ResetTransform

Graphics::RotateTransform

Graphics::ScaleTransform

Graphics::SetTransform

Graphics::TranslateTransform

Matrix

MatrixOrder

Transformations

Types of Coordinate Systems