如何通过20度VB 2015年旋转图片框里面的图片?

问题描述 投票:0回答:1

说,我在我的窗体中PictureBox1。这图片框有一个形象在里面,我想将它旋转。其实,我已经学会了如何通过90,180,270图像旋转....程度。但是,我怎么能以20度或45度旋转呢?

这是我学习

 PictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone)
vb.net rotation image-rotation
1个回答
-1
投票

我的解决方案:

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
© www.soinside.com 2019 - 2024. All rights reserved.