Efficient way to get R,G,B out of a color value
Or to whack a long or integer into bytes....
[code]
In a .BAS module--------------
You can also use the api calls above to get any byte out of a two or four byte integer or long.Code:Private Declare Function LoByte Lib "TLBINF32" Alias "lobyte" _ (ByVal Word As Integer) As Byte Private Declare Function HiByte Lib "TLBINF32" Alias "hibyte" _ (ByVal Word As Integer) As Byte Private Declare Function loword Lib "TLBINF32" (ByVal DWord As Long) _ As Integer Private Declare Function hiword Lib "TLBINF32" (ByVal DWord As Long) _ As Integer Public Sub From_RGB(Color as Long, R as Byte, G as Byte,B as Byte) R = LoByte(loword(Color)) ' Byte 1 G = HiByte(loword(Color)) ' Byte 2 B = LoByte(hiword(Color)) ' Byte 3 ' HiByte(hiword(Color)) Byte 4 - no meaning here just a comment End Sub




Reply With Quote