[gimp/gimp-2-10] libgimp: add GIMP_EXPORT_NEEDS_OPAQUE_LAYERS export capacity.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] libgimp: add GIMP_EXPORT_NEEDS_OPAQUE_LAYERS export capacity.
- Date: Sat, 29 Jun 2019 12:39:33 +0000 (UTC)
commit 390029020fb63e2568b26fb0ee7f0250fdb52cb8
Author: Jehan <jehan girinstud io>
Date: Fri Jun 28 13:20:44 2019 +0200
libgimp: add GIMP_EXPORT_NEEDS_OPAQUE_LAYERS export capacity.
Currently capability GIMP_EXPORT_CAN_HANDLE_LAYERS implies
GIMP_EXPORT_CAN_HANDLE_ALPHA. Though in many cases, multi-layer implies
alpha for basic compositing, our export plug-ins sometimes use the
concept of "layer export" for multi-pages or collection files.
Additionally sometimes alpha may not even be supported at all whereas
layers are. This will be the case in the next commit which will make use
of this new capability.
(cherry picked from commit 9933f46f855700ead0327d931456ec74d66ac406)
libgimp/gimpexport.c | 45 +++++++++++++++++++++++++++++++++++++++++----
libgimp/gimpexport.h | 3 ++-
2 files changed, 43 insertions(+), 5 deletions(-)
---
diff --git a/libgimp/gimpexport.c b/libgimp/gimpexport.c
index 157bf8cd49..9076db6ea5 100644
--- a/libgimp/gimpexport.c
+++ b/libgimp/gimpexport.c
@@ -151,6 +151,25 @@ export_flatten (gint32 image_ID,
*drawable_ID = flattened;
}
+static void
+export_remove_alpha (gint32 image_ID,
+ gint32 *drawable_ID)
+{
+ gint32 n_layers;
+ gint32 *layers;
+ gint i;
+
+ layers = gimp_image_get_layers (image_ID, &n_layers);
+
+ for (i = 0; i < n_layers; i++)
+ {
+ if (gimp_drawable_has_alpha (layers[i]))
+ gimp_layer_flatten (layers[i]);
+ }
+
+ g_free (layers);
+}
+
static void
export_apply_masks (gint32 image_ID,
gint *drawable_ID)
@@ -298,6 +317,15 @@ static ExportAction export_action_flatten =
0
};
+static ExportAction export_action_remove_alpha =
+{
+ export_remove_alpha,
+ NULL,
+ N_("%s plug-in can't handle transparent layers"),
+ { N_("Flatten Image"), NULL },
+ 0
+};
+
static ExportAction export_action_apply_masks =
{
export_apply_masks,
@@ -724,7 +752,8 @@ gimp_export_image (gint32 *image_ID,
if (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS)
capabilities |= GIMP_EXPORT_CAN_HANDLE_LAYERS;
- if (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYERS)
+ if (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYERS &&
+ ! (capabilities & GIMP_EXPORT_NEEDS_OPAQUE_LAYERS))
capabilities |= GIMP_EXPORT_CAN_HANDLE_ALPHA;
if (format_name && g_getenv ("GIMP_INTERACTIVE_EXPORT"))
@@ -768,9 +797,17 @@ gimp_export_image (gint32 *image_ID,
{
if (! (capabilities & GIMP_EXPORT_CAN_HANDLE_ALPHA))
{
- actions = g_slist_prepend (actions, &export_action_flatten);
- added_flatten = TRUE;
- break;
+ if (! (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYERS))
+ {
+ actions = g_slist_prepend (actions, &export_action_flatten);
+ added_flatten = TRUE;
+ break;
+ }
+ else
+ {
+ actions = g_slist_prepend (actions, &export_action_remove_alpha);
+ break;
+ }
}
}
else
diff --git a/libgimp/gimpexport.h b/libgimp/gimpexport.h
index 11d4dff187..7e340b311c 100644
--- a/libgimp/gimpexport.h
+++ b/libgimp/gimpexport.h
@@ -41,7 +41,8 @@ typedef enum
GIMP_EXPORT_CAN_HANDLE_LAYERS = 1 << 5,
GIMP_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION = 1 << 6,
GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS = 1 << 7,
- GIMP_EXPORT_NEEDS_ALPHA = 1 << 8
+ GIMP_EXPORT_NEEDS_ALPHA = 1 << 8,
+ GIMP_EXPORT_NEEDS_OPAQUE_LAYERS = 1 << 9
} GimpExportCapabilities;
typedef enum
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]