File indexing completed on 2024-05-12 15:59:40

0001 /*
0002  *  SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@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_PIXEL_UTILS_H
0009 #define __PSD_PIXEL_UTILS_H
0010 
0011 #include "kritapsd_export.h"
0012 
0013 #include <QRect>
0014 #include <QVector>
0015 #include <psd.h>
0016 
0017 #include "kis_types.h"
0018 
0019 class QIODevice;
0020 struct ChannelInfo;
0021 struct ChannelWritingInfo;
0022 
0023 namespace PsdPixelUtils
0024 {
0025 struct KRITAPSD_EXPORT ChannelWritingInfo {
0026     ChannelWritingInfo()
0027         : channelId(0)
0028         , sizeFieldOffset(-1)
0029         , rleBlockOffset(-1)
0030     {
0031     }
0032     ChannelWritingInfo(qint16 _channelId, int _sizeFieldOffset)
0033         : channelId(_channelId)
0034         , sizeFieldOffset(_sizeFieldOffset)
0035         , rleBlockOffset(-1)
0036     {
0037     }
0038     ChannelWritingInfo(qint16 _channelId, int _sizeFieldOffset, int _rleBlockOffset)
0039         : channelId(_channelId)
0040         , sizeFieldOffset(_sizeFieldOffset)
0041         , rleBlockOffset(_rleBlockOffset)
0042     {
0043     }
0044 
0045     qint16 channelId;
0046     int sizeFieldOffset;
0047     int rleBlockOffset;
0048 };
0049 
0050 void KRITAPSD_EXPORT readChannels(QIODevice &io,
0051                                   KisPaintDeviceSP device,
0052                                   psd_color_mode colorMode,
0053                                   int channelSize,
0054                                   const QRect &layerRect,
0055                                   QVector<ChannelInfo *> infoRecords,
0056                                   psd_byte_order byteOrder = psd_byte_order::psdBigEndian);
0057 
0058 void KRITAPSD_EXPORT readAlphaMaskChannels(QIODevice &io,
0059                                            KisPaintDeviceSP device,
0060                                            int channelSize,
0061                                            const QRect &layerRect,
0062                                            QVector<ChannelInfo *> infoRecords,
0063                                            psd_byte_order byteOrder = psd_byte_order::psdBigEndian);
0064 
0065 void KRITAPSD_EXPORT writeChannelDataRLE(QIODevice &io,
0066                                          const quint8 *plane,
0067                                          const int channelSize,
0068                                          const QRect &rc,
0069                                          const qint64 sizeFieldOffset,
0070                                          const qint64 rleBlockOffset,
0071                                          const bool writeCompressionType,
0072                                          psd_byte_order byteOrder = psd_byte_order::psdBigEndian);
0073 
0074 void KRITAPSD_EXPORT writePixelDataCommon(QIODevice &io,
0075                                           KisPaintDeviceSP dev,
0076                                           const QRect &rc,
0077                                           psd_color_mode colorMode,
0078                                           int channelSize,
0079                                           bool alphaFirst,
0080                                           const bool writeCompressionType,
0081                                           QVector<ChannelWritingInfo> &writingInfoList,
0082                                           psd_compression_type compressionType,
0083                                           psd_byte_order byteOrder = psd_byte_order::psdBigEndian);
0084 }
0085 
0086 #endif /* __PSD_PIXEL_UTILS_H */