JonD #1 there is code for this in the code archives already. It includes functions for putting RGB values into an integer, as well as extracting RG&B components from the integer.