[gimp] Bug 747156 - Gimp Development version crashes on processing masks from psds
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 747156 - Gimp Development version crashes on processing masks from psds
- Date: Sun, 26 Apr 2015 03:05:45 +0000 (UTC)
commit 7c4f3f02c7a9919551eb038956a8545e79ba1b06
Author: Michael Natterer <mitch gimp org>
Date: Sat Apr 25 23:02:54 2015 -0400
Bug 747156 - Gimp Development version crashes on processing masks from psds
Fix the other pixel format issue in this bug: split up
get_pixel_format() into 3 functions get_layer,channel,mask_format() so
we use the right one for the right drawable type, get_layer_format()
has an "alpha" parameter that is taken from the loaded layer instead
of from the PSDimage struct.
plug-ins/file-psd/psd-load.c | 98 ++++++++++++++++++++++++++++--------------
1 files changed, 65 insertions(+), 33 deletions(-)
---
diff --git a/plug-ins/file-psd/psd-load.c b/plug-ins/file-psd/psd-load.c
index 2a1b96c..2e9a44e 100644
--- a/plug-ins/file-psd/psd-load.c
+++ b/plug-ins/file-psd/psd-load.c
@@ -102,8 +102,10 @@ static void convert_1_bit (const gchar *src,
guint32 rows,
guint32 columns);
-static const Babl* get_pixel_format (PSDimage *img_a,
- gboolean mask_format);
+static const Babl* get_layer_format (PSDimage *img_a,
+ gboolean alpha);
+static const Babl* get_channel_format (PSDimage *img_a);
+static const Babl* get_mask_format (PSDimage *img_a);
/* Main file load function */
@@ -1391,7 +1393,7 @@ add_layers (gint32 image_id,
GEGL_RECTANGLE (0, 0,
gegl_buffer_get_width (buffer),
gegl_buffer_get_height (buffer)),
- 0, get_pixel_format (img_a, FALSE),
+ 0, get_layer_format (img_a, alpha),
pixels, GEGL_AUTO_ROWSTRIDE);
gimp_item_set_visible (layer_id, lyr_a[lidx]->layer_flags.visible);
if (lyr_a[lidx]->id)
@@ -1506,7 +1508,7 @@ add_layers (gint32 image_id,
buffer = gimp_drawable_get_buffer (mask_id);
gegl_buffer_set (buffer,
GEGL_RECTANGLE (lm_x, lm_y, lm_w, lm_h),
- 0, get_pixel_format (img_a, TRUE),
+ 0, get_mask_format (img_a),
pixels, GEGL_AUTO_ROWSTRIDE);
g_object_unref (buffer);
gimp_layer_set_apply_mask (layer_id,
@@ -1693,7 +1695,7 @@ add_merged_image (gint32 image_id,
GEGL_RECTANGLE (0, 0,
gegl_buffer_get_width (buffer),
gegl_buffer_get_height (buffer)),
- 0, get_pixel_format (img_a, FALSE),
+ 0, get_layer_format (img_a, img_a->transparency),
pixels, GEGL_AUTO_ROWSTRIDE);
g_object_unref (buffer);
g_free (pixels);
@@ -1788,7 +1790,7 @@ add_merged_image (gint32 image_id,
GEGL_RECTANGLE (0, 0,
gegl_buffer_get_width (buffer),
gegl_buffer_get_height (buffer)),
- 0, get_pixel_format (img_a, TRUE),
+ 0, get_channel_format (img_a),
pixels, GEGL_AUTO_ROWSTRIDE);
g_object_unref (buffer);
g_free (chn_a[cidx].data);
@@ -2029,36 +2031,12 @@ convert_1_bit (const gchar *src,
}
static const Babl*
-get_pixel_format (PSDimage *img_a,
- gboolean mask_format)
+get_layer_format (PSDimage *img_a,
+ gboolean alpha)
{
const Babl *format = NULL;
- if (mask_format)
- {
- switch (img_a->bps)
- {
- case 32:
- format = babl_format ("Y u32");
- break;
-
- case 16:
- format = babl_format ("Y u16");
- break;
-
- case 8:
- case 1:
- format = babl_format ("Y u8");
- break;
-
- default:
- break;
- }
-
- return format;
- }
-
- switch (get_gimp_image_type (img_a->base_type, img_a->transparency))
+ switch (get_gimp_image_type (img_a->base_type, alpha))
{
case GIMP_GRAY_IMAGE:
switch (img_a->bps)
@@ -2157,3 +2135,57 @@ get_pixel_format (PSDimage *img_a,
return format;
}
+
+static const Babl*
+get_channel_format (PSDimage *img_a)
+{
+ const Babl *format = NULL;
+
+ switch (img_a->bps)
+ {
+ case 32:
+ format = babl_format ("Y u32");
+ break;
+
+ case 16:
+ format = babl_format ("Y u16");
+ break;
+
+ case 8:
+ case 1:
+ format = babl_format ("Y u8");
+ break;
+
+ default:
+ break;
+ }
+
+ return format;
+}
+
+static const Babl*
+get_mask_format (PSDimage *img_a)
+{
+ const Babl *format = NULL;
+
+ switch (img_a->bps)
+ {
+ case 32:
+ format = babl_format ("Y u32");
+ break;
+
+ case 16:
+ format = babl_format ("Y u16");
+ break;
+
+ case 8:
+ case 1:
+ format = babl_format ("Y u8");
+ break;
+
+ default:
+ break;
+ }
+
+ return format;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]