[Digikam-devel] [Bug 146464] lighttable does not deal with colour management

Marcel Wiesweg marcel.wiesweg at gmx.de
Thu Jun 7 15:29:49 BST 2007


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=146464         




------- Additional Comments From marcel.wiesweg gmx de  2007-06-07 16:29 -------
SVN commit 672556 by mwiesweg:

Apply patch from Jakob Oestergaard to reflect 8/16 bit loading
in the cache key, needed to distinguish between lighttable, histogram
and image editor loading.

Adapt equalsOrBetterThan to only accept changes in the halfSizeColorImage field.
Adapt possibleCacheKeys.
Move constructors from .h to .cpp
Change some comments.

CCBUG: 146464


 M  +67 -19    loadingdescription.cpp  
 M  +14 -18    loadingdescription.h  
 M  +1 -0      previewloadthread.cpp  


--- branches/extragear/kde3/graphics/digikam/libs/threadimageio/loadingdescription.cpp #672555:672556
 @ -28,31 +28,70  @
 namespace Digikam
 {
 
+bool LoadingDescription::PreviewParameters::operator==(const PreviewParameters &other) const
+{
+    return isPreview  == other.isPreview
+            && size       == other.size
+            && exifRotate == other.exifRotate;
+}
+
+LoadingDescription::LoadingDescription(const QString &filePath)
+    : filePath(filePath)
+{
+    rawDecodingSettings = KDcrawIface::RawDecodingSettings();
+}
+
+LoadingDescription::LoadingDescription(const QString &filePath, KDcrawIface::RawDecodingSettings settings)
+    : filePath(filePath), rawDecodingSettings(settings)
+{
+}
+
+LoadingDescription::LoadingDescription(const QString &filePath, int size, bool exifRotate)
+    : filePath(filePath)
+{
+    rawDecodingSettings = KDcrawIface::RawDecodingSettings();
+    previewParameters.isPreview  = false;
+    previewParameters.size       = size;
+    previewParameters.exifRotate = exifRotate;
+}
+
 QString LoadingDescription::cacheKey() const
 {
     // Here we have the knowledge which LoadingDescriptions / RawFileDecodingSettings
     // must be cached separately.
-    // When the Raw loading settings are changed in setup, the cache is cleaned,
-    // so we do not need to store check for every option here.
+    // Current assumption:
+    // Eight-bit images are needed for LightTable, and if 16-bit is enabled,
+    // 16-bit half size images for the histogram sidebar,
+    // and 16-bit full size images for the image editor.
+    // Use previewParameters.size, not isPreview - if it is 0, full loading is used.
+
+    QString suffix = rawDecodingSettings.sixteenBitsImage ? "-16" : "-8";
+
     if (rawDecodingSettings.halfSizeColorImage)
-        return filePath + "-halfSizeColorImage";
+        return filePath + suffix + "-halfSizeColorImage";
     else if (previewParameters.size)
-        return filePath + "-previewImage";
+        return filePath + suffix + "-previewImage";
     else
-        return filePath;
+        return filePath + suffix;
 }
 
 QStringList LoadingDescription::lookupCacheKeys() const
 {
     // Build a hierarchy which cache entries may be used for this LoadingDescription.
-    // Typically, the first is the best, but an actual loading operation will use a faster
-    // way and will effectively add the last entry of the list to the cache
+    // Typically, the first is the best, but an actual loading operation may use a
+    // lower-quality loading and will effectively only add the last entry of the
+    // list to the cache, although it can accept the first if already available.
+    // Sixteen-bit images cannot be used used instead of eight-bit ones because
+    // color management is needed to display them.
+
+    QString suffix = rawDecodingSettings.sixteenBitsImage ? "-16" : "-8";
+
     QStringList keys;
-    keys.append(filePath);
+    keys.append(filePath + suffix);
     if (rawDecodingSettings.halfSizeColorImage)
-        keys.append(filePath + "-halfSizeColorImage");
+        keys.append(filePath + suffix + "-halfSizeColorImage");
     if (previewParameters.size)
-        keys.append(filePath + "-previewImage");
+        keys.append(filePath + suffix + "-previewImage");
     return keys;
 }
 
 @ -65,11 +104,9  @
 
 bool LoadingDescription::operator==(const LoadingDescription &other) const
 {
-    // NOTE: If we start loading RAW files with different loading settings in parallel,
-    //       this and the next methods must be better implemented!
     return filePath == other.filePath &&
-            rawDecodingSettings.halfSizeColorImage == other.rawDecodingSettings.halfSizeColorImage &&
-            previewParameters.size == other.previewParameters.size;
+            rawDecodingSettings == other.rawDecodingSettings &&
+            previewParameters == other.previewParameters;
 }
 
 bool LoadingDescription::equalsIgnoreReducedVersion(const LoadingDescription &other) const
 @ -79,10 +116,18  @
 
 bool LoadingDescription::equalsOrBetterThan(const LoadingDescription &other) const
 {
+    // This method is similar to operator==. But it returns true as well if other
+    // Loads a "better" version than this.
+    // Preview parameters must have the same size, or other has no size restriction.
+    // All raw decoding settings must be equal, only the half size parameter is allowed to vary.
+
+    KDcrawIface::RawDecodingSettings fullSize = other.rawDecodingSettings;
+    fullSize.halfSizeColorImage = false;
+
     return filePath == other.filePath &&
             (
-             (rawDecodingSettings.halfSizeColorImage == other.rawDecodingSettings.halfSizeColorImage) ||
-             other.rawDecodingSettings.halfSizeColorImage
+             rawDecodingSettings == other.rawDecodingSettings ||
+             rawDecodingSettings == fullSize
             ) &&
             (
              (previewParameters.size == other.previewParameters.size) ||
 @ -93,9 +138,12  @
 QStringList LoadingDescription::possibleCacheKeys(const QString &filePath)
 {
     QStringList keys;
-    keys.append(filePath);
-    keys.append(filePath + "-halfSizeColorImage");
-    keys.append(filePath + "-previewImage");
+    keys.append(filePath + "-16");
+    keys.append(filePath + "-16-halfSizeColorImage");
+    keys.append(filePath + "-16-previewImage");
+    keys.append(filePath + "-8");
+    keys.append(filePath + "-8-halfSizeColorImage");
+    keys.append(filePath + "-8-previewImage");
     return keys;
 }
 
--- branches/extragear/kde3/graphics/digikam/libs/threadimageio/loadingdescription.h #672555:672556
 @ -45,9 +45,12  @
             size       = 0;
             exifRotate = false;
         }
+
         bool isPreview;
         int  size;
         bool exifRotate;
+
+        bool operator==(const PreviewParameters &other) const;
     };
 
     /**
 @ -61,34 +64,26  @
      * Use this for files that are not raw files.
      * Stores only the filePath.
      */
-    LoadingDescription(const QString &filePath)
-        : filePath(filePath)
-        {
-            rawDecodingSettings = KDcrawIface::RawDecodingSettings();
-        };
+    LoadingDescription(const QString &filePath);
 
     /**
      * For raw files:
      * Stores filePath and RawDecodingSettings
      */
-    LoadingDescription(const QString &filePath, KDcrawIface::RawDecodingSettings settings)
-        : filePath(filePath), rawDecodingSettings(settings)
-        {};
+    LoadingDescription(const QString &filePath, KDcrawIface::RawDecodingSettings settings);
 
     /**
      * For preview jobs:
      * Stores preview max size and exif rotation.
-     * The exif rotation is only a hint.
-     * Call LoadSaveThread::exifRotate to make sure that the image is really
-     * rotated. It is safe to call this method even if the image is rotated.
+     * Exif Rotation:
+     *    The exif rotation is only a hint.
+     *    Call LoadSaveThread::exifRotate to make sure that the image is really
+     *    rotated. It is safe to call this method even if the image is rotated.
+     * Raw files:
+     *    If size is not 0, the embedded preview will be loaded if available.
+     *    If size is 0, DImg based loading will be used with default raw decoding settings.
      */
-    LoadingDescription(const QString &filePath, int size, bool exifRotate)
-        : filePath(filePath)
-        {
-            previewParameters.isPreview  = false;
-            previewParameters.size       = size;
-            previewParameters.exifRotate = exifRotate;
-        };
+    LoadingDescription(const QString &filePath, int size, bool exifRotate);
 
     QString                          filePath;
     KDcrawIface::RawDecodingSettings rawDecodingSettings;
 @ -121,6 +116,7  @
      * ignoring parameters used to specify a reduced version.
      */
     bool equalsIgnoreReducedVersion(const LoadingDescription &other) const;
+
     /**
      * Returns whether this loading task equals the other one
      * or is superior to it, if the other one is a reduced version
--- branches/extragear/kde3/graphics/digikam/libs/threadimageio/previewloadthread.cpp #672555:672556
 @ -37,6 +37,7  @
 
 void PreviewLoadThread::load(LoadingDescription description)
 {
+    description.rawDecodingSettings.sixteenBitsImage = false;
     ManagedLoadSaveThread::loadPreview(description);
 }



More information about the Digikam-devel mailing list