Operations on Bitmaps: 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:

private void btnManipulate_Click(object sender, EventArgs e)
        Bitmap bmpPicture = new Bitmap("person.jpg");
        CreateGraphics().DrawImage(bmpPicture, 10, 10);

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


Home Copyright 2008-2009, yevol.com