summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e1c7eb8)
raw | patch | inline | side by side (parent: e1c7eb8)
author | JucaBlues <JucaBlues@users.sourceforge.net> | |
Sat, 15 Aug 2009 05:59:15 +0000 (05:59 +0000) | ||
committer | JucaBlues <JucaBlues@users.sourceforge.net> | |
Sat, 15 Aug 2009 05:59:15 +0000 (05:59 +0000) |
src/color-profile.cpp | patch | blob | history | |
src/color-profile.h | patch | blob | history | |
src/widgets/sp-color-notebook.cpp | patch | blob | history |
diff --git a/src/color-profile.cpp b/src/color-profile.cpp
index de9dc6959cdff340ee30404f5a6e15eb6082b1d8..5f236444975d7bdc2bc5e12457f35cef7c480df4 100644 (file)
--- a/src/color-profile.cpp
+++ b/src/color-profile.cpp
#include <cstring>
#include <string>
#include "xml/repr.h"
+#include "color.h"
#include "color-profile.h"
#include "color-profile-fns.h"
#include "attributes.h"
return _sRGBProf;
}
+cmsHPROFILE ColorProfile::_NullProf = 0;
+
+cmsHPROFILE ColorProfile::getNULLProfile() {
+ if ( !_NullProf ) {
+ _NullProf = cmsCreateNULLProfile();
+ }
+ return _NullProf;
+}
+
#endif // ENABLE_LCMS
/**
cprof->_profileSpace = icSigRgbData;
cprof->_transf = 0;
cprof->_revTransf = 0;
+ cprof->_gamutTransf = 0;
#endif // ENABLE_LCMS
}
cmsDeleteTransform( _revTransf );
_revTransf = 0;
}
+ if ( _gamutTransf ) {
+ cmsDeleteTransform( _gamutTransf );
+ _gamutTransf = 0;
+ }
if ( profHandle ) {
cmsCloseProfile( profHandle );
profHandle = 0;
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>
diff --git a/src/color-profile.h b/src/color-profile.h
index 2e57e7ef0221b3b813b00dca270d4df2dbabf84a..40d0d769871f89e96974493f7662ab156767695a 100644 (file)
--- a/src/color-profile.h
+++ b/src/color-profile.h
static std::list<Glib::ustring> getProfileDirs();
#if ENABLE_LCMS
static cmsHPROFILE getSRGBProfile();
+ static cmsHPROFILE getNULLProfile();
icColorSpaceSignature getColorSpace() const {return _profileSpace;}
icProfileClassSignature getProfileClass() const {return _profileClass;}
cmsHTRANSFORM getTransfToSRGB8();
cmsHTRANSFORM getTransfFromSRGB8();
+ cmsHTRANSFORM getTransfGamutCheck();
+ bool GamutCheck(SPColor color);
+
#endif // ENABLE_LCMS
gchar* href;
void _clearProfile();
static cmsHPROFILE _sRGBProf;
+ static cmsHPROFILE _NullProf;
icProfileClassSignature _profileClass;
icColorSpaceSignature _profileSpace;
cmsHTRANSFORM _transf;
cmsHTRANSFORM _revTransf;
+ cmsHTRANSFORM _gamutTransf;
#endif // ENABLE_LCMS
};
index 52c78ba42af754871279493b9a8a6c034e8b6434..04a35e4ad8019efd5a5e2dc39aab1fdc089a8b09 100644 (file)
/* update out-of-gamut icon */
gtk_widget_set_sensitive (_box_outofgamut, false);
if (color.icc){
- BYTE outofgamut = 0;
- static cmsHPROFILE hNULL = cmsCreateNULLProfile();
- static cmsHPROFILE hsRGB = cmsCreate_sRGBProfile();
-
Inkscape::ColorProfile* target_profile = SP_ACTIVE_DOCUMENT->profileManager->find(color.icc->colorProfile.c_str());
- if ( target_profile ) {
- cmsHTRANSFORM trans = cmsCreateProofingTransform(hsRGB, TYPE_RGBA_8, hNULL, TYPE_GRAY_8, target_profile->profHandle,
- INTENT_RELATIVE_COLORIMETRIC, INTENT_RELATIVE_COLORIMETRIC, (cmsFLAGS_GAMUTCHECK|cmsFLAGS_SOFTPROOFING));
-
- if ( trans ) {
- 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(trans, &check_color, &outofgamut, 1);
- cmsSetAlarmCodes(alarm_r, alarm_g, alarm_b);
- gtk_widget_set_sensitive (_box_outofgamut, outofgamut == 255);
- }
- }
+ if ( target_profile )
+ gtk_widget_set_sensitive (_box_outofgamut, target_profile->GamutCheck(color));
}