• Welcome to Jose's Read Only Forum 2023.
 

GDI+: GdipRotateWorldTransform

Started by José Roca, June 23, 2008, 11:02:08 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 translation. The call to GdipRotateWorldTransform multiplies the Graphics object's existing world transformation matrix (translation) by a rotation matrix. The MatrixOrderAppend argument specifies that the multiplication is done with the rotation matrix on the right. At that point, the world transformation matrix of the Graphics object represents a composite transformation: first translate, then rotate. The call to GdipDrawEllipse draws a translated and rotated ellipse.

C++


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

   graphics.TranslateTransform(100.0f, 0.0f);           // first translate
   graphics.RotateTransform(30.0f, MatrixOrderAppend);  // then rotate
   graphics.DrawEllipse(&pen, 0, 0, 200, 80);
}


PowerBASIC


SUB GDIP_RotateWorldTransform (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 = GdipTranslateWorldTransform(pGraphics, 100.0!, 50.0!, %MatrixOrderPrepend)
   hStatus = GdipRotateWorldTransform(pGraphics, 30.0!, %MatrixOrderAppend)
   hStatus = GdipDrawEllipse(pGraphics, pPen, 0, 0, 200, 80)

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

END SUB