• Welcome to Jose's Read Only Forum 2023.
 

GDI+: GdipGetWorldTransform

Started by José Roca, June 23, 2008, 11:14:20 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example calls the GdipRotateWorldTransform function to set the world transformation matrix of that Graphics object. Then the code calls the GdipGetWorldTransform function to obtain its world transformation matrix (which now represents a 30-degree rotation). The call to GdipGetMatrixElements copies the elements of the retrieved matrix to an array.

C++


VOID Example_GetTransform(HDC hdc)
{
   Graphics graphics(hdc);

   graphics.RotateTransform(30.0f);

   Matrix matrix;
   REAL elements[6];
   graphics.GetTransform(&matrix);
   matrix.GetElements(elements);

   for(INT j = 0; j <= 5; ++j)
   {
      // Inspect or use the value in elements[j].
   }
}


PowerBASIC


SUB GDIP_GetWorldTransform (BYVAL hdc AS DWORD)

   LOCAL hStatus AS LONG
   LOCAL pGraphics AS DWORD
   LOCAL pMatrix AS DWORD
   LOCAL i AS LONG
   DIM   elements(5) AS SINGLE

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   hStatus = GdipRotateWorldTransform(pGraphics, 30.0!, %MatrixOrderPrepend)
   hStatus = GdipCreateMatrix(pMatrix)
   hStatus = GdipGetWorldTransform(pGraphics, pMatrix)
   hStatus = GdipGetMatrixElements(pMatrix, elements(0))

   FOR i = 0 TO 5
      ' // Inspect or use the calues in elements(i)
   NEXT

   ' // Cleanup
   IF pMatrix THEN GdipDeleteMatrix(pMatrix)
   IF pGraphics THEN GdipDeleteGraphics(pGraphics)

END SUB