1 /* GIMP - The GNU Image Manipulation Program 2 * Copyright (C) 1995 Spencer Kimball and Peter Mattis 3 * 4 * GIMP PSD Plug-in 5 * Copyright 2007 by John Marshall 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <https://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef __PSD_H__ 22 #define __PSD_H__ 23 24 25 /* Set to the level of debugging output you want, 0 for none. 26 * Setting higher than 2 will result in a very large amount of debug 27 * output being produced. */ 28 #define PSD_DEBUG 3 29 #define IFDBG(level) if (PSD_DEBUG >= level) 30 31 /* Set to FALSE to suppress pop-up warnings about lossy file conversions */ 32 #define CONVERSION_WARNINGS FALSE 33 34 #define LOAD_PROC "file-psd-load" 35 #define LOAD_MERGED_PROC "file-psd-load-merged" 36 #define LOAD_THUMB_PROC "file-psd-load-thumb" 37 #define SAVE_PROC "file-psd-save" 38 #define PLUG_IN_BINARY "file-psd" 39 #define PLUG_IN_ROLE "gimp-file-psd" 40 41 #define GIMP_PARASITE_COMMENT "gimp-comment" 42 43 #define PSD_PARASITE_DUOTONE_DATA "psd-duotone-data" 44 45 /* Copied from app/base/gimpimage-quick-mask.h - internal identifier for quick mask channel */ 46 #define GIMP_IMAGE_QUICK_MASK_NAME "Qmask" 47 48 #define MAX_RAW_SIZE 0 /* FIXME all images are raw if 0 */ 49 50 /* PSD spec defines */ 51 #define MAX_CHANNELS 56 /* Photoshop CS to CS3 support 56 channels */ 52 53 /* PSD spec constants */ 54 55 /* Layer resource IDs */ 56 57 /* Adjustment layer IDs */ 58 #define PSD_LADJ_LEVEL "levl" /* Adjustment layer - levels (PS4) */ 59 #define PSD_LADJ_CURVE "curv" /* Adjustment layer - curves (PS4) */ 60 #define PSD_LADJ_BRIGHTNESS "brit" /* Adjustment layer - brightness/contrast (PS4) */ 61 #define PSD_LADJ_BALANCE "blnc" /* Adjustment layer - color balance (PS4) */ 62 #define PSD_LADJ_BLACK_WHITE "blwh" /* Adjustment layer - black & white (PS10) */ 63 #define PSD_LADJ_HUE "hue " /* Adjustment layer - old hue/saturation (PS4) */ 64 #define PSD_LADJ_HUE2 "hue2" /* Adjustment layer - hue/saturation (PS5) */ 65 #define PSD_LADJ_SELECTIVE "selc" /* Adjustment layer - selective color (PS4) */ 66 #define PSD_LADJ_MIXER "mixr" /* Adjustment layer - channel mixer (PS9) */ 67 #define PSD_LADJ_GRAD_MAP "grdm" /* Adjustment layer - gradient map (PS9) */ 68 #define PSD_LADJ_PHOTO_FILT "phfl" /* Adjustment layer - photo filter (PS9) */ 69 #define PSD_LADJ_EXPOSURE "expA" /* Adjustment layer - exposure (PS10) */ 70 #define PSD_LADJ_INVERT "nvrt" /* Adjustment layer - invert (PS4) */ 71 #define PSD_LADJ_THRESHOLD "thrs" /* Adjustment layer - threshold (PS4) */ 72 #define PSD_LADJ_POSTERIZE "post" /* Adjustment layer - posterize (PS4) */ 73 #define PSD_LADJ_VIBRANCE "vibA" /* Adjustment layer - vibrance (PS10) */ 74 #define PSD_LADJ_COLOR_LOOKUP "clrL" /* Adjustment layer - color lookup (PS13) */ 75 76 /* Fill Layer IDs */ 77 #define PSD_LFIL_SOLID "SoCo" /* Solid color sheet setting (PS6) */ 78 #define PSD_LFIL_PATTERN "PtFl" /* Pattern fill setting (PS6) */ 79 #define PSD_LFIL_GRADIENT "GdFl" /* Gradient fill setting (PS6) */ 80 81 /* Effects Layer IDs */ 82 #define PSD_LFX_FX "lrFX" /* Effects layer info (PS5) */ 83 #define PSD_LFX_FX2 "lfx2" /* Object based effects layer info (PS6) */ 84 85 /* Type Tool Layers */ 86 #define PSD_LTYP_TYPE "tySh" /* Type tool layer (PS5) */ 87 #define PSD_LTYP_TYPE2 "TySh" /* Type tool object setting (PS6) */ 88 89 /* Layer Properties */ 90 #define PSD_LPRP_UNICODE "luni" /* Unicode layer name (PS5) */ 91 #define PSD_LPRP_SOURCE "lnsr" /* Layer name source setting (PS6) */ 92 #define PSD_LPRP_ID "lyid" /* Layer ID (PS5) */ 93 #define PSD_LPRP_BLEND_CLIP "clbl" /* Blend clipping elements (PS6) */ 94 #define PSD_LPRP_BLEND_INT "infx" /* Blend interior elements (PS6) */ 95 #define PSD_LPRP_KNOCKOUT "knko" /* Knockout setting (PS6) */ 96 #define PSD_LPRP_PROTECT "lspf" /* Protected setting (PS6) */ 97 #define PSD_LPRP_COLOR "lclr" /* Sheet color setting (PS6) */ 98 #define PSD_LPRP_REF_POINT "fxrp" /* Reference point (PS6) */ 99 #define PSD_LPRP_VERSION "lyvr" /* Layer version (PS7) */ 100 101 /* Vector mask */ 102 #define PSD_LMSK_VMASK "vmsk" /* Vector mask setting (PS6) */ 103 104 /* Parasites */ 105 #define PSD_LPAR_ANNOTATE "Anno" /* Annotation (PS6) */ 106 107 /* Other */ 108 #define PSD_LOTH_SECTION "lsct" /* Section divider setting - Layer groups (PS6) */ 109 #define PSD_LOTH_SECTION2 "lsdk" /* Nested section divider setting - Layer groups (CS5) */ 110 #define PSD_LOTH_PATTERN "Patt" /* Patterns (PS6) */ 111 #define PSD_LOTH_PATTERN_2 "Pat2" /* Patterns 2nd key (PS6) */ 112 #define PSD_LOTH_PATTERN_3 "Pat3" /* Patterns 3rd key (PS6) */ 113 #define PSD_LOTH_GRADIENT "grdm" /* Gradient settings (PS6) */ 114 #define PSD_LOTH_RESTRICT "brst" /* Channel blending restriction setting (PS6) */ 115 #define PSD_LOTH_FOREIGN_FX "ffxi" /* Foreign effect ID (PS6) */ 116 #define PSD_LOTH_PATT_DATA "shpa" /* Pattern data (PS6) */ 117 #define PSD_LOTH_META_DATA "shmd" /* Meta data setting (PS6) */ 118 #define PSD_LOTH_LAYER_DATA "layr" /* Layer data (PS6) */ 119 #define PSD_LOTH_CONTENT_GEN "CgEd" /* Content generator extra data (PS12) */ 120 #define PSD_LOTH_TEXT_ENGINE "Txt2" /* Text engine data (PS10) */ 121 #define PSD_LOTH_PATH_NAME "pths" /* Unicode path name (PS13) */ 122 #define PSD_LOTH_ANIMATION_FX "anFX" /* Animation effects (PS13) */ 123 #define PSD_LOTH_FILTER_MASK "FMsk" /* Filter mask (PS10) */ 124 #define PSD_LOTH_VECTOR_STROKE "vscg" /* Vector stroke data (PS13) */ 125 #define PSD_LOTH_ALIGN_RENDER "sn2P" /* Aligned rendering flag (?) */ 126 #define PSD_LOTH_USER_MASK "LMsk" /* User mask (?) */ 127 128 /* Effects layer resource IDs */ 129 #define PSD_LFX_COMMON "cmnS" /* Effects layer - common state (PS5) */ 130 #define PSD_LFX_DROP_SDW "dsdw" /* Effects layer - drop shadow (PS5) */ 131 #define PSD_LFX_INNER_SDW "isdw" /* Effects layer - inner shadow (PS5) */ 132 #define PSD_LFX_OUTER_GLW "oglw" /* Effects layer - outer glow (PS5) */ 133 #define PSD_LFX_INNER_GLW "iglw" /* Effects layer - inner glow (PS5) */ 134 #define PSD_LFX_BEVEL "bevl" /* Effects layer - bevel (PS5) */ 135 136 /* Placed Layer */ 137 #define PSD_LPL_PLACE_LAYER "plLd" /* Placed layer (?) */ 138 #define PSD_LPL_PLACE_LAYER_NEW "SoLd" /* Placed layer (PS10) */ 139 140 /* Linked Layer */ 141 #define PSD_LLL_LINKED_LAYER "lnkD" /* Linked layer (?) */ 142 #define PSD_LLL_LINKED_LAYER_2 "lnk2" /* Linked layer 2nd key */ 143 #define PSD_LLL_LINKED_LAYER_3 "lnk3" /* Linked layer 3rd key */ 144 145 /* Merged Transparency */ 146 #define PSD_LMT_MERGE_TRANS "Mtrn" /* Merged transparency save flag (?) */ 147 #define PSD_LMT_MERGE_TRANS_16 "Mt16" /* Merged transparency save flag 2 */ 148 #define PSD_LMT_MERGE_TRANS_32 "Mt32" /* Merged transparency save flag 3 */ 149 150 /* Filter Effects */ 151 #define PSD_LFFX_FILTER_FX "FXid" /* Filter effects (?) */ 152 #define PSD_LFFX_FILTER_FX_2 "FEid" /* Filter effects 2 */ 153 154 /* PSD spec enums */ 155 156 /* Image color modes */ 157 typedef enum { 158 PSD_BITMAP = 0, /* Bitmap image */ 159 PSD_GRAYSCALE = 1, /* Greyscale image */ 160 PSD_INDEXED = 2, /* Indexed image */ 161 PSD_RGB = 3, /* RGB image */ 162 PSD_CMYK = 4, /* CMYK */ 163 PSD_MULTICHANNEL = 7, /* Multichannel image*/ 164 PSD_DUOTONE = 8, /* Duotone image*/ 165 PSD_LAB = 9 /* L*a*b image */ 166 } PSDColorMode; 167 168 /* Image color spaces */ 169 typedef enum { 170 PSD_CS_RGB = 0, /* RGB */ 171 PSD_CS_HSB = 1, /* Hue, Saturation, Brightness */ 172 PSD_CS_CMYK = 2, /* CMYK */ 173 PSD_CS_PANTONE = 3, /* Pantone matching system (Lab)*/ 174 PSD_CS_FOCOLTONE = 4, /* Focoltone color system (CMYK)*/ 175 PSD_CS_TRUMATCH = 5, /* Trumatch color (CMYK)*/ 176 PSD_CS_TOYO = 6, /* Toyo 88 colorfinder 1050 (Lab)*/ 177 PSD_CS_LAB = 7, /* L*a*b*/ 178 PSD_CS_GRAYSCALE = 8, /* Grey scale */ 179 PSD_CS_HKS = 10, /* HKS colors (CMYK)*/ 180 PSD_CS_DIC = 11, /* DIC color guide (Lab)*/ 181 PSD_CS_ANPA = 3000, /* Anpa color (Lab)*/ 182 } PSDColorSpace; 183 184 /* Image Resource IDs */ 185 typedef enum { 186 PSD_PS2_IMAGE_INFO = 1000, /* 0x03e8 - Obsolete - ps 2.0 image info */ 187 PSD_MAC_PRINT_INFO = 1001, /* 0x03e9 - Optional - Mac print manager print info record */ 188 PSD_PS2_COLOR_TAB = 1003, /* 0x03eb - Obsolete - ps 2.0 indexed color table */ 189 PSD_RESN_INFO = 1005, /* 0x03ed - ResolutionInfo structure */ 190 PSD_ALPHA_NAMES = 1006, /* 0x03ee - Alpha channel names */ 191 PSD_DISPLAY_INFO = 1007, /* 0x03ef - Superceded by PSD_DISPLAY_INFO_NEW for ps CS3 and higher - DisplayInfo structure */ 192 PSD_CAPTION = 1008, /* 0x03f0 - Optional - Caption string */ 193 PSD_BORDER_INFO = 1009, /* 0x03f1 - Border info */ 194 PSD_BACKGROUND_COL = 1010, /* 0x03f2 - Background color */ 195 PSD_PRINT_FLAGS = 1011, /* 0x03f3 - Print flags */ 196 PSD_GREY_HALFTONE = 1012, /* 0x03f4 - Greyscale and multichannel halftoning info */ 197 PSD_COLOR_HALFTONE = 1013, /* 0x03f5 - Color halftoning info */ 198 PSD_DUOTONE_HALFTONE = 1014, /* 0x03f6 - Duotone halftoning info */ 199 PSD_GREY_XFER = 1015, /* 0x03f7 - Greyscale and multichannel transfer functions */ 200 PSD_COLOR_XFER = 1016, /* 0x03f8 - Color transfer functions */ 201 PSD_DUOTONE_XFER = 1017, /* 0x03f9 - Duotone transfer functions */ 202 PSD_DUOTONE_INFO = 1018, /* 0x03fa - Duotone image information */ 203 PSD_EFFECTIVE_BW = 1019, /* 0x03fb - Effective black & white values for dot range */ 204 PSD_OBSOLETE_01 = 1020, /* 0x03fc - Obsolete */ 205 PSD_EPS_OPT = 1021, /* 0x03fd - EPS options */ 206 PSD_QUICK_MASK = 1022, /* 0x03fe - Quick mask info */ 207 PSD_OBSOLETE_02 = 1023, /* 0x03ff - Obsolete */ 208 PSD_LAYER_STATE = 1024, /* 0x0400 - Layer state info */ 209 PSD_WORKING_PATH = 1025, /* 0x0401 - Working path (not saved) */ 210 PSD_LAYER_GROUP = 1026, /* 0x0402 - Layers group info */ 211 PSD_OBSOLETE_03 = 1027, /* 0x0403 - Obsolete */ 212 PSD_IPTC_NAA_DATA = 1028, /* 0x0404 - IPTC-NAA record (IMV4.pdf) */ 213 PSD_IMAGE_MODE_RAW = 1029, /* 0x0405 - Image mode for raw format files */ 214 PSD_JPEG_QUAL = 1030, /* 0x0406 - JPEG quality */ 215 PSD_GRID_GUIDE = 1032, /* 0x0408 - Grid & guide info */ 216 PSD_THUMB_RES = 1033, /* 0x0409 - Thumbnail resource */ 217 PSD_COPYRIGHT_FLG = 1034, /* 0x040a - Copyright flag */ 218 PSD_URL = 1035, /* 0x040b - URL string */ 219 PSD_THUMB_RES2 = 1036, /* 0x040c - Thumbnail resource */ 220 PSD_GLOBAL_ANGLE = 1037, /* 0x040d - Superceded by PSD_NEW_COLOR_SAMPLER for ps CS3 and higher - Global angle */ 221 PSD_COLOR_SAMPLER = 1038, /* 0x040e - Superceded by PSD_NEW_COLOR_SAMPLER for ps CS3 and higher - Color samplers resource */ 222 PSD_ICC_PROFILE = 1039, /* 0x040f - ICC Profile */ 223 PSD_WATERMARK = 1040, /* 0x0410 - Watermark */ 224 PSD_ICC_UNTAGGED = 1041, /* 0x0411 - Do not use ICC profile flag */ 225 PSD_EFFECTS_VISIBLE = 1042, /* 0x0412 - Show / hide all effects layers */ 226 PSD_SPOT_HALFTONE = 1043, /* 0x0413 - Spot halftone */ 227 PSD_DOC_IDS = 1044, /* 0x0414 - Document specific IDs */ 228 PSD_ALPHA_NAMES_UNI = 1045, /* 0x0415 - Unicode alpha names */ 229 PSD_IDX_COL_TAB_CNT = 1046, /* 0x0416 - Indexed color table count */ 230 PSD_IDX_TRANSPARENT = 1047, /* 0x0417 - Index of transparent color (if any) */ 231 PSD_GLOBAL_ALT = 1049, /* 0x0419 - Global altitude */ 232 PSD_SLICES = 1050, /* 0x041a - Slices */ 233 PSD_WORKFLOW_URL_UNI = 1051, /* 0x041b - Workflow URL - Unicode string */ 234 PSD_JUMP_TO_XPEP = 1052, /* 0x041c - Jump to XPEP (?) */ 235 PSD_ALPHA_ID = 1053, /* 0x041d - Alpha IDs */ 236 PSD_URL_LIST_UNI = 1054, /* 0x041e - URL list - unicode */ 237 PSD_VERSION_INFO = 1057, /* 0x0421 - Version info */ 238 PSD_EXIF_DATA = 1058, /* 0x0422 - Exif data block 1 */ 239 PSD_EXIF_DATA_3 = 1059, /* 0X0423 - Exif data block 3 (?) */ 240 PSD_XMP_DATA = 1060, /* 0x0424 - XMP data block */ 241 PSD_CAPTION_DIGEST = 1061, /* 0x0425 - Caption digest */ 242 PSD_PRINT_SCALE = 1062, /* 0x0426 - Print scale */ 243 PSD_PIXEL_AR = 1064, /* 0x0428 - Pixel aspect ratio */ 244 PSD_LAYER_COMPS = 1065, /* 0x0429 - Layer comps */ 245 PSD_ALT_DUOTONE_COLOR = 1066, /* 0x042A - Alternative Duotone colors */ 246 PSD_ALT_SPOT_COLOR = 1067, /* 0x042B - Alternative Spot colors */ 247 PSD_LAYER_SELECT_ID = 1069, /* 0x042D - Layer selection ID */ 248 PSD_HDR_TONING_INFO = 1070, /* 0x042E - HDR toning information */ 249 PSD_PRINT_INFO_SCALE = 1071, /* 0x042F - Print scale */ 250 PSD_LAYER_GROUP_E_ID = 1072, /* 0x0430 - Layer group(s) enabled ID */ 251 PSD_COLOR_SAMPLER_NEW = 1073, /* 0x0431 - Color sampler resource for ps CS3 and higher PSD files */ 252 PSD_MEASURE_SCALE = 1074, /* 0x0432 - Measurement scale */ 253 PSD_TIMELINE_INFO = 1075, /* 0x0433 - Timeline information */ 254 PSD_SHEET_DISCLOSE = 1076, /* 0x0434 - Sheet discloser */ 255 PSD_DISPLAY_INFO_NEW = 1077, /* 0x0435 - DisplayInfo structure for ps CS3 and higher PSD files */ 256 PSD_ONION_SKINS = 1078, /* 0x0436 - Onion skins */ 257 PSD_COUNT_INFO = 1080, /* 0x0438 - Count information*/ 258 PSD_PRINT_INFO = 1082, /* 0x043A - Print information added in ps CS5*/ 259 PSD_PRINT_STYLE = 1083, /* 0x043B - Print style */ 260 PSD_MAC_NSPRINTINFO = 1084, /* 0x043C - Mac NSPrintInfo*/ 261 PSD_WIN_DEVMODE = 1085, /* 0x043D - Windows DEVMODE */ 262 PSD_AUTO_SAVE_PATH = 1086, /* 0x043E - Auto save file path */ 263 PSD_AUTO_SAVE_FORMAT = 1087, /* 0x043F - Auto save format */ 264 PSD_PATH_INFO_FIRST = 2000, /* 0x07d0 - First path info block */ 265 PSD_PATH_INFO_LAST = 2998, /* 0x0bb6 - Last path info block */ 266 PSD_CLIPPING_PATH = 2999, /* 0x0bb7 - Name of clipping path */ 267 PSD_PLUGIN_R_FIRST = 4000, /* 0x0FA0 - First plugin resource */ 268 PSD_PLUGIN_R_LAST = 4999, /* 0x1387 - Last plugin resource */ 269 PSD_IMAGEREADY_VARS = 7000, /* 0x1B58 - Imageready variables */ 270 PSD_IMAGEREADY_DATA = 7001, /* 0x1B59 - Imageready data sets */ 271 PSD_LIGHTROOM_WORK = 8000, /* 0x1F40 - Lightroom workflow */ 272 PSD_PRINT_FLAGS_2 = 10000 /* 0x2710 - Print flags */ 273 } PSDImageResID; 274 275 /* Display resolution units */ 276 typedef enum { 277 PSD_RES_INCH = 1, /* Pixels / inch */ 278 PSD_RES_CM = 2, /* Pixels / cm */ 279 } PSDDisplayResUnit; 280 281 /* Width and height units */ 282 typedef enum { 283 PSD_UNIT_INCH = 1, /* inches */ 284 PSD_UNIT_CM = 2, /* cm */ 285 PSD_UNIT_POINT = 3, /* points (72 points = 1 inch) */ 286 PSD_UNIT_PICA = 4, /* pica ( 6 pica = 1 inch) */ 287 PSD_UNIT_COLUMN = 5, /* columns ( column defined in ps prefs, default = 2.5 inches) */ 288 } PSDUnit; 289 290 /* Thumbnail image data encoding */ 291 typedef enum { 292 kRawRGB = 0, /* RAW data format (never used?) */ 293 kJpegRGB = 1 /* JPEG compression */ 294 } PSDThumbFormat; 295 296 /* Path record types */ 297 typedef enum { 298 PSD_PATH_CL_LEN = 0, /* Closed sub-path length record */ 299 PSD_PATH_CL_LNK = 1, /* Closed sub-path Bezier knot, linked */ 300 PSD_PATH_CL_UNLNK = 2, /* Closed sub-path Bezier knot, unlinked */ 301 PSD_PATH_OP_LEN = 3, /* Open sub-path length record */ 302 PSD_PATH_OP_LNK = 4, /* Open sub-path Bezier knot, linked */ 303 PSD_PATH_OP_UNLNK = 5, /* Open sub-path Bezier knot, unlinked */ 304 PSD_PATH_FILL_RULE = 6, /* Path fill rule record */ 305 PSD_PATH_CLIPBOARD = 7, /* Path clipboard record */ 306 PSD_PATH_FILL_INIT = 8 /* Path initial fill record */ 307 } PSDpathtype; 308 309 /* Channel ID */ 310 typedef enum { 311 PSD_CHANNEL_EXTRA_MASK= -3, /* User supplied extra layer mask */ 312 PSD_CHANNEL_MASK = -2, /* User supplied layer mask */ 313 PSD_CHANNEL_ALPHA = -1, /* Transparency mask */ 314 PSD_CHANNEL_RED = 0, /* Red channel data */ 315 PSD_CHANNEL_GREEN = 1, /* Green channel data */ 316 PSD_CHANNEL_BLUE = 2 /* Blue channel data */ 317 } PSDChannelID; 318 319 /* Clipping */ 320 typedef enum { 321 PSD_CLIPPING_BASE = 0, /* Base clipping */ 322 PSD_CLIPPING_NON_BASE = 1 /* Non-base clipping */ 323 } PSDClipping; 324 325 /* Image compression mode */ 326 typedef enum { 327 PSD_COMP_RAW = 0, /* Raw data */ 328 PSD_COMP_RLE, /* RLE compressed */ 329 PSD_COMP_ZIP, /* ZIP without prediction */ 330 PSD_COMP_ZIP_PRED /* ZIP with prediction */ 331 } PSDCompressMode; 332 333 /* Vertical - horizontal selection */ 334 typedef enum { 335 PSD_VERTICAL = 0, /* Vertical */ 336 PSD_HORIZONTAL = 1 /* Horizontal */ 337 } VHSelect; 338 339 340 /* PSD spec data structures */ 341 342 /* PSD field types */ 343 typedef gint32 Fixed; /* Represents a fixed point implied decimal */ 344 345 346 /* Apple color space data structures */ 347 348 /* RGB Color Value 349 A color value expressed in the RGB color space is composed of red, green, 350 and blue component values. Each color component is expressed as a numeric 351 value within the range of 0 to 65535. 352 */ 353 typedef struct 354 { 355 guint16 red; 356 guint16 green; 357 guint16 blue; 358 } CMRGBColor; 359 360 /* HSV Color Value 361 A color value expressed in the HSV color space is composed of hue, 362 saturation, and value component values. Each color component is 363 expressed as a numeric value within the range of 0 to 65535 inclusive. 364 The hue value represents a fraction of a circle in which red is 365 positioned at 0. 366 */ 367 368 typedef struct 369 { 370 guint16 hue; 371 guint16 saturation; 372 guint16 value; 373 } CMHSVColor; 374 375 /* CMYK Color Value 376 A color value expressed in the CMYK color space is composed of cyan, magenta, 377 yellow, and black component values. Each color component is expressed as a 378 numeric value within the range of 0 to 65535 inclusive, with 0 representing 379 100% ink (e.g. pure cyan = 0, 65535, 65535, 65535). 380 */ 381 382 typedef struct 383 { 384 guint16 cyan; 385 guint16 magenta; 386 guint16 yellow; 387 guint16 black; 388 } CMCMYKColor; 389 390 /* L*a*b* Color Value 391 The first three values in the color data are, respectively, the colors 392 lightness, a chrominance, and b chrominance components. The lightness 393 component is a 16bit value ranging from 0 to 10000. The chrominance 394 components are each 16bit values ranging from 12800 to 12700. Gray 395 values are represented by chrominance components of 0 (e.g. pure white 396 is defined as 10000, 0, 0). 397 */ 398 typedef struct 399 { 400 guint16 L; 401 gint16 a; 402 gint16 b; 403 } CMLabColor; 404 405 /* Gray Color Value 406 A color value expressed in the Gray color space is composed of a single component, 407 gray, represented as a numeric value within the range of 0 to 10000. 408 */ 409 typedef struct 410 { 411 guint16 gray; 412 } CMGrayColor ; 413 414 /* The color union is defined by the CMColor type definition. 415 */ 416 typedef union 417 { 418 CMRGBColor rgb; 419 CMHSVColor hsv; 420 CMLabColor Lab; 421 CMCMYKColor cmyk; 422 CMGrayColor gray; 423 } CMColor; 424 425 /* GIMP layer mode info */ 426 typedef struct 427 { 428 GimpLayerMode mode; 429 GimpLayerColorSpace blend_space; 430 GimpLayerColorSpace composite_space; 431 GimpLayerCompositeMode composite_mode; 432 } LayerModeInfo; 433 434 /* Image resolution data */ 435 typedef struct { 436 Fixed hRes; /* Horizontal resolution pixels/inch */ 437 gint16 hResUnit; /* Horizontal display resolution unit */ 438 gint16 widthUnit; /* Width unit ?? */ 439 Fixed vRes; /* Vertical resolution pixels/inch */ 440 gint16 vResUnit; /* Vertical display resolution unit */ 441 gint16 heightUnit; /* Height unit ?? */ 442 } ResolutionInfo; 443 444 /* Grid & guide header */ 445 typedef struct { 446 guint32 fVersion; /* Version - always 1 for PS */ 447 guint32 fGridCycleV; /* Vertical grid size */ 448 guint32 fGridCycleH; /* Horizontal grid size */ 449 guint32 fGuideCount; /* Number of guides */ 450 } GuideHeader; 451 452 /* Guide resource block */ 453 typedef struct { 454 guint32 fLocation; /* Guide position in Pixels * 100 */ 455 gchar fDirection; /* Guide orientation */ 456 } GuideResource; 457 458 /* Thumbnail data */ 459 typedef struct { 460 gint32 format; /* Thumbnail image data format (1 = JPEG) */ 461 gint32 width; /* Thumbnail width in pixels */ 462 gint32 height; /* Thumbnail height in pixels */ 463 gint32 widthbytes; /* Padded row bytes ((width * bitspixel + 31) / 32 * 4) */ 464 gint32 size; /* Total size (widthbytes * height * planes */ 465 gint32 compressedsize; /* Size after compression for consistency */ 466 gint16 bitspixel; /* Bits per pixel (always 24) */ 467 gint16 planes; /* Number of planes (always 1) */ 468 } ThumbnailInfo; 469 470 /* Channel display info data for Adobe Photoshop CS2 and lower */ 471 typedef struct { 472 gint16 colorSpace; /* Color space from PSDColorSpace */ 473 guint16 color[4]; /* 4 * 16 bit color components */ 474 gint16 opacity; /* Opacity 0 to 100 */ 475 gchar kind; /* Selected = 0, Protected = 1 */ 476 gchar padding; /* Padding */ 477 } DisplayInfo; 478 479 /* Channel display info data for Adobe Photoshop CS3 and higher to support floating point colors */ 480 typedef struct { 481 gint16 colorSpace; /* Color space from PSDColorSpace */ 482 guint16 color[4]; /* 4 * 16 bit color components */ 483 gint16 opacity; /* Opacity 0 to 100 */ 484 gchar mode; /* Alpha = 0, Inverted alpha = 1, Spot = 2 */ 485 } DisplayInfoNew; 486 487 /* PSD Channel length info data structure */ 488 typedef struct 489 { 490 gint16 channel_id; /* Channel ID */ 491 guint32 data_len; /* Layer left */ 492 } ChannelLengthInfo; 493 494 /* PSD Layer flags */ 495 typedef struct 496 { 497 gboolean trans_prot; /* Transparency protected */ 498 gboolean visible; /* Visible */ 499 gboolean obsolete; /* Obsolete */ 500 gboolean bit4; /* Bit 4 in use */ 501 gboolean irrelevant; /* Pixel data irrelevant to image appearance */ 502 } LayerFlags; 503 504 /* PSD Layer mask flags */ 505 typedef struct 506 { 507 gboolean relative_pos; /* Mask position recorded relative to layer */ 508 gboolean disabled; /* Mask disabled */ 509 gboolean invert; /* Invert mask on blending (obsolete according to online specs) */ 510 gboolean rendered; /* User mask actually came from rendering other data */ 511 gboolean params_present; /* User and/or vector masks have parameters applied to them */ 512 } MaskFlags; 513 514 /* PSD Slices */ 515 typedef struct 516 { 517 gint32 id; /* ID */ 518 gint32 groupid; /* Group ID */ 519 gint32 origin; /* Origin */ 520 gint32 associatedid; /* Associated Layer ID */ 521 gchar *name; /* Name */ 522 gint32 type; /* Type */ 523 gint32 left; /* Position coordinates */ 524 gint32 top; 525 gint32 right; 526 gint32 bottom; 527 gchar *url; /* URL */ 528 gchar *target; /* Target */ 529 gchar *message; /* Message */ 530 gchar *alttag; /* Alt Tag */ 531 gchar html; /* Boolean for if cell text is HTML */ 532 gchar *celltext; /* Cell text */ 533 gint32 horizontal; /* Horizontal alignment */ 534 gint32 vertical; /* Vertical alignment */ 535 gchar alpha; /* Alpha */ 536 gchar red; /* Red */ 537 gchar green; /* Green */ 538 gchar blue; /* Blue */ 539 } PSDSlice; 540 541 /* PSD Layer mask data (length 20) */ 542 typedef struct 543 { 544 gint32 top; /* Layer top */ 545 gint32 left; /* Layer left */ 546 gint32 bottom; /* Layer bottom */ 547 gint32 right; /* Layer right */ 548 guchar def_color; /* Default background color */ 549 guchar flags; /* Layer flags */ 550 guchar mask_params; /* Mask parameters. Only present if bit 4 of flags is set. */ 551 guchar extra_flags; /* Real layer flags */ 552 guchar extra_def_color; /* Real user mask background */ 553 MaskFlags mask_flags; /* Flags */ 554 } LayerMask; 555 556 /* PSD Layer mask data (length 36) */ 557 typedef struct 558 { 559 gint32 top; /* Layer top */ 560 gint32 left; /* Layer left */ 561 gint32 bottom; /* Layer bottom */ 562 gint32 right; /* Layer right */ 563 } LayerMaskExtra; 564 565 /* PSD text reading */ 566 typedef struct 567 { 568 gdouble xx; /* Transform information */ 569 gdouble xy; 570 gdouble yx; 571 gdouble yy; 572 gdouble tx; 573 gdouble ty; 574 gchar *info; /* Text information */ 575 } PSDText; 576 577 /* PSD Layer data structure */ 578 typedef struct 579 { 580 gboolean drop; /* Do not add layer to GIMP image */ 581 gint32 top; /* Layer top */ 582 gint32 left; /* Layer left */ 583 gint32 bottom; /* Layer bottom */ 584 gint32 right; /* Layer right */ 585 guint16 num_channels; /* Number of channels */ 586 ChannelLengthInfo *chn_info; /* Channel length info */ 587 gchar mode_key[4]; /* Blend mode key */ 588 gchar blend_mode[4]; /* Blend mode */ 589 guchar opacity; /* Opacity - 0 = transparent ... 255 = opaque */ 590 guchar clipping; /* Clipping */ 591 guchar flags; /* Layer flags */ 592 guchar filler; /* Filler */ 593 guint32 extra_len; /* Extra data length */ 594 gchar *name; /* Layer name */ 595 guint32 mask_len; /* Layer mask data length */ 596 LayerMask layer_mask; /* Layer mask data */ 597 LayerMaskExtra layer_mask_extra; /* Layer mask extra data */ 598 LayerFlags layer_flags; /* Layer flags */ 599 PSDText text; /* PSD text */ 600 guint32 id; /* Layer ID (Tattoo) */ 601 guchar group_type; /* 0 -> not a group; 1 -> open folder; 2 -> closed folder; 3 -> end of group */ 602 guint16 color_tag[4]; /* 4 * 16 bit color components */ 603 } PSDlayer; 604 605 /* PSD Channel data structure */ 606 typedef struct 607 { 608 gint16 id; /* Channel ID */ 609 gchar *name; /* Channel name */ 610 gchar *data; /* Channel image data */ 611 guint32 rows; /* Channel rows */ 612 guint32 columns; /* Channel columns */ 613 } PSDchannel; 614 615 /* PSD Channel data structure */ 616 typedef struct 617 { 618 GimpRGB gimp_color; /* Gimp RGB color */ 619 gint16 opacity; /* Opacity */ 620 guchar ps_mode; /* PS mode flag */ 621 guchar ps_kind; /* PS type flag */ 622 gint16 ps_cspace; /* PS color space */ 623 CMColor ps_color; /* PS color */ 624 } PSDchanneldata; 625 626 /* PSD Image Resource data structure */ 627 typedef struct 628 { 629 gchar type[4]; /* Image resource type */ 630 gint16 id; /* Image resource ID */ 631 gchar name[256]; /* Image resource name (pascal string) */ 632 guint32 data_start; /* Image resource data start */ 633 guint32 data_len; /* Image resource data length */ 634 } PSDimageres; 635 636 /* PSD Layer Resource data structure */ 637 typedef struct 638 { 639 gchar sig[4]; /* Layer resource signature */ 640 gchar key[4]; /* Layer resource key */ 641 guint32 data_start; /* Layer resource data start */ 642 guint32 data_len; /* Layer resource data length */ 643 } PSDlayerres; 644 645 /* PSD File data structures */ 646 typedef struct 647 { 648 gboolean merged_image_only; /* Whether to load only the merged image data */ 649 650 guint16 channels; /* Number of channels: 1- 56 */ 651 gboolean transparency; /* Image has merged transparency alpha channel */ 652 guint32 rows; /* Number of rows: 1 - 30000 */ 653 guint32 columns; /* Number of columns: 1 - 30000 */ 654 guint16 bps; /* Bits per sample: 1, 8, 16, or 32 */ 655 guint16 color_mode; /* Image color mode: {PSDColorMode} */ 656 GimpImageBaseType base_type; /* Image base color mode: (GIMP) */ 657 guint16 comp_mode; /* Merged image compression mode */ 658 guchar *color_map; /* Color map data */ 659 guint32 color_map_len; /* Color map data length */ 660 guint32 color_map_entries; /* Color map number of entries */ 661 guint32 image_res_start; /* Image resource block start address */ 662 guint32 image_res_len; /* Image resource block length */ 663 guint32 mask_layer_start; /* Mask & layer block start address */ 664 guint32 mask_layer_len; /* Mask & layer block length */ 665 gint16 num_layers; /* Number of layers */ 666 guint32 layer_data_start; /* Layer pixel data start */ 667 guint32 layer_data_len; /* Layer pixel data length */ 668 guint32 merged_image_start; /* Merged image pixel data block start address */ 669 guint32 merged_image_len; /* Merged image pixel data block length */ 670 gboolean no_icc; /* Do not use ICC profile */ 671 guint16 layer_state; /* Active layer number counting from bottom up */ 672 GPtrArray *alpha_names; /* Alpha channel names */ 673 PSDchanneldata **alpha_display_info; /* Alpha channel display info */ 674 guint16 alpha_display_count; /* Number of alpha channel display info recs */ 675 guint32 *alpha_id; /* Alpha channel ids (tattoos) */ 676 guint16 alpha_id_count; /* Number of alpha channel id items */ 677 guint16 quick_mask_id; /* Channel number containing quick mask */ 678 679 GimpColorProfile *cmyk_profile; 680 gpointer cmyk_transform; 681 gpointer cmyk_transform_alpha; 682 } PSDimage; 683 684 /* Public functions */ 685 686 687 #endif /* __PSD_H__ */ 688