[Digikam-devel] extragear/graphics/digikam

Gilles Caulier caulier.gilles at free.fr
Wed May 10 13:08:29 BST 2006


SVN commit 539337 by cgilles:

digikam from trunk : 

- DImg API : new method to store an ICC profile from memory to a ICC file.
- Fix method name to set/get to/from memory to/from file. 
- Forget to close profile file at end.

Paco, this is the famous way to extract an embedded ICC profil into an image and to store it into a file. I remember that we have already discuted about this subject in the past when you have written your Color Management image plugin...

CCMAIL: digikam-devel at kde.org, francisco.jct at gmail.com


 M  +15 -1     libs/dimg/dimg.cpp  
 M  +2 -1      libs/dimg/dimg.h  
 M  +2 -2      utilities/imageeditor/canvas/dimginterface.cpp  


--- trunk/extragear/graphics/digikam/libs/dimg/dimg.cpp #539336:539337
@@ -568,7 +568,7 @@
     return m_priv->isReadOnly;
 }
 
-bool DImg::setICCProfilFromFile(const QString& filePath)
+bool DImg::getICCProfilFromFile(const QString& filePath)
 {
     QFile file(filePath);
     if ( !file.open(IO_ReadOnly) ) 
@@ -578,9 +578,23 @@
     QDataStream stream( &file );
     stream.readRawBytes(data.data(), data.size());
     setICCProfil(data);
+    file.close();
     return true;
 }
 
+bool DImg::setICCProfilToFile(const QString& filePath)
+{
+    QFile file(filePath);
+    if ( !file.open(IO_WriteOnly) ) 
+        return false;
+    
+    QByteArray data(getICCProfil());
+    QDataStream stream( &file );
+    stream.writeRawBytes(data.data(), data.size());
+    file.close();
+    return true;
+}
+
 void DImg::setICCProfil(const QByteArray& profile)
 {
     m_priv->ICCProfil = profile;
--- trunk/extragear/graphics/digikam/libs/dimg/dimg.h #539336:539337
@@ -209,7 +209,8 @@
     QByteArray getIptc() const;
     QByteArray metadata(METADATA key) const;
 
-    bool       setICCProfilFromFile(const QString& filePath);
+    bool       getICCProfilFromFile(const QString& filePath);
+    bool       setICCProfilToFile(const QString& filePath);
     void       setICCProfil(const QByteArray& profile);
     QByteArray getICCProfil() const;
 
--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/dimginterface.cpp #539336:539337
@@ -234,7 +234,7 @@
                     trans.setProfiles( QFile::encodeName(d->cmSettings->inputSetting),
                                        QFile::encodeName(d->cmSettings->workspaceSetting));
                     trans.apply( d->image );
-                    d->image.setICCProfilFromFile(QFile::encodeName(d->cmSettings->inputSetting));
+                    d->image.getICCProfilFromFile(QFile::encodeName(d->cmSettings->inputSetting));
                 }
                 else
                 {
@@ -255,7 +255,7 @@
                         trans.setProfiles( QFile::encodeName(d->cmSettings->inputSetting),
                                            QFile::encodeName(d->cmSettings->workspaceSetting));
                         trans.apply( d->image );
-                        d->image.setICCProfilFromFile(QFile::encodeName(d->cmSettings->inputSetting));
+                        d->image.getICCProfilFromFile(QFile::encodeName(d->cmSettings->inputSetting));
                     }
                 }
             }



More information about the Digikam-devel mailing list