-1

I would like to rotate an image based on the value of a parameter in my program. I have a class called DaylightForm.vb that pulls it's data from a class called DaylightParameters.vb. There is a property called "North" that the user inputs with a text box, and picture box with an arrow that I want to rotate based on the value of "North". And I want it to update when the user makes changes.

Thoughts? Thank you!

user1707675
  • 21
  • 1
  • 2
  • 9
  • If you want to rotate a bitmap by a specific degree (not compass directions) see [this thread](http://stackoverflow.com/questions/2163829/how-do-i-rotate-a-picture-in-c-sharp) and use a C# to VB.Net Code Converter. In future best to google simple questions like this: "VB.Net rotate bitmap image" – Jeremy Thompson Apr 29 '15 at 00:38

1 Answers1

1

Try using the Image Class; RotateFlip Method:

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) '<- HERE IS THE MAGIC!
        PictureBox1.Image = bitmap1
    End If 

End Sub
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
Hawkeye
  • 11
  • 1
  • Good to see you're participating in Stackoverflow! Generally external links to MSDN, CodeProject and github projects are acceptable though it's customary in StackOverflow answers to include a summary of the contents of a link or the highlights that specifically answer the question. With a link-only answer, people must dig through another resource to locate an answer they might not be sure about and most importantly, if the link were to ever break, the answer is useless for anyone who visits this page in the future. + 1 and good luck! – Jeremy Thompson Apr 29 '15 at 00:36