module1.bas
来自「这里有很多很实用的VB编程案例,方便大家学习VB.」· BAS 代码 · 共 63 行
BAS
63 行
Attribute VB_Name = "Module1"
Public Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Public Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Dim Red As Long
Dim Green As Long
Dim Blue As Long
Dim Red2 As Long
Dim Green2 As Long
Dim Blue2 As Long
Dim RedF As Long
Dim GreenF As Long
Dim BlueF As Long
Dim RGB1 As Long
Dim RGB2 As Long
Public Sub PaintTrans(Target As Long, Source As Long, X As Long, Y As Long, Width As Long, Height As Long)
Dim TrnsX As Long
Dim TrnsY As Long
For TrnsY = 0 To Height - 1
For TrnsX = 0 To Width - 1
RGB2 = GetPixel(Source, TrnsX, TrnsY)
If RGB2 <> 0 Then
GetRGBs RGB2
Red2 = Red
Green2 = Green
Blue2 = Blue
RGB1 = GetPixel(Target, TrnsX + X, TrnsY + Y)
GetRGBs RGB1
RedF = (Red + Red2) / 2
GreenF = (Green + Green2) / 2
BlueF = (Blue + Blue2) / 2
SetPixel Target, TrnsX + X, TrnsY + Y, RGB(RedF, GreenF, BlueF)
End If
Next TrnsX
Next TrnsY
End Sub
Public Sub GetRGBs(RGBVal As Long)
If RGBVal = 16777215 Then
Red = 255
Green = 255
Blue = 255
Exit Sub
End If
Red = RGBVal And 255
Green = RGBVal / 256 And 255
Blue = RGBVal / 65536 And 255
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?