LinearGradientBrush::GetTransform method (gdiplusbrush.h)

The LinearGradientBrush::GetTransform method gets the transformation matrix of this linear gradient brush.


Status GetTransform(
  [out] Matrix *matrix


[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.


A LinearGradientBrush object maintains a transformation matrix that can store any affine transformation. When you use a linear gradient brush to fill an area, GDI+ transforms the brush's boundary lines according to the brush's transformation matrix and then fills the area. The transformed boundaries exist only during rendering; the boundaries stored in the LinearGradientBrush object are not transformed.


The following example creates a linear gradient brush and sets its transformation matrix. Next, the code gets the brush's transformation matrix and proceeds to inspect or use the matrix elements.

VOID Example_GetTransform(HDC hdc)
   Graphics myGraphics(hdc);

   // Construct a linear gradient brush, and set its transformation.
   LinearGradientBrush linGrBrush( 
      Point(0, 0),
      Point(200, 0),
      Color(255, 255, 0, 0),    // red
      Color(255, 0, 0, 255));   // blue

   Matrix matrixSet(0, 1, -1, 0, 0, 0);


   // Obtain information about the linear gradient brush.
   Matrix matrixGet;
   REAL   elements[6];


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


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

See also

Brushes and Filled Shapes

Filling Shapes with a Gradient Brush

Filling a Shape with a Color Gradient




Matrix Representation of Transformations