Commit 572d5566 authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

Bug 553855 - Bucket fill colour is always blended with filled pixel colour...

...when threshold > 0

Add an "Antialias" toggle to the bucket fill options and set it on the
GimpFillOptions. In gimp_drawable_bucket_fill(), pass it to
gimp_pickable_contiguous_region_by_seed() instead of always defaulting
to TRUE.

The position of the toggle and its huge tooltip may need some
adjustment.
parent ea6946ed
......@@ -59,6 +59,7 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
GimpPickable *pickable;
GeglBuffer *buffer;
GeglBuffer *mask_buffer;
gboolean antialias;
gint x1, y1, x2, y2;
gint mask_offset_x = 0;
gint mask_offset_y = 0;
......@@ -84,11 +85,13 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
else
pickable = GIMP_PICKABLE (drawable);
antialias = gimp_fill_options_get_antialias (options);
/* Do a seed bucket fill...To do this, calculate a new
* contiguous region.
*/
mask_buffer = gimp_pickable_contiguous_region_by_seed (pickable,
TRUE,
antialias,
threshold,
fill_transparent,
fill_criterion,
......
......@@ -51,6 +51,7 @@ enum
PROP_FILL_TRANSPARENT,
PROP_SAMPLE_MERGED,
PROP_DIAGONAL_NEIGHBORS,
PROP_ANTIALIAS,
PROP_THRESHOLD,
PROP_FILL_CRITERION
};
......@@ -95,12 +96,14 @@ gimp_bucket_fill_options_class_init (GimpBucketFillOptionsClass *klass)
GIMP_TYPE_BUCKET_FILL_MODE,
GIMP_BUCKET_FILL_FG,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_FILL_SELECTION,
"fill-selection",
_("Fill selection"),
_("Which area will be filled"),
FALSE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_FILL_TRANSPARENT,
"fill-transparent",
_("Fill transparent areas"),
......@@ -108,12 +111,14 @@ gimp_bucket_fill_options_class_init (GimpBucketFillOptionsClass *klass)
"to be filled"),
TRUE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SAMPLE_MERGED,
"sample-merged",
_("Sample merged"),
_("Base filled area on all visible layers"),
FALSE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_DIAGONAL_NEIGHBORS,
"diagonal-neighbors",
_("Diagonal neighbors"),
......@@ -121,12 +126,24 @@ gimp_bucket_fill_options_class_init (GimpBucketFillOptionsClass *klass)
"connected"),
FALSE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_ANTIALIAS,
"antialias",
_("Antialiasing"),
_("Base fill opacity on color difference from "
"the clicked pixel (see threshold). Disable "
"antialiasing to fill the entire area "
"uniformly."),
TRUE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_THRESHOLD,
"threshold",
_("Threshold"),
_("Maximum color difference"),
0.0, 255.0, 15.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_ENUM (object_class, PROP_FILL_CRITERION,
"fill-criterion",
_("Fill by"),
......@@ -174,6 +191,9 @@ gimp_bucket_fill_options_set_property (GObject *object,
case PROP_DIAGONAL_NEIGHBORS:
options->diagonal_neighbors = g_value_get_boolean (value);
break;
case PROP_ANTIALIAS:
options->antialias = g_value_get_boolean (value);
break;
case PROP_THRESHOLD:
options->threshold = g_value_get_double (value);
break;
......@@ -212,6 +232,9 @@ gimp_bucket_fill_options_get_property (GObject *object,
case PROP_DIAGONAL_NEIGHBORS:
g_value_set_boolean (value, options->diagonal_neighbors);
break;
case PROP_ANTIALIAS:
g_value_set_boolean (value, options->antialias);
break;
case PROP_THRESHOLD:
g_value_set_double (value, options->threshold);
break;
......@@ -314,6 +337,11 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* the antialias toggle */
button = gimp_prop_check_button_new (config, "antialias", NULL);
gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* the threshold scale */
scale = gimp_prop_spin_scale_new (config, "threshold", NULL,
1.0, 16.0, 1);
......
......@@ -42,6 +42,7 @@ struct _GimpBucketFillOptions
gboolean fill_transparent;
gboolean sample_merged;
gboolean diagonal_neighbors;
gboolean antialias;
gdouble threshold;
GimpSelectCriterion fill_criterion;
};
......
......@@ -182,6 +182,8 @@ gimp_bucket_fill_tool_button_release (GimpTool *tool,
options->fill_mode,
&error))
{
gimp_fill_options_set_antialias (fill_options, options->antialias);
gimp_context_set_opacity (GIMP_CONTEXT (fill_options),
gimp_context_get_opacity (context));
gimp_context_set_paint_mode (GIMP_CONTEXT (fill_options),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment