File indexing completed on 2024-06-16 04:17:04

0001 /*
0002  *   SPDX-FileCopyrightText: 2011 Siddharth Sharma <siddharth.kde@gmail.com>
0003  *   SPDX-FileCopyrightText: 2021 L. E. Segovia <amy@amyspark.me>
0004  *
0005  *   SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 
0008 #ifndef PSD_IMAGE_DATA_H
0009 #define PSD_IMAGE_DATA_H
0010 
0011 #include <kis_paint_device.h>
0012 #include <kis_types.h>
0013 
0014 #include <psd.h>
0015 #include <psd_header.h>
0016 #include <compression.h>
0017 #include <psd_layer_record.h>
0018 
0019 #include <QFile>
0020 class QIODevice;
0021 
0022 
0023 class PSDImageData
0024 {
0025 
0026 public:
0027     PSDImageData(PSDHeader *header);
0028     virtual ~PSDImageData();
0029 
0030     bool read(QIODevice &io, KisPaintDeviceSP dev);
0031     bool write(QIODevice &io, KisPaintDeviceSP dev, bool hasAlpha, psd_compression_type compressionType);
0032 
0033     QString error;
0034 
0035 private:
0036     bool readRGB(QIODevice &io, KisPaintDeviceSP dev);
0037     bool readCMYK(QIODevice &io, KisPaintDeviceSP dev);
0038     bool readLAB(QIODevice &io, KisPaintDeviceSP dev);
0039     bool readGrayscale(QIODevice &io, KisPaintDeviceSP dev);
0040 
0041     PSDHeader *m_header {nullptr};
0042 
0043     quint16 m_compression {0};
0044     quint64 m_channelDataLength {0};
0045     quint32 m_channelSize {0};
0046 
0047     QVector<ChannelInfo> m_channelInfoRecords;
0048     QVector<int> m_channelOffsets; // this doesn't need to be global
0049 };
0050 
0051 #endif // PSD_IMAGE_DATA_H