[cairo] Spot colors (and CMYK)

Bill Spitzak spitzak at gmail.com
Thu Jan 14 17:13:20 PST 2010


James Cloos wrote:

> for cairo_t meaning one of DeviceRGB, sRGB or scRGB -- which one whould
> need to decided and documented.

In floating point sRGB and scRGB are identical. scRGB is just a larger 
than 0-1 range which floating point supports anyway.

You may be thinking of "linear" light levels rather than the gamma 
corrected levels sRGB define. In linear space adding two colors 
numerically is the same as adding two lights physically. I am not sure 
what to call this but scRGB is the wrong term. I use "linearRGB" but an 
awful lot of code uses the term "linear" for what you are calling Device 
space (in that the transformation to the device is the linear identity), 
this has led to a lot of confusion.

> There should be several well known values for cairo_color_space_t, such
> as sRGB, scRGB, CIELab, CIELuv, logLuv, DeviceRGB, DeviceGray, DeviceN,
> DeviceCMYK, CIEXYZ, CIEYxy, ICC, CIEBasedA, CIEBasedABC, CIEBasedDEF,
> CIEBasedDEFG and the typical set of Yuv-style spaces.
> 
> For ICC there would be a pointer to an ICC profile.
> 
> The CIEBased spaces require a function specifying their conversion to
> some other space such as XYZ.  Cairo should support specifying that
> function either as a C function pointer or as a string of something
> such as cairoscript code.

Here is my proposal:

The main detail is that back ends do not need to understand much of 
anything and thus new color spaces can be added without any work.

A color, once a space is chosen, is defined by a fixed-size structure. 
This structure has the following form:

	struct cairo_color_t {
	  unsigned32 enumeration;
	  float sRGBA[4];
	  float other[n];
	};

Where n depends on the enumeration and can range from 0 to any number. 
It is possible that data other than float may be placed in this memory.

Devices that do not understand the value in the enumeration can use the 
sRGBA values. This is actually device space though the sRGBA name is 
used because the numbers may be interpreted as exactly sRGB by other 
color spaces.

In more cases than you might think the other data can be zero. All 3-D 
spaces with a transformation to CIEXYZ can be transformed to non-clamped 
sRGB, the inverse transformation of the sRGBA values can be used to 
recover the values.

For spot colors the spot color is recovered by looking up the sRGB 
color. This assumes a 1:1 mapping between spot color and sRGB. Another 
channel is used to transfer this information.

Bill


More information about the cairo mailing list