[Digikam-devel] extragear/graphics/digikam

Gilles Caulier caulier.gilles at free.fr
Mon Dec 19 14:23:41 GMT 2005


SVN commit 489685 by cgilles:

Digikam from trunk : image histogram sidebar : using separate thread to load image. 

This implementation use a new class from digiKam core library name threadimageio dedicaced to perform load and saving operations on image files. This class has been written by Marcel Wiesweg.

In first, i have use this class to perform loading image on main window histogram sidebar tab. The old implementation performed loading in GUI thread that generated any time latency.
Now loading operations are separated and GUI isn't frozen.

TODO :

- To load RAW files DImg image loader use parce.c implementation from dcraw project. This source code using a lot of 'printf' to debug. This is wrong and generate any time latency problem. We need to fix it in the future, especially to port dcraw code to a dedicaced pure C++ class.
- Add progress to DImg image loader.
- Fix DImg image loader implementation to break an image io currently performed.
- Add thread image io support in Image editor Canvas.
- Add progress indicator in Image Editor canvas. We no need to use a progress bar here, just a text indicator in percent placed at canvas center. Like this, image editor layout isn't broken.

Thanks to Marcel to help me in these task !

CCMAIL: digikam-devel at kde.org, marcel.wiesweg at gmx.de

 M  +1 -0      digikam/Makefile.am  
 M  +1 -1      libs/Makefile.am  
 M  +2 -0      libs/imageproperties/Makefile.am  
 M  +21 -7     libs/imageproperties/imagepropertieshistogramtab.cpp  
 M  +7 -2      libs/imageproperties/imagepropertieshistogramtab.h  
 A             libs/threadimageio (directory)  
 A             libs/threadimageio/Makefile.am  
 A             libs/threadimageio/loadsavethread.cpp   [License: GPL]
 A             libs/threadimageio/loadsavethread.h   [License: GPL]


--- trunk/extragear/graphics/digikam/digikam/Makefile.am #489684:489685
@@ -60,6 +60,7 @@
 		        $(top_builddir)/digikam/libs/dialogs/libdialog.la \
 		        $(top_builddir)/digikam/libs/jpegutils/libjpegutils.la \
 		        $(top_builddir)/digikam/libs/imageproperties/libimagepropertiesdigikam.la \
+	            $(top_builddir)/digikam/libs/threadimageio/libthreadimageio.la \
 		        $(top_builddir)/digikam/utilities/cameragui/libcameragui.la \
 		        $(top_builddir)/digikam/utilities/imageeditor/canvas/libdimgcanvas.la \
 		        $(top_builddir)/digikam/utilities/imageeditor/editor/libdimgeditor.la \
--- trunk/extragear/graphics/digikam/libs/Makefile.am #489684:489685
@@ -1 +1 @@
-SUBDIRS = dcraw histogram levels curves dimg themeengine widgets filters thumbbar jpegutils imageproperties dialogs 
+SUBDIRS = dcraw histogram levels curves dimg themeengine widgets filters thumbbar jpegutils imageproperties dialogs threadimageio 
--- trunk/extragear/graphics/digikam/libs/imageproperties/Makefile.am #489684:489685
@@ -9,6 +9,7 @@
 
 libimagepropertiesshowfoto_la_LIBADD = $(top_builddir)/digikam/libs/widgets/libwidgets.la \
 	                               $(top_builddir)/digikam/libs/dimg/libdimg.la \
+	                               $(top_builddir)/digikam/libs/threadimageio/libthreadimageio.la \
 	                               $(top_builddir)/digikam/libs/histogram/libhistogram.la 
 
 libimagepropertiesshowfoto_la_LDFLAGS = $(all_libraries) $(KDE_RPATH)
@@ -24,6 +25,7 @@
 INCLUDES = -I$(top_srcdir)/digikam/libs/histogram \
 	   -I$(top_srcdir)/digikam/libs/widgets \
 	   -I$(top_srcdir)/digikam/libs/dimg \
+	   -I$(top_srcdir)/digikam/libs/threadimageio \
 	   -I$(top_srcdir)/digikam/digikam \
 	   $(LIBKEXIF_CFLAGS) $(all_includes)
 
--- trunk/extragear/graphics/digikam/libs/imageproperties/imagepropertieshistogramtab.cpp #489684:489685
@@ -52,6 +52,7 @@
 #include "histogramwidget.h"
 #include "colorgradientwidget.h"
 #include "navigatebarwidget.h"
+#include "loadsavethread.h"
 #include "imagepropertieshistogramtab.h"
 
 namespace Digikam
@@ -60,7 +61,8 @@
 ImagePropertiesHistogramTab::ImagePropertiesHistogramTab(QWidget* parent, QRect* selectionArea, bool navBar)
                            : QWidget(parent, 0, Qt::WDestructiveClose)
 {
-    m_selectionArea = selectionArea;
+    m_imageLoaderThreaded = 0;
+    m_selectionArea       = selectionArea;
    
     QGridLayout *topLayout = new QGridLayout(this, 7, 3, KDialog::marginHint(), KDialog::spacingHint());
 
@@ -332,7 +334,7 @@
                 
     if (!imageData && !imageWidth && !imageHeight)
     {
-        loadDataFromUrl(url);
+        loadImageFromUrl(url);
     }
     else 
     {
@@ -366,16 +368,28 @@
     }
 }
 
-void ImagePropertiesHistogramTab::loadDataFromUrl(const KURL& url)
+void ImagePropertiesHistogramTab::loadImageFromUrl(const KURL& url)
 {
-    // TODO : use a separate thread to load image.
+    if (m_imageLoaderThreaded)
+    {
+        delete m_imageLoaderThreaded;
+    }
 
-    m_image = DImg(url.path());
+    m_imageLoaderThreaded = new LoadSaveThread();
 
-    if ( !m_image.isNull() )
+    connect(m_imageLoaderThreaded, SIGNAL(signalImageLoaded(const QString&, const DImg&)),
+            this, SLOT(slotLoadImageFromUrlComplete(const QString&, const DImg&)));
+
+    m_imageLoaderThreaded->load(url.path());
+}
+
+void ImagePropertiesHistogramTab::slotLoadImageFromUrlComplete(const QString&, const DImg& img)
+{
+    if ( !img.isNull() )
     {
+        m_image = img;
         m_histogramWidget->updateData(m_image.bits(), m_image.width(), m_image.height(),
-                                        m_image.sixteenBit());
+                                      m_image.sixteenBit());
         m_regionBG->hide();
         m_maxInterv->setMaxValue(m_image.sixteenBit() ? 65535 : 255);
     }
--- trunk/extragear/graphics/digikam/libs/imageproperties/imagepropertieshistogramtab.h #489684:489685
@@ -46,6 +46,7 @@
 class HistogramWidget;
 class ColorGradientWidget;
 class NavigateBarWidget;
+class LoadSaveThread;
 
 class DIGIKAM_EXPORT ImagePropertiesHistogramTab : public QWidget
 {
@@ -71,7 +72,7 @@
 
 private:
 
-    void loadDataFromUrl(const KURL& url);
+    void loadImageFromUrl(const KURL& url);
     void updateInformation();
     
 private slots:
@@ -87,6 +88,8 @@
     void slotUpdateMinInterv(int min);
     void slotUpdateMaxInterv(int max);
 
+    void slotLoadImageFromUrlComplete(const QString&, const DImg& img);
+
 private:
 
     QComboBox           *m_channelCB;    
@@ -113,7 +116,9 @@
     
     ColorGradientWidget *m_hGradient;
     HistogramWidget     *m_histogramWidget;
-    NavigateBarWidget   *m_navigateBar;   
+    NavigateBarWidget   *m_navigateBar;
+    LoadSaveThread      *m_imageLoaderThreaded;
+    
 };
 
 }  // NameSpace Digikam



More information about the Digikam-devel mailing list