PathGradientBrush::GetTransform method (gdipluspath.h)

The PathGradientBrush::GetTransform method gets transformation matrix of this path gradient brush.

Syntax

Status GetTransform(
  [out] Matrix *matrix
);

Parameters

[out] matrix

Type: Matrix*

Pointer to a Matrix object that receives the transformation matrix.

Return value

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

A PathGradientBrush object maintains a transformation matrix that can store any affine transformation. When you use a path gradient brush to fill an area, GDI+ transforms the brush's boundary path according to the brush's transformation matrix and then fills the interior of the transformed path. The transformed path exists only during rendering; the boundary path stored in PathGradientBrush object is not transformed.

Examples

The following example creates a PathGradientBrush object based on an array of three points. The PathGradientBrush::ScaleTransform and PathGradientBrush::TranslateTransform methods set the elements of the brush's transformation matrix so that the matrix represents a composite transformation (first scale, then translate). That composite transformation applies to the brush's boundary path, so the call to FillRectangle fills the interior of a triangle that is the result of scaling and translating the boundary path. The code calls the PathGradientBrush::GetTransform method of the PathGradientBrush object to obtain the brush's transformation matrix and then calls the GetElements method of the retrieved Matrix object to fill an array with the matrix elements.

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

   // Create a path gradient brush and set its transformation.
   Point pts[] = {Point(0, 0), Point(50, 0), Point(50, 50)};
   PathGradientBrush pthGrBrush(pts, 3);
   pthGrBrush.ScaleTransform(3.0f, 1.0f);
   pthGrBrush.TranslateTransform(10.0f, 30.0f, MatrixOrderAppend);

   graphics.FillRectangle(&pthGrBrush, 0, 0, 200, 200);

   // Obtain information about the path gradient brush.
   Matrix matrix;
   REAL elements[6];

   pthGrBrush.GetTransform(&matrix);
   matrix.GetElements(elements);

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

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdipluspath.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Brushes and Filled Shapes

Creating a Path Gradient

Filling a Shape with a Color Gradient

Matrix

Matrix Representation of Transformations

PathGradientBrush

PathGradientBrush::SetTransform

Transformations