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

List:       kde-commits
Subject:    [calligra] krita/plugins/formats/tiff: fix order of colors for floating point (it is worth to note t
From:       Cyrille Berger <cberger () cberger ! net>
Date:       2015-05-02 9:50:54
Message-ID: E1YoU4U-0001HL-Mp () scm ! kde ! org
[Download RAW message or body]

Git commit 181a0545e353c4fbc2e2a7fbd8c2aaf45f1296cf by Cyrille Berger.
Committed on 02/05/2015 at 09:50.
Pushed by berger into branch 'master'.

fix order of colors for floating point (it is worth to note that photoshop and gimp \
are not respecting the TIFF standard in that aspect)

BUG: 344334

M  +19   -13   krita/plugins/formats/tiff/kis_tiff_converter.cc
M  +12   -7    krita/plugins/formats/tiff/kis_tiff_writer_visitor.cpp

http://commits.kde.org/calligra/181a0545e353c4fbc2e2a7fbd8c2aaf45f1296cf

diff --git a/krita/plugins/formats/tiff/kis_tiff_converter.cc \
b/krita/plugins/formats/tiff/kis_tiff_converter.cc index 583f878..386f397 100644
--- a/krita/plugins/formats/tiff/kis_tiff_converter.cc
+++ b/krita/plugins/formats/tiff/kis_tiff_converter.cc
@@ -404,7 +404,12 @@ KisImageBuilder_Result KisTIFFConverter::readTIFFDirectory(TIFF* \
image)  }
         break;
     case PHOTOMETRIC_RGB: {
-        poses[0] = 2; poses[1] = 1; poses[2] = 0; poses[3] = 3;
+        if (sampletype == SAMPLEFORMAT_IEEEFP)
+        {
+            poses[2] = 2; poses[1] = 1; poses[0] = 0; poses[3] = 3;
+        } else {
+            poses[0] = 2; poses[1] = 1; poses[2] = 0; poses[3] = 3;
+        }
         postprocessor = new KisTIFFPostProcessor(nbcolorsamples);
     }
         break;
@@ -454,26 +459,27 @@ KisImageBuilder_Result \
KisTIFFConverter::readTIFFDirectory(TIFF* image)  tiffReader = new \
KisTIFFReaderTarget8bit(layer->paintDevice(), poses, alphapos, depth, sampletype, \
nbcolorsamples, extrasamplescount, transform, postprocessor);  }
     else if (dstDepth == 16) {
-        uint16 alphValue;
-        if(sampletype == SAMPLEFORMAT_IEEEFP)
+        uint16 alphaValue;
+        if (sampletype == SAMPLEFORMAT_IEEEFP)
         {
-          float alpha = 1.0f;
-          alphValue = *(uint16*)&alpha;
+          alphaValue = 15360; // representation of 1.0 in half
         } else {
-          alphValue = quint16_MAX;
+          alphaValue = quint16_MAX;
         }
-        tiffReader = new KisTIFFReaderTarget16bit(layer->paintDevice(), poses, \
alphapos, depth, sampletype, nbcolorsamples, extrasamplescount, transform, \
postprocessor, alphValue); +        tiffReader = new \
KisTIFFReaderTarget16bit(layer->paintDevice(), poses, alphapos, depth, sampletype, \
nbcolorsamples, extrasamplescount, transform, postprocessor, alphaValue);  }
     else if (dstDepth == 32) {
-        uint32 alphValue;
-        if(sampletype == SAMPLEFORMAT_IEEEFP)
+        union {
+          float f;
+          uint32 i;
+        } alphaValue;
+        if (sampletype == SAMPLEFORMAT_IEEEFP)
         {
-          float alpha = 1.0;
-          alphValue = *(uint32*)&alpha;
+          alphaValue.f = 1.0f;
         } else {
-          alphValue = quint32_MAX;
+          alphaValue.i = quint32_MAX;
         }
-        tiffReader = new KisTIFFReaderTarget32bit(layer->paintDevice(), poses, \
alphapos, depth, sampletype, nbcolorsamples, extrasamplescount, transform, \
postprocessor, alphValue); +        tiffReader = new \
KisTIFFReaderTarget32bit(layer->paintDevice(), poses, alphapos, depth, sampletype, \
nbcolorsamples, extrasamplescount, transform, postprocessor, alphaValue.i);  }
 
     if (TIFFIsTiled(image)) {
diff --git a/krita/plugins/formats/tiff/kis_tiff_writer_visitor.cpp \
b/krita/plugins/formats/tiff/kis_tiff_writer_visitor.cpp index 6e7bdff..e5dbb1b \
                100644
--- a/krita/plugins/formats/tiff/kis_tiff_writer_visitor.cpp
+++ b/krita/plugins/formats/tiff/kis_tiff_writer_visitor.cpp
@@ -44,7 +44,7 @@
 
 namespace
 {
-    bool writeColorSpaceInformation(TIFF* image, const KoColorSpace * cs, uint16& \
color_type, uint16& /*sample_format*/) +    bool writeColorSpaceInformation(TIFF* \
image, const KoColorSpace * cs, uint16& color_type, uint16& sample_format)  {
         qDebug() << cs->id();
         if (cs->id() == "GRAYA" || cs->id() == "GRAYAU16") {
@@ -55,11 +55,11 @@ namespace
             color_type = PHOTOMETRIC_RGB;
             return true;
         }
-//        if (KoID(cs->id()) == KoID("RGBAF16") || KoID(cs->id()) == \
                KoID("RGBAF32")) {
-//            color_type = PHOTOMETRIC_RGB;
-//            sample_format = SAMPLEFORMAT_IEEEFP;
-//            return true;
-//        }
+       if (KoID(cs->id()) == KoID("RGBAF16") || KoID(cs->id()) == KoID("RGBAF32")) {
+           color_type = PHOTOMETRIC_RGB;
+           sample_format = SAMPLEFORMAT_IEEEFP;
+           return true;
+       }
         if (cs->id() == "CMYK" || cs->id() == "CMYKAU16") {
             color_type = PHOTOMETRIC_SEPARATED;
             TIFFSetField(image, TIFFTAG_INKSET, INKSET_CMYK);
@@ -241,7 +241,12 @@ bool KisTIFFWriterVisitor::saveLayerProjection(KisLayer * layer)
             }
             break;
         case PHOTOMETRIC_RGB: {
-                quint8 poses[] = { 2, 1, 0, 3};
+                quint8 poses[4];
+                if (sample_format == SAMPLEFORMAT_IEEEFP) {
+                    poses[2] = 2; poses[1] = 1; poses[0] = 0; poses[3] = 3;
+                } else {
+                    poses[0] = 2; poses[1] = 1; poses[2] = 0; poses[3] = 3;
+                }
                 r = copyDataToStrips(it, buff, depth, sample_format, 3, poses);
             }
             break;


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

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