Matrix.Clone method

Applies to: desktop apps only

The Matrix::Clone method creates a new Matrix object that is a copy of this Matrix object.

Syntax

Matrix* Clone();

Parameters

This method has no parameters.

Return value

Type:

Type: Matrix*

This method returns a pointer to the new Matrix object.

Examples

The following example creates a Matrix object that represents a horizontal scaling. The code creates a second matrix by calling the Matrix::Clone method of the first matrix. Then the code calls the Matrix::Translate method of the second matrix. At that point, the second matrix represents a composite transformation: first scale, then translate. The code passes the address of the first matrix to the SetTransform method of a Graphics object and then uses that Graphics object to draw a scaled rectangle. Then the code passes the address of the second matrix to the SetTransform method of the same Graphics object. Finally, the code calls the DrawRectangle method of the Graphics object a second time to draw a rectangle that is scaled and translated.


VOID Example_Clone(HDC hdc)
{  
   Graphics myGraphics(hdc);

   Matrix matrix(3.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);  // horizontal scaling
   Matrix* pMatrix = matrix.Clone();

   pMatrix->Translate(40.0f, 25.0f, MatrixOrderAppend);

   Pen myPen(Color(255, 0, 0, 255));
   myGraphics.SetTransform(&matrix);
   myGraphics.DrawRectangle(&myPen, 0, 0, 100, 100);  // scale
   myGraphics.SetTransform(pMatrix);
   myGraphics.DrawRectangle(&myPen, 0, 0, 100, 100);  // scale and translate

   delete pMatrix;  
}

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplusmatrix.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

Matrix
Matrix Constructors
Transformations
Global and Local Transformations
Matrix Representation of Transformations

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show: