Code for Mirror Image

In the following program we have drawn a mirror image.

__gc class WinForm: public Form

{

public:

WinForm( )

{

InitForm( ) ;

}

void Dispose( )

{

// Form is being destroyed. Do any necessary clean-up here.

Form::Dispose( ) ;

}

void InitForm( )

{

Text = "Drawing Shapes";

System::Drawing::Size s ;

s.Height = 300 ;

s.Width = 350 ;

ClientSize = s ;

}

protected:

virtual void OnPaint ( PaintEventArgs* e )

{

Graphics *g = e->Graphics ;

Image *myimg = Image::FromFile ( "fcode.gif" ) ;

g -> DrawImage ( myimg, 20, 20 ) ;

Matrix *mymat = new Matrix( ) ;

mymat -> Translate ( myimg->Width + 20, myimg->Height+ 30);

mymat -> Scale ( -1.0, 1 ) ;

g -> Transform = mymat ;

g -> DrawImage( myimg, 0, 0 );

g -> ResetTransform( ) ;

}

} ;

By scaling the image with a factor of -1.0 in the x direction, what we get is a mirror image.

Your Title