1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 #ifndef SCIMAGESTRUCTS_H
8 #define SCIMAGESTRUCTS_H
9 
10 #include <QImage>
11 #include <QList>
12 #include <QMap>
13 #include <QString>
14 
15 #include "fpointarray.h"
16 #include "sccolor.h"
17 
18 class ScImageCacheProxy;
19 
20 struct ImageLoadRequest
21 {
22 	bool visible;
23 	bool useMask;
24 	ushort opacity;
25 	QString blend;
26 	bool operator==(const ImageLoadRequest &rhs) const
27 	{
28 		return visible == rhs.visible && useMask == rhs.useMask && opacity == rhs.opacity && blend == rhs.blend;
29 	}
30 };
31 
32 struct ImageEffect
33 {
34 	enum EffectCode
35 	{
36 		EF_INVERT = 0,
37 		EF_GRAYSCALE = 1,
38 		EF_COLORIZE = 2,
39 		EF_BRIGHTNESS = 3,
40 		EF_CONTRAST = 4,
41 		EF_SHARPEN = 5,
42 		EF_BLUR = 6,
43 		EF_SOLARIZE = 7,
44 		EF_DUOTONE = 8,
45 		EF_TRITONE = 9,
46 		EF_QUADTONE = 10,
47 		EF_GRADUATE = 11
48 	};
49 
50 	int effectCode;
51 	QString effectParameters;
52 };
53 
54 class ScImageEffectList : public QList<ImageEffect>
55 {
56 public:
useColorEffect()57 	bool useColorEffect() const
58 	{
59 		int effectCount = this->count();
60 		if (effectCount <= 0)
61 			return false;
62 
63 		for (int i = 0; i < effectCount; ++i)
64 		{
65 			const auto& effect = at(i);
66 			if (effect.effectCode == ImageEffect::EF_COLORIZE)
67 				return true;
68 			if (effect.effectCode == ImageEffect::EF_DUOTONE)
69 				return true;
70 			if (effect.effectCode == ImageEffect::EF_TRITONE)
71 				return true;
72 			if (effect.effectCode == ImageEffect::EF_QUADTONE)
73 				return true;
74 		}
75 		return false;
76 	}
77 };
78 
79 struct PSDHeader
80 {
81 	uint signature;
82 	ushort version;
83 	uchar reserved[6];
84 	ushort channel_count;
85 	uint height;
86 	uint width;
87 	ushort depth;
88 	ushort color_mode;
89 };
90 
91 struct PSDLayer
92 {
93 	QList<uint> channelLen;
94 	QList<int> channelType;
95 	int xpos;
96 	int ypos;
97 	int width;
98 	int height;
99 	ushort opacity;
100 	uchar clipping;
101 	uchar flags;
102 	int maskXpos;
103 	int maskYpos;
104 	int maskWidth;
105 	int maskHeight;
106 	QString layerName;
107 	QString blend;
108 	QImage thumb;
109 	QImage thumb_mask;
110 };
111 
112 struct PSDDuotone_Color
113 {
114 	QString Name;
115 	ScColor Color;
116 	FPointArray Curve;
117 };
118 
119 class ExifValues
120 {
121 public:
122 	ExifValues();
123 	void init();
124 
125 	// Remember to increment this version number and update
126 	// the QDataStream operators if this class in changed.
127 	static const qint32 dsVersion;
128 
129 	int width;
130 	int height;
131 	int   orientation;
132 	float ExposureTime;
133 	float ApertureFNumber;
134 	int   ISOequivalent;
135 	QString cameraName;
136 	QString cameraVendor;
137 	QString comment;
138 	QString userComment;
139 	QString artist;
140 	QString copyright;
141 	QString dateTime;
142 	QImage thumbnail;
143 };
144 
145 typedef enum
146 {
147 	ImageTypeJPG = 0,
148 	ImageTypeTIF = 1,
149 	ImageTypePSD = 2,
150 	ImageTypeEPS = 3,
151 	ImageTypePDF = 4,
152 	ImageTypeJPG2K = 5,
153 	ImageTypeOther = 6,
154 	ImageType7 = 7
155 } ImageTypeEnum;
156 
157 typedef enum
158 {
159 	ColorSpaceRGB  = 0,
160 	ColorSpaceCMYK = 1,
161 	ColorSpaceGray = 2,
162 	ColorSpaceDuotone = 3,
163 	ColorSpaceMonochrome = 4
164 } ColorSpaceEnum;
165 
166 class ImageInfoRecord
167 {
168 public:
169 	ImageInfoRecord();
170 	void init();
171 
172 	// Remember to increment this version number and update
173 	// the serialization routines if this class in changed.
174 	static const int iirVersion;
175 
176 	bool canSerialize() const;
177 	bool serialize(ScImageCacheProxy & cache) const;
178 	bool deserialize(const ScImageCacheProxy & cache);
179 
180 	ImageTypeEnum type;			/* 0 = jpg, 1 = tiff, 2 = psd, 3 = eps/ps, 4 = pdf, 5 = jpg2000, 6 = other */
181 	int  xres;
182 	int  yres;
183 	int  BBoxX;
184 	int  BBoxH;
185 	ColorSpaceEnum colorspace; /* 0 = RGB  1 = CMYK  2 = Grayscale 3 = Duotone */
186 	bool valid;
187 	bool isRequest;
188 	bool progressive;
189 	bool isEmbedded;
190 	bool exifDataValid;
191 	int  lowResType; /* 0 = full Resolution, 1 = 72 dpi, 2 = 36 dpi */
192 	double lowResScale;
193 	int numberOfPages;
194 	int actualPageNumber;
195 	QMap<QString, FPointArray> PDSpathData;
196 	QMap<int, ImageLoadRequest> RequestProps;
197 	QString clipPath;
198 	QString usedPath;
199 	QString profileName;
200 	QString embeddedProfileName;
201 	QList<PSDLayer> layerInfo;
202 	QList<PSDDuotone_Color> duotoneColors;
203 	ExifValues exifInfo;
204 };
205 
206 #endif
207