【问题标题】:Rotate an image by 15 degrees increments?将图像旋转 15 度增量?
【发布时间】:2012-12-08 02:03:36
【问题描述】:

我面临着一项似乎非常艰巨的任务。我需要在 PictureBox 内以 15 度的增量旋转图像。在花了很长时间搜索互联网的深度之后,我还没有找到任何可以完成这项任务的东西。我能想到的最接近的方法是使用以下方法进行 90 度翻转:

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    InitializeBitmap()
End Sub

Dim bitmap1 As Bitmap

Private Sub InitializeBitmap()
    Try
        bitmap1 = CType(Bitmap.FromFile("G:\Documents\Dawson\Semster 3\Visual Basic I\Test\subs\subs\Wheel.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.Rotate90FlipXY)
        PictureBox1.Image = bitmap1
    End If
End Sub

我需要将图像翻转 15 度增量的代码;不多也不少。

任何愿意向我提供此代码的人将不胜感激。感谢您的宝贵时间。

【问题讨论】:

    标签: .net vb.net image image-rotation


    【解决方案1】:

    这是CodeProject article showing how to rotate an image in a PictureBox

    基本方法需要使用 GDI 和 Graphics class 获取图像,执行旋转(通过 Graphics.RotateTransform 等方法),然后将结果保存为图像,并将其分配给您的 PictureBox 控件。

    【讨论】:

    • 这个链接上的代码翻译成VB很好。它可以很好地完成我的工作。非常感谢您的帮助!
    猜你喜欢
    • 2019-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-06
    相关资源
    最近更新 更多