From: Felipe C. da S. Sanches Date: Mon, 7 Dec 2009 03:19:44 +0000 (-0200) Subject: This commit hooks device-cmyk handling to color pickers. Now we have basic initial... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8807c556b2f4c29ee400cea692633b6cda44c47a;p=inkscape.git This commit hooks device-cmyk handling to color pickers. Now we have basic initial support for SVG Color 1.2 uncalibrated device colors: http://www.w3.org/TR/2009/WD-SVGColor12-20091001/#device --- diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index c8782051b..2afcd6109 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -44,6 +44,7 @@ #include "desktop-style.h" #include "svg/svg-icc-color.h" +#include "svg/svg-device-color.h" #include "box3d-side.h" /** @@ -432,6 +433,8 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill paint_res->set = TRUE; SVGICCColor* iccColor = 0; + SVGDeviceColor* devColor = 0; + bool iccSeen = false; gfloat c[4]; c[0] = c[1] = c[2] = c[3] = 0.0; @@ -529,6 +532,23 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill c[1] += d[1]; c[2] += d[2]; c[3] += SP_SCALE24_TO_FLOAT (isfill? style->fill_opacity.value : style->stroke_opacity.value); + + // average device color + unsigned int it; + if (i==objects /*if this is the first object in the GList*/ + && paint->value.color.device){ + devColor = new SVGDeviceColor(*paint->value.color.device); + for (it=0; it < paint->value.color.device->colors.size(); it++){ + devColor->colors[it] = 0; + } + } + + if (devColor && paint->value.color.device && paint->value.color.device->type == devColor->type){ + for (it=0; it < paint->value.color.device->colors.size(); it++){ + devColor->colors[it] += paint->value.color.device->colors[it]; + } + } + num ++; } @@ -568,6 +588,14 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill paint_res->value.color.icc = tmp; } + // divide and store the device-color + if (devColor){ + for (unsigned int it=0; it < devColor->colors.size(); it++){ + devColor->colors[it] /= num; + } + paint_res->value.color.device = devColor; + } + if (num > 1) { if (same_color) return QUERY_STYLE_MULTIPLE_SAME; diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp index 0eaa4431a..46779311e 100644 --- a/src/svg/svg-color.cpp +++ b/src/svg/svg-color.cpp @@ -559,7 +559,6 @@ bool sp_svg_read_icc_color( gchar const *str, gchar const **end_ptr, SVGICCColor if ( !errno ) { if ( dest ) { dest->colors.push_back( dbl ); -g_message("color: %f", dbl); } str = endPtr; } else { @@ -662,7 +661,6 @@ bool sp_svg_read_device_color( gchar const *str, gchar const **end_ptr, SVGDevic if ( !errno ) { if ( dest ) { dest->colors.push_back( dbl ); -g_message("color: %f", dbl); } str = endPtr; } else { diff --git a/src/widgets/sp-color-scales.cpp b/src/widgets/sp-color-scales.cpp index a09a3a2ed..e41b81e5c 100644 --- a/src/widgets/sp-color-scales.cpp +++ b/src/widgets/sp-color-scales.cpp @@ -11,6 +11,7 @@ #include "../dialogs/dialog-events.h" #include "sp-color-scales.h" #include "svg/svg-icc-color.h" +#include "svg/svg-device-color.h" #define CSC_CHANNEL_R (1 << 0) #define CSC_CHANNEL_G (1 << 1) @@ -231,6 +232,12 @@ void ColorScales::_recalcColor( gboolean changing ) case SP_COLOR_SCALES_MODE_CMYK: { _getCmykaFloatv( c ); + color.device = new SVGDeviceColor(); + color.device->type=DEVICE_CMYK; + color.device->colors.clear(); + for (int i=0;i<4;i++){ + color.device->colors.push_back(c[i]); + } float rgb[3]; sp_color_cmyk_to_rgb_floatv( rgb, c[0], c[1], c[2], c[3] ); @@ -475,11 +482,20 @@ void ColorScales::setMode(SPColorScalesMode mode) gtk_widget_show (_s[4]); gtk_widget_show (_b[4]); _updating = TRUE; - sp_color_rgb_to_cmyk_floatv (c, rgba[0], rgba[1], rgba[2]); - setScaled( _a[0], c[0] ); - setScaled( _a[1], c[1] ); - setScaled( _a[2], c[2] ); - setScaled( _a[3], c[3] ); + + if (_color.device && _color.device->type == DEVICE_CMYK){ + setScaled( _a[0], _color.device->colors[0] ); + setScaled( _a[1], _color.device->colors[1] ); + setScaled( _a[2], _color.device->colors[2] ); + setScaled( _a[3], _color.device->colors[3] ); + } else { + //If we still dont have a device-color, convert from rbga + sp_color_rgb_to_cmyk_floatv (c, rgba[0], rgba[1], rgba[2]); + setScaled( _a[0], c[0] ); + setScaled( _a[1], c[1] ); + setScaled( _a[2], c[2] ); + setScaled( _a[3], c[3] ); + } setScaled( _a[4], rgba[3] ); _updating = FALSE; _updateSliders( CSC_CHANNELS_ALL );