📄 form0805.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "反转图片"
ClientHeight = 2655
ClientLeft = 60
ClientTop = 450
ClientWidth = 4845
ScaleHeight = 2655
ScaleWidth = 4845
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "反转图片"
Height = 375
Left = 2880
TabIndex = 3
Top = 1920
Width = 1095
End
Begin VB.PictureBox Picture2
Height = 855
Left = 2880
ScaleHeight = 53
ScaleMode = 3 'Pixel
ScaleWidth = 77
TabIndex = 2
Top = 480
Width = 1215
End
Begin VB.PictureBox Picture1
Height = 855
Left = 840
Picture = "Form0805.frx":0000
ScaleHeight = 53
ScaleMode = 3 'Pixel
ScaleWidth = 77
TabIndex = 1
Top = 480
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "扫描图片"
Height = 375
Left = 840
TabIndex = 0
Top = 1920
Width = 1095
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'定义一个ImageP三维数组
Dim ImageP() As Integer
Private Sub Command1_Click()
' 扫描图形,对装载入Picture1的原图进行扫描读取每个像素,存放在ImageP数组中。
Dim i As Integer, j As Integer
Dim Red As Integer, Green As Integer, Blue As Integer
Dim Col As Long
Dim x As Integer, y As Integer
Form1.MousePointer = 11 '设置鼠标为沙漏形状
x = Picture1.Width
y = Picture1.Height
'按图片框的大小重新定义数组
ReDim ImageP(2, x, y)
Picture1.AutoRedraw = True
For j = 0 To Picture1.Height - 1
For i = 0 To Picture1.Width - 1
Col = Form1.Picture1.Point(i, j)
Red = Col& And &HFF
Green = ((Col& And &HFF00) \ 256) Mod 256
Blue = (Col& And &HFF0000) \ 65536
ImageP(0, i, j) = Red
ImageP(1, i, j) = Green
ImageP(2, i, j) = Blue
Next
Next
Form1.MousePointer = 0
End Sub
Private Sub Command2_Click()
'单击反转图片按钮
Dim i, j As Integer
Dim Red, Green, Blue As Integer
Form1.MousePointer = 11
For j = 0 To Picture2.Height - 1
For i = 0 To Picture2.Width - 1
Red = 255 - ImageP(0, i, j)
Green = 255 - ImageP(1, i, j)
Blue = 255 - ImageP(2, i, j)
Picture2.PSet (i, j), RGB(Red, Green, Blue)
Next
Next
Form1.MousePointer = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -