Public Function TransparentBmp(DestPicture As PictureBox, BmpArray1() As ColorInfo, BmpArray2() As ColorInfo, StartX As Long, StartY As Long, StartX1 As Long, StartY1 As Long, StartX2 As Long, StartY2 As Long, iWidth As Long, iHeight As Long, Pellu As Long) As Long
Dim NowX As Long, NowY As Long, NowColor As Long
Dim RedClr As Long, GreenClr As Long, BlueClr As Long
Dim RedClr1 As Long, GreenClr1 As Long, BlueClr1 As Long
Dim RedClr2 As Long, GreenClr2 As Long, BlueClr2 As Long
Dim Pellu1 As Long, Pellu2 As Long
Const MaxPellu = 256
If Pellu < 0 Then Pellu = 0
If Pellu >= MaxPellu Then Pellu2 = MaxPellu - 1
Pellu1 = Pellu: Pellu2 = MaxPellu - Pellu
For NowX = 0 To iWidth Step Sgn(iWidth)
For NowY = 0 To iHeight Step Sgn(iHeight)
RedClr1 = BmpArray1(NowX + StartX1, NowY + StartY1).Red
GreenClr1 = BmpArray1(NowX + StartX1, NowY + StartY1).Green
BlueClr1 = BmpArray1(NowX + StartX1, NowY + StartY1).Blue
RedClr2 = BmpArray2(NowX + StartX2, NowY + StartY2).Red
GreenClr2 = BmpArray2(NowX + StartX2, NowY + StartY2).Green
BlueClr2 = BmpArray2(NowX + StartX2, NowY + StartY2).Blue
If RedClr2 < 128 And GreenClr2 < 128 And BlueClr2 < 128 Then
NowColor = RGB(RedClr1, GreenClr1, BlueClr1)
Else
RedClr = (RedClr1 * Pellu2 + RedClr2 * Pellu1) / &H100
GreenClr = (GreenClr1 * Pellu2 + GreenClr2 * Pellu1) / &H100
BlueClr = (BlueClr1 * Pellu2 + BlueClr2 * Pellu1) / &H100
'NowColor = BlueClr * &H10000 + GreenClr * &H100 + RedClr
NowColor = RGB(RedClr, GreenClr, BlueClr)
End If
SetPixelV DestPicture.hdc, NowX + StartX, NowY + StartY, NowColor
Next NowY
Next NowX
DestPicture.Refresh
End Function