[gimp] app: fix XCF loading of floating selections of != image's layer type
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: fix XCF loading of floating selections of != image's layer type
- Date: Fri, 11 May 2012 12:24:12 +0000 (UTC)
commit ce1179410baaaa17f7c3c8deee3d946e94722662
Author: Michael Natterer <mitch gimp org>
Date: Fri May 11 14:22:50 2012 +0200
app: fix XCF loading of floating selections of != image's layer type
Same fix needs to be applied to gimp-layer-new in the PDB.
app/xcf/xcf-load.c | 84 ++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 62 insertions(+), 22 deletions(-)
---
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index a62ceee..0165863 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -1083,23 +1083,25 @@ xcf_load_layer (XcfInfo *info,
GimpImage *image,
GList **item_path)
{
- GimpLayer *layer;
- GimpLayerMask *layer_mask;
- guint32 hierarchy_offset;
- guint32 layer_mask_offset;
- gboolean apply_mask = TRUE;
- gboolean edit_mask = FALSE;
- gboolean show_mask = FALSE;
- gboolean active;
- gboolean floating;
- guint32 group_layer_flags = 0;
- guint32 text_layer_flags = 0;
- gint width;
- gint height;
- gint type;
- gboolean has_alpha;
- gboolean is_fs_drawable;
- gchar *name;
+ GimpLayer *layer;
+ GimpLayerMask *layer_mask;
+ guint32 hierarchy_offset;
+ guint32 layer_mask_offset;
+ gboolean apply_mask = TRUE;
+ gboolean edit_mask = FALSE;
+ gboolean show_mask = FALSE;
+ gboolean active;
+ gboolean floating;
+ guint32 group_layer_flags = 0;
+ guint32 text_layer_flags = 0;
+ gint width;
+ gint height;
+ gint type;
+ GimpImageBaseType base_type;
+ gboolean has_alpha;
+ const Babl *format;
+ gboolean is_fs_drawable;
+ gchar *name;
/* check and see if this is the drawable the floating selection
* is attached to. if it is then we'll do the attachment in our caller.
@@ -1112,14 +1114,52 @@ xcf_load_layer (XcfInfo *info,
info->cp += xcf_read_int32 (info->fp, (guint32 *) &type, 1);
info->cp += xcf_read_string (info->fp, &name, 1);
- has_alpha = (type == GIMP_RGBA_IMAGE ||
- type == GIMP_GRAYA_IMAGE ||
- type == GIMP_INDEXEDA_IMAGE);
+ switch (type)
+ {
+ case GIMP_RGB_IMAGE:
+ base_type = GIMP_RGB;
+ has_alpha = FALSE;
+ break;
+
+ case GIMP_RGBA_IMAGE:
+ base_type = GIMP_RGB;
+ has_alpha = TRUE;
+ break;
+
+ case GIMP_GRAY_IMAGE:
+ base_type = GIMP_GRAY;
+ has_alpha = FALSE;
+ break;
+
+ case GIMP_GRAYA_IMAGE:
+ base_type = GIMP_GRAY;
+ has_alpha = TRUE;
+ break;
+
+ case GIMP_INDEXED_IMAGE:
+ base_type = GIMP_INDEXED;
+ has_alpha = FALSE;
+ break;
+
+ case GIMP_INDEXEDA_IMAGE:
+ base_type = GIMP_INDEXED;
+ has_alpha = TRUE;
+ break;
+
+ default:
+ return NULL;
+ }
+
+ /* do not use gimp_image_get_layer_format() because it might
+ * be the floating selection of a channel or mask
+ */
+ format = gimp_image_get_format (image, base_type,
+ gimp_image_get_precision (image),
+ has_alpha);
/* create a new layer */
layer = gimp_layer_new (image, width, height,
- gimp_image_get_layer_format (image, has_alpha),
- name, 255, GIMP_NORMAL_MODE);
+ format, name, 255, GIMP_NORMAL_MODE);
g_free (name);
if (! layer)
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]