summaryrefslogtreecommitdiffstats
path: root/src/color-profile.cpp
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2010-01-14 08:13:09 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2010-01-14 08:13:09 +0000
commit7f7da4643d6909af5cd58b2f24846774e3af509b (patch)
tree1fec13b3616ecc90fb251bb9e643aefc43c80c43 /src/color-profile.cpp
parentSome additional docs (diff)
parentInitial cut of disabling floating windows on window managers with problems. (diff)
downloadinkscape-7f7da4643d6909af5cd58b2f24846774e3af509b.tar.gz
inkscape-7f7da4643d6909af5cd58b2f24846774e3af509b.zip
* Merge from trunk
* Update to new snapping API * Modify the join action slightly (bzr r8846.2.11)
Diffstat (limited to 'src/color-profile.cpp')
-rw-r--r--src/color-profile.cpp52
1 files changed, 50 insertions, 2 deletions
diff --git a/src/color-profile.cpp b/src/color-profile.cpp
index 4b1307316..310a37356 100644
--- a/src/color-profile.cpp
+++ b/src/color-profile.cpp
@@ -2,7 +2,7 @@
# include "config.h"
#endif
-//#define DEBUG_LCMS
+#define DEBUG_LCMS
#include <glib/gstdio.h>
#include <sys/fcntl.h>
@@ -23,6 +23,7 @@
#endif
#include "xml/repr.h"
+#include "color.h"
#include "color-profile.h"
#include "color-profile-fns.h"
#include "attributes.h"
@@ -50,7 +51,7 @@ static cmsHPROFILE colorprofile_get_proof_profile_handle();
#ifdef DEBUG_LCMS
extern guint update_in_progress;
-#define DEBUG_MESSAGE(key, ...) \
+#define DEBUG_MESSAGE_SCISLAC(key, ...) \
{\
Inkscape::Preferences *prefs = Inkscape::Preferences::get();\
bool dump = prefs->getBool(Glib::ustring("/options/scislac/") + #key);\
@@ -76,6 +77,13 @@ extern guint update_in_progress;
gtk_widget_show_all( dialog );\
}\
}
+
+
+#define DEBUG_MESSAGE(key, ...)\
+{\
+ g_message( __VA_ARGS__ );\
+}
+
#endif // DEBUG_LCMS
static SPObjectClass *cprof_parent_class;
@@ -91,6 +99,15 @@ cmsHPROFILE ColorProfile::getSRGBProfile() {
return _sRGBProf;
}
+cmsHPROFILE ColorProfile::_NullProf = 0;
+
+cmsHPROFILE ColorProfile::getNULLProfile() {
+ if ( !_NullProf ) {
+ _NullProf = cmsCreateNULLProfile();
+ }
+ return _NullProf;
+}
+
#endif // ENABLE_LCMS
/**
@@ -151,6 +168,7 @@ void ColorProfile::init( ColorProfile *cprof )
cprof->_profileSpace = icSigRgbData;
cprof->_transf = 0;
cprof->_revTransf = 0;
+ cprof->_gamutTransf = 0;
#endif // ENABLE_LCMS
}
@@ -204,6 +222,10 @@ void ColorProfile::_clearProfile()
cmsDeleteTransform( _revTransf );
_revTransf = 0;
}
+ if ( _gamutTransf ) {
+ cmsDeleteTransform( _gamutTransf );
+ _gamutTransf = 0;
+ }
if ( profHandle ) {
cmsCloseProfile( profHandle );
profHandle = 0;
@@ -508,6 +530,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>