Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_tiff_psd_resource_record.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2009 Boudewijn Rempt <boud@valdyas.org>
3 * SPDX-FileCopyrightText: 2021 L. E. Segovia <amy@amyspark.me>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
8
9#include <QBuffer>
10#include <QIODevice>
11#include <algorithm>
12#include <kis_debug.h>
13#include <psd_resource_block.h>
14#include <psd_utils.h>
15
19
24
26{
27 // Unlike its PSD counterpart (PSDResourceSection), TIFF resource
28 // records are just a concatenation of resource blocks.
29
30 while (!buf.atEnd()) {
32 if (!block->read(buf)) {
33 error = "Error reading block: " + block->error;
34 dbgFile << error << ", skipping.";
35 delete block;
36 continue;
37 }
38 dbgFile << "resource block created. Type:" << block->identifier << "name" << block->name << "size" << block->dataSize << "," << buf.bytesAvailable()
39 << "bytes to go";
40
41 resources[(PSDResourceID)block->identifier] = block;
42 }
43
44 dbgFile << "Read" << resources.size() << "Image Resource Blocks";
45
46 return valid();
47}
48
50{
51 if (!valid()) {
52 error = "Resource Section is Invalid";
53 return false;
54 }
55 // write all the sections
56 QBuffer buf;
57 buf.open(QBuffer::WriteOnly);
58
59 for (const PSDResourceBlock *block : resources) {
60 if (!block->write(buf)) {
61 error = block->error;
62 return false;
63 }
64 }
65
66 buf.close();
67
68 // Then get the size
69 qint64 resourceSectionLength = buf.size();
70 dbgFile << "resource section has size" << resourceSectionLength;
71
72 // and write the whole buffer
73 return (io.write(buf.data()) == resourceSectionLength);
74}
75
77{
78 return true;
79}
80
82{
83 switch (id) {
84 case UNKNOWN:
85 return "Unknown";
86
87 case PS2_IMAGE_INFO:
88 return "0x03e8 - Obsolete - ps 2.0 image info";
89 case MAC_PRINT_INFO:
90 return "0x03e9 - Optional - Mac print manager print info record";
91 case PS2_COLOR_TAB:
92 return "0x03eb - Obsolete - ps 2.0 indexed color table";
93 case RESN_INFO:
94 return "0x03ed - ResolutionInfo structure";
95 case ALPHA_NAMES:
96 return "0x03ee - Alpha channel names";
97 case DISPLAY_INFO:
98 return "0x03ef - DisplayInfo structure";
99 case CAPTION:
100 return "0x03f0 - Optional - Caption string";
101 case BORDER_INFO:
102 return "0x03f1 - Border info";
103
104 case BACKGROUND_COL:
105 return "0x03f2 - Background color";
106 case PRINT_FLAGS:
107 return "0x03f3 - Print flags";
108 case GREY_HALFTONE:
109 return "0x03f4 - Greyscale and multichannel halftoning info";
110 case COLOR_HALFTONE:
111 return "0x03f5 - Color halftoning info";
112 case DUOTONE_HALFTONE:
113 return "0x03f6 - Duotone halftoning info";
114 case GREY_XFER:
115 return "0x03f7 - Greyscale and multichannel transfer functions";
116 case COLOR_XFER:
117 return "0x03f8 - Color transfer functions";
118 case DUOTONE_XFER:
119 return "0x03f9 - Duotone transfer functions";
120 case DUOTONE_INFO:
121 return "0x03fa - Duotone image information";
122 case EFFECTIVE_BW:
123 return "0x03fb - Effective black & white values for dot range";
124
125 case OBSOLETE_01:
126 return "0x03fc - Obsolete";
127 case EPS_OPT:
128 return "0x03fd - EPS options";
129 case QUICK_MASK:
130 return "0x03fe - Quick mask info";
131 case OBSOLETE_02:
132 return "0x03ff - Obsolete";
133 case LAYER_STATE:
134 return "0x0400 - Layer state info";
135 case WORKING_PATH:
136 return "0x0401 - Working path (not saved)";
137 case LAYER_GROUP:
138 return "0x0402 - Layers group info";
139 case OBSOLETE_03:
140 return "0x0403 - Obsolete";
141 case IPTC_NAA_DATA:
142 return "0x0404 - IPTC-NAA record (IMV4.pdf)";
143 case IMAGE_MODE_RAW:
144 return "0x0405 - Image mode for raw format files";
145
146 case JPEG_QUAL:
147 return "0x0406 - JPEG quality";
148 case GRID_GUIDE:
149 return "0x0408 - Grid & guide info";
150 case THUMB_RES:
151 return "0x0409 - Thumbnail resource";
152 case COPYRIGHT_FLG:
153 return "0x040a - Copyright flag";
154 case URL:
155 return "0x040b - URL string";
156 case THUMB_RES2:
157 return "0x040c - Thumbnail resource";
158 case GLOBAL_ANGLE:
159 return "0x040d - Global angle";
160 case COLOR_SAMPLER:
161 return "0x040e - Color samplers resource";
162 case ICC_PROFILE:
163 return "0x040f - ICC Profile";
164
165 case WATERMARK:
166 return "0x0410 - Watermark";
167 case ICC_UNTAGGED:
168 return "0x0411 - Do not use ICC profile flag";
169 case EFFECTS_VISIBLE:
170 return "0x0412 - Show / hide all effects layers";
171 case SPOT_HALFTONE:
172 return "0x0413 - Spot halftone";
173 case DOC_IDS:
174 return "0x0414 - Document specific IDs";
175 case ALPHA_NAMES_UNI:
176 return "0x0415 - Unicode alpha names";
177 case IDX_COL_TAB_CNT:
178 return "0x0416 - Indexed color table count";
179 case IDX_TRANSPARENT:
180 return "0x0417 - Index of transparent color (if any)";
181 case GLOBAL_ALT:
182 return "0x0419 - Global altitude";
183
184 case SLICES:
185 return "0x041a - Slices";
186 case WORKFLOW_URL_UNI:
187 return "0x041b - Workflow URL - Unicode string";
188 case JUMP_TO_XPEP:
189 return "0x041c - Jump to XPEP (?)";
190 case ALPHA_ID:
191 return "0x041d - Alpha IDs";
192 case URL_LIST_UNI:
193 return "0x041e - URL list - unicode";
194 case VERSION_INFO:
195 return "0x0421 - Version info";
196 case EXIF_DATA:
197 return "0x0422 - (Photoshop 7.0) EXIF data 1. See http://www.kodak.com/global/plugins/acrobat/en/service/digCam/exifStandard2.pdf";
198 case EXIF_DATA_3:
199 return "0x0423 - (Photoshop 7.0) EXIF data 3. See http://www.kodak.com/global/plugins/acrobat/en/service/digCam/exifStandard2.pdf";
200
201 case XMP_DATA:
202 return "0x0424 - XMP data block";
203 case CAPTION_DIGEST:
204 return "0x0425 - (Photoshop 7.0) Caption digest. 16 bytes: RSA Data Security, MD5 message-digest algorithm";
205 case PRINT_SCALE:
206 return "0x0426 - (Photoshop 7.0) Print scale. 2 bytes style (0 = centered, 1 = size to fit, 2 = user defined). 4 bytes x location (floating point). 4 "
207 "bytes y location (floating point). 4 bytes scale (floating point)";
209 return "0x0428 - (Photoshop CS) Pixel Aspect Ratio. 4 bytes (version = 1 or 2), 8 bytes double, x / y of a pixel. Version 2, attempting to correct "
210 "values for NTSC and PAL, previously off by a factor of approx. 5%.";
211 case LAYER_COMPS:
212 return "0x0429 - (Photoshop CS) Layer Comps. 4 bytes (descriptor version = 16), Descriptor (see Descriptor structure)";
214 return "0x042A - (Photoshop CS) Alternate Duotone Colors. 2 bytes (version = 1), 2 bytes count, following is repeated for each count: [ Color: 2 bytes "
215 "for space followed by 4 * 2 byte color component ], following this is another 2 byte count, usually 256, followed by Lab colors one byte each "
216 "for L, a, b. This resource is not read or used by Photoshop.";
217 case ALTERNATE_SPOT:
218 return "0x042B - (Photoshop CS)Alternate Spot Colors. 2 bytes (version = 1), 2 bytes channel count, following is repeated for each count: 4 bytes "
219 "channel ID, Color: 2 bytes for space followed by 4 * 2 byte color component. This resource is not read or used by Photoshop.";
221 return "0x042D - (Photoshop CS2) Layer Selection ID(s). 2 bytes count, following is repeated for each count: 4 bytes layer ID";
222
223 case HDR_TONING:
224 return "0x042E - (Photoshop CS2) HDR Toning information";
225 case CS2_PRINT_INFO:
226 return "0x042F - (Photoshop CS2) Print info";
228 return "0x0430 - (Photoshop CS2) Layer Group(s) Enabled ID. 1 byte for each layer in the document, repeated by length of the resource. NOTE: Layer "
229 "groups have start and end markers";
230 case COLOR_SAMPLERS:
231 return "0x0431 - (Photoshop CS3) Color samplers resource. Also see ID 1038 for old format. See Color samplers resource format.";
233 return "0x0432 - (Photoshop CS3) Measurement Scale. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure)";
234 case TIMELINE_INFO:
235 return "0x0433 - (Photoshop CS3) Timeline Information. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure)";
236 case SHEET_DISCLOSURE:
237 return "0x0434 - (Photoshop CS3) Sheet Disclosure. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure)";
238 case CS3_DISPLAY_INFO:
239 return "0x0435 - (Photoshop CS3) DisplayInfo structure to support floating point colors. Also see ID 1007. See Appendix A in Photoshop API Guide.pdf .";
240 case ONION_SKINS:
241 return "0x0436 - (Photoshop CS3) Onion Skins. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure)";
242
243 case COUNT_INFO:
244 return "0x0438 - (Photoshop CS4) Count Information. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure) Information about the "
245 "count in the document. See the Count Tool.";
246 case CS5_PRINT_INFO:
247 return "0x043A - (Photoshop CS5) Print Information. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure) Information about the "
248 "current print settings in the document. The color management options.";
249 case CS5_PRINT_STYLE:
250 return "0x043B - (Photoshop CS5) Print Style. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure) Information about the "
251 "current print style in the document. The printing marks, labels, ornaments, etc.";
252 case CS5_NSPrintInfo:
253 return "0x043C - (Photoshop CS5) Macintosh NSPrintInfo. Variable OS specific info for Macintosh. NSPrintInfo. It is recommended that you do not "
254 "interpret or use this data.";
255 case CS5_WIN_DEVMODE:
256 return "0x043D - (Photoshop CS5) Windows DEVMODE. Variable OS specific info for Windows. DEVMODE. It is recommended that you do not interpret or use "
257 "this data.";
259 return "0x043E - (Photoshop CS6) Auto Save File Path. Unicode string. It is recommended that you do not interpret or use this data.";
261 return "0x043F - (Photoshop CS6) Auto Save Format. Unicode string. It is recommended that you do not interpret or use this data.";
263 return "0x0440 - (Photoshop CC) Path Selection State. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure) Information about "
264 "the current path selection state.";
265
266 case PATH_INFO_FIRST:
267 return "0x07d0 - First path info block";
268 case PATH_INFO_LAST:
269 return "0x0bb6 - Last path info block";
270 case CLIPPING_PATH:
271 return "0x0bb7 - Name of clipping path";
272
274 return "0x0BB8 (Photoshop CC) Origin Path Info. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure) Information about the "
275 "origin path data.";
276
278 return "0x0FA0-0x1387 Plug-In resource(s). Resources added by a plug-in. See the plug-in API found in the SDK documentation ";
280 return "Last plug-in resource";
281
282 case IMAGE_READY_VARS:
283 return "0x1B58 Image Ready variables. XML representation of variables definition";
285 return "0x1B59 Image Ready data sets";
286
288 return "0x1F40 (Photoshop CS3) Lightroom workflow, if present the document is in the middle of a Lightroom workflow.";
289
290 case PRINT_FLAGS_2:
291 return "0x2710 - Print flags";
292 default: {
293 if (id > PATH_INFO_FIRST && id < PATH_INFO_LAST)
294 return "Path Info Block";
296 return "Plug-In Resource";
297 }
298 };
299 return QString("Unknown Resource Block: %1").arg(id);
300}
static QString idToString(PSDResourceID id)
QMap< PSDResourceID, PSDResourceBlock * > resources
#define dbgFile
Definition kis_debug.h:53