File indexing completed on 2024-12-22 04:15:56
0001 /* 0002 * SPDX-FileCopyrightText: 2005-2006 Cyrille Berger <cberger@cberger.net> 0003 * SPDX-FileCopyrightText: 2021 L. E. Segovia <amy@amyspark.me> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "kis_tiff_converter.h" 0009 0010 #include <tiffio.h> 0011 0012 #include <kis_properties_configuration.h> 0013 #include <psd.h> 0014 0015 KisPropertiesConfigurationSP KisTIFFOptions::toProperties() const 0016 { 0017 QHash<int, int> compToIndex; 0018 compToIndex[COMPRESSION_NONE] = 0; 0019 compToIndex[COMPRESSION_JPEG] = 1; 0020 compToIndex[COMPRESSION_ADOBE_DEFLATE] = 2; 0021 compToIndex[COMPRESSION_LZW] = 3; 0022 compToIndex[COMPRESSION_PIXARLOG] = 8; 0023 0024 const QHash<quint16, int> psdCompToIndex = { 0025 {psd_compression_type::RLE, 0}, 0026 {psd_compression_type::ZIP, 1}, 0027 }; 0028 0029 KisPropertiesConfigurationSP cfg = new KisPropertiesConfiguration(); 0030 0031 cfg->setProperty("compressiontype", compToIndex.value(compressionType, 0)); 0032 cfg->setProperty("predictor", predictor - 1); 0033 cfg->setProperty("alpha", alpha); 0034 cfg->setProperty("psdCompressionType", 0035 psdCompToIndex.value(psdCompressionType, 0)); 0036 cfg->setProperty("saveAsPhotoshop", saveAsPhotoshop); 0037 cfg->setProperty("flatten", flatten); 0038 cfg->setProperty("quality", jpegQuality); 0039 cfg->setProperty("deflate", deflateCompress); 0040 cfg->setProperty("pixarlog", pixarLogCompress); 0041 cfg->setProperty("saveProfile", saveProfile); 0042 0043 return cfg; 0044 } 0045 0046 void KisTIFFOptions::fromProperties(KisPropertiesConfigurationSP cfg) 0047 { 0048 QHash<int, int> indexToComp; 0049 indexToComp[0] = COMPRESSION_NONE; 0050 indexToComp[1] = COMPRESSION_JPEG; 0051 indexToComp[2] = COMPRESSION_ADOBE_DEFLATE; 0052 indexToComp[3] = COMPRESSION_LZW; 0053 indexToComp[4] = COMPRESSION_PIXARLOG; 0054 0055 // old value that might be still stored in a config (remove after Krita 5.0 0056 // :) ) 0057 indexToComp[8] = COMPRESSION_PIXARLOG; 0058 0059 const QHash<int, quint16> psdIndexToComp = { 0060 {0, psd_compression_type::RLE}, 0061 {1, psd_compression_type::ZIP}, 0062 }; 0063 0064 compressionType = static_cast<quint16>( 0065 indexToComp.value(cfg->getInt("compressiontype", 0), COMPRESSION_NONE)); 0066 0067 predictor = static_cast<quint16>(cfg->getInt("predictor", 0)) + 1; 0068 alpha = cfg->getBool("alpha", false); 0069 saveAsPhotoshop = cfg->getBool("saveAsPhotoshop", false); 0070 psdCompressionType = 0071 psdIndexToComp.value(cfg->getInt("psdCompressionType", 0), 0072 psd_compression_type::RLE); 0073 flatten = cfg->getBool("flatten", true); 0074 jpegQuality = static_cast<quint16>(cfg->getInt("quality", 80)); 0075 deflateCompress = static_cast<quint16>(cfg->getInt("deflate", 6)); 0076 pixarLogCompress = static_cast<quint16>(cfg->getInt("pixarlog", 6)); 0077 saveProfile = cfg->getBool("saveProfile", true); 0078 }