Graphics::TranslateTransform method (gdiplusgraphics.h)

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, optional] MatrixOrder order
);

Parameters

[in] dx

Type: REAL

Real number that specifies the horizontal component of the translation.

[in] dy

Type: REAL

Real number that specifies the vertical component of the translation.

[in, optional] 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: 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

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

Coordinate Systems and Transformations

Graphics

Graphics::GetTransform

Graphics::ResetTransform

Graphics::ScaleTransform

Graphics::SetTransform

Graphics::TransformPoints

Matrix

MatrixOrder

Transformations