[英]How to rotate a PictureBox on a windows form using vb.net
当满足if语句中的条件时,我需要将图片框旋转180度。 这可能吗?
我假设你想要在里面旋转图像,因为旋转盒子本身没有多大意义(无论如何都是不可能的)。
尝试这个:
myPictureBox.Image.RotateFlip(RotateFlipType.Rotate180FlipNone);
PictureBox1.Image.RotateFlip(RotateFlipType.Rotate180FlipNone)
PictureBox1.Refresh()
当您尝试旋转图像时:
PictureBox1.Image.RotateFlip(RotateFlipType.Rotate180FlipNone)
在关闭表单并再次打开它之前不会发生任何事情(不是项目,只是表单)。 如果要立即旋转,则应使用PictureBox1.Refresh()
。
System.Drawing.Image.RotateFlip()方法允许您旋转图片框中显示的实际图像。 看到这个页面
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.