8.5. Putting It All Together

Most of 2D's color handling is behind-the-scenes work. You'll hardly ever need to deal with CIEXYZ or sRGB conversions yourself. You can control 2D's color handling with a rendering hint (see Chapter 5). The name of the hint key is KEY_COLOR_RENDERING. It has three possible values:

VALUE_COLOR_RENDER_QUALITY

With this hint setting, the 2D API will do its very best to represent colors correctly. The API accomplishes this by attempting to find a color profile for your screen. Every color that is shown will be converted to a color space constructed from this profile. The way that profiles are located depends on the underlying operating system.

VALUE_COLOR_RENDER_SPEED

This hint value specifies that 2D should render things speedily, not worrying about a screen profile. This means that sRGB colors will be transferred directly to an RGB screen, even though this is not quite a correct match.

VALUE_COLOR_RENDER_DEFAULT

This hint value tells 2D to do whatever it usually does for color rendering.

Remember, rendering hints are only suggestions. Even if you tell 2D to use the VALUE_COLOR_RENDER_QUALITY hint, you still might not get colors that have been corrected for a particular screen, for either of these reasons:

  • If the 2D implementation doesn't support the color rendering hint, no color correction will be done.

  • If 2D can't find a color profile for your screen, it can't do color correction.

The initial release of Java 2 does not do any special processing ...

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.