diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2007-09-25 02:54:32 +0000 |
|---|---|---|
| committer | joncruz <joncruz@users.sourceforge.net> | 2007-09-25 02:54:32 +0000 |
| commit | ba9fad5667d32413d00b2b628c305bdb5bd129de (patch) | |
| tree | aa0bcfd18d50709f953e7c0d023b2ed3eb0e016d /src/color.cpp | |
| parent | Fixed const (diff) | |
| download | inkscape-ba9fad5667d32413d00b2b628c305bdb5bd129de.tar.gz inkscape-ba9fad5667d32413d00b2b628c305bdb5bd129de.zip | |
Initial support for icc color selection including CMYK
(bzr r3794)
Diffstat (limited to 'src/color.cpp')
| -rw-r--r-- | src/color.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/color.cpp b/src/color.cpp index 8dc4c8657..6b2281f26 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -17,6 +17,12 @@ #include <math.h> #include "color.h" #include "svg/svg-icc-color.h" +#include "svg/svg-color.h" + +#include "svg/css-ostringstream.h" + +using Inkscape::CSSOStringStream; +using std::vector; static bool profileMatches( SVGICCColor const* first, SVGICCColor const* second ); @@ -96,8 +102,7 @@ bool SPColor::isClose( SPColor const& other, float epsilon ) const && (fabs((v.c[1]) - (other.v.c[1])) < epsilon) && (fabs((v.c[2]) - (other.v.c[2])) < epsilon); - // TODO uncomment once we start using that profile. Will be RSN - //match &= profileMatches( icc, other.icc ); + match &= profileMatches( icc, other.icc ); return match; } @@ -176,6 +181,31 @@ guint32 SPColor::toRGBA32( gdouble alpha ) const return toRGBA32( static_cast<gint>(SP_COLOR_F_TO_U(alpha)) ); } +std::string SPColor::toString() const +{ + CSSOStringStream css; + + std::string result; + char tmp[64] = {0}; + + sp_svg_write_color(tmp, sizeof(tmp), toRGBA32(0x0ff)); + css << tmp; + + if ( !css.str().empty() ) { + css << " "; + } + css << "icc-color(" << icc->colorProfile; + for (vector<double>::const_iterator i(icc->colors.begin()), + iEnd(icc->colors.end()); + i != iEnd; ++i) { + css << ", " << *i; + } + css << ')'; + + return css.str(); +} + + /** * Fill rgb float array with values from SPColor. * \pre color != NULL && rgb != NULL && rgb[0-2] is meaningful |
