Version: 1.6.0 (using KDE KDE 3.5.5) Installed from: SuSE RPMs OS: Linux I'll attach a screen shot with the settings which trigger this error while I was testing CMYK TIFF export.
Created an attachment (id=18119) [details] TIFF save settings
www.scribus.net/downloads/testfiles/krita3acmyk.kra.bz2 is the original file imported from rgb jpeg, then converted
It doesn't open correctly with krita either
SVN commit 595861 by berger: - forward port fix for bug:135649 - allow saving/loading of float images (note to boud, as I suspected I can't test if it builds, so it probably doesn't) CCBUG:135649 M +26 -6 kis_tiff_converter.cc M +19 -6 kis_tiff_export.cc M +27 -1 kis_tiff_reader.cc M +11 -11 kis_tiff_reader.h M +25 -3 kis_tiff_writer_visitor.cpp --- trunk/koffice/filters/krita/tiff/kis_tiff_converter.cc #595860:595861 @@ -64,13 +64,26 @@ } else if(color_type == PHOTOMETRIC_RGB /*|| color_type == */ ) { if(nbchannels == 0) nbchannels = 3; extrasamplescount = nbchannels - 3; // FIX the extrasamples count in case of - if(color_nb_bits <= 8) + if(sampletype == SAMPLEFORMAT_IEEEFP) { - destDepth = 8; - return "RGBA"; + if(color_nb_bits == 16) + { + destDepth = 16; + return "RGBAF16HALF"; + } else if( color_nb_bits == 32) { + destDepth = 32; + return "RGBAF32"; + } + return ""; } else { - destDepth = 16; - return "RGBA16"; + if(color_nb_bits <= 8) + { + destDepth = 8; + return "RGBA"; + } else { + destDepth = 16; + return "RGBA16"; + } } } else if(color_type == PHOTOMETRIC_YCBCR ) { if(nbchannels == 0) nbchannels = 3; @@ -189,7 +202,12 @@ kDebug(41008) << "Image does not define its depth" << endl; depth = 1; } - // Determine the number of channels (useful to know if a file has an alpha or not + uint16 sampletype; + if((TIFFGetField(image, TIFFTAG_SAMPLEFORMAT, &sampletype) == 0)){ + kdDebug(41008) << "Image does not define its sample type" << endl; + sampletype = SAMPLEFORMAT_UINT; + } + // Determine the number of channels (usefull to know if a file has an alpha or not uint16 nbchannels; if(TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &nbchannels) == 0){ kDebug(41008) << "Image has an undefined number of samples per pixel" << endl; @@ -422,6 +440,8 @@ tiffReader = new KisTIFFReaderTarget8bit( layer->paintDevice(), poses, alphapos, depth, nbcolorsamples, extrasamplescount, transform, postprocessor); } else if(dstDepth == 16) { tiffReader = new KisTIFFReaderTarget16bit( layer->paintDevice(), poses, alphapos, depth, nbcolorsamples, extrasamplescount, transform, postprocessor); + } else if(dstDepth == 32) { + tiffReader = new KisTIFFReaderTarget32bit( layer->paintDevice(), poses, alphapos, depth, nbcolorsamples, extrasamplescount, transform, postprocessor); } if(TIFFIsTiled(image)) --- trunk/koffice/filters/krita/tiff/kis_tiff_export.cc #595860:595861 @@ -55,10 +55,20 @@ if (from != "application/x-krita") return KoFilter::NotImplemented; - - KisDlgOptionsTIFF* kdb = new KisDlgOptionsTIFF(0); - kdb->setObjectName( "options dialog for tiff" ); - + + KisDlgOptionsTIFF* kdb = new KisDlgOptionsTIFF(0, "options dialog for tiff"); + + KisDoc *output = dynamic_cast<KisDoc*>(m_chain->inputDocument()); + + KisColorSpace* cs = output->currentImage()->colorSpace(); + KisChannelInfo::enumChannelValueType type = cs->channels()[0]->channelValueType(); + if( type == KisChannelInfo::FLOAT16 || type == KisChannelInfo::FLOAT32) + { + kdb->optionswdg->kComboBoxPredictor->removeItem(1); + } else { + kdb->optionswdg->kComboBoxPredictor->removeItem(2); + } + if(kdb->exec() == QDialog::Rejected) { return KoFilter::UserCancelled; @@ -66,9 +76,12 @@ KisTIFFOptions options = kdb->options(); + if( ( type == KisChannelInfo::FLOAT16 || type == KisChannelInfo::FLOAT32) && options.predictor == 2 ) + { // FIXME THIS IS AN HACK FIX THAT IN 2.0 !! + options.predictor = 3; + } delete kdb; - - KisDoc2 *output = dynamic_cast<KisDoc2*>(m_chain->inputDocument()); + QString filename = m_chain->outputFile(); if (!output) --- trunk/koffice/filters/krita/tiff/kis_tiff_reader.cc #595860:595861 @@ -79,8 +79,34 @@ return 1; } - uint KisTIFFReaderFromPalette::copyDataToChannels(quint32 x, quint32 y, quint32 dataWidth, TIFFStreamBase* tiffstream) + uint KisTIFFReaderTarget32bit::copyDataToChannels( Q_UINT32 x, Q_UINT32 y, Q_UINT32 dataWidth, TIFFStreamBase* tiffstream) { + KisHLineIterator it = paintDevice() -> createHLineIterator(x, y, dataWidth, true); + double coeff = Q_UINT32_MAX / (double)( pow(2, sourceDepth() ) - 1 ); +// kdDebug(41008) << " depth expension coefficient : " << coeff << endl; + while (!it.isDone()) { + Q_UINT32 *d = reinterpret_cast<Q_UINT32 *>(it.rawData()); + Q_UINT8 i; + for(i = 0; i < nbColorsSamples(); i++) + { + d[poses()[i]] = (Q_UINT32)( tiffstream->nextValue() * coeff ); + } + postProcessor()->postProcess32bit( d); + if(transform()) cmsDoTransform(transform(), d, d, 1); + d[poses()[i]] = Q_UINT32_MAX; + for(int k = 0; k < nbExtraSamples(); k++) + { + if(k == alphaPos()) + d[poses()[i]] = (Q_UINT32) ( tiffstream->nextValue() * coeff ); + else + tiffstream->nextValue(); + } + ++it; + } + return 1; + } + uint KisTIFFReaderFromPalette::copyDataToChannels(Q_UINT32 x, Q_UINT32 y, Q_UINT32 dataWidth, TIFFStreamBase* tiffstream) + { KisHLineIterator it = paintDevice() -> createHLineIterator(x, y, dataWidth); while (!it.isDone()) { quint16* d = reinterpret_cast<quint16 *>(it.rawData()); --- trunk/koffice/filters/krita/tiff/kis_tiff_reader.h #595860:595861 @@ -177,11 +177,21 @@ class KisTIFFReaderTarget16bit : public KisTIFFReaderBase { public: - KisTIFFReaderTarget16bit( KisPaintDeviceSP device, quint8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor) : KisTIFFReaderBase(device, poses, alphapos, sourceDepth, nbcolorssamples, extrasamplescount, transformProfile, postprocessor ) + KisTIFFReaderTarget16bit( KisPaintDeviceSP device, Q_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor) : KisTIFFReaderBase(device, poses, alphapos, sourceDepth, nbcolorssamples, extrasamplescount, transformProfile, postprocessor ) { } public: + virtual uint copyDataToChannels( Q_UINT32 x, Q_UINT32 y, Q_UINT32 dataWidth, TIFFStreamBase* tiffstream) ; +}; + +class KisTIFFReaderTarget32bit : public KisTIFFReaderBase { + public: + KisTIFFReaderTarget32bit( KisPaintDeviceSP device, Q_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor) : KisTIFFReaderBase(device, poses, alphapos, sourceDepth, nbcolorssamples, extrasamplescount, transformProfile, postprocessor ) + { + + } + public: virtual uint copyDataToChannels( quint32 x, quint32 y, quint32 dataWidth, TIFFStreamBase* tiffstream) ; }; @@ -197,14 +207,4 @@ uint16 *m_red, *m_green, *m_blue; }; -// class KisTIFFReaderBaseTarget32bit { -// public: -// KisTIFFReaderBaseTarget32bit( int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, quint8* poses, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor postprocessor) : KisTiffReader(alphapos, sourceDepth, nbcolorssamples, extrasamplescount, poses, transformProfile, postprocessor ) -// { -// -// } -// public: -// virtual void copyDataToChannels( KisHLineIterator it, TIFFStream* tiffstream) =0; -// }; - #endif --- trunk/koffice/filters/krita/tiff/kis_tiff_writer_visitor.cpp #595860:595861 @@ -39,11 +39,17 @@ color_type = PHOTOMETRIC_MINISBLACK; return true; } - if ( cs->id() == "RGBA" || cs->id() == "RGBA16" ) + if ( cs->id() == KisID("RGBA") || cs->id() == KisID("RGBA16") ) { color_type = PHOTOMETRIC_RGB; return true; } + if ( cs->id() == KisID("RGBAF16HALF") || cs->id() == KisID("RGBAF32") ) + { + color_type = PHOTOMETRIC_RGB; + sample_format = SAMPLEFORMAT_IEEEFP; + return true; + } if ( cs->id() == "CMYK" || cs->id() == "CMYKA16" ) { color_type = PHOTOMETRIC_SEPARATED; @@ -74,8 +80,22 @@ bool KisTIFFWriterVisitor::copyDataToStrips( KisHLineConstIterator it, tdata_t buff, uint8 depth, uint8 nbcolorssamples, quint8* poses) { - if(depth == 16) + if(depth == 32) { + Q_UINT32 *dst = reinterpret_cast<Q_UINT32 *>(buff); + while (!it.isDone()) { + const Q_UINT32 *d = reinterpret_cast<const Q_UINT32 *>(it.rawData()); + int i; + for(i = 0; i < nbcolorssamples; i++) + { + *(dst++) = d[poses[i]]; + } + if(saveAlpha()) *(dst++) = d[poses[i]]; + ++it; + } + return true; + } else if(depth == 16) + { quint16 *dst = reinterpret_cast<quint16 *>(buff); while (!it.isDone()) { const quint16 *d = reinterpret_cast<const quint16 *>(it.rawData()); @@ -125,11 +145,13 @@ } // Save colorspace information uint16 color_type; - if(!writeColorSpaceInformation(image(), pd->colorSpace(), color_type)) + uint16 sample_format; + if(!writeColorSpaceInformation(image(), pd->colorSpace(), color_type, sample_format)) { // unsupported colorspace return false; } TIFFSetField(image(), TIFFTAG_PHOTOMETRIC, color_type); + TIFFSetField(image(), TIFFTAG_SAMPLEFORMAT, sample_format); TIFFSetField(image(), TIFFTAG_IMAGEWIDTH, layer->image()->width()); TIFFSetField(image(), TIFFTAG_IMAGELENGTH, layer->image()->height());
SVN commit 595862 by berger: - fix doesn't allow to use the float predictor for int images (bug #135649) - allow reading and writing of float tiff BUG:135649 M +27 -7 kis_tiff_converter.cc M +17 -2 kis_tiff_export.cc M +26 -0 kis_tiff_reader.cc M +10 -10 kis_tiff_reader.h M +26 -3 kis_tiff_writer_visitor.cpp --- branches/koffice/1.6/koffice/filters/krita/tiff/kis_tiff_converter.cc #595861:595862 @@ -49,7 +49,7 @@ namespace { - QString getColorSpaceForColorType(uint16 color_type, uint16 color_nb_bits, TIFF *image, uint16 &nbchannels, uint16 &extrasamplescount, uint8 &destDepth) { + QString getColorSpaceForColorType(uint16 color_type, uint16 color_nb_bits, TIFF *image, uint16 &nbchannels, uint16 &extrasamplescount, uint8 &destDepth, uint16 sampletype) { if(color_type == PHOTOMETRIC_MINISWHITE || color_type == PHOTOMETRIC_MINISBLACK) { if(nbchannels == 0) nbchannels = 1; @@ -65,13 +65,26 @@ } else if(color_type == PHOTOMETRIC_RGB /*|| color_type == */ ) { if(nbchannels == 0) nbchannels = 3; extrasamplescount = nbchannels - 3; // FIX the extrasamples count in case of - if(color_nb_bits <= 8) + if(sampletype == SAMPLEFORMAT_IEEEFP) { - destDepth = 8; - return "RGBA"; + if(color_nb_bits == 16) + { + destDepth = 16; + return "RGBAF16HALF"; + } else if( color_nb_bits == 32) { + destDepth = 32; + return "RGBAF32"; + } + return ""; } else { - destDepth = 16; - return "RGBA16"; + if(color_nb_bits <= 8) + { + destDepth = 8; + return "RGBA"; + } else { + destDepth = 16; + return "RGBA16"; + } } } else if(color_type == PHOTOMETRIC_YCBCR ) { if(nbchannels == 0) nbchannels = 3; @@ -190,6 +203,11 @@ kdDebug(41008) << "Image does not define its depth" << endl; depth = 1; } + uint16 sampletype; + if((TIFFGetField(image, TIFFTAG_SAMPLEFORMAT, &sampletype) == 0)){ + kdDebug(41008) << "Image does not define its sample type" << endl; + sampletype = SAMPLEFORMAT_UINT; + } // Determine the number of channels (usefull to know if a file has an alpha or not uint16 nbchannels; if(TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &nbchannels) == 0){ @@ -209,7 +227,7 @@ color_type = PHOTOMETRIC_MINISWHITE; } uint8 dstDepth; - QString csName = getColorSpaceForColorType(color_type, depth, image, nbchannels, extrasamplescount, dstDepth); + QString csName = getColorSpaceForColorType(color_type, depth, image, nbchannels, extrasamplescount, dstDepth,sampletype); if(csName.isEmpty()) { kdDebug(41008) << "Image has an unsupported colorspace : " << color_type << " for this depth : "<< depth << endl; TIFFClose(image); @@ -419,6 +437,8 @@ tiffReader = new KisTIFFReaderTarget8bit( layer->paintDevice(), poses, alphapos, depth, nbcolorsamples, extrasamplescount, transform, postprocessor); } else if(dstDepth == 16) { tiffReader = new KisTIFFReaderTarget16bit( layer->paintDevice(), poses, alphapos, depth, nbcolorsamples, extrasamplescount, transform, postprocessor); + } else if(dstDepth == 32) { + tiffReader = new KisTIFFReaderTarget32bit( layer->paintDevice(), poses, alphapos, depth, nbcolorsamples, extrasamplescount, transform, postprocessor); } if(TIFFIsTiled(image)) --- branches/koffice/1.6/koffice/filters/krita/tiff/kis_tiff_export.cc #595861:595862 @@ -23,6 +23,7 @@ #include <qslider.h> #include <kapplication.h> +#include <kcombobox.h> #include <kdialogbase.h> #include <kgenericfactory.h> @@ -59,6 +60,17 @@ KisDlgOptionsTIFF* kdb = new KisDlgOptionsTIFF(0, "options dialog for tiff"); + KisDoc *output = dynamic_cast<KisDoc*>(m_chain->inputDocument()); + + KisColorSpace* cs = output->currentImage()->colorSpace(); + KisChannelInfo::enumChannelValueType type = cs->channels()[0]->channelValueType(); + if( type == KisChannelInfo::FLOAT16 || type == KisChannelInfo::FLOAT32) + { + kdb->optionswdg->kComboBoxPredictor->removeItem(1); + } else { + kdb->optionswdg->kComboBoxPredictor->removeItem(2); + } + if(kdb->exec() == QDialog::Rejected) { return KoFilter::OK; // FIXME Cancel doesn't exist :( @@ -66,9 +78,12 @@ KisTIFFOptions options = kdb->options(); + if( ( type == KisChannelInfo::FLOAT16 || type == KisChannelInfo::FLOAT32) && options.predictor == 2 ) + { // FIXME THIS IS AN HACK FIX THAT IN 2.0 !! + options.predictor = 3; + } delete kdb; - - KisDoc *output = dynamic_cast<KisDoc*>(m_chain->inputDocument()); + QString filename = m_chain->outputFile(); if (!output) --- branches/koffice/1.6/koffice/filters/krita/tiff/kis_tiff_reader.cc #595861:595862 @@ -79,6 +79,32 @@ return 1; } + uint KisTIFFReaderTarget32bit::copyDataToChannels( Q_UINT32 x, Q_UINT32 y, Q_UINT32 dataWidth, TIFFStreamBase* tiffstream) + { + KisHLineIterator it = paintDevice() -> createHLineIterator(x, y, dataWidth, true); + double coeff = Q_UINT32_MAX / (double)( pow(2, sourceDepth() ) - 1 ); +// kdDebug(41008) << " depth expension coefficient : " << coeff << endl; + while (!it.isDone()) { + Q_UINT32 *d = reinterpret_cast<Q_UINT32 *>(it.rawData()); + Q_UINT8 i; + for(i = 0; i < nbColorsSamples(); i++) + { + d[poses()[i]] = (Q_UINT32)( tiffstream->nextValue() * coeff ); + } + postProcessor()->postProcess32bit( d); + if(transform()) cmsDoTransform(transform(), d, d, 1); + d[poses()[i]] = Q_UINT32_MAX; + for(int k = 0; k < nbExtraSamples(); k++) + { + if(k == alphaPos()) + d[poses()[i]] = (Q_UINT32) ( tiffstream->nextValue() * coeff ); + else + tiffstream->nextValue(); + } + ++it; + } + return 1; + } uint KisTIFFReaderFromPalette::copyDataToChannels(Q_UINT32 x, Q_UINT32 y, Q_UINT32 dataWidth, TIFFStreamBase* tiffstream) { KisHLineIterator it = paintDevice() -> createHLineIterator(x, y, dataWidth, true); --- branches/koffice/1.6/koffice/filters/krita/tiff/kis_tiff_reader.h #595861:595862 @@ -181,6 +181,16 @@ virtual uint copyDataToChannels( Q_UINT32 x, Q_UINT32 y, Q_UINT32 dataWidth, TIFFStreamBase* tiffstream) ; }; +class KisTIFFReaderTarget32bit : public KisTIFFReaderBase { + public: + KisTIFFReaderTarget32bit( KisPaintDeviceSP device, Q_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor) : KisTIFFReaderBase(device, poses, alphapos, sourceDepth, nbcolorssamples, extrasamplescount, transformProfile, postprocessor ) + { + + } + public: + virtual uint copyDataToChannels( Q_UINT32 x, Q_UINT32 y, Q_UINT32 dataWidth, TIFFStreamBase* tiffstream) ; +}; + class KisTIFFReaderFromPalette : public KisTIFFReaderBase { public: KisTIFFReaderFromPalette( KisPaintDeviceSP device, uint16 *red, uint16 *green, uint16 *blue, Q_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor) : KisTIFFReaderBase(device, poses, alphapos, sourceDepth, nbcolorssamples, extrasamplescount, transformProfile, postprocessor ), m_red(red), m_green(green), m_blue(blue) @@ -193,14 +203,4 @@ uint16 *m_red, *m_green, *m_blue; }; -// class KisTIFFReaderBaseTarget32bit { -// public: -// KisTIFFReaderBaseTarget32bit( int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, Q_UINT8* poses, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor postprocessor) : KisTiffReader(alphapos, sourceDepth, nbcolorssamples, extrasamplescount, poses, transformProfile, postprocessor ) -// { -// -// } -// public: -// virtual void copyDataToChannels( KisHLineIterator it, TIFFStream* tiffstream) =0; -// }; - #endif --- branches/koffice/1.6/koffice/filters/krita/tiff/kis_tiff_writer_visitor.cpp #595861:595862 @@ -32,8 +32,9 @@ #include "kis_tiff_converter.h" namespace { - bool writeColorSpaceInformation( TIFF* image, KisColorSpace * cs, uint16& color_type ) + bool writeColorSpaceInformation( TIFF* image, KisColorSpace * cs, uint16& color_type, uint16& sample_format ) { + sample_format = SAMPLEFORMAT_UINT; if ( cs->id() == KisID("GRAYA") || cs->id() == KisID("GRAYA16") ) { color_type = PHOTOMETRIC_MINISBLACK; @@ -44,6 +45,12 @@ color_type = PHOTOMETRIC_RGB; return true; } + if ( cs->id() == KisID("RGBAF16HALF") || cs->id() == KisID("RGBAF32") ) + { + color_type = PHOTOMETRIC_RGB; + sample_format = SAMPLEFORMAT_IEEEFP; + return true; + } if ( cs->id() == KisID("CMYK") || cs->id() == KisID("CMYKA16") ) { color_type = PHOTOMETRIC_SEPARATED; @@ -74,8 +81,22 @@ bool KisTIFFWriterVisitor::copyDataToStrips( KisHLineIterator it, tdata_t buff, uint8 depth, uint8 nbcolorssamples, Q_UINT8* poses) { - if(depth == 16) + if(depth == 32) { + Q_UINT32 *dst = reinterpret_cast<Q_UINT32 *>(buff); + while (!it.isDone()) { + const Q_UINT32 *d = reinterpret_cast<const Q_UINT32 *>(it.rawData()); + int i; + for(i = 0; i < nbcolorssamples; i++) + { + *(dst++) = d[poses[i]]; + } + if(saveAlpha()) *(dst++) = d[poses[i]]; + ++it; + } + return true; + } else if(depth == 16) + { Q_UINT16 *dst = reinterpret_cast<Q_UINT16 *>(buff); while (!it.isDone()) { const Q_UINT16 *d = reinterpret_cast<const Q_UINT16 *>(it.rawData()); @@ -125,11 +146,13 @@ } // Save colorspace information uint16 color_type; - if(!writeColorSpaceInformation(image(), pd->colorSpace(), color_type)) + uint16 sample_format; + if(!writeColorSpaceInformation(image(), pd->colorSpace(), color_type, sample_format)) { // unsupported colorspace return false; } TIFFSetField(image(), TIFFTAG_PHOTOMETRIC, color_type); + TIFFSetField(image(), TIFFTAG_SAMPLEFORMAT, sample_format); TIFFSetField(image(), TIFFTAG_IMAGEWIDTH, layer->image()->width()); TIFFSetField(image(), TIFFTAG_IMAGELENGTH, layer->image()->height());
You need to log in before you can comment on or make changes to this bug.