>Hi All,
>I need to convert hex color value to RGB Value, is there any code can do it ?
>
>TIA
Hi Senna,
You can convert the hexidecimal value directly, depending on what the source of the value is. For example, lndec = 0xFD, will assign the value 253 to lndec. If, however, you have the hex value as a string then lndec = EVALUATE('0x' + "FD"), will produce the same result.
Now, there are a couple of ways to retrieve the individual color values. Easiest, is to use the RGBComp() function in Foxtools. Another way is to use the bit functions to mask out the individual values. Here's how:
STORE 0 TO lnred, lngreen, lnblue
= RGBComp(lncolor, @lnred, @lngreen, @lnblue)
lnblue = BITAND(lncolor, 255)
lncolor = BITRSHIFT(lncolor, 8)
lngreen = BITAND(lncolor, 255)
lncolor = BITRSHIFT(lncolor, 8)
lnred = BITAND(lncolor, 255)
Additionally, there are variations on the bit shifting above and also you could use integer division.
hth,
George
Ubi caritas et amor, deus ibi est