[gimp/metadata-browser] pdb: same fix as for XCF loading below
- From: Roman Joost <romanofski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-browser] pdb: same fix as for XCF loading below
- Date: Thu, 13 Sep 2012 00:13:30 +0000 (UTC)
commit b09316aa5f987e59707de3442af2f52cb557dab8
Author: Michael Natterer <mitch gimp org>
Date: Fri May 11 14:30:38 2012 +0200
pdb: same fix as for XCF loading below
app/pdb/layer-cmds.c | 49 +++++++++++++++++++++++++++++++++++++++----
tools/pdbgen/pdb/layer.pdb | 49 +++++++++++++++++++++++++++++++++++++++----
2 files changed, 88 insertions(+), 10 deletions(-)
---
diff --git a/app/pdb/layer-cmds.c b/app/pdb/layer-cmds.c
index a146f9b..4931c2e 100644
--- a/app/pdb/layer-cmds.c
+++ b/app/pdb/layer-cmds.c
@@ -79,13 +79,52 @@ layer_new_invoker (GimpProcedure *procedure,
if (success)
{
- gboolean has_alpha = (type == GIMP_RGBA_IMAGE ||
- type == GIMP_GRAYA_IMAGE ||
- type == GIMP_INDEXEDA_IMAGE);
+ GimpImageBaseType base_type = GIMP_RGB;
+ gboolean has_alpha = FALSE;
+ const Babl *format;
+
+ 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;
+ }
+
+ /* 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);
layer = gimp_layer_new (image, width, height,
- gimp_image_get_layer_format (image, has_alpha),
- name, opacity / 100.0, mode);
+ format, name, opacity / 100.0, mode);
if (! layer)
success = FALSE;
diff --git a/tools/pdbgen/pdb/layer.pdb b/tools/pdbgen/pdb/layer.pdb
index eddbc9e..6a3d5b1 100644
--- a/tools/pdbgen/pdb/layer.pdb
+++ b/tools/pdbgen/pdb/layer.pdb
@@ -55,13 +55,52 @@ HELP
%invoke = (
code => <<'CODE'
{
- gboolean has_alpha = (type == GIMP_RGBA_IMAGE ||
- type == GIMP_GRAYA_IMAGE ||
- type == GIMP_INDEXEDA_IMAGE);
+ GimpImageBaseType base_type = GIMP_RGB;
+ gboolean has_alpha = FALSE;
+ const Babl *format;
+
+ 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;
+ }
+
+ /* 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);
layer = gimp_layer_new (image, width, height,
- gimp_image_get_layer_format (image, has_alpha),
- name, opacity / 100.0, mode);
+ format, name, opacity / 100.0, mode);
if (! layer)
success = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]