⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 12.6.frm

📁 vb编程+从基础到实践光盘代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "图片旋转"
   ClientHeight    =   6120
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   12135
   LinkTopic       =   "Form1"
   ScaleHeight     =   6120
   ScaleWidth      =   12135
   StartUpPosition =   3  'Windows Default
   Begin VB.PictureBox PicSource 
      Height          =   5295
      Left            =   0
      ScaleHeight     =   5235
      ScaleWidth      =   5955
      TabIndex        =   5
      Top             =   0
      Width           =   6015
   End
   Begin VB.CommandButton CmdExit 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   9840
      TabIndex        =   4
      Top             =   5520
      Width           =   1215
   End
   Begin VB.CommandButton CmdOK 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   7560
      TabIndex        =   3
      Top             =   5520
      Width           =   1215
   End
   Begin VB.TextBox TxtValue 
      Alignment       =   2  'Center
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   3960
      TabIndex        =   1
      Top             =   5520
      Width           =   1095
   End
   Begin VB.PictureBox PicTarget 
      Height          =   5295
      Left            =   6120
      ScaleHeight     =   5235
      ScaleWidth      =   5925
      TabIndex        =   0
      Top             =   0
      Width           =   5985
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   300
      Left            =   1560
      TabIndex        =   2
      Top             =   5640
      Width           =   150
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const pi = 3.141592653589

Private Sub CmdExit_Click()
    End
End Sub

Private Sub CmdOK_Click()
    Dim X As Double, Y As Double
    Dim X0 As Double, Y0 As Double
    Dim Xc As Double, Yc As Double
    Dim Xn As Double, Yn As Double
    Dim K As Single, pcolor As Long
    PicTarget.Cls
    K = Val(TxtValue.Text) * pi / 180
    PicSource.ScaleMode = vbPixels
    PicTarget.ScaleMode = vbPixels
    For X = 0 To PicSource.ScaleWidth - 1
        Xc = X - PicSource.ScaleWidth \ 2
        For Y = 0 To PicSource.ScaleHeight - 1
            Yc = Y - PicSource.ScaleHeight \ 2
            X0 = Xc * Cos(-K) + Yc * Sin(-K)
            Y0 = Yc * Cos(-K) - Xc * Sin(-K)
            Xn = X0 + PicTarget.ScaleWidth \ 2
            Yn = Y0 + PicSource.ScaleHeight \ 2
            pcolor = PicSource.Point(X, Y)
            PicTarget.PSet (Xn, Yn), pcolor
        Next Y
    Next X
End Sub

Private Sub Form_Load()
    PicSource.Picture = LoadPicture(App.Path + "\1.jpg")
    TxtValue.Text = "0"
    Label1.Caption = "请输入旋转角度:"
    CmdOK.Caption = "旋转"
    CmdExit.Caption = "退出"
    PicSource.ScaleMode = vbPixels
    PicTarget.ScaleMode = vbPixels
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -