【VB开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了VB开源代码-combinar.frm的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "图形合并"
ClientHeight = 4845
ClientLeft = 45
ClientTop = 330
ClientWidth = 6465
Icon = "combinar.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 4845
ScaleWidth = 6465
StartUpPosition = 2 '屏幕中心
Begin VB.ListBox List1
Height = 1860
ItemData = "combinar.frx":0E42
Left = 3240
List = "combinar.frx":0E58
TabIndex = 3
Top = 2760
Width = 2985
End
Begin VB.PictureBox Picture3
AutoRedraw = -1 'True
Height = 2280
Left = 30
ScaleHeight = 148
ScaleMode = 3 'Pixel
ScaleWidth = 200
TabIndex = 2
Top = 2430
Width = 3060
End
Begin VB.PictureBox Picture2
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 2310
Left = 3210
Picture = "combinar.frx":0ECE
ScaleHeight = 150
ScaleMode = 3 'Pixel
ScaleWidth = 200
TabIndex = 1
Top = 60
Width = 3060
End
Begin
VB.PictureBox Picture1
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 2310
Left = 30
Picture = "combinar.frx":3302
ScaleHeight = 150
ScaleMode = 3 'Pixel
ScaleWidth = 200
TabIndex = 0
Top = 60
Width = 3060
End
Begin VB.Label Label1
Caption = "双击查看图像合并效果"
Height = 585
Left = 3240
TabIndex = 4
Top = 2400
Width = 3615
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub MERGE(INVERTED1 As Boolean, INVERTED2 As Boolean)
On Error GoTo fin:
Dim X As Long
Dim y As Long
Dim R1 As Integer
Dim G1 As Integer
Dim B1 As Integer
Dim R2 As Integer
Dim G2 As Integer
Dim B2 As Integer
Picture3.Cls
Picture3.Height = Picture1.Height
Picture3.Width = Picture1.Width
For X = 0 To Picture1.ScaleWidth
DoEvents
For y = 0 To Picture1.ScaleHeight
'HERE WE GET THE RGB VALUES OF THE FIRST PICTURE
GET_COLORS Picture1.Point(X, y), R1, G1, B1, INVERTED1
'HERE WE GET THE RGB VALUES OF THE SECOND PICTURE
GET_COLORS Picture2.Point(X, y), R2, G2, B2, INVERTED2
'WE PUT AN AVERAGE OF BOTH PIXELS IN THE THIRD PICTURE BOX
'pset puts a pixel on a specified x,y point, with a RGB color.
Picture3.PSet (X, y), RGB((R1 + R2) / 2, (G2 + G1) / 2, (B2 + B1) / 2)
Next y
Next X
Beep
Exit Sub
fin:
TEMP = MsgBox(Err.Description, vbExclamation, "Picture Mixer")
End Sub
Private Sub NEGATIVE_IMAGE(PICTURE As PictureBox)
On Error GoTo fin:
Dim X As Long
Dim y As Long
Dim R1 As Integer
Dim G1 As Integer
Dim B1 As Integer
Dim R2 As Integer
Dim G2 As Integer
Dim B2 As Integer
Picture3.Cls
Picture3.Height = Picture1.Height
Picture3.Width = Picture1.Width
For X = 0 To Picture1.ScaleWidth
DoEvents
For y = 0 To Picture1.ScaleHeight
'HERE WE GET THE RGB VALUES OF THE PICTURE
GET_COLORS PICTURE.Point(X, y), R1, G1, B1, True
'pset puts a pixel on a specified x,y point, with a RGB color.
Picture3.PSet (X, y), RGB(R1, G1, B1)
Next y
Next X
Beep
Exit Sub
fin:
TEMP = MsgBox(Err.Description, vbExclamation, "Picture Mixer")
End Sub
Private Sub GET_COLORS(COLOR As Long, ByRef R As Integer, ByRef G As Integer, ByRef B As Integer, INVERTED As Boolean)
'here you get the RGB values
Dim TEMP As Long
TEMP = (COLOR And 255)
R = TEMP And 255
TEMP = Int(COLOR / 256)
G = TEMP And 255
TEMP = Int(COLOR / 65536)
B = TEMP And 255
'Now, we are going to check if we need to invert an image...
If INVERTED = True Then
R = Abs(R - 255)
G = Abs(G - 255)
B = Abs(B - 255)
End If
End Sub
Private Sub List1_DblClick()
On Error GoTo fin:
Select Case List1.ListIndex
Case 0:
MERGE False, False
Case 1:
MERGE True, False
Case 2:
MERGE False, True
Case 3:
MERGE True, True
Case 4:
NEGATIVE_IMAGE Picture1
Case 5:
NEGATIVE_IMAGE Picture2
End Select
Exit Sub
fin:
TEMP = MsgBox(Err.Description, vbExclamation, "Picture Mixer")
End Sub