Matrix::Invert method (gdiplusmatrix.h)

If this matrix is invertible, the Matrix::Invert method replaces the elements of this matrix with the elements of its inverse.

Syntax

Status Invert();

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

If this matrix is not invertible, the method fails and returns InvalidParameter.

Examples

The following example passes the address of a Matrix object to the SetTransform method of a Graphics object and then draws a rectangle. The rectangle is translated 30 units right and 20 units down by the world transformation of the Graphics object. The code calls the Matrix::Invert method of the Matrix object and sets the world transformation of the Graphics object to the inverted matrix. The code draws a second rectangle that is translated 30 units left and 20 units up.

VOID Example_Invert(HDC hdc)
{
   Graphics myGraphics(hdc);
   Pen myPen(Color(255, 0, 0, 255));

   Matrix matrix(1.0f, 0.0f, 0.0f, 1.0f, 30.0f, 20.0f);

   myGraphics.SetTransform(&matrix);
   myGraphics.DrawRectangle(&myPen, 0, 0, 200, 100);
   matrix.Invert();
   myGraphics.SetTransform(&matrix);
   myGraphics.DrawRectangle(&myPen, 0, 0, 200, 100);  
}

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 gdiplusmatrix.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Global and Local Transformations

Matrix

Matrix Representation of Transformations

Matrix::IsInvertible

Transformations