[gimp/soc-2013-psd: 2/10] file-psd: More cleanup of documentation and formatting of code. Image resource 1077 now loaded to en
- From: Simon Lui <simonlui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2013-psd: 2/10] file-psd: More cleanup of documentation and formatting of code. Image resource 1077 now loaded to en
- Date: Mon, 28 Oct 2013 00:44:43 +0000 (UTC)
commit d0298e7e422619593614e877fbef47e16509e5a6
Author: Simon Lui <simonlui src gnome org>
Date: Fri Jun 28 16:58:22 2013 -0400
file-psd: More cleanup of documentation and formatting of code. Image resource
1077 now loaded to ensure channel compatibility with PS CS3+ psds. Slight
changes to "PSDchannelData" struct also to support that. Debug mode enabled
also for the time being in code.
plug-ins/file-psd/psd-image-res-load.c | 409 ++++++++++++++++++++++----------
plug-ins/file-psd/psd-layer-res-load.c | 3 +-
plug-ins/file-psd/psd-load.c | 36 ++--
plug-ins/file-psd/psd-save.c | 153 ++++++-------
plug-ins/file-psd/psd.h | 30 ++--
5 files changed, 389 insertions(+), 242 deletions(-)
---
diff --git a/plug-ins/file-psd/psd-image-res-load.c b/plug-ins/file-psd/psd-image-res-load.c
index bc7b624..af09cc2 100644
--- a/plug-ins/file-psd/psd-image-res-load.c
+++ b/plug-ins/file-psd/psd-image-res-load.c
@@ -75,7 +75,8 @@
PSD_ALPHA_ID = 1053, Loaded * 0x041d - Alpha IDs *
PSD_URL_LIST_UNI = 1054, * 0x041e - URL list - unicode *
PSD_VERSION_INFO = 1057, * 0x0421 - Version info *
- PSD_EXIF_DATA = 1058, Loaded * 0x0422 - Exif data block *
+ PSD_EXIF_DATA = 1058, Loaded * 0x0422 - Exif data block 1 *
+ PSD_EXIF_DATA_3 = 1059 * 0X0423 - Exif data block 3 (?) *
PSD_XMP_DATA = 1060, Loaded * 0x0424 - XMP data block *
PSD_CAPTION_DIGEST = 1061, * 0x0425 - Caption digest *
PSD_PRINT_SCALE = 1062, * 0x0426 - Print scale *
@@ -91,7 +92,7 @@
PSD_MEASURE_SCALE = 1074, * 0x0432 - Measurement scale *
PSD_TIMELINE_INFO = 1075, * 0x0433 - Timeline information *
PSD_SHEET_DISCLOSE = 1076, * 0x0434 - Sheet discloser *
- PSD_DISPLAY_INFO_NEW = 1077, * 0x0435 - DisplayInfo structure for ps CS3 and higher PSD
files *
+ PSD_DISPLAY_INFO_NEW = 1077, Loaded * 0x0435 - DisplayInfo structure for ps CS3 and higher PSD
files *
PSD_ONION_SKINS = 1078, * 0x0436 - Onion skins *
PSD_COUNT_INFO = 1080, * 0x0438 - Count information*
PSD_PRINT_INFO = 1082, * 0x043A - Print information added in ps CS5*
@@ -105,9 +106,9 @@
PSD_CLIPPING_PATH = 2999, * 0x0bb7 - Name of clipping path *
PSD_PLUGIN_R_FIRST = 4000, * 0x0FA0 - First plugin resource *
PSD_PLUGIN_R_LAST = 4999, * 0x1387 - Last plugin resource *
- PSD_IMAGEREADY_VARS = 7000, * 0x1B58 - Name of clipping path *
- PSD_IMAGEREADY_DATA = 7001, * 0x1B59 - Name of clipping path *
- PSD_LIGHTROOM_WORK = 8000, * 0x1F40 - Lightroom workflow *
+ PSD_IMAGEREADY_VARS = 7000, PS Only * 0x1B58 - Imageready variables *
+ PSD_IMAGEREADY_DATA = 7001, PS Only * 0x1B59 - Imageready data sets *
+ PSD_LIGHTROOM_WORK = 8000, PS Only * 0x1F40 - Lightroom workflow *
PSD_PRINT_FLAGS_2 = 10000 * 0x2710 - Print flags *
*/
@@ -221,6 +222,20 @@ static gint load_resource_1058 (const PSDimageres *res_a,
FILE *f,
GError **error);
+<<<<<<< HEAD
+=======
+static gint load_resource_1060 (const PSDimageres *res_a,
+ const gint32 image_id,
+ FILE *f,
+ GError **error);
+
+static gint load_resource_1077 (const PSDimageres *res_a,
+ const gint32 image_id,
+ PSDimage *img_a,
+ FILE *f,
+ GError **error);
+
+>>>>>>> file-psd: More cleanup of documentation and formatting of code. Image resource
static gint load_resource_2000 (const PSDimageres *res_a,
const gint32 image_id,
FILE *f,
@@ -294,6 +309,7 @@ load_image_resource (PSDimageres *res_a,
switch (res_a->id)
{
<<<<<<< HEAD
+<<<<<<< HEAD
case PSD_PS2_IMAGE_INFO:
case PSD_PS2_COLOR_TAB:
case PSD_OBSOLETE_01:
@@ -400,82 +416,111 @@ load_image_resource (PSDimageres *res_a,
/* Drop thumbnails from standard file load */
IFDBG(2) g_debug ("Thumbnail resource block: %d",
res_a->id);
+=======
+ case PSD_PS2_IMAGE_INFO:
+ case PSD_PS2_COLOR_TAB:
+ case PSD_OBSOLETE_01:
+ case PSD_OBSOLETE_02:
+ case PSD_OBSOLETE_03:
+ /* Drop obsolete image resource blocks */
+ IFDBG(2) g_debug ("Obsolete image resource block: %d",
+ res_a->id);
+ break;
+
+ case PSD_THUMB_RES:
+ case PSD_THUMB_RES2:
+ /* Drop thumbnails from standard file load */
+ IFDBG(2) g_debug ("Thumbnail resource block: %d",
+ res_a->id);
+>>>>>>> file-psd: More cleanup of documentation and formatting of code. Image resource
break;
- case PSD_MAC_PRINT_INFO:
- case PSD_JPEG_QUAL:
- /* Save photoshop resources with no meaning for GIMP
+ case PSD_MAC_PRINT_INFO:
+ case PSD_JPEG_QUAL:
+ case PSD_IMAGEREADY_VARS:
+ case PSD_IMAGEREADY_DATA:
+ case PSD_LIGHTROOM_WORK:
+ /* Save photoshop resources with no meaning for GIMP
as image parasites */
- load_resource_ps_only (res_a, image_id, f, error);
- break;
+ load_resource_ps_only (res_a, image_id, f, error);
+ break;
- case PSD_RESN_INFO:
- load_resource_1005 (res_a, image_id, f, error);
- break;
+ case PSD_RESN_INFO:
+ load_resource_1005 (res_a, image_id, f, error);
+ break;
- case PSD_ALPHA_NAMES:
- load_resource_1006 (res_a, image_id, img_a, f, error);
- break;
+ case PSD_ALPHA_NAMES:
+ load_resource_1006 (res_a, image_id, img_a, f, error);
+ break;
- case PSD_DISPLAY_INFO:
- load_resource_1007 (res_a, image_id, img_a, f, error);
- break;
+ case PSD_DISPLAY_INFO:
+ load_resource_1007 (res_a, image_id, img_a, f, error);
+ break;
- case PSD_CAPTION:
- load_resource_1008 (res_a, image_id, f, error);
- break;
+ case PSD_CAPTION:
+ load_resource_1008 (res_a, image_id, f, error);
+ break;
- case PSD_QUICK_MASK:
- load_resource_1022 (res_a, image_id, img_a, f, error);
- break;
+ case PSD_QUICK_MASK:
+ load_resource_1022 (res_a, image_id, img_a, f, error);
+ break;
- case PSD_LAYER_STATE:
- load_resource_1024 (res_a, image_id, img_a, f, error);
- break;
+ case PSD_LAYER_STATE:
+ load_resource_1024 (res_a, image_id, img_a, f, error);
+ break;
- case PSD_WORKING_PATH:
- load_resource_2000 (res_a, image_id, f, error);
- break;
+ case PSD_WORKING_PATH:
+ load_resource_2000 (res_a, image_id, f, error);
+<<<<<<< HEAD
+ else
+ load_resource_unknown (res_a, image_id, f, error);
+>>>>>>> plug-ins: Initial branch creation and updated documentation.
+=======
+ break;
- case PSD_IPTC_NAA_DATA:
- load_resource_1028 (res_a, image_id, f, error);
- break;
+ case PSD_IPTC_NAA_DATA:
+ load_resource_1028 (res_a, image_id, f, error);
+ break;
- case PSD_GRID_GUIDE:
- load_resource_1032 (res_a, image_id, f, error);
- break;
+ case PSD_GRID_GUIDE:
+ load_resource_1032 (res_a, image_id, f, error);
+ break;
- case PSD_ICC_PROFILE:
- load_resource_1039 (res_a, image_id, f, error);
- break;
+ case PSD_ICC_PROFILE:
+ load_resource_1039 (res_a, image_id, f, error);
+ break;
- case PSD_ALPHA_NAMES_UNI:
- load_resource_1045 (res_a, image_id, img_a, f, error);
- break;
+ case PSD_ALPHA_NAMES_UNI:
+ load_resource_1045 (res_a, image_id, img_a, f, error);
+ break;
- case PSD_IDX_COL_TAB_CNT:
- load_resource_1046 (res_a, image_id, f, error);
- break;
+ case PSD_IDX_COL_TAB_CNT:
+ load_resource_1046 (res_a, image_id, f, error);
+ break;
- case PSD_ALPHA_ID:
- load_resource_1053 (res_a, image_id, img_a, f, error);
- break;
+ case PSD_ALPHA_ID:
+ load_resource_1053 (res_a, image_id, img_a, f, error);
+ break;
- case PSD_EXIF_DATA:
- load_resource_1058 (res_a, image_id, f, error);
- break;
+ case PSD_EXIF_DATA:
+ load_resource_1058 (res_a, image_id, f, error);
+ break;
- case PSD_XMP_DATA:
- load_resource_1060 (res_a, image_id, f, error);
- break;
+ case PSD_XMP_DATA:
+ load_resource_1060 (res_a, image_id, f, error);
+ break;
- default:
- if (res_a->id >= 2000 &&
- res_a->id < 2999)
- load_resource_2000 (res_a, image_id, f, error);
- else
- load_resource_unknown (res_a, image_id, f, error);
->>>>>>> plug-ins: Initial branch creation and updated documentation.
+ case PSD_DISPLAY_INFO_NEW:
+ load_resource_1077 (res_a, image_id, img_a, f, error);
+ break;
+
+ default:
+ if (res_a->id >= 2000 &&
+ res_a->id < 2999)
+ load_resource_2000 (res_a, image_id, f, error);
+ else
+ load_resource_unknown (res_a, image_id, f, error);
+>>>>>>> file-psd: More cleanup of documentation and formatting of code. Image resource
}
}
@@ -560,7 +605,7 @@ load_resource_unknown (const PSDimageres *res_a,
}
name = g_strdup_printf ("psd-image-resource-%.4s-%.4x",
- res_a->type, res_a->id);
+ res_a->type, res_a->id);
IFDBG(2) g_debug ("Parasite name: %s", name);
parasite = gimp_parasite_new (name, 0, res_a->data_len, data);
@@ -595,7 +640,7 @@ load_resource_ps_only (const PSDimageres *res_a,
}
name = g_strdup_printf ("psd-image-resource-%.4s-%.4x",
- res_a->type, res_a->id);
+ res_a->type, res_a->id);
IFDBG(2) g_debug ("Parasite name: %s", name);
parasite = gimp_parasite_new (name, 0, res_a->data_len, data);
@@ -640,12 +685,12 @@ load_resource_1005 (const PSDimageres *res_a,
res_info.heightUnit = GINT16_FROM_BE (res_info.heightUnit);
IFDBG(3) g_debug ("Resolution: %d, %d, %d, %d, %d, %d",
- res_info.hRes,
- res_info.hResUnit,
- res_info.widthUnit,
- res_info.vRes,
- res_info.vResUnit,
- res_info.heightUnit);
+ res_info.hRes,
+ res_info.hResUnit,
+ res_info.widthUnit,
+ res_info.vRes,
+ res_info.vResUnit,
+ res_info.heightUnit);
/* Resolution always recorded as pixels / inch in a fixed point implied
decimal int32 with 16 bits before point and 16 after (i.e. cast as
@@ -757,58 +802,58 @@ load_resource_1007 (const PSDimageres *res_a,
switch (dsp_info.colorSpace)
{
- case PSD_CS_RGB:
- gimp_rgb_set (&gimp_rgb, ps_color.rgb.red / 65535.0,
- ps_color.rgb.green / 65535.0,
- ps_color.rgb.blue / 65535.0);
- break;
-
- case PSD_CS_HSB:
- gimp_hsv_set (&gimp_hsv, ps_color.hsv.hue / 65535.0,
- ps_color.hsv.saturation / 65535.0,
- ps_color.hsv.value / 65535.0);
- gimp_hsv_to_rgb (&gimp_hsv, &gimp_rgb);
- break;
-
- case PSD_CS_CMYK:
- gimp_cmyk_set (&gimp_cmyk, 1.0 - ps_color.cmyk.cyan / 65535.0,
- 1.0 - ps_color.cmyk.magenta / 65535.0,
- 1.0 - ps_color.cmyk.yellow / 65535.0,
- 1.0 - ps_color.cmyk.black / 65535.0);
- gimp_cmyk_to_rgb (&gimp_cmyk, &gimp_rgb);
- break;
-
- case PSD_CS_GRAYSCALE:
- gimp_rgb_set (&gimp_rgb, ps_color.gray.gray / 10000.0,
- ps_color.gray.gray / 10000.0,
- ps_color.gray.gray / 10000.0);
- break;
-
- case PSD_CS_FOCOLTONE:
- case PSD_CS_TRUMATCH:
- case PSD_CS_HKS:
- case PSD_CS_LAB:
- case PSD_CS_PANTONE:
- case PSD_CS_TOYO:
- case PSD_CS_DIC:
- case PSD_CS_ANPA:
- default:
- if (CONVERSION_WARNINGS)
- g_message ("Unsupported color space: %d",
- dsp_info.colorSpace);
- gimp_rgb_set (&gimp_rgb, 1.0, 0.0, 0.0);
+ case PSD_CS_RGB:
+ gimp_rgb_set (&gimp_rgb, ps_color.rgb.red / 65535.0,
+ ps_color.rgb.green / 65535.0,
+ ps_color.rgb.blue / 65535.0);
+ break;
+
+ case PSD_CS_HSB:
+ gimp_hsv_set (&gimp_hsv, ps_color.hsv.hue / 65535.0,
+ ps_color.hsv.saturation / 65535.0,
+ ps_color.hsv.value / 65535.0);
+ gimp_hsv_to_rgb (&gimp_hsv, &gimp_rgb);
+ break;
+
+ case PSD_CS_CMYK:
+ gimp_cmyk_set (&gimp_cmyk, 1.0 - ps_color.cmyk.cyan / 65535.0,
+ 1.0 - ps_color.cmyk.magenta / 65535.0,
+ 1.0 - ps_color.cmyk.yellow / 65535.0,
+ 1.0 - ps_color.cmyk.black / 65535.0);
+ gimp_cmyk_to_rgb (&gimp_cmyk, &gimp_rgb);
+ break;
+
+ case PSD_CS_GRAYSCALE:
+ gimp_rgb_set (&gimp_rgb, ps_color.gray.gray / 10000.0,
+ ps_color.gray.gray / 10000.0,
+ ps_color.gray.gray / 10000.0);
+ break;
+
+ case PSD_CS_FOCOLTONE:
+ case PSD_CS_TRUMATCH:
+ case PSD_CS_HKS:
+ case PSD_CS_LAB:
+ case PSD_CS_PANTONE:
+ case PSD_CS_TOYO:
+ case PSD_CS_DIC:
+ case PSD_CS_ANPA:
+ default:
+ if (CONVERSION_WARNINGS)
+ g_message ("Unsupported color space: %d",
+ dsp_info.colorSpace);
+ gimp_rgb_set (&gimp_rgb, 1.0, 0.0, 0.0);
}
gimp_rgb_set_alpha (&gimp_rgb, 1.0);
IFDBG(2) g_debug ("PS cSpace: %d, col: %d %d %d %d, opacity: %d, kind: %d",
- dsp_info.colorSpace, ps_color.cmyk.cyan, ps_color.cmyk.magenta,
- ps_color.cmyk.yellow, ps_color.cmyk.black, dsp_info.opacity,
- dsp_info.kind);
+ dsp_info.colorSpace, ps_color.cmyk.cyan, ps_color.cmyk.magenta,
+ ps_color.cmyk.yellow, ps_color.cmyk.black, dsp_info.opacity,
+ dsp_info.kind);
IFDBG(2) g_debug ("cSpace: %d, col: %g %g %g, opacity: %d, kind: %d",
- dsp_info.colorSpace, gimp_rgb.r * 255 , gimp_rgb.g * 255,
- gimp_rgb.b * 255, dsp_info.opacity, dsp_info.kind);
+ dsp_info.colorSpace, gimp_rgb.r * 255 , gimp_rgb.g * 255,
+ gimp_rgb.b * 255, dsp_info.opacity, dsp_info.kind);
img_a->alpha_display_info[cidx] = g_malloc (sizeof (PSDchanneldata));
img_a->alpha_display_info[cidx]->gimp_color = gimp_rgb;
@@ -949,7 +994,7 @@ load_resource_1028 (const PSDimageres *res_a,
/* Store resource data as a standard psd parasite */
IFDBG (2) g_debug ("Processing IPTC data as psd parasite");
name = g_strdup_printf ("psd-image-resource-%.4s-%.4x",
- res_a->type, res_a->id);
+ res_a->type, res_a->id);
IFDBG(3) g_debug ("Parasite name: %s", name);
parasite = gimp_parasite_new (name, 0, res_a->data_len, res_data);
@@ -993,10 +1038,10 @@ load_resource_1032 (const PSDimageres *res_a,
hdr.fGuideCount = GUINT32_FROM_BE (hdr.fGuideCount);
IFDBG(3) g_debug ("Grids & Guides: %d, %d, %d, %d",
- hdr.fVersion,
- hdr.fGridCycleV,
- hdr.fGridCycleH,
- hdr.fGuideCount);
+ hdr.fVersion,
+ hdr.fGridCycleV,
+ hdr.fGridCycleH,
+ hdr.fGuideCount);
for (i = 0; i < hdr.fGuideCount; ++i)
{
@@ -1010,8 +1055,8 @@ load_resource_1032 (const PSDimageres *res_a,
guide.fLocation /= 32;
IFDBG(3) g_debug ("Guide: %d px, %d",
- guide.fLocation,
- guide.fDirection);
+ guide.fLocation,
+ guide.fDirection);
if (guide.fDirection == PSD_VERTICAL)
gimp_image_add_vguide (image_id, guide.fLocation);
@@ -1069,9 +1114,9 @@ load_resource_1033 (const PSDimageres *res_a,
IFDBG(2) g_debug ("\nThumbnail:\n"
"\tFormat: %d\n"
"\tDimensions: %d x %d\n",
- thumb_info.format,
- thumb_info.width,
- thumb_info.height);
+ thumb_info.format,
+ thumb_info.width,
+ thumb_info.height);
if (thumb_info.format != 1)
{
@@ -1341,7 +1386,7 @@ load_resource_1058 (const PSDimageres *res_a,
/* Store resource data as a standard psd parasite */
IFDBG (2) g_debug ("Processing exif data as psd parasite");
name = g_strdup_printf ("psd-image-resource-%.4s-%.4x",
- res_a->type, res_a->id);
+ res_a->type, res_a->id);
IFDBG(3) g_debug ("Parasite name: %s", name);
parasite = gimp_parasite_new (name, 0, res_a->data_len, res_data);
@@ -1354,6 +1399,118 @@ load_resource_1058 (const PSDimageres *res_a,
}
static gint
+load_resource_1077 (const PSDimageres *res_a,
+ const gint32 image_id,
+ PSDimage *img_a,
+ FILE *f,
+ GError **error)
+{
+ /* Load alpha channel display info */
+
+ DisplayInfoNew dsp_info;
+ CMColor ps_color;
+ GimpRGB gimp_rgb;
+ GimpHSV gimp_hsv;
+ GimpCMYK gimp_cmyk;
+ gint16 tot_rec;
+ gint cidx;
+
+ IFDBG(2) g_debug ("Process image resource block 1077: Display Info New");
+
+ /* For now, skip first 4 bytes since intention is unclear. Seems to be
+ a version number that is always one, but who knows. */
+ fseek (f, 4, SEEK_CUR);
+
+ tot_rec = res_a->data_len / 13;
+ if (tot_rec == 0)
+ return 0;
+
+ img_a->alpha_display_info = g_new (PSDchanneldata *, tot_rec);
+ img_a->alpha_display_count = tot_rec;
+ for (cidx = 0; cidx < tot_rec; ++cidx)
+ {
+ if (fread (&dsp_info.colorSpace, 2, 1, f) < 1
+ || fread (&dsp_info.color, 8, 1, f) < 1
+ || fread (&dsp_info.opacity, 2, 1, f) < 1
+ || fread (&dsp_info.mode, 1, 1, f) < 1)
+ {
+ psd_set_error (feof (f), errno, error);
+ return -1;
+ }
+ dsp_info.colorSpace = GINT16_FROM_BE (dsp_info.colorSpace);
+ ps_color.cmyk.cyan = GUINT16_FROM_BE (dsp_info.color[0]);
+ ps_color.cmyk.magenta = GUINT16_FROM_BE (dsp_info.color[1]);
+ ps_color.cmyk.yellow = GUINT16_FROM_BE (dsp_info.color[2]);
+ ps_color.cmyk.black = GUINT16_FROM_BE (dsp_info.color[3]);
+ dsp_info.opacity = GINT16_FROM_BE (dsp_info.opacity);
+
+ switch (dsp_info.colorSpace)
+ {
+ case PSD_CS_RGB:
+ gimp_rgb_set (&gimp_rgb, ps_color.rgb.red / 65535.0,
+ ps_color.rgb.green / 65535.0,
+ ps_color.rgb.blue / 65535.0);
+ break;
+
+ case PSD_CS_HSB:
+ gimp_hsv_set (&gimp_hsv, ps_color.hsv.hue / 65535.0,
+ ps_color.hsv.saturation / 65535.0,
+ ps_color.hsv.value / 65535.0);
+ gimp_hsv_to_rgb (&gimp_hsv, &gimp_rgb);
+ break;
+
+ case PSD_CS_CMYK:
+ gimp_cmyk_set (&gimp_cmyk, 1.0 - ps_color.cmyk.cyan / 65535.0,
+ 1.0 - ps_color.cmyk.magenta / 65535.0,
+ 1.0 - ps_color.cmyk.yellow / 65535.0,
+ 1.0 - ps_color.cmyk.black / 65535.0);
+ gimp_cmyk_to_rgb (&gimp_cmyk, &gimp_rgb);
+ break;
+
+ case PSD_CS_GRAYSCALE:
+ gimp_rgb_set (&gimp_rgb, ps_color.gray.gray / 10000.0,
+ ps_color.gray.gray / 10000.0,
+ ps_color.gray.gray / 10000.0);
+ break;
+
+ case PSD_CS_FOCOLTONE:
+ case PSD_CS_TRUMATCH:
+ case PSD_CS_HKS:
+ case PSD_CS_LAB:
+ case PSD_CS_PANTONE:
+ case PSD_CS_TOYO:
+ case PSD_CS_DIC:
+ case PSD_CS_ANPA:
+ default:
+ if (CONVERSION_WARNINGS)
+ g_message ("Unsupported color space: %d",
+ dsp_info.colorSpace);
+ gimp_rgb_set (&gimp_rgb, 1.0, 0.0, 0.0);
+ }
+
+ gimp_rgb_set_alpha (&gimp_rgb, 1.0);
+
+ IFDBG(2) g_debug ("PS cSpace: %d, col: %d %d %d %d, opacity: %d, kind: %d",
+ dsp_info.colorSpace, ps_color.cmyk.cyan, ps_color.cmyk.magenta,
+ ps_color.cmyk.yellow, ps_color.cmyk.black, dsp_info.opacity,
+ dsp_info.kind);
+
+ IFDBG(2) g_debug ("cSpace: %d, col: %g %g %g, opacity: %d, kind: %d",
+ dsp_info.colorSpace, gimp_rgb.r * 255 , gimp_rgb.g * 255,
+ gimp_rgb.b * 255, dsp_info.opacity, dsp_info.kind);
+
+ img_a->alpha_display_info[cidx] = g_malloc (sizeof (PSDchanneldata));
+ img_a->alpha_display_info[cidx]->gimp_color = gimp_rgb;
+ img_a->alpha_display_info[cidx]->opacity = dsp_info.opacity;
+ img_a->alpha_display_info[cidx]->ps_mode = dsp_info.mode;
+ img_a->alpha_display_info[cidx]->ps_cspace = dsp_info.colorSpace;
+ img_a->alpha_display_info[cidx]->ps_color = ps_color;
+ }
+
+ return 0;
+}
+
+static gint
load_resource_2000 (const PSDimageres *res_a,
const gint32 image_id,
FILE *f,
diff --git a/plug-ins/file-psd/psd-layer-res-load.c b/plug-ins/file-psd/psd-layer-res-load.c
index 8884ea1..2147a16 100644
--- a/plug-ins/file-psd/psd-layer-res-load.c
+++ b/plug-ins/file-psd/psd-layer-res-load.c
@@ -191,7 +191,7 @@ get_layer_resource_header (PSDlayerres *res_a,
res_a->data_start = ftell (f);
IFDBG(2) g_debug ("Sig: %.4s, key: %.4s, start: %d, len: %d",
- res_a->sig, res_a->key, res_a->data_start, res_a->data_len);
+ res_a->sig, res_a->key, res_a->data_start, res_a->data_len);
return 0;
}
@@ -501,4 +501,3 @@ load_resource_lsct (const PSDlayerres *res_a,
lyr_a->group_type = type;
return 0;
}
-
diff --git a/plug-ins/file-psd/psd-load.c b/plug-ins/file-psd/psd-load.c
index 5c556d6..9a26642 100644
--- a/plug-ins/file-psd/psd-load.c
+++ b/plug-ins/file-psd/psd-load.c
@@ -1092,24 +1092,30 @@ add_layers (const gint32 image_id,
}
else
{
- if (lyr_a[lidx]->group_type != 0)
+ switch (lyr_a[lidx]->group_type)
{
- if (lyr_a[lidx]->group_type == 3)
- {
- /* the </Layer group> marker layers are used to
- assemble the layer structure in a single pass */
- layer_id = gimp_layer_group_new (image_id);
- }
- else /* group-type == 1 || group_type == 2 */
- {
- layer_id = g_array_index (parent_group_stack, gint32,
- parent_group_stack->len-1);
- /* since the layers are stored in reverse, the group
+ case 1:
+ case 2:
+ layer_id = g_array_index (parent_group_stack, gint32,
+ parent_group_stack->len-1);
+ /* since the layers are stored in reverse, the group
layer start marker actually means we're done with
that layer group */
- g_array_remove_index (parent_group_stack,
- parent_group_stack->len-1);
- }
+ g_array_remove_index (parent_group_stack,
+ parent_group_stack->len-1);
+ g_message("Case 1 and 2");
+ break;
+ case 3:
+ /* the </Layer group> marker layers are used to
+ assemble the layer structure in a single pass */
+ layer_id = gimp_layer_group_new (image_id);
+ g_message("Case 3");
+ break;
+ default:
+ /* Type 0 and non-marked layers are not touched
+ and they are their own layer */
+ g_message("Case 0");
+ break;
}
/* Empty layer */
diff --git a/plug-ins/file-psd/psd-save.c b/plug-ins/file-psd/psd-save.c
index 70883d1..00105a5 100644
--- a/plug-ins/file-psd/psd-save.c
+++ b/plug-ins/file-psd/psd-save.c
@@ -86,12 +86,11 @@
#define DEBUG FALSE
/* 1: Normal debuggin, 2: Deep debuggin */
-#define DEBUG_LEVEL 1
+#define DEBUG_LEVEL 2
#define IFDBG if (DEBUG)
#define IF_DEEP_DBG if (DEBUG && DEBUG_LEVEL == 2)
-
#define PSD_UNIT_INCH 1
#define PSD_UNIT_CM 2
@@ -101,7 +100,6 @@
/* Local types etc
*/
-
typedef struct PsdLayerDimension
{
gint left;
@@ -110,7 +108,6 @@ typedef struct PsdLayerDimension
gint32 height;
} PSD_Layer_Dimension;
-
typedef struct PsdImageData
{
gboolean compression;
@@ -134,63 +131,78 @@ typedef struct PsdImageData
static PSD_Image_Data PSDImageData;
-
/* Declare some local functions.
*/
static void query (void);
-static void run (const gchar *name,
- gint nparams,
- const GimpParam *param,
- gint *nreturn_vals,
- GimpParam **return_vals);
-
-static void psd_lmode_layer (gint32 idLayer,
- gchar *psdMode);
-static void reshuffle_cmap_write (guchar *mapGimp);
-static void save_header (FILE *fd,
- gint32 image_id);
-static void save_color_mode_data (FILE *fd,
- gint32 image_id);
-static void save_resources (FILE *fd,
- gint32 image_id);
-static void save_layer_and_mask (FILE *fd,
- gint32 image_id);
-static void save_data (FILE *fd,
- gint32 image_id);
-static gint save_image (const gchar *filename,
- gint32 image_id,
- GError **error);
-static void xfwrite (FILE *fd,
- gconstpointer buf,
- glong len,
- const gchar *why);
-static void write_pascalstring (FILE *fd,
- const gchar *val,
- gint padding,
- const gchar *why);
-static void write_string (FILE *fd,
- const gchar *val,
- const gchar *why);
-static void write_gchar (FILE *fd,
- guchar val,
- const gchar *why);
-static void write_gint16 (FILE *fd,
- gint16 val,
- const gchar *why);
-static void write_gint32 (FILE *fd,
- gint32 val,
- const gchar *why);
-static void write_datablock_luni (FILE *fd,
- const gchar *val,
- const gchar *why);
-
-static void write_pixel_data (FILE *fd,
- gint32 drawableID,
- glong *ChanLenPosition,
- gint32 rowlenOffset);
-
-static gint32 create_merged_image (gint32 imageID);
+
+static void run (const gchar *name,
+ gint nparams,
+ const GimpParam *param,
+ gint *nreturn_vals,
+ GimpParam **return_vals);
+
+static void psd_lmode_layer (gint32 idLayer,
+ gchar *psdMode);
+
+static void reshuffle_cmap_write (guchar *mapGimp);
+
+static void save_header (FILE *fd,
+ gint32 image_id);
+
+static void save_color_mode_data (FILE *fd,
+ gint32 image_id);
+
+static void save_resources (FILE *fd,
+ gint32 image_id);
+
+static void save_layer_and_mask (FILE *fd,
+ gint32 image_id);
+
+static void save_data (FILE *fd,
+ gint32 image_id);
+
+static gint save_image (const gchar *filename,
+ gint32 image_id,
+ GError **error);
+
+static void xfwrite (FILE *fd,
+ gconstpointer buf,
+ glong len,
+ const gchar *why);
+
+static void write_pascalstring (FILE *fd,
+ const gchar *val,
+ gint padding,
+ const gchar *why);
+
+static void write_string (FILE *fd,
+ const gchar *val,
+ const gchar *why);
+
+static void write_gchar (FILE *fd,
+ guchar val,
+ const gchar *why);
+
+static void write_gint16 (FILE *fd,
+ gint16 val,
+ const gchar *why);
+
+static void write_gint32 (FILE *fd,
+ gint32 val,
+ const gchar *why);
+
+static void write_datablock_luni (FILE *fd,
+ const gchar *val,
+ const gchar *why);
+
+
+static void write_pixel_data (FILE *fd,
+ gint32 drawableID,
+ glong *ChanLenPosition,
+ gint32 rowlenOffset);
+
+static gint32 create_merged_image (gint32 imageID);
const GimpPlugInInfo PLUG_IN_INFO =
@@ -235,7 +247,6 @@ query (void)
gimp_register_save_handler (SAVE_PROC, "psd", "");
}
-
static void
run (const gchar *name,
gint nparams,
@@ -411,7 +422,6 @@ psd_lmode_layer (gint32 idLayer,
}
}
-
static void
write_string (FILE *fd,
const gchar *val,
@@ -421,7 +431,6 @@ write_string (FILE *fd,
xfwrite (fd, val, strlen (val), why);
}
-
static void
write_pascalstring (FILE *fd,
const gchar *val,
@@ -459,7 +468,6 @@ write_pascalstring (FILE *fd,
write_gchar (fd, 0, why);
}
-
static void
xfwrite (FILE *fd,
gconstpointer buf,
@@ -476,7 +484,6 @@ xfwrite (FILE *fd,
}
}
-
static void
write_gchar (FILE *fd,
guchar val,
@@ -497,7 +504,6 @@ write_gchar (FILE *fd,
fseek (fd, pos + 1, SEEK_SET);
}
-
static void
write_gint16 (FILE *fd,
gint16 val,
@@ -517,9 +523,6 @@ write_gint16 (FILE *fd,
}
}
-
-
-
static void
write_gint32 (FILE *fd,
gint32 val,
@@ -539,7 +542,6 @@ write_gint32 (FILE *fd,
}
}
-
static void
write_datablock_luni (FILE *fd,
const gchar *val,
@@ -581,7 +583,6 @@ write_datablock_luni (FILE *fd,
}
}
-
static gint32
pack_pb_line (guchar *start,
gint32 length,
@@ -666,7 +667,6 @@ gimpBaseTypeToPsdMode (GimpImageBaseType gimpBaseType)
}
}
-
static gint
nChansLayer (gint gimpBaseType,
gint hasAlpha,
@@ -691,7 +691,6 @@ nChansLayer (gint gimpBaseType,
}
}
-
static void
reshuffle_cmap_write (guchar *mapGimp)
{
@@ -715,7 +714,6 @@ reshuffle_cmap_write (guchar *mapGimp)
g_free (mapPSD);
}
-
static void
save_header (FILE *fd,
gint32 image_id)
@@ -741,8 +739,6 @@ save_header (FILE *fd,
write_gint16 (fd, gimpBaseTypeToPsdMode (PSDImageData.baseType), "mode");
}
-
-
static void
save_color_mode_data (FILE *fd,
gint32 image_id)
@@ -800,8 +796,6 @@ save_color_mode_data (FILE *fd,
}
}
-
-
static void
save_resources (FILE *fd,
gint32 image_id)
@@ -1031,8 +1025,6 @@ save_resources (FILE *fd,
fseek (fd, eof_pos, SEEK_SET);
}
-
-
static int
get_compress_channel_data (guchar *channel_data,
gint32 channel_cols,
@@ -1062,7 +1054,6 @@ get_compress_channel_data (guchar *channel_data,
return len;
}
-
static void
save_layer_and_mask (FILE *fd,
gint32 image_id)
@@ -1284,8 +1275,6 @@ save_layer_and_mask (FILE *fd,
fseek (fd, eof_pos, SEEK_SET);
}
-
-
static void
write_pixel_data (FILE *fd,
gint32 drawableID,
@@ -1484,8 +1473,6 @@ write_pixel_data (FILE *fd,
g_free (LengthsTable);
}
-
-
static void
save_data (FILE *fd,
gint32 image_id)
@@ -1628,8 +1615,6 @@ get_image_data (FILE *fd,
PSDImageData.layersDim = g_new (PSD_Layer_Dimension, PSDImageData.nLayers);
}
-
-
static gint
save_image (const gchar *filename,
gint32 image_id,
diff --git a/plug-ins/file-psd/psd.h b/plug-ins/file-psd/psd.h
index 7221632..20edcae 100644
--- a/plug-ins/file-psd/psd.h
+++ b/plug-ins/file-psd/psd.h
@@ -31,7 +31,7 @@
/* Set to the level of debugging output you want, 0 for none.
* Setting higher than 2 will result in a very large amount of debug
* output being produced. */
-#define PSD_DEBUG 0
+#define PSD_DEBUG 3
#define IFDBG(level) if (PSD_DEBUG >= level)
/* Set to FALSE to suppress pop-up warnings about lossy file conversions */
@@ -248,7 +248,8 @@ typedef enum {
PSD_ALPHA_ID = 1053, /* 0x041d - Alpha IDs */
PSD_URL_LIST_UNI = 1054, /* 0x041e - URL list - unicode */
PSD_VERSION_INFO = 1057, /* 0x0421 - Version info */
- PSD_EXIF_DATA = 1058, /* 0x0422 - Exif data block */
+ PSD_EXIF_DATA = 1058, /* 0x0422 - Exif data block 1 */
+ PSD_EXIF_DATA_3 = 1059, /* 0X0423 - Exif data block 3 (?) */
PSD_XMP_DATA = 1060, /* 0x0424 - XMP data block */
PSD_CAPTION_DIGEST = 1061, /* 0x0425 - Caption digest */
PSD_PRINT_SCALE = 1062, /* 0x0426 - Print scale */
@@ -278,8 +279,8 @@ typedef enum {
PSD_CLIPPING_PATH = 2999, /* 0x0bb7 - Name of clipping path */
PSD_PLUGIN_R_FIRST = 4000, /* 0x0FA0 - First plugin resource */
PSD_PLUGIN_R_LAST = 4999, /* 0x1387 - Last plugin resource */
- PSD_IMAGEREADY_VARS = 7000, /* 0x1B58 - Name of clipping path */
- PSD_IMAGEREADY_DATA = 7001, /* 0x1B59 - Name of clipping path */
+ PSD_IMAGEREADY_VARS = 7000, /* 0x1B58 - Imageready variables */
+ PSD_IMAGEREADY_DATA = 7001, /* 0x1B59 - Imageready data sets */
PSD_LIGHTROOM_WORK = 8000, /* 0x1F40 - Lightroom workflow */
PSD_PRINT_FLAGS_2 = 10000 /* 0x2710 - Print flags */
} PSDImageResID;
@@ -472,23 +473,21 @@ typedef struct {
/* Channel display info data for Adobe Photoshop CS2 and lower */
typedef struct {
- gint16 colorSpace; /* Color space from PSDColorSpace */
+ gint16 colorSpace; /* Color space from PSDColorSpace */
guint16 color[4]; /* 4 * 16 bit color components */
gint16 opacity; /* Opacity 0 to 100 */
gchar kind; /* Selected = 0, Protected = 1 */
gchar padding; /* Padding */
} DisplayInfo;
-/* Channel display info data for Adobe Photoshop CS3 and higher to support floating point colors
---Note-- There are an additional 4 bytes at the beginning of the block, that contain the version number
-(which seems to be 1). */
- typedef struct {
- gint16 colorSpace; /* Color space from PSDColorSpace */
- guint16 color[4]; /* 4 * 16 bit color components */
- gint16 opacity; /* Opacity 0 to 100 */
- gchar kind; /* Selected = 0, Protected = 1 */
- gchar mode; /* Alpha = 0, Inverted alpha = 1, Spot = 2 */
- } DisplayInfoNew;
+/* Channel display info data for Adobe Photoshop CS3 and higher to support floating point colors */
+typedef struct {
+ gint16 colorSpace; /* Color space from PSDColorSpace */
+ guint16 color[4]; /* 4 * 16 bit color components */
+ gint16 opacity; /* Opacity 0 to 100 */
+ gchar kind; /* Selected = 0, Protected = 1 */
+ gchar mode; /* Alpha = 0, Inverted alpha = 1, Spot = 2 */
+} DisplayInfoNew;
/* PSD Channel length info data structure */
@@ -580,6 +579,7 @@ typedef struct
{
GimpRGB gimp_color; /* Gimp RGB color */
gint16 opacity; /* Opacity */
+ guchar ps_mode; /* PS mode flag */
guchar ps_kind; /* PS type flag */
gint16 ps_cspace; /* PS color space */
CMColor ps_color; /* PS color */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]