I have colour values from a Flash application that are ARGB format(A being the alpha/transparency value).
I have to convert that long decimal number to a RGB/Hexadecimal number in Javascript. I REALLY struggle with bitwise operations. In Flash the colour white is represented by the decimal number: 16777215, black is obviously 0. Other colours are like: 84545883, 4803910 etc which I have no idea what colour they are.
Do you know how I can extract the individual R, G, B & A values from a long(8 digit) number?
Can you help me get these functions to extract the (R,G,B,A) values?
function getA( num )
{
// eg value for num is 84545883
return (parseInt(num,10)) & 0xFF000000; // does this correctly get the A value from a ARGB value?
}
function getR( num )
{
// eg value for num is 84545883
return (parseInt(num,10)) & 0x00FF0000; // does this correctly get the R value from a ARGB value?
}
function getG( num )
{
// eg value for num is 84545883
return (parseInt(num,10)) & 0x0000FF00; // does this correctly get the G value from a ARGB value?
}