[gimp] Bug 592533 - Mask positions move to top-left when saving as PSD
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 592533 - Mask positions move to top-left when saving as PSD
- Date: Mon, 4 Sep 2017 20:07:25 +0000 (UTC)
commit eb2741ed70d156e40bdd8f43be17100c550d502f
Author: Ell <ell_se yahoo com>
Date: Mon Sep 4 15:53:00 2017 -0400
Bug 592533 - Mask positions move to top-left when saving as PSD
And: Bug 593251 - Mask positions may be incorrect when opening a PSD
The position-relative flag of layer masks doesn't specify how the
mask position is represented in the PSD -- it's always absolute --
but rather whether the layer and the mask are linked or unlinked.
Since masks are always linked to their layers in GIMP, just ignore
this flag (and, when saving, clear the flag so that the mask is
linked to layer when loaded in PS.)
plug-ins/file-psd/psd-load.c | 25 ++++++-------------------
plug-ins/file-psd/psd-save.c | 22 ++++++++++++----------
2 files changed, 18 insertions(+), 29 deletions(-)
---
diff --git a/plug-ins/file-psd/psd-load.c b/plug-ins/file-psd/psd-load.c
index c2a189b..d691b55 100644
--- a/plug-ins/file-psd/psd-load.c
+++ b/plug-ins/file-psd/psd-load.c
@@ -767,12 +767,11 @@ read_layer_info (PSDimage *img_a,
return NULL;
}
- IFDBG(2) g_debug ("Layer mask coords %d %d %d %d, Rel pos %d",
+ IFDBG(2) g_debug ("Layer mask coords %d %d %d %d",
lyr_a[lidx]->layer_mask.left,
lyr_a[lidx]->layer_mask.top,
lyr_a[lidx]->layer_mask.right,
- lyr_a[lidx]->layer_mask.bottom,
- lyr_a[lidx]->layer_mask.mask_flags.relative_pos);
+ lyr_a[lidx]->layer_mask.bottom);
IFDBG(3) g_debug ("Default mask color, %d, %d",
lyr_a[lidx]->layer_mask.def_color,
@@ -1535,23 +1534,11 @@ add_layers (gint32 image_id,
else
{
/* Load layer mask data */
- if (lyr_a[lidx]->layer_mask.mask_flags.relative_pos)
- {
- lm_x = lyr_a[lidx]->layer_mask.left;
- lm_y = lyr_a[lidx]->layer_mask.top;
- lm_w = lyr_a[lidx]->layer_mask.right - lyr_a[lidx]->layer_mask.left;
- lm_h = lyr_a[lidx]->layer_mask.bottom - lyr_a[lidx]->layer_mask.top;
- }
- else
- {
- lm_x = lyr_a[lidx]->layer_mask.left - l_x;
- lm_y = lyr_a[lidx]->layer_mask.top - l_y;
- lm_w = lyr_a[lidx]->layer_mask.right - lyr_a[lidx]->layer_mask.left;
- lm_h = lyr_a[lidx]->layer_mask.bottom - lyr_a[lidx]->layer_mask.top;
- }
+ lm_x = lyr_a[lidx]->layer_mask.left - l_x;
+ lm_y = lyr_a[lidx]->layer_mask.top - l_y;
+ lm_w = lyr_a[lidx]->layer_mask.right - lyr_a[lidx]->layer_mask.left;
+ lm_h = lyr_a[lidx]->layer_mask.bottom - lyr_a[lidx]->layer_mask.top;
IFDBG(3) g_debug ("Mask channel index %d", user_mask_chn);
- IFDBG(3) g_debug ("Relative pos %d",
- lyr_a[lidx]->layer_mask.mask_flags.relative_pos);
bps = (img_a->bps + 1) / 8;
layer_size = lm_w * lm_h * bps;
pixels = g_malloc (layer_size);
diff --git a/plug-ins/file-psd/psd-save.c b/plug-ins/file-psd/psd-save.c
index ee91796..552ec8c 100644
--- a/plug-ins/file-psd/psd-save.c
+++ b/plug-ins/file-psd/psd-save.c
@@ -1019,20 +1019,22 @@ save_layer_and_mask (FILE *fd,
mask = gimp_layer_get_mask (PSDImageData.lLayers[i].id);
if (mask >= 0)
{
- gboolean apply = gimp_layer_get_apply_mask (PSDImageData.lLayers[i].id);
+ gint maskWidth = gimp_drawable_width (mask);
+ gint maskHeight = gimp_drawable_height (mask);
+ gboolean apply = gimp_layer_get_apply_mask (PSDImageData.lLayers[i].id);
IFDBG printf ("\t\tLayer mask size: %d\n", 20);
- write_gint32 (fd, 20, "Layer mask size");
- write_gint32 (fd, 0, "Layer mask top");
- write_gint32 (fd, 0, "Layer mask left");
- write_gint32 (fd, gimp_drawable_height(mask),"Layer mask bottom");
- write_gint32 (fd, gimp_drawable_width(mask), "Layer mask right");
- write_gchar (fd, 0, "Layer mask default color");
- flags = (1 | /* position relative to layer */
+ write_gint32 (fd, 20, "Layer mask size");
+ write_gint32 (fd, offset_y, "Layer mask top");
+ write_gint32 (fd, offset_x, "Layer mask left");
+ write_gint32 (fd, offset_y + maskHeight, "Layer mask bottom");
+ write_gint32 (fd, offset_x + maskWidth, "Layer mask right");
+ write_gchar (fd, 0, "Layer mask default color");
+ flags = (0 | /* position relative to layer */
(apply ? 0 : 1) << 1 | /* layer mask disabled */
0 << 2); /* invert layer mask */
- write_gchar (fd, flags, "Layer mask flags");
- write_gint16 (fd, 0, "Layer mask Padding");
+ write_gchar (fd, flags, "Layer mask flags");
+ write_gint16 (fd, 0, "Layer mask Padding");
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]