You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Color Handling

Introduction

This page shall discuss an approach to represent the various colors supported by upcoming SVG and XSL-FO specifications in Java.

Requirements

Both SVG and XSL-FO allow specification of color in various color spaces (defined by ICC color profiles, with 1, 3, 4 or n components). In both cases, sRGB is the default color space. sRGB also serves as fallback in both cases. With SVG 1.2 and XSL 2.0, additional color specifications will be introduced. Among these are:

  • device-specific (uncalibrated) colors, mainly for specifying CMYK colors, but also for gray, RGB values and N-Component colorspaces (like HP's IndiChrome 6-color printing).
  • CIE LAB and CIE LCHab colors
  • ICC Named Color (for spot colors)

Not all possible output formats for SVG and XSL-FO documents support all of the above color specifications. In all cases, fallback colors in sRGB color space are specified to achieve at least an approximation of the intended color. What's intended here is to find a way to represent these colors as primary color specifications for output formats that support them. In all other case, the sRGB fallback shall be used.

Color in the Java class library

java.awt.Color is Java's way to specify color, primarily in the sRGB color space. But it also has constructors taking a [ColorSpace] parameter, so arbitrary colors with n components and color values between 0.0 and 1.0 can be specified. The class uses the float[] [ColorSpace].toRGB(float[]) method to calculate the sRGB fallback value for such a color.

What the class doesn't support is the specification of named colors based on an ICC named color profile (or any other source for named colors). A possible work-around is thinkable: A named color profile is split up into its various named colors and a ColorSpace object is created for each of them with one component each for the tint (see notes below).

Various notes

ICC Named Color Profiles

The ICC specification provides a way to specify various named spot colors in a color profile. However, this facet is not very well supported by consumers as well as producers of ICC color profiles. So while the use of ICC named colors is not a bad idea per se, without the right tooling, it is rather difficult to handle. Furthermore, many print shops define named colors directly on the RIP/printer. PDF and PostScript allow to specify a "Separation" color space with an abstract named color which is only mapped to the final spot color on the RIP (raster image processor). In this case an ICC named color profile is not involved. This may make it necessary to define pseudo (or virtual) named color profiles which take their color specs from somewhere else (like a proprietary XML file). Furthermore, PDF and PostScript don't allow using an ICC named color profile.

Using named/spot colors

In offset printing spot colors are special inks that are premixed to achieve an exact color instead of having to mix the right color from 4 or more subtractive colors. That way it is, for example, possible to put a layer of gold "ink" on paper.

Often, named (or spot) colors are accompanied with a single tint value that specifies the amount of coverage with the spot color. 0.0 uses no ink while 1.0 specifies the maximum ink usage (complete coverage). For example, PDF's separation color space supports that. It is however interesting that at the moment the SVG and XSL working drafts don't provide means to specify tints on named colors.

Spec references

  • No labels