Link to home
Start Free TrialLog in
Avatar of Ahmadal_najjar2003
Ahmadal_najjar2003Flag for Kuwait

asked on

Rotate Image

I have a PictureBox that it has backgroudImage
I try to rotate left or right
what I have to do.

 PhotoPictureBox.BackgroundImage.RotateFlip(RotateFlipType.Rotate90FlipX)

does not work
ASKER CERTIFIED SOLUTION
Avatar of Stephen Manderson
Stephen Manderson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ahmadal_najjar2003

ASKER

Thats right man . Thanks Alot
Your welcome,

This may also be useful to you. Of course just add the combobox "cmbRotationType"

All the best
Steve
Public Class Form1
 
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        cmbRotationType.Items.Add("Rotate180FlipNone")
        cmbRotationType.Items.Add("Rotate180FlipX")
        cmbRotationType.Items.Add("Rotate180FlipXY")
        cmbRotationType.Items.Add("Rotate180FlipY")
        cmbRotationType.Items.Add("Rotate270FlipNone")
        cmbRotationType.Items.Add("Rotate270FlipX")
        cmbRotationType.Items.Add("Rotate270FlipXY")
        cmbRotationType.Items.Add("Rotate270FlipY")
        cmbRotationType.Items.Add("Rotate90FlipNone")
        cmbRotationType.Items.Add("Rotate90FlipX")
        cmbRotationType.Items.Add("Rotate90FlipXY")
        cmbRotationType.Items.Add("Rotate90FlipY")
        cmbRotationType.Items.Add("RotateNoneFlipNone")
        cmbRotationType.Items.Add("RotateNoneFlipX")
        cmbRotationType.Items.Add("RotateNoneFlipXY")
        cmbRotationType.Items.Add("RotateNoneFlipY")
    End Sub
 
    Private Sub RotateImage(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbRotationType.SelectedValueChanged
 
        If cmbRotationType.SelectedIndex < 0 Then Exit Sub
 
        Dim picOut As New Bitmap(PhotoPictureBox.BackgroundImage)
 
        Select Case cmbRotationType.SelectedIndex
            Case 0
                picOut.RotateFlip(RotateFlipType.Rotate180FlipNone)
            Case 1
                picOut.RotateFlip(RotateFlipType.Rotate180FlipX)
            Case 2
                picOut.RotateFlip(RotateFlipType.Rotate180FlipXY)
            Case 3
                picOut.RotateFlip(RotateFlipType.Rotate180FlipY)
            Case 4
                picOut.RotateFlip(RotateFlipType.Rotate270FlipNone)
            Case 5
                picOut.RotateFlip(RotateFlipType.Rotate270FlipX)
            Case 6
                picOut.RotateFlip(RotateFlipType.Rotate270FlipXY)
            Case 7
                picOut.RotateFlip(RotateFlipType.Rotate270FlipY)
            Case 8
                picOut.RotateFlip(RotateFlipType.Rotate90FlipNone)
            Case 9
                picOut.RotateFlip(RotateFlipType.Rotate90FlipX)
            Case 10
                picOut.RotateFlip(RotateFlipType.Rotate90FlipXY)
            Case 11
                picOut.RotateFlip(RotateFlipType.Rotate90FlipY)
            Case 12
                picOut.RotateFlip(RotateFlipType.RotateNoneFlipNone)
            Case 13
                picOut.RotateFlip(RotateFlipType.RotateNoneFlipX)
            Case 14
                picOut.RotateFlip(RotateFlipType.RotateNoneFlipXY)
            Case 15
                picOut.RotateFlip(RotateFlipType.RotateNoneFlipY)
        End Select
 
        PhotoPictureBox.BackgroundImage = picOut
    End Sub
 
End Class

Open in new window

Very Nice Code and all rotation.

Really Thanks Again