diff options
| author | Felipe Corr??a da Silva Sanches <juca@members.fsf.org> | 2009-06-20 11:49:01 +0000 |
|---|---|---|
| committer | JucaBlues <JucaBlues@users.sourceforge.net> | 2009-06-20 11:49:01 +0000 |
| commit | 59c1c219f9b89e50bd9fa9acce9bed9860a281e7 (patch) | |
| tree | 4bf3bfd95e92122ee96aedea4a2d91d92d7a1732 /src/svg/svg-color.cpp | |
| parent | bool sp_svg_read_icc_color( gchar const *str, SVGICCColor* dest ); (diff) | |
| download | inkscape-59c1c219f9b89e50bd9fa9acce9bed9860a281e7.tar.gz inkscape-59c1c219f9b89e50bd9fa9acce9bed9860a281e7.zip | |
parsing and handling of icc-color in feFlood SVG Filters
TODO: implement interface to set icc-color to the flood-color parameter
(bzr r8050.1.4)
Diffstat (limited to 'src/svg/svg-color.cpp')
| -rw-r--r-- | src/svg/svg-color.cpp | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp index 743d2bbc8..fcfbbdbd8 100644 --- a/src/svg/svg-color.cpp +++ b/src/svg/svg-color.cpp @@ -36,6 +36,15 @@ #include "svg-color.h" #include "svg-icc-color.h" +#if ENABLE_LCMS +#include <lcms.h> +#include "color.h" +#include "color-profile.h" +#include "document.h" +#include "inkscape.h" +#include "profile-manager.h" +#endif // ENABLE_LCMS + using std::sprintf; struct SPSVGColor { @@ -454,6 +463,39 @@ sp_svg_create_color_hash() return colors; } +//helper function borrowed from src/widgets/sp-color-icc-selector.cpp: +void getThings( DWORD space, gchar const**& namers, gchar const**& tippies, guint const*& scalies ); + +void icc_color_to_sRGB(SVGICCColor* icc, guchar* r, guchar* g, guchar* b){ + guchar color_out[4]; + guchar color_in[4]; + if (icc){ +g_message("profile name: %s", icc->colorProfile.c_str()); + Inkscape::ColorProfile* prof = SP_ACTIVE_DOCUMENT->profileManager->find(icc->colorProfile.c_str()); + if ( prof ) { + cmsHTRANSFORM trans = prof->getTransfToSRGB8(); + if ( trans ) { + gchar const** names = 0; + gchar const** tips = 0; + guint const* scales = 0; + getThings( prof->getColorSpace(), names, tips, scales ); + + guint count = _cmsChannelsOf( prof->getColorSpace() ); + if (count>4) count=4; //do we need it? Should we allow an arbitrary number of color values? Or should we limit to a maximum? (max==4?) + for (guint i=0;i<count; i++){ + color_in[i] = (guchar) ((((gdouble)icc->colors[i])*256.0) * (gdouble)scales[i]); +g_message("input[%d]: %d",i, color_in[i]); + } + + cmsDoTransform( trans, color_in, color_out, 1 ); +g_message("transform to sRGB done"); + } + *r = color_out[0]; + *g = color_out[1]; + *b = color_out[2]; + } + } +} bool sp_svg_read_icc_color( gchar const *str, gchar const **end_ptr, SVGICCColor* dest ) { @@ -508,6 +550,7 @@ 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 { @@ -529,7 +572,7 @@ bool sp_svg_read_icc_color( gchar const *str, gchar const **end_ptr, SVGICCColor while ( g_ascii_isspace(*str) ) { str++; } - good &= *str == ')'; + good &= (*str == ')'); } } @@ -550,7 +593,7 @@ bool sp_svg_read_icc_color( gchar const *str, gchar const **end_ptr, SVGICCColor bool sp_svg_read_icc_color( gchar const *str, SVGICCColor* dest ) { - sp_svg_read_icc_color(str, NULL, dest); + return sp_svg_read_icc_color(str, NULL, dest); } /* |
