[gimp] app: in file-psd, make layer-group saving more Photoshop-like
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: in file-psd, make layer-group saving more Photoshop-like
- Date: Mon, 9 Oct 2017 14:46:11 +0000 (UTC)
commit adff950d5863ab8189cd2c67ce7607b45eb1ec3a
Author: Ell <ell_se yahoo com>
Date: Mon Oct 9 10:42:28 2017 -0400
app: in file-psd, make layer-group saving more Photoshop-like
Tweak the layer group saving code so that the saved PSDs match
Photoshop-produced PSDs a bit more closely. For the most part, it
doesn't seem to matter much, but it does somewhat improve
compatibility with other programs that read PSDs.
plug-ins/file-psd/psd-save.c | 38 +++++++++++++++++++-------------------
1 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/plug-ins/file-psd/psd-save.c b/plug-ins/file-psd/psd-save.c
index 552ec8c..ff8943a 100644
--- a/plug-ins/file-psd/psd-save.c
+++ b/plug-ins/file-psd/psd-save.c
@@ -137,7 +137,8 @@ static PSD_Image_Data PSDImageData;
/* Declare some local functions.
*/
-static const gchar * psd_lmode_layer (gint32 idLayer);
+static const gchar * psd_lmode_layer (gint32 idLayer,
+ gboolean section_divider);
static void reshuffle_cmap_write (guchar *mapGimp);
@@ -202,7 +203,8 @@ static PSD_Layer * image_get_all_layers (gint32 imageID,
gint *n_layers);
static const gchar *
-psd_lmode_layer (gint32 idLayer)
+psd_lmode_layer (gint32 idLayer,
+ gboolean section_divider)
{
LayerModeInfo mode_info;
@@ -214,7 +216,7 @@ psd_lmode_layer (gint32 idLayer)
/* pass-through groups use normal mode in their layer record; the
* pass-through mode is specified in their section divider resource.
*/
- if (mode_info.mode == GIMP_LAYER_MODE_PASS_THROUGH)
+ if (mode_info.mode == GIMP_LAYER_MODE_PASS_THROUGH && ! section_divider)
mode_info.mode = GIMP_LAYER_MODE_NORMAL;
return gimp_to_psd_blend_mode (&mode_info);
@@ -993,7 +995,7 @@ save_layer_and_mask (FILE *fd,
xfwrite (fd, "8BIM", 4, "blend mode signature");
- blendMode = psd_lmode_layer (PSDImageData.lLayers[i].id);
+ blendMode = psd_lmode_layer (PSDImageData.lLayers[i].id, FALSE);
IFDBG printf ("\t\tBlend mode: %s\n", blendMode);
xfwrite (fd, blendMode, 4, "blend mode key");
@@ -1007,6 +1009,7 @@ save_layer_and_mask (FILE *fd,
flags = 0;
if (gimp_layer_get_lock_alpha (PSDImageData.lLayers[i].id)) flags |= 1;
if (! gimp_item_get_visible (PSDImageData.lLayers[i].id)) flags |= 2;
+ if (PSDImageData.lLayers[i].type != PSD_LAYER_TYPE_LAYER) flags |= 0x18;
IFDBG printf ("\t\tFlags: %u\n", flags);
write_gchar (fd, flags, "Flags");
@@ -1047,7 +1050,10 @@ save_layer_and_mask (FILE *fd,
write_gint32 (fd, 0, "Layer blending size");
IFDBG printf ("\t\tLayer blending size: %d\n", 0);
- layerName = gimp_item_get_name (PSDImageData.lLayers[i].id);
+ if (PSDImageData.lLayers[i].type != PSD_LAYER_TYPE_GROUP_END)
+ layerName = gimp_item_get_name (PSDImageData.lLayers[i].id);
+ else
+ layerName = g_strdup ("</Layer group>");
write_pascalstring (fd, layerName, 4, "layer name");
IFDBG printf ("\t\tLayer name: %s\n", layerName);
@@ -1055,6 +1061,8 @@ save_layer_and_mask (FILE *fd,
/* Unicode layer name */
write_datablock_luni(fd, layerName, "luni extra data block");
+ g_free (layerName);
+
/* Layer color tag */
xfwrite (fd, "8BIMlclr", 8, "sheet color signature");
write_gint32 (fd, 8, "sheet color size");
@@ -1068,31 +1076,23 @@ save_layer_and_mask (FILE *fd,
/* Group layer section divider */
if (PSDImageData.lLayers[i].type != PSD_LAYER_TYPE_LAYER)
{
- gint32 size;
- gint32 type;
- gboolean pass_through;
+ gint32 size;
+ gint32 type;
- size = 4;
+ size = 12;
if (PSDImageData.lLayers[i].type == PSD_LAYER_TYPE_GROUP_START)
type = 1;
else
type = 3;
- /* pass-through groups use normal mode in their layer record; the
- * pass-through mode is specified in their section divider resource.
- */
- pass_through = gimp_layer_get_mode (PSDImageData.lLayers[i].id) ==
- GIMP_LAYER_MODE_PASS_THROUGH;
-
- if (pass_through)
- size += 8;
+ blendMode = psd_lmode_layer (PSDImageData.lLayers[i].id, TRUE);
xfwrite (fd, "8BIMlsct", 8, "section divider");
write_gint32 (fd, size, "section divider size");
write_gint32 (fd, type, "section divider type");
- if (pass_through)
- xfwrite (fd, "8BIMpass", 8, "section divider blend mode");
+ xfwrite (fd, "8BIM", 4, "section divider blend mode signature");
+ xfwrite (fd, blendMode, 4, "section divider blend mode key");
}
/* Write real length for: Extra data */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]