[gimp] app: add possibility to antialias line art colorization.



commit d2f9549c9fad2fd1874f3abb562a9b06009f51f5
Author: Jehan <jehan girinstud io>
Date:   Mon Nov 26 12:33:45 2018 +0100

    app: add possibility to antialias line art colorization.

 app/core/gimpdrawable-bucket-fill.c | 28 ++++++++++++++++++++++++++++
 app/tools/gimpbucketfilloptions.c   | 12 ++++--------
 2 files changed, 32 insertions(+), 8 deletions(-)
---
diff --git a/app/core/gimpdrawable-bucket-fill.c b/app/core/gimpdrawable-bucket-fill.c
index 6be89c59e8..3ae150a0a7 100644
--- a/app/core/gimpdrawable-bucket-fill.c
+++ b/app/core/gimpdrawable-bucket-fill.c
@@ -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)
diff --git a/app/tools/gimpbucketfilloptions.c b/app/tools/gimpbucketfilloptions.c
index 8221c04ed5..a5e7726492 100644
--- a/app/tools/gimpbucketfilloptions.c
+++ b/app/tools/gimpbucketfilloptions.c
@@ -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  */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]