2009-02-13 53 views

Trả lời

7

Tôi giả định rằng bạn muốn xoay hình ảnh bên trong, bởi vì xoay hộp chính nó không có ý nghĩa nhiều (và không thể nào được).

Hãy thử điều này:

myPictureBox.Image.RotateFlip(RotateFlipType.Rotate180FlipNone); 
2

Các System.Drawing.Image.RotateFlip() phương pháp cho phép bạn xoay hình ảnh thực tế được hiển thị trong hình tượng. Xem this page

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 
+0

Mã này hữu ích - Cảm ơn! – user39035

1
PictureBox1.Image.RotateFlip(RotateFlipType.Rotate180FlipNone) 
PictureBox1.Refresh() 

Khi bạn cố gắng để xoay hình ảnh của bạn với:

PictureBox1.Image.RotateFlip(RotateFlipType.Rotate180FlipNone) 

gì sẽ xảy ra cho đến khi bạn đóng biểu mẫu và mở nó một lần nữa (không phải là dự án, chỉ là hình thức). Nếu bạn muốn xoay cùng một lúc thì bạn nên sử dụng PictureBox1.Refresh().

Các vấn đề liên quan