[Digikam-devel] extragear/graphics/digikam

Gilles Caulier caulier.gilles at free.fr
Thu Dec 1 13:21:47 GMT 2005


SVN commit 484691 by cgilles:

digikam from trunk : New image plugin tool supporting 16 bits images : invert image.
CCMAIL: digikam-devel at kde.org

 M  +6 -11     imageplugins/imageplugin_core.cpp  
 M  +30 -21    libs/filters/imagefilters.cpp  
 M  +5 -10     libs/filters/imagefilters.h  
 M  +2 -0      libs/levels/imagelevels.cpp  


--- trunk/extragear/graphics/digikam/imageplugins/imageplugin_core.cpp #484690:484691
@@ -32,8 +32,9 @@
 
 // Local includes.
 
-#include <imageiface.h>
-#include <imagefilters.h>
+#include "dimg.h"
+#include "imageiface.h"
+#include "imagefilters.h"
 #include "imageeffect_rgb.h"
 #include "imageeffect_hsl.h"
 #include "imageeffect_bcg.h"
@@ -174,16 +175,10 @@
     parentWidget()->setCursor( KCursor::waitCursor() );
         
     Digikam::ImageIface iface(0, 0);
+    Digikam::DImg image = iface.getOriginalImage();
+    Digikam::ImageFilters::invertImage(image.bits(), image.width(), image.height(), image.sixteenBit());
+    iface.putOriginalImage(i18n("Invert"), image);
 
-    uint* data = iface.getOriginalData();
-    int   w    = iface.originalWidth(); 
-    int   h    = iface.originalHeight();
-    
-    Digikam::ImageFilters::invertImage(data, w, h);
-    
-    iface.putOriginalData(i18n("Invert"), data);
-    delete [] data;
-
     parentWidget()->setCursor( KCursor::arrowCursor()  );
 }
 
--- trunk/extragear/graphics/digikam/libs/filters/imagefilters.cpp #484690:484691
@@ -684,35 +684,44 @@
     delete levels;
 }
 
-//////////////////////////////////////////////////////////////////////////////
-// Performs image colors inversion. This tool is used for negate image 
-// resulting of a positive film scanned.
+/** Performs image colors inversion. This tool is used for negate image
+    resulting of a positive film scanned.*/
 
-void ImageFilters::invertImage(uint *data, int w, int h)
+void ImageFilters::invertImage(uchar *data, int w, int h, bool sixteenBit)
 {
     if (!data || !w || !h)
-       {
+    {
        kdWarning() << ("ImageFilters::invertImage: no image data available!")
                    << endl;
        return;
-       }
-       
-    int           i;
-    uchar         red, green, blue;
-    imageData     imagedata;
-    
-    for (i = 0; i < w*h; i++)
+    }
+
+    if (!sixteenBit)        // 8 bits image.
+    {
+        uchar *ptr = data;
+        
+        for (int i = 0 ; i < w*h ; i++)
         {
-        imagedata.raw = data[i];
-        red           = imagedata.channel.red;
-        green         = imagedata.channel.green;
-        blue          = imagedata.channel.blue;
-    
-        imagedata.channel.red   = 255 - red;
-        imagedata.channel.green = 255 - green;
-        imagedata.channel.blue  = 255 - blue;
-        data[i] = imagedata.raw;
+            ptr[0] = 255 - ptr[0];
+            ptr[1] = 255 - ptr[1];
+            ptr[2] = 255 - ptr[2];
+            ptr[3] = 255 - ptr[3];
+            ptr += 4;
         }
+    }
+    else               // 16 bits image.
+    {
+        unsigned short *ptr = (unsigned short *)data;
+        
+        for (int i = 0 ; i < w*h ; i++)
+        {
+            ptr[0] = 65535 - ptr[0];
+            ptr[1] = 65535 - ptr[1];
+            ptr[2] = 65535 - ptr[2];
+            ptr[3] = 65535 - ptr[3];
+            ptr += 4;
+        }
+    }
 }
 
 //////////////////////////////////////////////////////////////////////////////
--- trunk/extragear/graphics/digikam/libs/filters/imagefilters.h #484690:484691
@@ -43,6 +43,8 @@
 {
 public: // Structures to use for color management filters depending of architectures.
 
+// FIXME remove this endianness rule when all image plugins will support 16 bits images.
+
 #ifdef WORDS_BIGENDIAN  // PPC like
     struct channels
     {
@@ -85,14 +87,6 @@
     unsigned int alpha;
     };
 
-    struct short_packet
-    {
-    unsigned short int red;
-    unsigned short int green;
-    unsigned short int blue;
-    unsigned short int alpha;
-    };
-
     struct NormalizeParam
     {
     unsigned short *lut;
@@ -144,9 +138,10 @@
     static void equalizeImage(uchar *data, int w, int h, bool sixteenBit);
     static void stretchContrastImage(uchar *data, int w, int h, bool sixteenBit);
     static void normalizeImage(uchar *data, int w, int h, bool sixteenBit);
-
     static void autoLevelsCorrectionImage(uchar *data, int w, int h, bool sixteenBit);
-    static void invertImage(uint *data, int w, int h);
+    static void invertImage(uchar *data, int w, int h, bool sixteenBit);
+
+    // FIXME : support 16 bits images.
     static void gaussianBlurImage(uint *data, int Width, int Height, int Radius);
     static void channelMixerImage(uint *data, int Width, int Height, bool bPreserveLum, bool bMonochrome,
                                   float rrGain, float rgGain, float rbGain,
--- trunk/extragear/graphics/digikam/libs/levels/imagelevels.cpp #484690:484691
@@ -180,6 +180,7 @@
     return 0;  // just to please the compiler.
 }
 
+// FIXME : support 16 bits image.
 void ImageLevels::levelsBlackToneAdjustByColors(int channel, QColor color)
 {
     if (!m_levels) return;
@@ -187,6 +188,7 @@
     m_levels->low_input[channel] = levelsInputFromColor(channel, color);
 }
 
+// FIXME : support 16 bits image.
 void ImageLevels::levelsWhiteToneAdjustByColors(int channel, QColor color)
 {
     if (!m_levels) return;



More information about the Digikam-devel mailing list