Image.RotateFlip Method (RotateFlipType)
Rotates, flips, or rotates and flips the Image.
Assembly: System.Drawing (in System.Drawing.dll)
Parameters
- rotateFlipType
-
Type:
System.Drawing.RotateFlipType
A RotateFlipType member that specifies the type of rotation and flip to apply to the image.
The RotateFlip method rotates the image clockwise.
If you wish to draw on an image once it has been rotated, you should always retrieve a new graphics object from the image, otherwise an exception could occur.
The following code example demonstrates how to call the RotateFlip method on an Image and the RotateFlipType enumeration.
This example is designed to be used with a Windows Form that contains a PictureBox named PictureBox1 and a button named Button1. Paste the code into a form, call InitializeBitmap from the form's constructor, and associate Button1_Click with the button's Click event. Ensure the file path to the bitmap is valid on your system.
Dim bitmap1 As Bitmap Private Sub InitializeBitmap() Try bitmap1 = CType(Bitmap.FromFile("C:\Documents and Settings\All Users\" _ & "Documents\My Music\music.bmp"), Bitmap) PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize PictureBox1.Image = bitmap1 Catch ex As System.IO.FileNotFoundException MessageBox.Show("There was an error. Check the path to the bitmap.") End Try End Sub Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click If bitmap1 IsNot Nothing Then bitmap1.RotateFlip(RotateFlipType.Rotate180FlipY) PictureBox1.Image = bitmap1 End If End Sub
Available since 1.1