Graphics::TranslateTransform method

The Graphics::TranslateTransform method updates this Graphics object's world transformation matrix with the product of itself and a translation matrix.

Syntax

Status TranslateTransform(
  IN REAL        dx,
  IN REAL        dy,
  IN MatrixOrder order
);

Parameters

dx

Type: REAL

Real number that specifies the horizontal component of the translation.

dy

Type: REAL

Real number that specifies the vertical component of the translation.

order

Type: MatrixOrder

Optional. Element of the MatrixOrder enumeration that specifies the order of multiplication. MatrixOrderPrepend specifies that the translation matrix is on the left, and MatrixOrderAppend specifies that the translation matrix is on the right. The default value is MatrixOrderPrepend.

Return Value

Type: 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

Note  GDI+ handles brushes differently when the world transform scale is less than 100%(1.0f) in either the x or y direction. If the world transform scale is less than 100%(1.0f), be sure to multiply the offset for TranslateTransform by the world transform scale.
 

Examples

The following example sets the world transformation of a Graphics object to a rotation. The call to Graphics::TranslateTransform multiplies the Graphics object's existing world transformation matrix (rotation) by a translation matrix. The MatrixOrderAppend argument specifies that the multiplication is done with the translation matrix on the right. At that point, the world transformation matrix of the Graphics object represents a composite transformation: first rotate, then translate. The call to DrawEllipse draws a rotated and translated ellipse.

VOID Example_TranslateTransform(HDC hdc)
{
   Graphics graphics(hdc);
   Pen pen(Color(255, 0, 0, 255));

   graphics.RotateTransform(30.0f);
   graphics.TranslateTransform(100.0f, 50.0f, MatrixOrderAppend);
   graphics.DrawEllipse(&pen, 0, 0, 200, 80);
}

Requirements

   
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

Coordinate Systems and Transformations

Graphics

Graphics::GetTransform

Graphics::ResetTransform

Graphics::ScaleTransform

Graphics::SetTransform

Graphics::TransformPoints

Matrix

MatrixOrder

Transformations