forked from roniemartinez/libqpsd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qpsdhandler.h
111 lines (101 loc) · 4.74 KB
/
qpsdhandler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
Copyright (c) 2012-2018 Ronie Martinez ([email protected])
All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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 Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#ifndef QPSDHANDLER_H
#define QPSDHANDLER_H
#include <QImageIOHandler>
#include <QImage>
#include <QColor>
#include <QVariant>
#include <qmath.h>
class QPsdHandler : public QImageIOHandler
{
public:
QPsdHandler();
~QPsdHandler();
bool canRead() const;
bool read(QImage *image);
//bool write(const QImage &image);
static bool canRead(QIODevice *device);
QVariant option(ImageOption option) const;
//void setOption(ImageOption option, const QVariant &value);
bool supportsOption(ImageOption option) const;
private:
bool isValidSignature(quint32 signature);
bool isValidVersion(quint16 version);
bool isChannelCountSupported(quint16 channel);
bool isValidWidthOrHeight(quint16 version, quint32 value);
bool isSupportedDepth(quint16 depth);
bool isSupportedColorMode(quint16 colorMode);
QByteArray readColorData(QDataStream& input);
void skipImageResources(QDataStream& input);
void skipLayerAndMaskSection(QDataStream& input);
enum Compression {
RAW = 0,
RLE = 1,
ZIP_WITHOUT_PREDICTION = 2,
ZIP_WITH_PREDICTION = 3
};
QByteArray readImageData(QDataStream& input, Compression compression, quint64 size=0);
enum ColorMode {
BITMAP = 0,
GRAYSCALE = 1,
INDEXED = 2,
RGB = 3,
CMYK = 4,
MULTICHANNEL = 7,
DUOTONE = 8,
LAB = 9,
};
QImage processBitmap(QByteArray& imageData, quint32 width, quint32 height);
QImage processGrayscale8(QByteArray& imageData, quint32 width, quint32 height);
QImage processGrayscale8WithAlpha(QByteArray& imageData, quint32 width, quint32 height,
quint64 totalBytesPerChannel);
QImage processGrayscale16(QByteArray& imageData, quint32 width, quint32 height);
QImage processGrayscale16WithAlpha(QByteArray& imageData, quint32 width, quint32 height,
quint64 totalBytesPerChannel);
QImage processIndexed(QByteArray& colorData, QByteArray& imageData, quint32 width,
quint32 height);
QImage processRGB8(QByteArray& imageData, quint32 width, quint32 height,
quint64 totalBytesPerChannel);
QImage processRGB16(QByteArray& imageData, quint32 width, quint32 height,
quint64 totalBytesPerChannel);
QImage processRGB8WithAlpha(QByteArray& imageData, quint32 width, quint32 height,
quint64 totalBytesPerChannel);
QImage processRGB16WithAlpha(QByteArray& imageData, quint32 width, quint32 height,
quint64 totalBytesPerChannel);
QImage processCMY8(QByteArray& imageData, quint32 width, quint32 height,
quint64 totalBytesPerChannel);
QImage processCMYK8(QByteArray& imageData, quint32 width, quint32 height,
quint64 totalBytesPerChannel);
QImage processCMYK8WithAlpha(QByteArray& imageData, quint32 width, quint32 height,
quint64 totalBytesPerChannel);
QImage processCMYK16(QByteArray& imageData, quint32 width, quint32 height,
quint64 totalBytesPerChannel);
QImage processCMYK16WithAlpha(QByteArray& imageData, quint32 width, quint32 height,
quint64 totalBytesPerChannel);
QImage processDuotone(QByteArray& imageData, quint32 width, quint32 height);
QImage processLAB8(QByteArray& imageData, quint32 width, quint32 height,
quint64 totalBytesPerChannel);
QImage processLAB8WithAlpha(QByteArray& imageData, quint32 width, quint32 height,
quint64 totalBytesPerChannel);
QImage processLAB16(QByteArray& imageData, quint32 width, quint32 height,
quint64 totalBytesPerChannel);
QImage processLAB16WithAlpha(QByteArray& imageData, quint32 width, quint32 height,
quint64 totalBytesPerChannel);
};
#endif // QPSDHANDLER_H