[gimp] plug-ins,pdb: Add compatibility wrappers for mosaic



commit 5063aada1d44771db49de6f7261dcd38bd8555ea
Author: Téo Mazars <teo mazars ensimag fr>
Date:   Mon Sep 23 15:48:46 2013 +0200

    plug-ins,pdb: Add compatibility wrappers for mosaic
    
    and remove the old plug-in

 app/pdb/internal-procs.c            |    2 +-
 app/pdb/plug-in-compat-cmds.c       |  205 +++
 plug-ins/common/.gitignore          |    2 -
 plug-ins/common/Makefile.am         |   18 -
 plug-ins/common/gimprc.common       |    1 -
 plug-ins/common/mosaic.c            | 2837 -----------------------------------
 plug-ins/common/plugin-defs.pl      |    1 -
 po-plug-ins/POTFILES.in             |    1 -
 tools/pdbgen/pdb/plug_in_compat.pdb |  106 ++
 9 files changed, 312 insertions(+), 2861 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 87fda3e..8504f1d 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 697 procedures registered total */
+/* 698 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)
diff --git a/app/pdb/plug-in-compat-cmds.c b/app/pdb/plug-in-compat-cmds.c
index 1b6c62b..4290272 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -592,6 +592,103 @@ plug_in_mblur_inward_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+plug_in_mosaic_invoker (GimpProcedure         *procedure,
+                        Gimp                  *gimp,
+                        GimpContext           *context,
+                        GimpProgress          *progress,
+                        const GimpValueArray  *args,
+                        GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  gdouble tile_size;
+  gdouble tile_height;
+  gdouble tile_spacing;
+  gdouble tile_neatness;
+  gint32 tile_allow_split;
+  gdouble light_dir;
+  gdouble color_variation;
+  gint32 antialiasing;
+  gint32 color_averaging;
+  gint32 tile_type;
+  gint32 tile_surface;
+  gint32 grout_color;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  tile_size = g_value_get_double (gimp_value_array_index (args, 3));
+  tile_height = g_value_get_double (gimp_value_array_index (args, 4));
+  tile_spacing = g_value_get_double (gimp_value_array_index (args, 5));
+  tile_neatness = g_value_get_double (gimp_value_array_index (args, 6));
+  tile_allow_split = g_value_get_int (gimp_value_array_index (args, 7));
+  light_dir = g_value_get_double (gimp_value_array_index (args, 8));
+  color_variation = g_value_get_double (gimp_value_array_index (args, 9));
+  antialiasing = g_value_get_int (gimp_value_array_index (args, 10));
+  color_averaging = g_value_get_int (gimp_value_array_index (args, 11));
+  tile_type = g_value_get_int (gimp_value_array_index (args, 12));
+  tile_surface = g_value_get_int (gimp_value_array_index (args, 13));
+  grout_color = g_value_get_int (gimp_value_array_index (args, 14));
+
+  if (success)
+    {
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+                                     GIMP_PDB_ITEM_CONTENT, error) &&
+          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+        {
+          GeglColor *fg_color;
+          GeglColor *bg_color;
+          GeglNode  *node;
+
+          if (grout_color)
+            {
+              GimpRGB fgcolor, bgcolor;
+
+              gimp_context_get_background (context, &bgcolor);
+              bg_color = gimp_gegl_color_new (&bgcolor);
+
+              gimp_context_get_foreground (context, &fgcolor);
+              fg_color = gimp_gegl_color_new (&fgcolor);
+            }
+          else
+            {
+              /* sic */
+              fg_color = gegl_color_new ("white");
+              bg_color = gegl_color_new ("black");
+            }
+
+          node = gegl_node_new_child (NULL,
+                     "operation",        "gegl:mosaic",
+                     "tile-size",        (gdouble)  tile_size,
+                     "tile-height",      (gdouble)  tile_height,
+                     "tile-spacing",     (gdouble)  tile_spacing,
+                     "tile-neatness",    (gdouble)  tile_neatness,
+                     "tile-allow-split", (gboolean) tile_allow_split,
+                     "light-dir",        (gdouble)  light_dir,
+                     "color-variation",  (gfloat)   color_variation,
+                     "antialiasing",     (gboolean) antialiasing,
+                     "color-averaging",  (gboolean) color_averaging,
+                     "tile-type",        (gint)     tile_type,
+                     "tile-surface",     (gboolean) tile_surface,
+                     "light-color",      fg_color,
+                     "joints-color",     bg_color,
+                     NULL);
+
+          g_object_unref (fg_color);
+          g_object_unref (bg_color);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Mosaic"),
+                                         node);
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 plug_in_pixelize_invoker (GimpProcedure         *procedure,
                           Gimp                  *gimp,
                           GimpContext           *context,
@@ -1883,6 +1980,114 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-plug-in-mosaic
+   */
+  procedure = gimp_procedure_new (plug_in_mosaic_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-mosaic");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-mosaic",
+                                     "Convert the image into irregular tiles",
+                                     "Mosaic is a filter which transforms an image into what appears to be a 
mosaic, composed of small primitives, each of constant color and of an approximate size.",
+                                     "Compatibility procedure. Please see 'gegl:mosaic' for credits.",
+                                     "Compatibility procedure. Please see 'gegl:mosaic' for credits.",
+                                     "2013",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_enum ("run-mode",
+                                                  "run mode",
+                                                  "The run mode",
+                                                  GIMP_TYPE_RUN_MODE,
+                                                  GIMP_RUN_INTERACTIVE,
+                                                  GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_image_id ("image",
+                                                         "image",
+                                                         "Input image (unused)",
+                                                         pdb->gimp, FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_drawable_id ("drawable",
+                                                            "drawable",
+                                                            "Input drawable",
+                                                            pdb->gimp, FALSE,
+                                                            GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("tile-size",
+                                                    "tile size",
+                                                    "Average diameter of each tile (in pixels)",
+                                                    1, 1000, 1,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("tile-height",
+                                                    "tile height",
+                                                    "Apparent height of each tile (in pixels)",
+                                                    1, 1000, 1,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("tile-spacing",
+                                                    "tile spacing",
+                                                    "Inter_tile spacing (in pixels)",
+                                                    0.1, 1000, 0.1,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("tile-neatness",
+                                                    "tile neatness",
+                                                    "Deviation from perfectly formed tiles",
+                                                    0, 1.0, 0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("tile-allow-split",
+                                                      "tile allow split",
+                                                      "Allows splitting tiles at hard edges",
+                                                      0, 1, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("light-dir",
+                                                    "light dir",
+                                                    "Direction of light_source (in degrees)",
+                                                    0, 360, 0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("color-variation",
+                                                    "color variation",
+                                                    "Magnitude of random color variations",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("antialiasing",
+                                                      "antialiasing",
+                                                      "Enables smoother tile output at the cost of speed",
+                                                      0, 1, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("color-averaging",
+                                                      "color averaging",
+                                                      "Tile color based on average of subsumed pixels",
+                                                      0, 1, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("tile-type",
+                                                      "tile type",
+                                                      "Tile geometry { SQUARES (0), HEXAGONS (1), OCTAGONS 
(2), TRIANGLES (3) }",
+                                                      0, 3, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("tile-surface",
+                                                      "tile surface",
+                                                      "Surface characteristics { SMOOTH (0), ROUGH (1) }",
+                                                      0, 1, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("grout-color",
+                                                      "grout color",
+                                                      "Grout color (black/white or fore/background) { BW 
(0), FG-BG (1) }",
+                                                      0, 1, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-plug-in-pixelize
    */
   procedure = gimp_procedure_new (plug_in_pixelize_invoker);
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index 31ebf19..5e69a6f 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -186,8 +186,6 @@
 /mail.exe
 /max-rgb
 /max-rgb.exe
-/mosaic
-/mosaic.exe
 /newsprint
 /newsprint.exe
 /nl-filter
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 047b52c..7bc509c 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -136,7 +136,6 @@ libexec_PROGRAMS = \
        lens-flare \
        $(MAIL) \
        max-rgb \
-       mosaic \
        newsprint \
        nl-filter \
        noise-hsv \
@@ -1809,23 +1808,6 @@ max_rgb_LDADD = \
        $(INTLLIBS)             \
        $(max_rgb_RC)
 
-mosaic_SOURCES = \
-       mosaic.c
-
-mosaic_LDADD = \
-       $(libgimpui)            \
-       $(libgimpwidgets)       \
-       $(libgimpmodule)        \
-       $(libgimp)              \
-       $(libgimpmath)          \
-       $(libgimpconfig)        \
-       $(libgimpcolor)         \
-       $(libgimpbase)          \
-       $(GTK_LIBS)             \
-       $(RT_LIBS)              \
-       $(INTLLIBS)             \
-       $(mosaic_RC)
-
 newsprint_SOURCES = \
        newsprint.c
 
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index d4f731f..8d035ab 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -90,7 +90,6 @@ lens_distortion_RC = lens-distortion.rc.o
 lens_flare_RC = lens-flare.rc.o
 mail_RC = mail.rc.o
 max_rgb_RC = max-rgb.rc.o
-mosaic_RC = mosaic.rc.o
 newsprint_RC = newsprint.rc.o
 nl_filter_RC = nl-filter.rc.o
 noise_hsv_RC = noise-hsv.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 7dfe32e..54858ed 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -91,7 +91,6 @@
     'lens-flare' => { ui => 1 },
     'mail' => { ui => 1, optional => 1 },
     'max-rgb' => { ui => 1 },
-    'mosaic' => { ui => 1 },
     'newsprint' => { ui => 1 },
     'nl-filter' => { ui => 1 },
     'noise-hsv' => { ui => 1 },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index c64b268..4353404 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -98,7 +98,6 @@ plug-ins/common/lens-distortion.c
 plug-ins/common/lens-flare.c
 plug-ins/common/mail.c
 plug-ins/common/max-rgb.c
-plug-ins/common/mosaic.c
 plug-ins/common/newsprint.c
 plug-ins/common/nl-filter.c
 plug-ins/common/noise-hsv.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index 93498c3..dbf8828 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -610,6 +610,111 @@ CODE
     );
 }
 
+sub plug_in_mosaic {
+    $blurb = 'Convert the image into irregular tiles';
+
+    $help = <<'HELP';
+Mosaic is a filter which transforms an image into
+what appears to be a mosaic, composed of small primitives,
+each of constant color and of an approximate size.
+HELP
+
+    &std_pdb_compat('gegl:mosaic');
+    $date = '2013';
+
+    @inargs = (
+        { name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
+          desc => 'The run mode' },
+        { name => 'image', type => 'image', dead => 1,
+          desc => 'Input image (unused)' },
+        { name => 'drawable', type => 'drawable',
+          desc => 'Input drawable' },
+        { name => 'tile_size', type => '1 <= float <= 1000',
+          desc => 'Average diameter of each tile (in pixels)' },
+        { name => 'tile_height', type => '1 <= float <= 1000',
+          desc => 'Apparent height of each tile (in pixels)' },
+        { name => 'tile_spacing', type => '0.1 <= float <= 1000',
+          desc => 'Inter_tile spacing (in pixels)' },
+        { name => 'tile_neatness', type => '0 <= float <= 1.0',
+          desc => 'Deviation from perfectly formed tiles' },
+        { name => 'tile_allow_split', type => '0 <= int32 <= 1',
+          desc => 'Allows splitting tiles at hard edges' },
+        { name => 'light_dir', type => '0 <= float <= 360',
+          desc => 'Direction of light_source (in degrees)' },
+        { name => 'color_variation', type => '0.0 <= float <= 1.0',
+          desc => 'Magnitude of random color variations' },
+        { name => 'antialiasing', type => '0 <= int32 <= 1',
+          desc => 'Enables smoother tile output at the cost of speed' },
+        { name => 'color_averaging', type => '0 <= int32 <= 1',
+          desc => 'Tile color based on average of subsumed pixels' },
+        { name => 'tile_type', type => '0 <= int32 <= 3',
+          desc => 'Tile geometry { SQUARES (0), HEXAGONS (1), OCTAGONS (2), TRIANGLES (3) }' },
+        { name => 'tile_surface', type => '0 <= int32 <= 1',
+          desc => 'Surface characteristics { SMOOTH (0), ROUGH (1) }' },
+        { name => 'grout_color', type => '0 <= int32 <= 1',
+          desc => 'Grout color (black/white or fore/background) { BW (0), FG-BG (1) }' }
+    );
+
+    %invoke = (
+        code => <<'CODE'
+{
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+                                 GIMP_PDB_ITEM_CONTENT, error) &&
+      gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+    {
+      GeglColor *fg_color;
+      GeglColor *bg_color;
+      GeglNode  *node;
+
+      if (grout_color)
+        {
+          GimpRGB fgcolor, bgcolor;
+
+          gimp_context_get_background (context, &bgcolor);
+          bg_color = gimp_gegl_color_new (&bgcolor);
+
+          gimp_context_get_foreground (context, &fgcolor);
+          fg_color = gimp_gegl_color_new (&fgcolor);
+        }
+      else
+        {
+          /* sic */
+          fg_color = gegl_color_new ("white");
+          bg_color = gegl_color_new ("black");
+        }
+
+      node = gegl_node_new_child (NULL,
+                 "operation",        "gegl:mosaic",
+                 "tile-size",        (gdouble)  tile_size,
+                 "tile-height",      (gdouble)  tile_height,
+                 "tile-spacing",     (gdouble)  tile_spacing,
+                 "tile-neatness",    (gdouble)  tile_neatness,
+                 "tile-allow-split", (gboolean) tile_allow_split,
+                 "light-dir",        (gdouble)  light_dir,
+                 "color-variation",  (gfloat)   color_variation,
+                 "antialiasing",     (gboolean) antialiasing,
+                 "color-averaging",  (gboolean) color_averaging,
+                 "tile-type",        (gint)     tile_type,
+                 "tile-surface",     (gboolean) tile_surface,
+                 "light-color",      fg_color,
+                 "joints-color",     bg_color,
+                 NULL);
+
+      g_object_unref (fg_color);
+      g_object_unref (bg_color);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Mosaic"),
+                                     node);
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub plug_in_pixelize {
     $blurb = 'Simplify image into an array of solid-colored squares';
 
@@ -1512,6 +1617,7 @@ CODE
            plug_in_cubism
             plug_in_mblur
             plug_in_mblur_inward
+            plug_in_mosaic
             plug_in_pixelize
             plug_in_pixelize2
             plug_in_plasma


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