我想根据程序中参数的值旋转图像。我有一个名为DaylightForm.vb的类,它从名为DaylightParameters.vb的类中提取它的数据。有一个名为" North"用户使用文本框输入,带有箭头的图片框我想根据" North"的值旋转。我希望在用户进行更改时进行更新。
思考?谢谢!
答案 0 :(得分: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