i build 1 sub for do the transparent opacy.
and i belive that i have some errors on it, because i have bad results
Code:
'Opacy an image(alpha blend): finalrgb = a*rgb1 + (1-a)rgb2
Public Sub TransparentAlphaBlend(ByRef SrcHDC As Long, ByRef DstHDC As Long, ByRef SrcWidth As Long, SrcHeight, ByRef Opacy As Integer, ByRef TransparentColor As Long)
Dim x As Long, y As Long
Dim lngsrcColor As Long
Dim lngdstColor As Long
Dim lngNewColor As Long
Dim dblAlphaDst As Long
Dim dblAlpha As Double, R As Long, G As Long, B As Long
Dim SrcRed As Long, SrcBlue As Long, SrcGreen As Long
Dim DstRed As Long, DstBlue As Long, DstGreen As Long
'convert between 0-100 to 255
dblAlpha = Opacy * 255 / 100
dblAlphaDst = dblAlpha - 1
For x = 0 To SrcWidth - 1
For y = 0 To SrcHeight - 1
lngdstColor = GetPixel(DstHDC, x, y)
lngsrcColor = GetPixel(SrcHDC, x, y)
If lngsrcColor <> TransparentColor Then
DstRed = lngdstColor And 255
DstGreen = (lngdstColor And 65535) \ 256
DstBlue = (lngdstColor And &HFF0000) \ 65536
SrcRed = lngsrcColor And 255
SrcGreen = (lngsrcColor And 65535) \ 256
SrcBlue = (lngsrcColor And &HFF0000) \ 65536
R = (dblAlpha * SrcRed) + dblAlphaDst * DstRed
G = (dblAlpha * SrcGreen) + dblAlphaDst * DstGreen
B = (dblAlpha * SrcBlue) + dblAlphaDst * DstBlue
lngNewColor = RGB(R, G, B)
SetPixelV DstHDC, x, y, lngNewColor
End If
Next y
Next x
End Sub
maybe is my converstion or how i combine the colors i don't have sure. can anyone tell me how combine the colors for opacy, then maybe i can fix the sub. the R,G or B are more than 255 and i know that isn't a correct result(i recive overflow error on RGB function)
can anyone advice me?