Home

Operations on Bitmaps:
Mirroring a Picture

 

Mirroring a Picture

When it comes to bitmaps, mirroring is the process of changing the horizontal direction of a picture. For example imagine you have the picture of a person directed to the right:

 

With mirroring, you can make that face look to the left:

To support mirroring, the Bitmap class inherits a method named RotateFlip from its parent Image class. Its syntax is:

public:
    void RotateFlip(RotateFlipType rotateFlipType);

This function takes one argument that specifies the mirroring option through the RotateFlipType enumeration. The members of  the RotateFlipType enumeration that can be used to mirror a picture are RotateNoneFlipX and Rotate180FlipY. Here is an example of mirroring a picture:

System::Void Mirror_Paint(System::Object^  sender, 
			  System::Windows::Forms::PaintEventArgs^  e)
{
    Bitmap ^ bmpPicture = gcnew Bitmap(L"person.jpg");
    bmpPicture->RotateFlip(RotateFlipType::RotateNoneFlipX);
    e->Graphics->DrawImage(bmpPicture, 10, 10);
}

When this method is called, the bitmap horizontal direction would be changed.

 

Home Copyright © 2007 FunctionX, Inc.