[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra/calligra/2.9] krita/plugins/formats/tiff: BUG:310359 Fix loading and saving Lab TIFF image
From:       Boudewijn Rempt <boud () valdyas ! org>
Date:       2015-09-19 12:26:55
Message-ID: E1ZdHEF-0007ko-Kl () scm ! kde ! org
[Download RAW message or body]

Git commit f4ac4cd2e553bb86b711fa77701953e7a13bac7b by Boudewijn Rempt.
Committed on 19/09/2015 at 12:23.
Pushed by rempt into branch 'calligra/2.9'.

BUG:310359 Fix loading and saving Lab TIFF images

Internally, Krita uses the ICCLAB definition, not the CIELAB
definition, so we shouldn't convert what we read to CIELAB, and
should save what we save tagged as ICCLAB.

Photoshop CS2 and CC can now load our TIFF Lab images! (We don't have
a gimp devel build to test with atm.)

M  +3    -3    krita/plugins/formats/tiff/kis_tiff_converter.cc
M  +6    -6    krita/plugins/formats/tiff/kis_tiff_reader.h
M  +2    -2    krita/plugins/formats/tiff/kis_tiff_writer_visitor.cpp

http://commits.kde.org/calligra/f4ac4cd2e553bb86b711fa77701953e7a13bac7b

diff --git a/krita/plugins/formats/tiff/kis_tiff_converter.cc \
b/krita/plugins/formats/tiff/kis_tiff_converter.cc index aa94529..e6becd7 100644
--- a/krita/plugins/formats/tiff/kis_tiff_converter.cc
+++ b/krita/plugins/formats/tiff/kis_tiff_converter.cc
@@ -151,13 +151,13 @@ QPair<QString, QString> getColorSpaceForColorType(uint16 sampletype, \
                uint16 colo
     else if (color_type == PHOTOMETRIC_CIELAB || color_type == PHOTOMETRIC_ICCLAB) {
         destDepth = 16;
         if (nbchannels == 0) nbchannels = 3;
-        extrasamplescount = nbchannels - 3; // FIX the extrasamples count in case of
+        extrasamplescount = nbchannels - 3; // FIX the extrasamples count
         return QPair<QString, QString>(LABAColorModelID.id(), Integer16BitsColorDepthID.id());
     }
     else if (color_type ==  PHOTOMETRIC_PALETTE) {
         destDepth = 16;
         if (nbchannels == 0) nbchannels = 2;
-        extrasamplescount = nbchannels - 2; // FIX the extrasamples count in case of
+        extrasamplescount = nbchannels - 2; // FIX the extrasamples count
         // <-- we will convert the index image to RGBA16 as the palette is always on 16bits \
                colors
         return QPair<QString, QString>(RGBAColorModelID.id(), Integer16BitsColorDepthID.id());
     }
@@ -397,7 +397,7 @@ KisImageBuilder_Result KisTIFFConverter::readTIFFDirectory(TIFF* image)
         break;
     case PHOTOMETRIC_CIELAB: {
         poses[0] = 0; poses[1] = 1; poses[2] = 2; poses[3] = 3;
-        postprocessor = new KisTIFFPostProcessorICCLABtoCIELAB(nbcolorsamples);
+        postprocessor = new KisTIFFPostProcessorCIELABtoICCLAB(nbcolorsamples);
     }
         break;
     case PHOTOMETRIC_ICCLAB: {
diff --git a/krita/plugins/formats/tiff/kis_tiff_reader.h \
b/krita/plugins/formats/tiff/kis_tiff_reader.h index 7a646e7..543d82a 100644
--- a/krita/plugins/formats/tiff/kis_tiff_reader.h
+++ b/krita/plugins/formats/tiff/kis_tiff_reader.h
@@ -76,30 +76,30 @@ public:
     }
 };
 
-class KisTIFFPostProcessorICCLABtoCIELAB : public KisTIFFPostProcessor
+class KisTIFFPostProcessorCIELABtoICCLAB : public KisTIFFPostProcessor
 {
 public:
-    KisTIFFPostProcessorICCLABtoCIELAB(uint8 nbcolorssamples) : \
                KisTIFFPostProcessor(nbcolorssamples) {}
-    virtual ~KisTIFFPostProcessorICCLABtoCIELAB() {}
+    KisTIFFPostProcessorCIELABtoICCLAB(uint8 nbcolorssamples) : \
KisTIFFPostProcessor(nbcolorssamples) {} +    virtual ~KisTIFFPostProcessorCIELABtoICCLAB() {}
 public:
     void postProcess8bit(quint8* data) {
         qint8* ds = (qint8*) data;
         for (int i = 1; i < nbColorsSamples(); i++) {
-            ds[i] = data[i] - quint8_MAX / 2;
+            ds[i] = data[i] + quint8_MAX / 2;
         }
     }
     void postProcess16bit(quint16* data) {
         quint16* d = (quint16*) data;
         qint16* ds = (qint16*) data;
         for (int i = 1; i < nbColorsSamples(); i++) {
-            ds[i] = d[i] - quint16_MAX / 2;
+            ds[i] = d[i] + quint16_MAX / 2;
         }
     }
     void postProcess32bit(quint32* data) {
         quint32* d = (quint32*) data;
         qint32* ds = (qint32*) data;
         for (int i = 1; i < nbColorsSamples(); i++) {
-            ds[i] = d[i] - quint32_MAX / 2;
+            ds[i] = d[i] + quint32_MAX / 2;
         }
     }
 };
diff --git a/krita/plugins/formats/tiff/kis_tiff_writer_visitor.cpp \
b/krita/plugins/formats/tiff/kis_tiff_writer_visitor.cpp index 92a5989..605700d 100644
--- a/krita/plugins/formats/tiff/kis_tiff_writer_visitor.cpp
+++ b/krita/plugins/formats/tiff/kis_tiff_writer_visitor.cpp
@@ -66,7 +66,7 @@ namespace
             return true;
         }
         if (cs->id() == "LABA") {
-            color_type = PHOTOMETRIC_CIELAB;
+            color_type = PHOTOMETRIC_ICCLAB;
             return true;
         }
 
@@ -252,7 +252,7 @@ bool KisTIFFWriterVisitor::saveLayerProjection(KisLayer * layer)
                 r = copyDataToStrips(it, buff, depth, sample_format, 4, poses);
             }
             break;
-        case PHOTOMETRIC_CIELAB: {
+        case PHOTOMETRIC_ICCLAB: {
                 quint8 poses[] = { 0, 1, 2, 3 };
                 r = copyDataToStrips(it, buff, depth, sample_format, 3, poses);
             }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic