如何使用vb.net在Windows窗体上旋转PictureBox

时间:2009-02-13 03:50:06

标签: vb.net

当我的if语句中的条件满足时,我需要将图片框旋转180度。这可能吗?

4 个答案:

答案 0 :(得分:7)

我假设你想要在里面旋转图像,因为旋转盒子本身没有多大意义(无论如何都是不可能的)。

试试这个:

myPictureBox.Image.RotateFlip(RotateFlipType.Rotate180FlipNone);

答案 1 :(得分:2)

System.Drawing.Image.RotateFlip()方法允许您旋转图片框中显示的实际图像。见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

答案 2 :(得分:2)

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

尝试使用以下方式旋转图像时

PictureBox1.Image.RotateFlip(RotateFlipType.Rotate180FlipNone)

在关闭表单并再次打开它之前不会发生任何事情(不是项目,只是表单)。如果您想立即轮换,则应使用PictureBox1.Refresh()

答案 3 :(得分:0)