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/plugi= ns/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::readTIFFDirec= tory(TIFF* image) } break; case PHOTOMETRIC_RGB: { - poses[0] =3D 2; poses[1] =3D 1; poses[2] =3D 0; poses[3] =3D 3; + if (sampletype =3D=3D SAMPLEFORMAT_IEEEFP) + { + poses[2] =3D 2; poses[1] =3D 1; poses[0] =3D 0; poses[3] =3D 3; + } else { + poses[0] =3D 2; poses[1] =3D 1; poses[2] =3D 0; poses[3] =3D 3; + } postprocessor =3D new KisTIFFPostProcessor(nbcolorsamples); } break; @@ -454,26 +459,27 @@ KisImageBuilder_Result KisTIFFConverter::readTIFFDire= ctory(TIFF* image) tiffReader =3D new KisTIFFReaderTarget8bit(layer->paintDevice(), p= oses, alphapos, depth, sampletype, nbcolorsamples, extrasamplescount, trans= form, postprocessor); } else if (dstDepth =3D=3D 16) { - uint16 alphValue; - if(sampletype =3D=3D SAMPLEFORMAT_IEEEFP) + uint16 alphaValue; + if (sampletype =3D=3D SAMPLEFORMAT_IEEEFP) { - float alpha =3D 1.0f; - alphValue =3D *(uint16*)α + alphaValue =3D 15360; // representation of 1.0 in half } else { - alphValue =3D quint16_MAX; + alphaValue =3D quint16_MAX; } - tiffReader =3D new KisTIFFReaderTarget16bit(layer->paintDevice(), = poses, alphapos, depth, sampletype, nbcolorsamples, extrasamplescount, tran= sform, postprocessor, alphValue); + tiffReader =3D new KisTIFFReaderTarget16bit(layer->paintDevice(), = poses, alphapos, depth, sampletype, nbcolorsamples, extrasamplescount, tran= sform, postprocessor, alphaValue); } else if (dstDepth =3D=3D 32) { - uint32 alphValue; - if(sampletype =3D=3D SAMPLEFORMAT_IEEEFP) + union { + float f; + uint32 i; + } alphaValue; + if (sampletype =3D=3D SAMPLEFORMAT_IEEEFP) { - float alpha =3D 1.0; - alphValue =3D *(uint32*)α + alphaValue.f =3D 1.0f; } else { - alphValue =3D quint32_MAX; + alphaValue.i =3D quint32_MAX; } - tiffReader =3D new KisTIFFReaderTarget32bit(layer->paintDevice(), = poses, alphapos, depth, sampletype, nbcolorsamples, extrasamplescount, tran= sform, postprocessor, alphValue); + tiffReader =3D new KisTIFFReaderTarget32bit(layer->paintDevice(), = poses, alphapos, depth, sampletype, nbcolorsamples, extrasamplescount, tran= sform, 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() =3D=3D "GRAYA" || cs->id() =3D=3D "GRAYAU16") { @@ -55,11 +55,11 @@ namespace color_type =3D PHOTOMETRIC_RGB; return true; } -// if (KoID(cs->id()) =3D=3D KoID("RGBAF16") || KoID(cs->id()) =3D= =3D KoID("RGBAF32")) { -// color_type =3D PHOTOMETRIC_RGB; -// sample_format =3D SAMPLEFORMAT_IEEEFP; -// return true; -// } + if (KoID(cs->id()) =3D=3D KoID("RGBAF16") || KoID(cs->id()) =3D=3D = KoID("RGBAF32")) { + color_type =3D PHOTOMETRIC_RGB; + sample_format =3D SAMPLEFORMAT_IEEEFP; + return true; + } if (cs->id() =3D=3D "CMYK" || cs->id() =3D=3D "CMYKAU16") { color_type =3D PHOTOMETRIC_SEPARATED; TIFFSetField(image, TIFFTAG_INKSET, INKSET_CMYK); @@ -241,7 +241,12 @@ bool KisTIFFWriterVisitor::saveLayerProjection(KisLaye= r * layer) } break; case PHOTOMETRIC_RGB: { - quint8 poses[] =3D { 2, 1, 0, 3}; + quint8 poses[4]; + if (sample_format =3D=3D SAMPLEFORMAT_IEEEFP) { + poses[2] =3D 2; poses[1] =3D 1; poses[0] =3D 0; poses[= 3] =3D 3; + } else { + poses[0] =3D 2; poses[1] =3D 1; poses[2] =3D 0; poses[= 3] =3D 3; + } r =3D copyDataToStrips(it, buff, depth, sample_format, 3, = poses); } break;