说,我在我的窗体中PictureBox1。这图片框有一个形象在里面,我想将它旋转。其实,我已经学会了如何通过90,180,270图像旋转....程度。但是,我怎么能以20度或45度旋转呢?
这是我学习
PictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone)
我的解决方案:
Public Function RotateImage(ByRef image As Image, ByVal offset As PointF, ByVal angle As Decimal) As Bitmap
If image Is Nothing Then
Throw New ArgumentNullException("image")
End If
''create a new empty bitmap to hold rotated image
Dim rotatedBmp As Bitmap = New Bitmap(image.Width, image.Height)
'Dim rotatedBmp As Bitmap = New Bitmap(image)
rotatedBmp.SetResolution(image.HorizontalResolution, image.VerticalResolution)
''make a graphics object from the empty bitmap
Dim g As Graphics = Graphics.FromImage(rotatedBmp)
''Put the rotation point in the center of the image
g.TranslateTransform(offset.X, offset.Y)
''rotate the image
g.RotateTransform(angle)
''move the image back
g.TranslateTransform(-offset.X, -offset.Y)
''draw passed in image onto graphics object
'g.DrawImage(image, New PointF(0, 0))
g.DrawImage(image, offset)
Return rotatedBmp
End Function