PowerBasic Museum 2020-A

Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Source Code => Graphics and Multimedia => GDI+ (GDI Plus) => Topic started by: José Roca on June 23, 2008, 10:56:45 AM

Title: GDI+: GdipScaleWorldTransform
Post by: José Roca on June 23, 2008, 10:56:45 AM


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

C++


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

   graphics.TranslateTransform(80.0f, 80.0f);               // first translate
   graphics.ScaleTransform(3.0f, 1.0f, MatrixOrderAppend);  // then scale
   graphics.DrawEllipse(&pen, 0, 0, 50, 50);
}


PowerBASIC


SUB GDIP_ScaleWorldTransform (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, 80.0!, 80.0!, %MatrixOrderAppend)
   hStatus = GdipScaleWorldTransform(pGraphics, 3.0!, 1.0!, %MatrixOrderAppend)
   hStatus = GdipDrawEllipse(pGraphics, pPen, 0, 0, 50, 50)

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

END SUB


(http://www.jose.it-berater.org/captures/GdipScaleWorldTransform.png)