Color Values

24-Bit Color Values

The Color iLCD controller supports commands for setting colors such as background color or foreground color. Although the Color iLCD controller internally works with 16-Bit Color Values, all commands except the read and write scan line commands use 24 bit color values to allow future expansions.

In the ilcd package description, 24-bit color values are always described as type "color" in the corresponding parameter tables.

The 24-bit color value is converted to a 16-bit color value by the iLCD controller internally by using the following formula:

color_16_bit = ((red >> 3) << 11) + ((green >> 2) << 5) + (blue >> 3)

where red, green and blue are 8-bit values with a range between 0 and 255.

The color values must be set in a 24-bit format, where color_r describes the 8-bit red part, color_g the green and color_b the blue part of the 24-bit color value.

Syntax in iLCD Manager XE:

short red = 0x00;     //ranging from 0x00 to 0xFF
short green = 0xFF;   //ranging from 0x00 to 0xFF
short blue = 0x00;    //ranging from 0x00 to 0xFF
int color_24_bit = (red << 16) + (green << 8) + blue;