diff options
| author | Felipe Corr??a da Silva Sanches <juca@members.fsf.org> | 2009-08-15 05:59:15 +0000 |
|---|---|---|
| committer | JucaBlues <JucaBlues@users.sourceforge.net> | 2009-08-15 05:59:15 +0000 |
| commit | db87667df0c9068024267a4de6137487904048f2 (patch) | |
| tree | f9e77a6825898cc5ce2f30ee79ccf37c3414d326 /src/color-profile.cpp | |
| parent | refactoring ICC out-of-gamut check (diff) | |
| download | inkscape-db87667df0c9068024267a4de6137487904048f2.tar.gz inkscape-db87667df0c9068024267a4de6137487904048f2.zip | |
now gamut check works!
(bzr r8050.1.14)
Diffstat (limited to 'src/color-profile.cpp')
| -rw-r--r-- | src/color-profile.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/color-profile.cpp b/src/color-profile.cpp index de9dc6959..5f2364449 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -13,6 +13,7 @@ #include <cstring> #include <string> #include "xml/repr.h" +#include "color.h" #include "color-profile.h" #include "color-profile-fns.h" #include "attributes.h" @@ -84,6 +85,15 @@ cmsHPROFILE ColorProfile::getSRGBProfile() { return _sRGBProf; } +cmsHPROFILE ColorProfile::_NullProf = 0; + +cmsHPROFILE ColorProfile::getNULLProfile() { + if ( !_NullProf ) { + _NullProf = cmsCreateNULLProfile(); + } + return _NullProf; +} + #endif // ENABLE_LCMS /** @@ -144,6 +154,7 @@ void ColorProfile::init( ColorProfile *cprof ) cprof->_profileSpace = icSigRgbData; cprof->_transf = 0; cprof->_revTransf = 0; + cprof->_gamutTransf = 0; #endif // ENABLE_LCMS } @@ -197,6 +208,10 @@ void ColorProfile::_clearProfile() cmsDeleteTransform( _revTransf ); _revTransf = 0; } + if ( _gamutTransf ) { + cmsDeleteTransform( _gamutTransf ); + _gamutTransf = 0; + } if ( profHandle ) { cmsCloseProfile( profHandle ); profHandle = 0; @@ -496,6 +511,32 @@ cmsHTRANSFORM ColorProfile::getTransfFromSRGB8() return _revTransf; } +cmsHTRANSFORM ColorProfile::getTransfGamutCheck() +{ + if ( !_gamutTransf ) { + _gamutTransf = cmsCreateProofingTransform(getSRGBProfile(), TYPE_RGBA_8, getNULLProfile(), TYPE_GRAY_8, profHandle, INTENT_RELATIVE_COLORIMETRIC, INTENT_RELATIVE_COLORIMETRIC, (cmsFLAGS_GAMUTCHECK|cmsFLAGS_SOFTPROOFING)); + } + return _gamutTransf; +} + +bool ColorProfile::GamutCheck(SPColor color){ + BYTE outofgamut = 0; + + guint32 val = color.toRGBA32(0); + guchar check_color[4] = { + SP_RGBA32_R_U(val), + SP_RGBA32_G_U(val), + SP_RGBA32_B_U(val), + 255}; + + int alarm_r, alarm_g, alarm_b; + cmsGetAlarmCodes(&alarm_r, &alarm_g, &alarm_b); + cmsSetAlarmCodes(255, 255, 255); + cmsDoTransform(ColorProfile::getTransfGamutCheck(), &check_color, &outofgamut, 1); + cmsSetAlarmCodes(alarm_r, alarm_g, alarm_b); + return (outofgamut == 255); +} + #include <io/sys.h> |
