[cairo] Spot colors (and CMYK)
Kai-Uwe Behrmann
ku.b at gmx.de
Wed Feb 17 09:44:26 PST 2010
Am 17.02.10, 17:30 +0100 schrieb ecir hana:
> On Wed, Feb 17, 2010 at 7:17 AM, Bill Spitzak <spitzak at gmail.com> wrote:
>>
>>
>> ecir hana wrote:
>>>
>>> I have a picture in CMYK (SWOP ICC), that's "deviceA". I want to
>>> preview it on screen, *application* converts it to sRGB and sends this
>>> 3D data to Cairo. Then, Cairo converts it to the space of my monitor
>>> ("deviceB") and draws it.
>>>
>>> It looks ok, so I want to export PDF - *application* converts my
>>> picture to sRGB and Cairo converts it back to SWOP CMYK (because I
>>> print in US on coated paper).
>>>
>>> Is this what you said?
>>
>> Yes.
>>
>> If you really want to control the CMYK on the output device you have to use
>> a device-specific api.
>
> Yes, I really want to control the CMYK, such API is the topic of this thread.
>
> If I say CMYK(40, 30, 30, 100) I want CMYK(40, 30, 30, 100). I bet you
> understand what I'm talking about - it's the same as reading Quicktime
> and writing it back as Quicktime, as you wrote above - going from CMYK
> to sRGB and back to CMYK makes no sense.
>
> Again, the real question is, how do you supply CMYK image to Cairo and
The API is not (yet) existent. Perhaps:
typedef enum {
CAIRO_COLOR, /* no alpha is present */
CAIRO_COLOR_ALPHA_PREMULTIPLIED,
CAIRO_COLOR_ALPHA_NON_PREMULTIPLIED
} cairo_channel_layout_e;
/* create a ICC profile container */
cairo_profile_t * profile = cairo_profile_create(
cairo_profile_e CAIRO_ICC_PROFILE,
void * blob,
size_t blob_size );
/* Specify arbitrary, well defined colour data to cairo.
* Care is to be taken for the alpha channel.
* Alpha is specified after color.
*/
cairo_color_t * color = cairo_color_create(
cairo_profile_t * cmyk_profile,
float * native_channels,
cairo_channel_layout_e CAIRO_COLOR_ALPHA_NON_PREMULTIPLIED );
cairo_set_blending_color_space(
cairo_t * cr,
cairo_profile_t * well_behaved );
/* replace the cairo_set_source_rgb toy API
* cairo_set_source_rgb() can be handled as it would be sRGB with
* implicite colour space assigment.
*/
cairo_set_source_color(
cairo_t * cr,
cairo_color_t * color );
All _rgb and _rgba functions need complementing cairo_color_t versions.
As well the image input has to accept a assigned cairo_profile_t container
and cairo_channel_layout_e enum.
The profile and color references can be reused and afterward freed.
The above example requires changes to cairo's core:
* CMS hooks or linked in CMS
* cmyk is only possible with four or multi channel support
Adrian had suggested per colour space constructors for rgb, rgba
and later for cmyk and cmyka. I would be afraid that the channels count
requirements would grow in some years beyond the cmyka contructor and the
API would need to grow further.
If checking the colour creation can be a runtime thing as in my above
example, Cmyk and more channels can be added later on need.
> first, show it on the screen and second, export it to PDF with the
a) cairo knows how to use a hooked in CMS or uses a internal one - real
color API:
it will convert cairo_color_t to whatever is required or configured for
intermediate blending and after drawing to the required or
configured output backends colour space
b) only cairos PDF backend knows - circumvent cairo toy color API:
glueless
c) only cairos Xlib backend knows - circumvent cairo toy color API:
convert in advance to some RGB and configure the backend to know about
your delivered colour space
> same set of graphic operators?
a) - yes, straight forward
b) and c) - not really
To honour the threads name, spot colour could be made a property of
cairo_color_t with according setters and getters? But I do not have much
knowledge about that part.
kind regards
Kai-Uwe Behrmann
--
developing for colour management
www.behrmann.name + www.oyranos.org
More information about the cairo
mailing list