Code

Initial draft of the out-of-gamut check. It is not working yet. I will continue work...
authorJucaBlues <JucaBlues@users.sourceforge.net>
Fri, 14 Aug 2009 06:34:14 +0000 (06:34 +0000)
committerJucaBlues <JucaBlues@users.sourceforge.net>
Fri, 14 Aug 2009 06:34:14 +0000 (06:34 +0000)
src/widgets/sp-color-notebook.cpp

index 44de40115796f95124f17ac78dd87deb9b001234..5eb44c2cb3d8b4ab1805d38f42db37d9b250a91c 100644 (file)
 #include "sp-color-scales.h"
 #include "sp-color-icc-selector.h"
 #include "sp-color-wheel-selector.h"
+#include "svg/svg-icc-color.h"
+#include "../inkscape.h"
+#include "../document.h"
+#include "../profile-manager.h"
 
 struct SPColorNotebookTracker {
        const gchar* name;
@@ -504,6 +508,35 @@ void ColorNotebook::_updateRgbaEntry( const SPColor& color, gfloat alpha )
     /* update color management icon*/
     gtk_widget_set_sensitive (_box_colormanaged, color.icc != NULL);
 
+    /* update out-of-gamut icon */
+    gtk_widget_set_sensitive (_box_outofgamut, false);
+    if (color.icc){
+        BYTE outofgamut;
+        cmsSetAlarmCodes(255, 255, 255);
+        static cmsHPROFILE hNULL = cmsCreateNULLProfile();
+        static cmsHPROFILE hsRGB = cmsCreate_sRGBProfile();
+
+        cmsHTRANSFORM trans;
+        Inkscape::ColorProfile* target_profile = SP_ACTIVE_DOCUMENT->profileManager->find(color.icc->colorProfile.c_str());
+        if ( target_profile ) {
+            trans = cmsCreateProofingTransform(hsRGB, TYPE_RGB_DBL, 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};
+
+                cmsDoTransform(trans, &check_color, &outofgamut, 1);
+                gtk_widget_set_sensitive (_box_outofgamut, outofgamut == 255);
+            }
+        }
+    }
+
+
     if ( !_updatingrgba )
     {
         gchar s[32];