app: add possibility to antialias line art colorization.

This commit is contained in:
Jehan 2018-11-26 12:33:45 +01:00
parent c32b0ecc92
commit d2f9549c9f
2 changed files with 32 additions and 8 deletions

View File

@ -296,6 +296,34 @@ gimp_drawable_get_bucket_fill_buffer (GimpDrawable *drawable,
gimp_gegl_apply_opacity (buffer, NULL, NULL, buffer, new_mask,
-mask_offset_x, -mask_offset_y, 1.0);
if (fill_criterion == GIMP_SELECT_CRITERION_LINE_ART && antialias)
{
/* Antialias for the line art algorithm is not applied during mask
* creation because it is not based on individual pixel colors.
* Instead we just want to apply it on the borders of the mask at
* the end (since the mask can evolve, we don't want to actually
* touch it, but only the intermediate results).
*/
GeglNode *graph;
GeglNode *input;
GeglNode *op;
graph = gegl_node_new ();
input = gegl_node_new_child (graph,
"operation", "gegl:buffer-source",
"buffer", buffer,
NULL);
op = gegl_node_new_child (graph,
"operation", "gegl:gaussian-blur",
"std-dev-x", 0.5,
"std-dev-y", 0.5,
NULL);
gegl_node_connect_to (input, "output", op, "input");
gegl_node_blit_buffer (op, buffer, NULL, 0,
GEGL_ABYSS_NONE);
g_object_unref (graph);
}
if (mask_x)
*mask_x = x;
if (mask_y)

View File

@ -61,7 +61,6 @@ enum
struct _GimpBucketFillOptionsPrivate
{
GtkWidget *diagonal_neighbors_checkbox;
GtkWidget *antialias_checkbox;
GtkWidget *threshold_scale;
GtkWidget *line_art_threshold_scale;
@ -144,9 +143,9 @@ gimp_bucket_fill_options_class_init (GimpBucketFillOptionsClass *klass)
"antialias",
_("Antialiasing"),
_("Base fill opacity on color difference from "
"the clicked pixel (see threshold). Disable "
"antialiasing to fill the entire area "
"uniformly."),
"the clicked pixel (see threshold) or on line "
" art borders. Disable antialiasing to fill "
"the entire area uniformly."),
TRUE,
GIMP_PARAM_STATIC_STRINGS);
@ -309,13 +308,12 @@ static void
gimp_bucket_fill_options_update_criterion (GimpBucketFillOptions *options)
{
/* GUI not created yet. */
if (! options->priv->antialias_checkbox)
if (! options->priv->threshold_scale)
return;
switch (options->fill_criterion)
{
case GIMP_SELECT_CRITERION_LINE_ART:
gtk_widget_hide (options->priv->antialias_checkbox);
gtk_widget_hide (options->priv->diagonal_neighbors_checkbox);
gtk_widget_hide (options->priv->threshold_scale);
@ -326,7 +324,6 @@ gimp_bucket_fill_options_update_criterion (GimpBucketFillOptions *options)
gtk_widget_hide (options->priv->line_art_threshold_scale);
gtk_widget_hide (options->priv->line_art_grow_scale);
gtk_widget_show (options->priv->antialias_checkbox);
gtk_widget_show (options->priv->diagonal_neighbors_checkbox);
gtk_widget_show (options->priv->threshold_scale);
break;
@ -411,7 +408,6 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
/* the antialias toggle */
button = gimp_prop_check_button_new (config, "antialias", NULL);
gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
options->priv->antialias_checkbox = button;
gtk_widget_show (button);
/* the threshold scale */