13#include <QLatin1String>
24 uint16_t channelDepth,
26 uint16_t photometricInterpretation,
31 , m_channelDepth(channelDepth)
32 , m_nChannels(nChannels)
33 , m_hasTransparency(hasTransparency)
36 if (photometricInterpretation == PHOTOMETRIC_MINISWHITE || photometricInterpretation == PHOTOMETRIC_MINISBLACK) {
38 }
else if (photometricInterpretation == PHOTOMETRIC_RGB) {
40 }
else if (photometricInterpretation == PHOTOMETRIC_SEPARATED) {
41 dbgFile <<
"PSD warning: assuming CMYK for color separations";
43 }
else if (photometricInterpretation == PHOTOMETRIC_CIELAB || photometricInterpretation == PHOTOMETRIC_ICCLAB) {
45 }
else if (photometricInterpretation == PHOTOMETRIC_PALETTE) {
48 dbgFile <<
"TIFF PSD error: " << photometricInterpretation <<
"does not map to a Photoshop supported mode";
57 return readImpl<psd_byte_order::psdLittleEndian>(io);
67 return writeImpl<psd_byte_order::psdLittleEndian>(io, rootLayer, compressionType);
69 return writeImpl(io, rootLayer, compressionType);
73template<psd_
byte_order
byteOrder>
85 m_record = std::make_shared<PSDLayerMaskSection>(header);
87 QLatin1String signature(
"Adobe Photoshop Document Data Block");
88 QByteArray b = device.read(signature.size() + 1);
89 if (b.size() != signature.size() + 1 || QLatin1String(b) != signature) {
90 m_record->error = QString(
"Invalid Photoshop data block: %1").arg(QLatin1String(b));
106template<psd_
byte_order
byteOrder>
118 m_record = std::make_shared<PSDLayerMaskSection>(header);
122 buf.open(QIODevice::WriteOnly);
124 psdwrite(buf,
"Adobe Photoshop Document Data Block");
127 if (!
m_record->write(buf, rootLayer, compressionType)) {
135 qint64 layerSectionLength = buf.size();
136 dbgFile <<
"layer section has size" << layerSectionLength;
139 return (device.write(buf.data()) == layerSectionLength);
bool readImpl(QIODevice &device)
bool write(QIODevice &io, KisNodeSP rootLayer, psd_compression_type compressionType)
KisTiffPsdLayerRecord(bool isBigEndian, uint32_t width, uint32_t height, uint16_t channelDepth, uint16_t nChannels, uint16_t photometricInterpretation, bool hasTransparency=false)
std::shared_ptr< PSDLayerMaskSection > record() const
bool writeImpl(QIODevice &device, KisNodeSP rootLayer, psd_compression_type compressionType)
std::shared_ptr< PSDLayerMaskSection > m_record
psd_byte_order m_byteOrder
psd_color_mode m_colorMode
bool psdpad(QIODevice &io, quint32 padding)
std::enable_if_t< std::is_arithmetic< T >::value, bool > psdwrite(QIODevice &io, T v)