[cairo] RGB to CIELab transformation

Andrea Canciani ranma42 at gmail.com
Fri Jan 20 02:55:17 PST 2012

On Fri, Jan 20, 2012 at 8:01 AM, Necko Nedjoni <opustenom at hotmail.com> wrote:
> As a part of a larger project, I was recently assigned to investigate the
> possibility of colorings
> within our visualizations.
> Namely, I came across the CIELab color space, which seems to be preferable
> choice in the related
> literature. The initial readings suggest that a conversion from
> device-depended RGB is possible, and
> I wonder how this could be achieved with cairo.

Converting a color in a device-dependent colorspace to a color in a
device-independent colorspace is not actually a meaningful operation.
You might assume that the RGB components are in a specific
device-independent colorspace (given current cairo behavior I would
suggest a linear rgb colorspace with the same primaries as sRGB or
sRGB itself).
You could then use normal color conversion routines, like those
provided by LittleCMS.

> The function I use currently (sample):
> cairo_set_source_rgb(cr, 1, 0.0, 1.0);
> Perhaps someone could share the conversion code.

I should have something that does it in my colorspaces branches.
I will try to extract it to a standalone snippet.


> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo

More information about the cairo mailing list