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

0001 /*
0002  *  SPDX-FileCopyrightText: 2009 Boudewijn Rempt <boud@valdyas.org>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 #ifndef PSD_RESOURCE_SECTION_H
0007 #define PSD_RESOURCE_SECTION_H
0008 
0009 #include "kritapsd_export.h"
0010 
0011 #include <QMap>
0012 #include <QString>
0013 
0014 class QIODevice;
0015 class PSDResourceBlock;
0016 
0017 /**
0018  * loads all the resource sections
0019  */
0020 class KRITAPSD_EXPORT PSDImageResourceSection
0021 {
0022 public:
0023     enum PSDResourceID {
0024         UNKNOWN = 0,
0025 
0026         PS2_IMAGE_INFO = 1000, /* 0x03e8 - Obsolete - ps 2.0 image info */
0027         MAC_PRINT_INFO = 1001, /* 0x03e9 - Optional - Mac print manager print info record */
0028         PS2_COLOR_TAB = 1003, /* 0x03eb - Obsolete - ps 2.0 indexed color table */
0029         RESN_INFO = 1005, /* 0x03ed - ResolutionInfo structure */
0030         ALPHA_NAMES = 1006, /* 0x03ee - Alpha channel names */
0031         DISPLAY_INFO = 1007, /* 0x03ef - DisplayInfo structure */
0032         CAPTION = 1008, /* 0x03f0 - Optional - Caption string */
0033         BORDER_INFO = 1009, /* 0x03f1 - Border info */
0034 
0035         BACKGROUND_COL = 1010, /* 0x03f2 - Background color */
0036         PRINT_FLAGS = 1011, /* 0x03f3 - Print flags */
0037         GREY_HALFTONE = 1012, /* 0x03f4 - Greyscale and multichannel halftoning info */
0038         COLOR_HALFTONE = 1013, /* 0x03f5 - Color halftoning info */
0039         DUOTONE_HALFTONE = 1014, /* 0x03f6 - Duotone halftoning info */
0040         GREY_XFER = 1015, /* 0x03f7 - Greyscale and multichannel transfer functions */
0041         COLOR_XFER = 1016, /* 0x03f8 - Color transfer functions */
0042         DUOTONE_XFER = 1017, /* 0x03f9 - Duotone transfer functions */
0043         DUOTONE_INFO = 1018, /* 0x03fa - Duotone image information */
0044         EFFECTIVE_BW = 1019, /* 0x03fb - Effective black & white values for dot range */
0045 
0046         OBSOLETE_01 = 1020, /* 0x03fc - Obsolete */
0047         EPS_OPT = 1021, /* 0x03fd - EPS options */
0048         QUICK_MASK = 1022, /* 0x03fe - Quick mask info */
0049         OBSOLETE_02 = 1023, /* 0x03ff - Obsolete */
0050         LAYER_STATE = 1024, /* 0x0400 - Layer state info */
0051         WORKING_PATH = 1025, /* 0x0401 - Working path (not saved) */
0052         LAYER_GROUP = 1026, /* 0x0402 - Layers group info */
0053         OBSOLETE_03 = 1027, /* 0x0403 - Obsolete */
0054         IPTC_NAA_DATA = 1028, /* 0x0404 - IPTC-NAA record (IMV4.pdf) */
0055         IMAGE_MODE_RAW = 1029, /* 0x0405 - Image mode for raw format files */
0056 
0057         JPEG_QUAL = 1030, /* 0x0406 - JPEG quality */
0058         GRID_GUIDE = 1032, /* 0x0408 - Grid & guide info */
0059         THUMB_RES = 1033, /* 0x0409 - Thumbnail resource */
0060         COPYRIGHT_FLG = 1034, /* 0x040a - Copyright flag */
0061         URL = 1035, /* 0x040b - URL string */
0062         THUMB_RES2 = 1036, /* 0x040c - Thumbnail resource */
0063         GLOBAL_ANGLE = 1037, /* 0x040d - Global angle */
0064         COLOR_SAMPLER = 1038, /* 0x040e - Color samplers resource */
0065         ICC_PROFILE = 1039, /* 0x040f - ICC Profile */
0066 
0067         WATERMARK = 1040, /* 0x0410 - Watermark */
0068         ICC_UNTAGGED = 1041, /* 0x0411 - Do not use ICC profile flag */
0069         EFFECTS_VISIBLE = 1042, /* 0x0412 - Show / hide all effects layers */
0070         SPOT_HALFTONE = 1043, /* 0x0413 - Spot halftone */
0071         DOC_IDS = 1044, /* 0x0414 - Document specific IDs */
0072         ALPHA_NAMES_UNI = 1045, /* 0x0415 - Unicode alpha names */
0073         IDX_COL_TAB_CNT = 1046, /* 0x0416 - Indexed color table count */
0074         IDX_TRANSPARENT = 1047, /* 0x0417 - Index of transparent color (if any) */
0075         GLOBAL_ALT = 1049, /* 0x0419 - Global altitude */
0076 
0077         SLICES = 1050, /* 0x041a - Slices */
0078         WORKFLOW_URL_UNI = 1051, /* 0x041b - Workflow URL - Unicode string */
0079         JUMP_TO_XPEP = 1052, /* 0x041c - Jump to XPEP (?) */
0080         ALPHA_ID = 1053, /* 0x041d - Alpha IDs */
0081         URL_LIST_UNI = 1054, /* 0x041e - URL list - unicode */
0082         VERSION_INFO = 1057, /* 0x0421 - Version info */
0083         EXIF_DATA = 1058, /* 0x0422 - (Photoshop 7.0) EXIF data 1. See http://www.kodak.com/global/plugins/acrobat/en/service/digCam/exifStandard2.pdf */
0084         EXIF_DATA_3 = 1059, /* 0x0423 - (Photoshop 7.0) EXIF data 3. See http://www.kodak.com/global/plugins/acrobat/en/service/digCam/exifStandard2.pdf */
0085 
0086         XMP_DATA = 1060, /* 0x0424 - XMP data block */
0087         CAPTION_DIGEST = 1061, /* 0x0425 - (Photoshop 7.0) Caption digest. 16 bytes: RSA Data Security, MD5 message-digest algorithm */
0088         PRINT_SCALE = 1062, /* 0x0426 - (Photoshop 7.0) Print scale. 2 bytes style (0 = centered, 1 = size to fit, 2 = user defined). 4 bytes x location
0089                                (floating point). 4 bytes y location (floating point). 4 bytes scale (floating point) */
0090         PIXEL_ASPECT_RATION = 1064, /* 0x0428 - (Photoshop CS) Pixel Aspect Ratio. 4 bytes (version = 1 or 2), 8 bytes double, x / y of a pixel. Version 2,
0091                                        attempting to correct values for NTSC and PAL, previously off by a factor of approx. 5%. */
0092         LAYER_COMPS = 1065, /* 0x0429 - (Photoshop CS) Layer Comps. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure) */
0093         ALTERNATE_DUOTONE = 1066, /* 0x042A - (Photoshop CS) Alternate Duotone Colors. 2 bytes (version = 1), 2 bytes count, following is repeated for each
0094                                      count: [ Color: 2 bytes for space followed by 4 * 2 byte color component ], following this is another 2 byte count, usually
0095                                      256, followed by Lab colors one byte each for L, a, b. This resource is not read or used by Photoshop. */
0096         ALTERNATE_SPOT =
0097             1067, /* 0x042B - (Photoshop CS)Alternate Spot Colors. 2 bytes (version = 1), 2 bytes channel count, following is repeated for each count: 4 bytes
0098                      channel ID, Color: 2 bytes for space followed by 4 * 2 byte color component. This resource is not read or used by Photoshop. */
0099         LAYER_SELECTION_ID = 1069, /* 0x042D - (Photoshop CS2) Layer Selection ID(s). 2 bytes count, following is repeated for each count: 4 bytes layer ID */
0100 
0101         HDR_TONING = 1070, /* 0x042E - (Photoshop CS2) HDR Toning information */
0102         CS2_PRINT_INFO = 1071, /* 0x042F - (Photoshop CS2) Print info */
0103         LAYER_GROUP_ENABLED_ID = 1072, /* 0x0430 - (Photoshop CS2) Layer Group(s) Enabled ID. 1 byte for each layer in the document, repeated by length of the
0104                                           resource. NOTE: Layer groups have start and end markers */
0105         COLOR_SAMPLERS = 1073, /* 0x0431 - (Photoshop CS3) Color samplers resource. Also see ID 1038 for old format. See See Color samplers resource format. */
0106         MEASUREMENT_SCALE = 1074, /* 0x0432 - (Photoshop CS3) Measurement Scale. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure) */
0107         TIMELINE_INFO = 1075, /* 0x0433 - (Photoshop CS3) Timeline Information. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure) */
0108         SHEET_DISCLOSURE = 1076, /* 0x0434 - (Photoshop CS3) Sheet Disclosure. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure) */
0109         CS3_DISPLAY_INFO = 1077, /* 0x0435 - (Photoshop CS3) DisplayInfo structure to support floating point clors. Also see ID 1007. See Appendix A in
0110                                     Photoshop API Guide.pdf . */
0111         ONION_SKINS = 1078, /* 0x0436 - (Photoshop CS3) Onion Skins. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure) */
0112 
0113         COUNT_INFO = 1080, /* 0x0438 - (Photoshop CS4) Count Information. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure)
0114                               Information about the count in the document. See the Count Tool. */
0115         CS5_PRINT_INFO = 1082, /* 0x043A - (Photoshop CS5) Print Information. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure)
0116                                   Information about the current print settings in the document. The color management options. */
0117         CS5_PRINT_STYLE = 1083, /* 0x043B - (Photoshop CS5) Print Style. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure)
0118                                    Information about the current print style in the document. The printing marks, labels, ornaments, etc. */
0119         CS5_NSPrintInfo = 1084, /* 0x043C - (Photoshop CS5) Macintosh NSPrintInfo. Variable OS specific info for Macintosh. NSPrintInfo. It is recommended that
0120                                    you do not interpret or use this data. */
0121         CS5_WIN_DEVMODE = 1085, /* 0x043D - (Photoshop CS5) Windows DEVMODE. Variable OS specific info for Windows. DEVMODE. It is recommended that you do not
0122                                    interpret or use this data. */
0123         CS6_AUTOSAVE_FILE_PATH =
0124             1086, /* 0x043E - (Photoshop CS6) Auto Save File Path. Unicode string. It is recommended that you do not interpret or use this data. */
0125         CS6_AUTOSAVE_FORMAT =
0126             1087, /* 0x043F - (Photoshop CS6) Auto Save Format. Unicode string. It is recommended that you do not interpret or use this data. */
0127         CC_PATH_SELECTION_SATE = 1088, /* 0x0440 - (Photoshop CC) Path Selection State. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor
0128                                           structure) Information about the current path selection state. */
0129 
0130         PATH_INFO_FIRST = 2000, /* 0x07d0 - First path info block */
0131         PATH_INFO_LAST = 2998, /* 0x0bb6 - Last path info block */
0132         CLIPPING_PATH = 2999, /* 0x0bb7 - Name of clipping path */
0133 
0134         CC_ORIGIN_PATH_INFO = 3000, /* 0x0BB8 (Photoshop CC) Origin Path Info. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure)
0135                                        Information about the origin path data. */
0136 
0137         PLUGIN_RESOURCE_START = 4000, /* 0x0FA0-0x1387 Plug-In resource(s). Resources added by a plug-in. See the plug-in API found in the SDK documentation  */
0138         PLUGIN_RESOURCE_END = 4999, /* Last plug-in resource */
0139 
0140         IMAGE_READY_VARS = 7000, /* 0x1B58 Image Ready variables. XML representation of variables definition */
0141         IMAGE_READY_DATA_SETS = 7001, /* 0x1B59 Image Ready data sets */
0142 
0143         LIGHTROOM_WORKFLOW = 8000, /* 0x1F40 (Photoshop CS3) Lightroom workflow, if present the document is in the middle of a Lightroom workflow. */
0144 
0145         PRINT_FLAGS_2 = 10000 /* 0x2710 - Print flags */
0146     };
0147 
0148     PSDImageResourceSection();
0149     ~PSDImageResourceSection();
0150 
0151     bool read(QIODevice &io);
0152     bool write(QIODevice &io);
0153     bool valid();
0154 
0155     static QString idToString(PSDResourceID id);
0156 
0157     QMap<PSDResourceID, PSDResourceBlock *> resources;
0158 
0159     QString error;
0160 };
0161 
0162 #endif // PSD_RESOURCE_SECTION_H