Forum Discussion
Sakthi,
As far as I know, in a typical case, an RGBa color is coded as a 4-byte value: (a, r, g, b). See http://en.wikipedia.org/wiki/RGBA_color_space. Depending on the data type, this 4-byte can be treated as an integer value, or a hexadecimal value. For instance, the color a=255, r=255, g=0, b=0 can be displayed as a signed integer (-65536, the highest bit is used to code the sign, that is why, you get a negative number) or like a hexadecimal number FFFF0000.
I guess, you get colors as numbers. You can either compare the colors directly, or convert them into strings and then compare the strings. To get a string of hexadecimal symbols that correspond to a color, you can use VBScript's Hex function. The code snippet below demonstrates how you can use it in your tests.
If you want to exclude the a channel from comparison, you can simply use only 6 right characters, that is,
s = RGBaToStr(...)
s = Right(s, 6)
If you decide to compare colors as ordinary numbers and want to exclude the a channel, you can use this code --
colorWithoutA = colorWithA and &H00FFFFFF
Here is a function that converts a color to a string of hex digits:
Sub Test
' Use
s1 = RGBaToStr(-65536)
s2 = RGBaToStr(16711680) ' r = 255, g = 0, b = 0
Log.Message "Result: " + s1
Log.Message "Result: " + s2
End Sub
Function RGBaToStr(AValue)
' Convert
s = Hex(AValue)
' Add leading spaces, if needed
L = Len(s)
If L < 8 Then
For i = 1 to 8 - L
s = "0" + s
Next
End If
' Return the result
RGBaToStr = s
End Function