~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to plug-ins/common/dog.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: james.westby@ubuntu.com-20070502163303-6wchheivjxgjtlna
Tags: upstream-2.3.16
ImportĀ upstreamĀ versionĀ 2.3.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
29
29
 
30
30
#include <string.h>
31
31
 
32
 
#include <gtk/gtk.h>
33
 
 
34
32
#include <libgimp/gimp.h>
35
33
#include <libgimp/gimpui.h>
36
34
 
37
35
#include "libgimp/stdplugins-intl.h"
38
36
 
 
37
 
 
38
#define PLUG_IN_PROC   "plug-in-dog"
 
39
#define PLUG_IN_BINARY "dog"
 
40
 
 
41
 
39
42
typedef struct
40
43
{
41
44
  gdouble  inner;
45
48
  gboolean preview;
46
49
} DoGValues;
47
50
 
 
51
 
48
52
/* Declare local functions.
49
53
 */
50
54
static void      query  (void);
94
98
                                          gint       width);
95
99
 
96
100
 
97
 
GimpPlugInInfo PLUG_IN_INFO =
 
101
const GimpPlugInInfo PLUG_IN_INFO =
98
102
{
99
103
  NULL,  /* init_proc  */
100
104
  NULL,  /* quit_proc  */
116
120
static void
117
121
query (void)
118
122
{
119
 
  static GimpParamDef args[] =
 
123
  static const GimpParamDef args[] =
120
124
  {
121
 
    { GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
122
 
    { GIMP_PDB_IMAGE, "image", "Input image" },
123
 
    { GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
124
 
    { GIMP_PDB_FLOAT, "inner", "Radius of inner gaussian blur (in pixels, > 0.0)" },
125
 
    { GIMP_PDB_FLOAT, "outer",   "Radius of outer gaussian blur (in pixels, > 0.0)" },
126
 
    { GIMP_PDB_INT32, "normalize", "True, False" },
127
 
    { GIMP_PDB_INT32, "invert", "True, False" }
 
125
    { GIMP_PDB_INT32,    "run-mode",  "Interactive, non-interactive" },
 
126
    { GIMP_PDB_IMAGE,    "image",     "Input image" },
 
127
    { GIMP_PDB_DRAWABLE, "drawable",  "Input drawable" },
 
128
    { GIMP_PDB_FLOAT,    "inner",     "Radius of inner gaussian blur (in pixels, > 0.0)" },
 
129
    { GIMP_PDB_FLOAT,    "outer",     "Radius of outer gaussian blur (in pixels, > 0.0)" },
 
130
    { GIMP_PDB_INT32,    "normalize", "True, False" },
 
131
    { GIMP_PDB_INT32,    "invert",    "True, False" }
128
132
  };
129
133
 
130
 
  gimp_install_procedure ("plug_in_dog",
131
 
                          "Edge detection using difference of Gaussians.",
 
134
  gimp_install_procedure (PLUG_IN_PROC,
 
135
                          N_("Edge detection with control of edge thickness"),
132
136
                          "Applies two Gaussian blurs to the drawable, and "
133
137
                          "subtracts the results.  This is robust and widely "
134
 
                          "used method for detecting edges. Uses Gauss IIR "
135
 
                          "algorithm for the Gaussians.",
 
138
                          "used method for detecting edges.",
136
139
                          "Spencer Kimball, Peter Mattis, Sven Neumann, William Skaggs",
137
140
                          "Spencer Kimball, Peter Mattis, Sven Neumann, William Skaggs",
138
141
                          "1995-2004",
139
 
                          N_("Difference of Gaussians..."),
 
142
                          N_("_Difference of Gaussians..."),
140
143
                          "RGB*, GRAY*",
141
144
                          GIMP_PLUGIN,
142
145
                          G_N_ELEMENTS (args), 0,
143
146
                          args, NULL);
144
147
 
145
 
  gimp_plugin_menu_register ("plug_in_dog", "<Image>/Filters/Edge-Detect");
 
148
  gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Filters/Edge-Detect");
146
149
}
147
150
 
148
151
static void
177
180
                          (MAX (drawable->width, drawable->height) /
178
181
                           gimp_tile_width () + 1));
179
182
 
180
 
  if (strcmp (name, "plug_in_dog") == 0)
 
183
  if (strcmp (name, PLUG_IN_PROC) == 0)
181
184
    {
182
185
      switch (run_mode)
183
186
        {
184
187
        case GIMP_RUN_INTERACTIVE:
185
188
          /*  Possibly retrieve data  */
186
 
          gimp_get_data ("plug_in_dog", &dogvals);
 
189
          gimp_get_data (PLUG_IN_PROC, &dogvals);
187
190
 
188
191
          /*  First acquire information with a dialog  */
189
192
          if (! dog_dialog (image_ID, drawable))
208
211
 
209
212
        case GIMP_RUN_WITH_LAST_VALS:
210
213
          /*  Possibly retrieve data  */
211
 
          gimp_get_data ("plug_in_dog", &dogvals);
 
214
          gimp_get_data (PLUG_IN_PROC, &dogvals);
212
215
          break;
213
216
 
214
217
        default:
235
238
 
236
239
          /*  Store data  */
237
240
          if (run_mode == GIMP_RUN_INTERACTIVE)
238
 
            {
239
 
              gimp_set_data ("plug_in_dog",
240
 
                             &dogvals, sizeof (DoGValues));
241
 
            }
 
241
            gimp_set_data (PLUG_IN_PROC, &dogvals, sizeof (DoGValues));
 
242
 
242
243
          if (run_mode != GIMP_RUN_NONINTERACTIVE)
243
244
            gimp_displays_flush ();
244
245
        }
269
270
  gdouble    yres;
270
271
  gboolean   run;
271
272
 
272
 
  gimp_ui_init ("dog", FALSE);
 
273
  gimp_ui_init (PLUG_IN_BINARY, FALSE);
273
274
 
274
 
  dialog = gimp_dialog_new (_("DoG Edge Detect"), "dog",
 
275
  dialog = gimp_dialog_new (_("DoG Edge Detect"), PLUG_IN_BINARY,
275
276
                            NULL, 0,
276
 
                            gimp_standard_help_func, "plug-in-dog",
 
277
                            gimp_standard_help_func, PLUG_IN_PROC,
277
278
 
278
279
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
279
280
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,
280
281
 
281
282
                            NULL);
282
283
 
 
284
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
 
285
                                           GTK_RESPONSE_OK,
 
286
                                           GTK_RESPONSE_CANCEL,
 
287
                                           -1);
 
288
 
 
289
  gimp_window_set_transient (GTK_WINDOW (dialog));
 
290
 
283
291
  main_vbox = gtk_vbox_new (FALSE, 12);
284
292
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
285
293
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
292
300
                    G_CALLBACK (preview_update_preview),
293
301
                    drawable);
294
302
 
295
 
  frame = gimp_frame_new (_("Smoothing parameters"));
 
303
  frame = gimp_frame_new (_("Smoothing Parameters"));
296
304
  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
297
305
  gtk_widget_show (frame);
298
306
 
679
687
                       TRUE, TRUE);
680
688
 
681
689
  progress = 0.0;
682
 
  max_progress  = 2 * width * height * radius;
 
690
  max_progress  = 2 * width * height;
683
691
 
684
692
  /*  First the vertical pass  */
685
693
  radius = fabs (radius) + 1.0;
754
762
 
755
763
      if (show_progress)
756
764
        {
757
 
          progress += height * radius;
 
765
          progress += height;
758
766
 
759
 
          if ((col % 5) == 0)
760
 
            gimp_progress_update (0.5 * (pass + progress / max_progress));
 
767
          if ((col % 20) == 0)
 
768
            gimp_progress_update (0.5 * (pass + (progress / max_progress)));
761
769
        }
762
770
    }
763
771
 
823
831
 
824
832
      if (show_progress)
825
833
        {
826
 
          progress += width * radius;
 
834
          progress += width;
827
835
 
828
 
          if ((row % 5) == 0)
829
 
            gimp_progress_update (0.5 * (pass + progress / max_progress));
 
836
          if ((row % 20) == 0)
 
837
            gimp_progress_update (0.5 * (pass + (progress / max_progress)));
830
838
        }
831
839
    }
832
840