📄 form1.frm
字号:
VERSION 5.00
Object = "{27395F88-0C0C-101B-A3C9-08002B2F49FB}#1.1#0"; "PICCLP32.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
BackColor = &H00C0C0C0&
Caption = "图片剪切"
ClientHeight = 6345
ClientLeft = 60
ClientTop = 345
ClientWidth = 9885
Icon = "Form1.frx":0000
LinkTopic = "Form1"
ScaleHeight = 6345
ScaleWidth = 9885
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton Command3
Caption = "打开图片"
Height = 525
Left = 5085
TabIndex = 4
Top = 5595
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "退出"
Height = 525
Left = 8280
TabIndex = 3
Top = 5595
Width = 1335
End
Begin VB.CommandButton Command2
Caption = "图片另存为"
Height = 525
Left = 6690
TabIndex = 2
Top = 5595
Width = 1335
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 5550
Top = 5190
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.PictureBox Picture1
BackColor = &H00C0C0C0&
DrawStyle = 2 'Dot
Height = 5730
Left = 120
MouseIcon = "Form1.frx":000C
MousePointer = 99 'Custom
Picture = "Form1.frx":09F6
ScaleHeight = 5670
ScaleWidth = 4725
TabIndex = 1
Top = 420
Width = 4785
End
Begin VB.PictureBox Picture2
AutoSize = -1 'True
Height = 3285
Left = 5010
ScaleHeight = 3225
ScaleWidth = 4740
TabIndex = 0
Top = 480
Width = 4800
End
Begin PicClip.PictureClip PictureClip1
Left = 135
Top = 420
_ExtentX = 7938
_ExtentY = 5741
_Version = 393216
Picture = "Form1.frx":524A2
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "目标图片"
Height = 345
Left = 5505
TabIndex = 6
Top = 150
Width = 2535
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "源图片"
Height = 345
Left = 105
TabIndex = 5
Top = 150
Width = 2535
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public x1 As Single, y1 As Single
Public x2 As Single, y2 As Single
Public color1 As Long, mycolor As Long
Private Sub Command2_Click()
'保存剪切的图片
CommonDialog1.Filter = "Bmp文件|*.bmp|jpg文件|*.jpg"
CommonDialog1.ShowSave
CommonDialog1.Flags = &H2 + &H4 + &H8
If CommonDialog1.FileName <> "" Then
SavePicture Picture2.Picture, CommonDialog1.FileName
End If
End Sub
Private Sub Command3_Click()
'打开图片
CommonDialog1.Filter = "Bmp文件|*.bmp|jpg文件|*.jpg"
CommonDialog1.ShowOpen
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
PictureClip1.Picture = Picture1.Picture
End Sub
Private Sub Form_Load()
color1 = Form1.BackColor
mycolor = &HFF00&
Picture1.ScaleMode = 3
Picture1.DrawMode = 7
Picture2.ScaleMode = 3
Command2.Enabled = False
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
x1 = X
y1 = Y
x2 = X
y2 = Y
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Picture1.Line (x1, y1)-(x2, y2), mycolor, B
Picture1.Line (x1, y1)-(X, Y), mycolor, B
x2 = X
y2 = Y
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Picture1.Line (x1, y1)-(X, Y), mycolor, B
PictureClip1.ClipX = IIf(x1 < X, x1, X)
PictureClip1.ClipY = IIf(y1 < Y, y1, Y)
PictureClip1.ClipWidth = Abs(X - x1)
PictureClip1.ClipHeight = Abs(Y - y1)
Command2.Enabled = True
Picture2.Picture = PictureClip1.Clip
End If
End Sub
Private Sub Command1_Click()
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -