diff --git a/plugins/impex/tiff/kis_tiff_export.cc b/plugins/impex/tiff/kis_tiff_export.cc index e6c3f7ba3f..1bf81d4965 100644 --- a/plugins/impex/tiff/kis_tiff_export.cc +++ b/plugins/impex/tiff/kis_tiff_export.cc @@ -1,135 +1,144 @@ /* * Copyright (c) 2005 Cyrille Berger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kis_tiff_export.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include +#include "kis_layer_utils.h" #include "kis_tiff_converter.h" #include "kis_dlg_options_tiff.h" #include "ui_kis_wdg_options_tiff.h" K_PLUGIN_FACTORY_WITH_JSON(KisTIFFExportFactory, "krita_tiff_export.json", registerPlugin();) KisTIFFExport::KisTIFFExport(QObject *parent, const QVariantList &) : KisImportExportFilter(parent) { } KisTIFFExport::~KisTIFFExport() { } KisImportExportFilter::ConversionStatus KisTIFFExport::convert(KisDocument *document, QIODevice */*io*/, KisPropertiesConfigurationSP configuration) { // If a configuration object was passed to the convert method, we use that, otherwise we load from the settings KisPropertiesConfigurationSP cfg(new KisPropertiesConfiguration()); if (configuration) { cfg->fromXML(configuration->toXML()); } else { cfg = lastSavedConfiguration(KisDocument::nativeFormatMimeType(), "image/tiff"); } const KoColorSpace* cs = document->savingImage()->colorSpace(); cfg->setProperty("type", (int)cs->channels()[0]->channelValueType()); cfg->setProperty("isCMYK", (cs->colorModelId() == CMYKAColorModelID)); KisTIFFOptions options; options.fromProperties(configuration); + if (!options.flatten) { + const bool hasGroupLayers = + KisLayerUtils::recursiveFindNode(document->savingImage()->root(), + [] (KisNodeSP node) { + return node->parent() && node->inherits("KisGroupLayer"); + }); + options.flatten = hasGroupLayers; + } + if ((cs->channels()[0]->channelValueType() == KoChannelInfo::FLOAT16 || cs->channels()[0]->channelValueType() == KoChannelInfo::FLOAT32) && options.predictor == 2) { // FIXME THIS IS AN HACK FIX THAT IN 2.0 !! (62456a7b47636548c6507593df3e2bdf440f7544, BUG:135649) options.predictor = 3; } KisImageSP image; if (options.flatten) { image = new KisImage(0, document->savingImage()->width(), document->savingImage()->height(), document->savingImage()->colorSpace(), ""); image->setResolution(document->savingImage()->xRes(), document->savingImage()->yRes()); KisPaintDeviceSP pd = KisPaintDeviceSP(new KisPaintDevice(*document->savingImage()->projection())); KisPaintLayerSP l = KisPaintLayerSP(new KisPaintLayer(image.data(), "projection", OPACITY_OPAQUE_U8, pd)); image->addNode(KisNodeSP(l.data()), image->rootLayer().data()); } else { image = document->savingImage(); } KisTIFFConverter tiffConverter(document); KisImageBuilder_Result res; if ((res = tiffConverter.buildFile(filename(), image, options)) == KisImageBuilder_RESULT_OK) { dbgFile << "success !"; return KisImportExportFilter::OK; } dbgFile << " Result =" << res; return KisImportExportFilter::InternalError; } KisPropertiesConfigurationSP KisTIFFExport::defaultConfiguration(const QByteArray &/*from*/, const QByteArray &/*to*/) const { KisTIFFOptions options; return options.toProperties(); } KisConfigWidget *KisTIFFExport::createConfigurationWidget(QWidget *parent, const QByteArray &/*from*/, const QByteArray &/*to*/) const { return new KisTIFFOptionsWidget(parent); } void KisTIFFExport::initializeCapabilities() { - addCapability(KisExportCheckRegistry::instance()->get("NodeTypeCheck/KisGroupLayer")->create(KisExportCheckBase::UNSUPPORTED)); addCapability(KisExportCheckRegistry::instance()->get("MultiLayerCheck")->create(KisExportCheckBase::SUPPORTED)); addCapability(KisExportCheckRegistry::instance()->get("sRGBProfileCheck")->create(KisExportCheckBase::SUPPORTED)); QList > supportedColorModels; supportedColorModels << QPair() << QPair(RGBAColorModelID, Integer8BitsColorDepthID) << QPair(RGBAColorModelID, Integer16BitsColorDepthID) << QPair(RGBAColorModelID, Float16BitsColorDepthID) << QPair(RGBAColorModelID, Float32BitsColorDepthID) << QPair(GrayAColorModelID, Integer8BitsColorDepthID) << QPair(GrayAColorModelID, Integer16BitsColorDepthID) << QPair(CMYKAColorModelID, Integer8BitsColorDepthID) << QPair(CMYKAColorModelID, Integer16BitsColorDepthID) << QPair(LABAColorModelID, Integer16BitsColorDepthID); addSupportedColorModels(supportedColorModels, "TIFF"); } #include