Graphics.TranslateTransform method

Applies to: desktop apps only

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

dx [in]

Type: REAL

Real number that specifies the horizontal component of the translation.

dy [in]

Type: REAL

Real number that specifies the vertical component of the translation.

order [in, optional]

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

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplusgraphics.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

Graphics
Graphics::GetTransform
Matrix
MatrixOrder
Graphics::ResetTransform
Graphics::ScaleTransform
Graphics::SetTransform
Graphics::TransformPoints
Transformations
Coordinate Systems and Transformations

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show: