[gimp] Issue #1975 - Color to alpha now requires an alpha-channel ...
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Issue #1975 - Color to alpha now requires an alpha-channel ...
- Date: Fri, 17 Jan 2020 10:17:00 +0000 (UTC)
commit 50b655de270208956d570cb56e3f6d219ccb7e85
Author: Ell <ell_se yahoo com>
Date: Fri Jan 17 10:51:30 2020 +0200
Issue #1975 - Color to alpha now requires an alpha-channel ...
... (used to add one automatically)
In GimpFilterTool and gimp_drawable_apply_operation(), use
gimp_drawable_filter_set_add_alpha() to add an alpha channel when
applying an operation that specifies "needs-alpha" to a drawable
that can have alpha.
Don't disable gegl:color-to-alpha (which has "needs-alpha") when
the drawable doesn't have an alpha channel, if one can be added.
app/actions/filters-actions.c | 16 +++++++++-------
app/core/gimpdrawable-operation.c | 8 ++++++++
app/pdb/plug-in-compat-cmds.c | 2 +-
app/tools/gimpfiltertool.c | 37 ++++++++++++++++++++++++-------------
pdb/groups/plug_in_compat.pdb | 2 +-
5 files changed, 43 insertions(+), 22 deletions(-)
---
diff --git a/app/actions/filters-actions.c b/app/actions/filters-actions.c
index 29a7949f54..f5fb1cb856 100644
--- a/app/actions/filters-actions.c
+++ b/app/actions/filters-actions.c
@@ -842,10 +842,11 @@ filters_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpImage *image;
- GimpDrawable *drawable = NULL;
- gboolean writable = FALSE;
- gboolean gray = FALSE;
- gboolean alpha = FALSE;
+ GimpDrawable *drawable = NULL;
+ gboolean writable = FALSE;
+ gboolean gray = FALSE;
+ gboolean alpha = FALSE;
+ gboolean supports_alpha = FALSE;
image = action_data_get_image (data);
@@ -857,8 +858,9 @@ filters_actions_update (GimpActionGroup *group,
{
GimpItem *item;
- alpha = gimp_drawable_has_alpha (drawable);
- gray = gimp_drawable_is_gray (drawable);
+ gray = gimp_drawable_is_gray (drawable);
+ alpha = gimp_drawable_has_alpha (drawable);
+ supports_alpha = gimp_drawable_supports_alpha (drawable);
if (GIMP_IS_LAYER_MASK (drawable))
item = GIMP_ITEM (gimp_layer_mask_get_layer (GIMP_LAYER_MASK (drawable)));
@@ -893,7 +895,7 @@ filters_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("filters-dither", writable);
SET_SENSITIVE ("filters-color-rotate", writable);
SET_SENSITIVE ("filters-color-temperature", writable && !gray);
- SET_SENSITIVE ("filters-color-to-alpha", writable && !gray && alpha);
+ SET_SENSITIVE ("filters-color-to-alpha", writable && !gray && supports_alpha);
SET_SENSITIVE ("filters-component-extract", writable);
SET_SENSITIVE ("filters-convolution-matrix", writable);
SET_SENSITIVE ("filters-cubism", writable);
diff --git a/app/core/gimpdrawable-operation.c b/app/core/gimpdrawable-operation.c
index d4994fa3b4..3e64ab4d89 100644
--- a/app/core/gimpdrawable-operation.c
+++ b/app/core/gimpdrawable-operation.c
@@ -27,6 +27,8 @@
#include "core-types.h"
+#include "gegl/gimp-gegl-utils.h"
+
#include "gimpdrawable.h"
#include "gimpdrawable-operation.h"
#include "gimpdrawablefilter.h"
@@ -58,6 +60,12 @@ gimp_drawable_apply_operation (GimpDrawable *drawable,
filter = gimp_drawable_filter_new (drawable, undo_desc, operation, NULL);
+ if (gimp_drawable_supports_alpha (drawable) &&
+ gimp_gegl_node_get_key (operation, "needs-alpha"))
+ {
+ gimp_drawable_filter_set_add_alpha (filter, TRUE);
+ }
+
gimp_drawable_filter_apply (filter, NULL);
gimp_drawable_filter_commit (filter, progress, TRUE);
diff --git a/app/pdb/plug-in-compat-cmds.c b/app/pdb/plug-in-compat-cmds.c
index ebcb2326e4..539d43fbb4 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -1083,7 +1083,7 @@ plug_in_colortoalpha_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
- /* XXX: fixme disable for gray, and add alpha when needed */
+ /* XXX: fixme disable for gray */
GeglColor *gegl_color = gimp_gegl_color_new (&color, NULL);
GeglNode *node =
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index 54334c03bc..326603b2f3 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -1384,23 +1384,34 @@ gimp_filter_tool_update_filter (GimpFilterTool *filter_tool)
{
GimpTool *tool = GIMP_TOOL (filter_tool);
GimpFilterOptions *options = GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool);
+ const gchar *operation_name;
+ gboolean add_alpha;
+ gboolean clip;
if (! filter_tool->filter)
return;
- gimp_drawable_filter_set_clip (filter_tool->filter,
- options->clip ==
- GIMP_TRANSFORM_RESIZE_CLIP ||
- ! gimp_drawable_has_alpha (
- tool->drawable));
- gimp_drawable_filter_set_region (filter_tool->filter,
- options->region);
- gimp_drawable_filter_set_preview (filter_tool->filter,
- options->preview_split,
- options->preview_alignment,
- options->preview_position);
- gimp_drawable_filter_set_gamma_hack (filter_tool->filter,
- options->gamma_hack);
+ operation_name = gegl_node_get_operation (filter_tool->operation);
+
+ add_alpha = gimp_drawable_supports_alpha (tool->drawable) &&
+ operation_name &&
+ gegl_operation_get_key (operation_name, "needs-alpha");
+ clip = options->clip == GIMP_TRANSFORM_RESIZE_CLIP ||
+ ! (gimp_drawable_has_alpha (tool->drawable) ||
+ add_alpha);
+
+ gimp_drawable_filter_set_clip (filter_tool->filter,
+ clip);
+ gimp_drawable_filter_set_region (filter_tool->filter,
+ options->region);
+ gimp_drawable_filter_set_preview (filter_tool->filter,
+ options->preview_split,
+ options->preview_alignment,
+ options->preview_position);
+ gimp_drawable_filter_set_add_alpha (filter_tool->filter,
+ add_alpha);
+ gimp_drawable_filter_set_gamma_hack (filter_tool->filter,
+ options->gamma_hack);
}
static void
diff --git a/pdb/groups/plug_in_compat.pdb b/pdb/groups/plug_in_compat.pdb
index c9136b7395..a97216d71f 100644
--- a/pdb/groups/plug_in_compat.pdb
+++ b/pdb/groups/plug_in_compat.pdb
@@ -788,7 +788,7 @@ HELP
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
- /* XXX: fixme disable for gray, and add alpha when needed */
+ /* XXX: fixme disable for gray */
GeglColor *gegl_color = gimp_gegl_color_new (&color, NULL);
GeglNode *node =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]