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 e1cc8402b9..3b68d028d9 100644 --- a/app/pdb/plug-in-compat-cmds.c +++ b/app/pdb/plug-in-compat-cmds.c @@ -1040,7 +1040,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); GeglNode *node = diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c index 24f91c0295..3ba638c27e 100644 --- a/app/tools/gimpfiltertool.c +++ b/app/tools/gimpfiltertool.c @@ -1396,21 +1396,32 @@ 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; + 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, - options->clip == - GIMP_TRANSFORM_RESIZE_CLIP || - ! gimp_drawable_has_alpha ( - tool->drawable)); + 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_color_managed (filter_tool->filter, options->color_managed); gimp_drawable_filter_set_gamma_hack (filter_tool->filter, diff --git a/pdb/groups/plug_in_compat.pdb b/pdb/groups/plug_in_compat.pdb index 1bc5515b02..bb6e5bde73 100644 --- a/pdb/groups/plug_in_compat.pdb +++ b/pdb/groups/plug_in_compat.pdb @@ -722,7 +722,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); GeglNode *node =