hello I usually used this function to combine two Olecolors, but I want to add the Alpha channel, but I have the problem of> 127, (add a value and if it is 255 it goes to 0 leaving a transparent color) can someone help.
I am using this function to convert an OleColor to RGBA (GDI+)Code:Private Function ShiftColor(ByVal clrFirst As Long, ByVal clrSecond As Long, ByVal Percent As Long) As Long Dim clrFore(3) As Byte Dim clrBack(3) As Byte Dim cResult(3) As Byte clrFore(0) = ((clrFirst \ &H10000) And &HFF) clrFore(1) = ((clrFirst \ &H100) And &HFF) clrFore(2) = (clrFirst And &HFF) clrFore(3) = ((clrFirst \ &H1000000) And &HFF) clrBack(0) = ((clrSecond \ &H10000) And &HFF) clrBack(1) = ((clrSecond \ &H100) And &HFF) clrBack(2) = (clrSecond And &HFF) clrBack(3) = ((clrSecond \ &H1000000) And &HFF) cResult(0) = (clrFore(0) * Percent + clrBack(0) * (255 - Percent)) / 255 cResult(1) = (clrFore(1) * Percent + clrBack(1) * (255 - Percent)) / 255 cResult(2) = (clrFore(2) * Percent + clrBack(2) * (255 - Percent)) / 255 cResult(3) = (clrFore(3) * Percent + clrBack(3) * (255 - Percent)) / 255 CopyMemory ShiftColor, cResult(0), 4 End Function
Code:Private Function ConvertColor(Color As Long, Opacity As Byte) As Long Dim BGRA(0 To 3) As Byte BGRA(3) = Opacity BGRA(0) = ((Color \ &H10000) And &HFF) BGRA(1) = ((Color \ &H100) And &HFF) BGRA(2) = (Color And &HFF) CopyMemory ConvertColor, BGRA(0), 4& End Function




Reply With Quote