【发布时间】:2019-12-11 19:34:13
【问题描述】:
我是使用 VB.Net 框架 4.7.2 Winforms 的初学者。 我试图在我的应用程序中旋转平面图像,但它显示了旋转后的图像和原始图像。
左图不旋转,右图旋转-25°
Private Sub Rotation(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
With e.Graphics
.TranslateTransform(PictureBox1.Width \ 2, PictureBox1.Height \ 2)
.RotateTransform(dgr)
.DrawImage(PictureBox1.Image, (-PictureBox1.Width \ 2), (-PictureBox1.Height \ 2))
End With
End Sub
这是我用来旋转图像的代码
我只想显示旋转后的图像。 提前致谢。
【问题讨论】:
-
先清除图形。
-
不要使用 PictureBox.Image 属性。将该 Image 分配给 Bitmap 对象并使用
Graphics.DrawImage()将其绘制在 PictureBox 的表面上。在这种情况下,您可以尝试Matrix.RotateAt()方法。
标签: vb.net winforms picturebox