colorspace converters



Hi,

Would like to add a function to convert between colorspaces, probably
to gdk-pixbuf. 

At the moment GTK contains code in static functions to do RGB<->HSV
and RGB<->HLS. I need RGB<->HLS in another file, is the immediate need
for the public converter function. Anyhow, those three colorspace
converters would be what we'd initially support.

GdkPixbuf is already using the GdkColorspace enum, not sure whether we
want to use this same enum for the converter function.

Anyhow, as a generic API, best idea so far is:

void
gdk_colorspace_convert (gdouble *src_values,
                        GdkColorspace src_format,
                        gdouble *dest_values,
                        GdkColorspace dest_format);


Where the length and content of the gdouble arrays depends on the format.

Another option would be to have RGB always used as intermediate
format:

void 
gdk_rgb_to_colorspace (GdkColor *src,
                       gdouble *dest_values,
                       GdkColorspace dest_format);

void 
gdk_colorspace_to_rgb (gdouble *src_values,
                       GdkColorspace src_format,
                       GdkColor *dest);

That's easier to implement and maybe simpler to use, but probably
slower and loses precision/information.

Comments on best way to do this are welcome.

Havoc




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]