[gimp/gimp-2-10] Issue #1621 - Alpha incorrectly exported in PSD
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] Issue #1621 - Alpha incorrectly exported in PSD
- Date: Tue, 12 Jun 2018 01:06:47 +0000 (UTC)
commit 3c9d513be9544c041a55137fbc4f6486a75b73e6
Author: Ell <ell_se yahoo com>
Date: Mon Jun 11 21:00:00 2018 -0400
Issue #1621 - Alpha incorrectly exported in PSD
In file-psd, fix the creation of the "merged" image data, saved in
PSD files along with the actual layer data.
(cherry picked from commit 8a01866af0359a64545ef7a2a9b37d6a8564a7b6)
plug-ins/file-psd/psd-save.c | 53 ++++++++++++++++++--------------------------
1 file changed, 22 insertions(+), 31 deletions(-)
---
diff --git a/plug-ins/file-psd/psd-save.c b/plug-ins/file-psd/psd-save.c
index 9f296a5e9a..1e10b7934d 100644
--- a/plug-ins/file-psd/psd-save.c
+++ b/plug-ins/file-psd/psd-save.c
@@ -1455,50 +1455,42 @@ create_merged_image (gint32 image_id)
projection = gimp_layer_new_from_visible (image_id, image_id, "psd-save");
+ if (! gimp_drawable_has_alpha (projection))
+ return projection;
+
if (gimp_image_base_type (image_id) != GIMP_INDEXED)
{
- GeglBuffer *buffer = gimp_drawable_get_buffer (projection);
- const Babl *format = get_pixel_format (projection);
- gboolean transparency_found = FALSE;
- gint bpp = babl_format_get_bytes_per_pixel (format);
- gint n_components = babl_format_get_n_components (format);
- gint width = gegl_buffer_get_width (buffer);
- gint height = gegl_buffer_get_height (buffer);
- GeglBufferIterator *iter = gegl_buffer_iterator_new (buffer, GEGL_RECTANGLE (0, 0,
width, height),
- 0, format,
- GEGL_ACCESS_READ,
GEGL_ABYSS_NONE);
+ GeglBuffer *buffer = gimp_drawable_get_buffer (projection);
+ const Babl *format = get_pixel_format (projection);
+ gboolean transparency_found = FALSE;
+ gint bpp = babl_format_get_bytes_per_pixel (format);
+ GeglBufferIterator *iter;
+
+ iter = gegl_buffer_iterator_new (buffer, NULL, 0, format,
+ GEGL_ACCESS_READWRITE, GEGL_ABYSS_NONE);
while (gegl_buffer_iterator_next (iter))
{
- guchar *data = iter->data[0];
- gint y;
+ guchar *d = iter->data[0];
+ gint i;
- for (y = 0; y < iter->roi->height; y++)
+ for (i = 0; i < iter->length; i++)
{
- guchar *d = data;
- gint x;
+ gint32 alpha = d[bpp - 1];
- for (x = 0; x < iter->roi->width; x++)
+ if (alpha < 255)
{
- gint32 alpha = d[bpp - 1];
-
- if (alpha < 255)
- {
- gint i;
+ gint c;
- transparency_found = TRUE;
-
- /* blend against white, photoshop does this. */
- for (i = 0; i < bpp - 1; i++)
- d[i] = ((guint32) d[i] * alpha) / 255 + 255 - alpha;
- }
+ transparency_found = TRUE;
+ /* blend against white, photoshop does this. */
+ for (c = 0; c < bpp - 1; c++)
+ d[c] = ((guint32) d[c] * alpha + 128) / 255 + 255 - alpha;
}
d += bpp;
}
-
- data += n_components;
}
g_object_unref (buffer);
@@ -1508,8 +1500,7 @@ create_merged_image (gint32 image_id)
}
else
{
- if (gimp_drawable_has_alpha (projection))
- gimp_layer_flatten (projection); /* PSDs don't support transparency information in indexed images*/
+ gimp_layer_flatten (projection); /* PSDs don't support transparency information in indexed images*/
}
return projection;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]