8.3. Color Spaces

A color space is a collection of all colors that can be shown by a particular device. An RGB monitor, for example, has a certain range of colors that it can display, based on its red, green, and blue lights and the ranges of intensity for each. A different RGB monitor will have a different color space, because of variations in the colors of the red, green, and blue lights and other variations in electronics and manufacture. Both monitors use the same color space type, RGB, but each has a device-dependent color space. Similarly, some printers use combinations of cyan, magenta, yellow, and black ink to create colors. These types of printers have a CMYK color space type, but each printer defines its own CMYK color space.

If you specify an RGB color, then, you can easily display it on any device with an RGB color space, but it may look different on each device. To show a color on two different devices and have it look the same, you need some way to specify the color in absolute terms. Then it can be translated into the specific color spaces of each device.

8.3.1. CIEXYZ

The Commission Internationale de l'Eclairage (CIE) designed an absolute color space in 1931. They defined three primary colors, called X, Y, and Z, instead of red, green, and blue. Any visible color can be reproduced using only positive amounts of X, Y, and Z. The name of this color space is CIEXYZ.

It's usually not convenient for devices to deal with CIEXYZ. A monitor creates colors by mixing ...

Get Java 2D Graphics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.