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.
This commit is contained in:
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 =
|
||||
|
@ -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,
|
||||
|
@ -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 =
|
||||
|
Reference in New Issue
Block a user