[Digikam-devel] extragear/graphics/digikam

Gilles Caulier caulier.gilles at free.fr
Fri Dec 1 13:26:16 GMT 2006


SVN commit 609570 by cgilles:

digikam from trunk: fix in color management :

- To be abble to use CM is no input color profile is set in CM setup. In this case, we use built-in sRGB color profile from lcms. This will be enough for 0.9.0. Paco, perhaps we must provide an option into CM setup to choose the right mode between "built-in" or "from input icc file". Krita run like this.

- By default, using the CM plugin with RAW file instead Color correction dialog. 
Paco, in fact, I think it's a a non-sence to use ColorCorrection with RAW file. A common option in CM setup is certainly better than 2 separate options : if user choose "Ask when open an image in Image editor" option, well digikam will start CM plugin if the image is a RAW file, or if its JPEG/TIFF/PNG it will start Color correction dialog.

- Fix Color Managed View (for Monitor) color management. In fact this mode do not work properlly before this commit, because the input profile is the camera profile. This is wrong with managed view : the input profile must be the workspace profile. This is why some users have reported a wrong color rendering if this option is enable.

Paco, please let's me here your comments if necessary. Please update your TODO accordinly for future actions later 0.9.0 final release.

CCMAIL: digikam-devel at kde.org, fj.cruz at supercable.es
CCBUGS: 131947

 M  +4 -1      libs/dimg/dimg.cpp  
 M  +27 -18    libs/dimg/filters/icctransform.cpp  
 M  +3 -0      libs/dimg/filters/icctransform.h  
 M  +24 -11    utilities/imageeditor/canvas/dimginterface.cpp  
 M  +1 -1      utilities/imageeditor/editor/imageiface.cpp  


--- trunk/extragear/graphics/digikam/libs/dimg/dimg.cpp #609569:609570
@@ -1202,7 +1202,10 @@
     // Without embedded profile
     if (img.getICCProfil().isNull())
     {
-        monitorICCtrans->apply( img );
+        QByteArray fakeProfile; 
+        monitorICCtrans->apply(img, fakeProfile, monitorICCtrans->getRenderingIntent(),
+                               monitorICCtrans->getUseBPC(), false, 
+                               monitorICCtrans->inputProfile().isNull()); 
     }
     // With embedded profile.
     else
--- trunk/extragear/graphics/digikam/libs/dimg/filters/icctransform.cpp #609569:609570
@@ -53,14 +53,12 @@
 
     IccTransformPriv()
     {
-        has_output_profile   = false;
         has_embedded_profile = false;
         do_proof_profile     = false;
     }
 
     bool       do_proof_profile;
     bool       has_embedded_profile; 
-    bool       has_output_profile; 
 
     QByteArray embedded_profile;
     QByteArray input_profile;
@@ -79,9 +77,14 @@
     delete d;
 }
 
+bool IccTransform::hasInputProfile()
+{
+    return !(d->input_profile.isEmpty());
+}
+
 bool IccTransform::hasOutputProfile()
 {
-    return d->has_output_profile;
+    return !(d->output_profile.isEmpty());
 }
 
 QByteArray IccTransform::embeddedProfile() const
@@ -140,11 +143,18 @@
     return config->readNumEntry("RenderingIntent", 0);
 }
 
+bool IccTransform::getUseBPC()
+{
+    KConfig* config = kapp->config();
+    config->setGroup("Color Management");
+    return config->readBoolEntry("BPCAlgorithm", false);
+}
+
 QByteArray IccTransform::loadICCProfilFile(const QString& filePath)
 {
     QFile file(filePath);
     if ( !file.open(IO_ReadOnly) )
-        return false;
+        return QByteArray();
 
     QByteArray data(file.size());
     QDataStream stream( &file );
@@ -155,40 +165,39 @@
 
 void IccTransform::setProfiles(const QString& input_profile, const QString& output_profile)
 {
-    d->input_profile      = loadICCProfilFile(input_profile);
-    d->output_profile     = loadICCProfilFile(output_profile);
-    d->has_output_profile = true;
+    d->input_profile  = loadICCProfilFile(input_profile);
+    d->output_profile = loadICCProfilFile(output_profile);
 }
 
 void IccTransform::setProfiles(const QString& input_profile, const QString& output_profile, 
                                const QString& proof_profile)
 {
-    d->input_profile      = loadICCProfilFile(input_profile);
-    d->output_profile     = loadICCProfilFile(output_profile);
-    d->proof_profile      = loadICCProfilFile(proof_profile);
-    d->has_output_profile = true;
+    d->input_profile  = loadICCProfilFile(input_profile);
+    d->output_profile = loadICCProfilFile(output_profile);
+    d->proof_profile  = loadICCProfilFile(proof_profile);
 }
 
 void IccTransform::setProfiles(const QString& output_profile)
 {
-    d->output_profile     = loadICCProfilFile(output_profile);
-    d->has_output_profile = true;
+    d->output_profile = loadICCProfilFile(output_profile);
 }
 
 void IccTransform::setProfiles(const QString& output_profile, const QString& proof_profile, bool forProof)
 {
     if (forProof)
     {
-        d->output_profile     = loadICCProfilFile(output_profile);
-        d->proof_profile      = loadICCProfilFile(proof_profile);
-        d->has_output_profile = true;
+        d->output_profile = loadICCProfilFile(output_profile);
+        d->proof_profile  = loadICCProfilFile(proof_profile);
     }
 }
 
 QString IccTransform::getEmbeddedProfileDescriptor()
 {
-    if (d->embedded_profile.isEmpty()) return QString();
-    cmsHPROFILE tmpProfile = cmsOpenProfileFromMem(d->embedded_profile.data(), (DWORD)d->embedded_profile.size());
+    if (d->embedded_profile.isEmpty())
+        return QString();
+
+    cmsHPROFILE tmpProfile = cmsOpenProfileFromMem(d->embedded_profile.data(),
+                                                   (DWORD)d->embedded_profile.size());
     QString embeddedProfileDescriptor = QString(cmsTakeProductDesc(tmpProfile));
     cmsCloseProfile(tmpProfile);
     return embeddedProfileDescriptor;
--- trunk/extragear/graphics/digikam/libs/dimg/filters/icctransform.h #609569:609570
@@ -50,6 +50,9 @@
     void getTransformType(bool do_proof_profile);
     void getEmbeddedProfile(const DImg& image);
     int  getRenderingIntent();
+    bool getUseBPC();
+
+    bool hasInputProfile();
     bool hasOutputProfile();
 
     QByteArray embeddedProfile() const;
--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/dimginterface.cpp #609569:609570
@@ -221,7 +221,7 @@
 void DImgInterface::setICCSettings(ICCSettingsContainer *cmSettings)
 {
     d->cmSettings = cmSettings;
-    d->monitorICCtrans.setProfiles(d->cmSettings->inputSetting, d->cmSettings->monitorSetting);
+    d->monitorICCtrans.setProfiles(d->cmSettings->workspaceSetting, d->cmSettings->monitorSetting);
 }
 
 void DImgInterface::slotImageLoaded(const LoadingDescription &loadingDescription, const DImg& img)
@@ -263,11 +263,11 @@
                 // With RAW files, we load the Color Management image plugin.
                 emit signalColorManagementTool();        
             }
-            else if (QFile::exists(d->cmSettings->workspaceSetting) && 
-                     QFile::exists(d->cmSettings->inputSetting))
+            else if (QFile::exists(d->cmSettings->workspaceSetting))
             {
                 IccTransform trans;
-    
+                QByteArray fakeProfile;
+
                 // First possibility: image has no embedded profile
                 if(d->image.getICCProfil().isNull())
                 {
@@ -275,9 +275,14 @@
                     if (d->cmSettings->askOrApplySetting)
                     {
                         if (d->parent) d->parent->setCursor( KCursor::waitCursor() );
-                        trans.setProfiles( QFile::encodeName(d->cmSettings->inputSetting),
-                                           QFile::encodeName(d->cmSettings->workspaceSetting));
-                        trans.apply( d->image );
+                        trans.setProfiles(QFile::encodeName(d->cmSettings->inputSetting),
+                                          QFile::encodeName(d->cmSettings->workspaceSetting));
+
+                        // NOTE: If Input color profile do not exist, using built-in sRGB intead.
+                        trans.apply(d->image, fakeProfile, d->cmSettings->renderingSetting,
+                                    d->cmSettings->BPCSetting, false, 
+                                    QFile::exists(d->cmSettings->inputSetting)); 
+
                         d->image.getICCProfilFromFile(QFile::encodeName(d->cmSettings->workspaceSetting));
                         if (d->parent) d->parent->unsetCursor();
                     }
@@ -295,7 +300,12 @@
                         {
                             case QDialog::Accepted:
                                 if (d->parent) d->parent->setCursor( KCursor::waitCursor() );
-                                trans.apply( d->image );
+        
+                                // NOTE: If Input color profile do not exist, using built-in sRGB intead.
+                                trans.apply(d->image, fakeProfile, d->cmSettings->renderingSetting,
+                                            d->cmSettings->BPCSetting, false, 
+                                            QFile::exists(d->cmSettings->inputSetting)); 
+
                                 d->image.getICCProfilFromFile(QFile::encodeName(d->cmSettings->workspaceSetting));
                                 if (d->parent) d->parent->unsetCursor();
                             break;
@@ -318,7 +328,8 @@
                     {
                         if (d->parent) d->parent->setCursor( KCursor::waitCursor() );
                         trans.setProfiles(QFile::encodeName(d->cmSettings->workspaceSetting));
-                        trans.apply( d->image );
+                        trans.apply(d->image, fakeProfile, d->cmSettings->renderingSetting,
+                                    d->cmSettings->BPCSetting, false, false); 
                         if (d->parent) d->parent->unsetCursor();
                     }
                     else
@@ -341,7 +352,8 @@
                             {
                                 case QDialog::Accepted:
                                     if (d->parent) d->parent->setCursor( KCursor::waitCursor() );
-                                    trans.apply( d->image );
+                                    trans.apply(d->image, fakeProfile, d->cmSettings->renderingSetting,
+                                                d->cmSettings->BPCSetting, false, false); 
                                     d->image.getICCProfilFromFile(QFile::encodeName(d->cmSettings->workspaceSetting));
                                     if (d->parent) d->parent->unsetCursor();
                                 break;
@@ -358,7 +370,8 @@
             }
             else
             {
-                QString message = i18n("ICC profiles path seems to be invalid. "
+                QString message = i18n("Cannot find ICC color-space profile file."
+                                       "ICC profiles path seems to be invalid. "
                                        "No color transform will be done. "
                                        "Please, check the color management "
                                        "configuration it in digiKam setup.");
--- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/imageiface.cpp #609569:609570
@@ -349,7 +349,7 @@
         QPixmap      pixImage;
         IccTransform monitorICCtrans;
         ICCSettingsContainer* iccSettings = DImgInterface::instance()->getICCSettings();
-        monitorICCtrans.setProfiles(iccSettings->inputSetting, iccSettings->monitorSetting);
+        monitorICCtrans.setProfiles(iccSettings->workspaceSetting, iccSettings->monitorSetting);
 
         if (iccSettings)
         {



More information about the Digikam-devel mailing list