📄 form1.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents Panel2 As System.Windows.Forms.Panel
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button2 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.Button4 = New System.Windows.Forms.Button
Me.Panel1 = New System.Windows.Forms.Panel
Me.Panel2 = New System.Windows.Forms.Panel
Me.SuspendLayout()
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(88, 232)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(64, 24)
Me.Button2.TabIndex = 3
Me.Button2.Text = "翻 转"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(216, 232)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(64, 24)
Me.Button3.TabIndex = 4
Me.Button3.Text = "镜 像"
'
'Button4
'
Me.Button4.Location = New System.Drawing.Point(328, 232)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(56, 24)
Me.Button4.TabIndex = 5
Me.Button4.Text = "退 出"
'
'Panel1
'
Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Panel1.Location = New System.Drawing.Point(24, 16)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(200, 184)
Me.Panel1.TabIndex = 10
'
'Panel2
'
Me.Panel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Panel2.Location = New System.Drawing.Point(248, 16)
Me.Panel2.Name = "Panel2"
Me.Panel2.Size = New System.Drawing.Size(208, 184)
Me.Panel2.TabIndex = 11
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(464, 286)
Me.Controls.Add(Me.Panel2)
Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Dim pic1, pic2 As Bitmap
Dim flag As Integer = 0
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
flag = 1
Panel2.Invalidate()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
flag = 2
Panel2.Invalidate()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Panel1.Height = Panel1.Width
Panel2.Width = Panel1.Width
Panel2.Height = Panel2.Width
Dim pic As Image = Image.FromFile("Water lilies.jpg")
pic1 = New Bitmap(pic, Panel1.Width, Panel1.Height)
pic2 = New Bitmap(pic1)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
End
End Sub
Private Sub Panel1_Paint1(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
Dim g As Graphics = e.Graphics
g.DrawImage(pic1, 0, 0)
End Sub
Private Sub Panel2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel2.Paint
Dim g As Graphics = e.Graphics
Dim x As Integer = Panel2.Width
Dim col As Color = New Color
Select Case flag
Case 1
Dim pic3 As Bitmap
pic3 = New Bitmap(x, x)
Dim i, j As Integer
For i = 0 To x - 1
For j = 0 To x - 1
col = pic2.GetPixel(i, j)
pic3.SetPixel(i, x - 1 - j, col)
Next
Next
g.DrawImage(pic3, 0, 0)
pic2 = New Bitmap(pic3)
Case 2
Dim pic4 As Bitmap
pic4 = New Bitmap(x, x)
Dim i, j As Integer
For i = 0 To x - 1
For j = 0 To x - 1
col = pic2.GetPixel(i, j)
pic4.SetPixel(x - i - 1, j, col)
Next
Next
g.DrawImage(pic4, 0, 0)
pic2 = New Bitmap(pic4)
End Select
flag = 0
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -