Convert a RGB colour value to Decimal
RGB integers are typically treated as three distinct bytes where the left-most (highest-order) byte is red, the middle byte is green and the right-most (lowest-order) byte is blue. You can retrieve the values of these individual bytes like this:
var c = 0xff03c0; // 16712640
var components = {
r: (c & 0xff0000) >> 16,
g: (c & 0x00ff00) >> 8,
b: (c & 0x0000ff)
};
You can re-create a color from its components by shifting the bytes back in:
c = (components.r << 16) + (components.g << 8) + (components.b);
In your case, simply substitute components.r
(etc) with your actual variables.
A much better answer (in terms of clarity) is this:
'Convert RGB to LONG:
LONG = B * 65536 + G * 256 + R
'Convert LONG to RGB:
B = LONG \ 65536
G = (LONG - B * 65536) \ 256
R = LONG - B * 65536 - G * 256
LONG is your long integer (decimal) that you want to make. Easy huh? Sure, bitshift