3.3.4.3 Color representation

All methods that take color arguments accept the following two color representations:

For 12 and 16 bit color modes the color component values are simply truncated to the lower bit depth. For the 8-bit grayscale mode images the color is converted into grayscale using the formula (2*r+5*g+b)/8, rounded down to the nearest integer. For 1-bit black and white mode images the color is converted into black (0) or white (1) using the formula (2*r+5*g+b)/1024.

Examples of valid colors:

Examples of invalid colors:

Invalid code, do not use!

See About this document... for information on suggesting changes.