• Welcome to Jose's Read Only Forum 2023.
 

GDI+: GdipTranslateWorldTransform

Started by José Roca, June 23, 2008, 10:51:30 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example sets the world transformation of a Graphics object to a rotation. The call to GdipTranslateWorldTransform 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 GdipDrawEllipse draws a rotated and translated ellipse.

C++


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


PowerBASIC


SUB GDIP_TranslateWorldTransform (BYVAL hdc AS DWORD)

   LOCAL hStatus AS LONG
   LOCAL pGraphics AS DWORD
   LOCAL pPen AS DWORD

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   hStatus = GdipCreatePen1(GDIP_ARGB(255, 0, 0, 255), 1, %UnitPixel, pPen)
   hStatus = GdipRotateWorldTransform(pGraphics, 50.0!, %MatrixOrderPrepend)
   hStatus = GdipTranslateWorldTransform(pGraphics, 100.0!, 50.0!, %MatrixOrderAppend)
   hStatus = GdipDrawEllipse(pGraphics, pPen, 0, 0, 200, 80)

   ' // Cleanup
   IF pPen THEN GdipDeletePen(pPen)
   IF pGraphics THEN GdipDeleteGraphics(pGraphics)

END SUB