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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

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
24
24
#include <stdlib.h>
25
25
#include <string.h>
26
26
 
27
 
#include <gtk/gtk.h>
28
 
 
29
27
#include <libgimp/gimp.h>
30
28
#include <libgimp/gimpui.h>
31
29
 
32
30
#include "libgimp/stdplugins-intl.h"
33
31
 
34
32
 
 
33
#define PLUG_IN_PROC   "plug-in-sobel"
 
34
#define PLUG_IN_BINARY "sobel"
 
35
 
 
36
 
35
37
typedef struct
36
38
{
37
39
  gboolean horizontal;
71
73
                                    gint          w);
72
74
 
73
75
 
74
 
GimpPlugInInfo PLUG_IN_INFO =
 
76
const GimpPlugInInfo PLUG_IN_INFO =
75
77
{
76
78
  NULL,  /* init_proc  */
77
79
  NULL,  /* quit_proc  */
92
94
static void
93
95
query (void)
94
96
{
95
 
  static GimpParamDef args[] =
 
97
  static const GimpParamDef args[] =
96
98
  {
97
 
    { GIMP_PDB_INT32,    "run_mode",   "Interactive, non-interactive" },
98
 
    { GIMP_PDB_IMAGE,    "image",      "Input image (unused)" },
99
 
    { GIMP_PDB_DRAWABLE, "drawable",   "Input drawable" },
 
99
    { GIMP_PDB_INT32,    "run-mode",   "Interactive, non-interactive"  },
 
100
    { GIMP_PDB_IMAGE,    "image",      "Input image (unused)"          },
 
101
    { GIMP_PDB_DRAWABLE, "drawable",   "Input drawable"                },
100
102
    { GIMP_PDB_INT32,    "horizontal", "Sobel in horizontal direction" },
101
 
    { GIMP_PDB_INT32,    "vertical",   "Sobel in vertical direction" },
102
 
    { GIMP_PDB_INT32,    "keep_sign",  "Keep sign of result (one direction only)" }
 
103
    { GIMP_PDB_INT32,    "vertical",   "Sobel in vertical direction"   },
 
104
    { GIMP_PDB_INT32,    "keep-sign",  "Keep sign of result (one direction only)" }
103
105
  };
104
106
 
105
 
  gimp_install_procedure ("plug_in_sobel",
106
 
                          "Edge Detection with Sobel Operation",
 
107
  gimp_install_procedure (PLUG_IN_PROC,
 
108
                          N_("Specialized direction-dependent edge detection"),
107
109
                          "This plugin calculates the gradient with a sobel "
108
110
                          "operator. The user can specify which direction to "
109
111
                          "use. When both directions are used, the result is "
122
124
                          G_N_ELEMENTS (args), 0,
123
125
                          args, NULL);
124
126
 
125
 
  gimp_plugin_menu_register ("plug_in_sobel", "<Image>/Filters/Edge-Detect");
 
127
  gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Filters/Edge-Detect");
126
128
}
127
129
 
128
130
static void
156
158
   {
157
159
    case GIMP_RUN_INTERACTIVE:
158
160
      /*  Possibly retrieve data  */
159
 
      gimp_get_data ("plug_in_sobel", &bvals);
 
161
      gimp_get_data (PLUG_IN_PROC, &bvals);
160
162
 
161
163
      /*  First acquire information with a dialog  */
162
164
      if (! sobel_dialog (drawable))
179
181
 
180
182
    case GIMP_RUN_WITH_LAST_VALS:
181
183
      /*  Possibly retrieve data  */
182
 
      gimp_get_data ("plug_in_sobel", &bvals);
 
184
      gimp_get_data (PLUG_IN_PROC, &bvals);
183
185
      break;
184
186
 
185
187
    default:
200
202
 
201
203
      /*  Store data  */
202
204
      if (run_mode == GIMP_RUN_INTERACTIVE)
203
 
        gimp_set_data ("plug_in_sobel", &bvals, sizeof (bvals));
 
205
        gimp_set_data (PLUG_IN_PROC, &bvals, sizeof (bvals));
204
206
    }
205
207
  else
206
208
    {
222
224
  GtkWidget *toggle;
223
225
  gboolean   run;
224
226
 
225
 
  gimp_ui_init ("sobel", FALSE);
 
227
  gimp_ui_init (PLUG_IN_BINARY, FALSE);
226
228
 
227
 
  dialog = gimp_dialog_new (_("Sobel Edge Detection"), "sobel",
 
229
  dialog = gimp_dialog_new (_("Sobel Edge Detection"), PLUG_IN_BINARY,
228
230
                            NULL, 0,
229
 
                            gimp_standard_help_func, "plug-in-sobel",
 
231
                            gimp_standard_help_func, PLUG_IN_PROC,
230
232
 
231
233
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
232
234
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,
233
235
 
234
236
                            NULL);
235
237
 
 
238
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
 
239
                                           GTK_RESPONSE_OK,
 
240
                                           GTK_RESPONSE_CANCEL,
 
241
                                           -1);
 
242
 
 
243
  gimp_window_set_transient (GTK_WINDOW (dialog));
 
244
 
236
245
  main_vbox = gtk_vbox_new (FALSE, 12);
237
246
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
238
247
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
246
255
                    G_CALLBACK (sobel_preview_update),
247
256
                    NULL);
248
257
 
249
 
  toggle = gtk_check_button_new_with_mnemonic (_("Sobel _Horizontally"));
 
258
  toggle = gtk_check_button_new_with_mnemonic (_("Sobel _horizontally"));
250
259
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), bvals.horizontal);
251
260
  gtk_box_pack_start (GTK_BOX (main_vbox), toggle, FALSE, FALSE, 0);
252
261
  gtk_widget_show (toggle);
258
267
                            G_CALLBACK (gimp_preview_invalidate),
259
268
                            preview);
260
269
 
261
 
  toggle = gtk_check_button_new_with_mnemonic (_("Sobel _Vertically"));
 
270
  toggle = gtk_check_button_new_with_mnemonic (_("Sobel _vertically"));
262
271
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), bvals.vertical);
263
272
  gtk_box_pack_start (GTK_BOX (main_vbox), toggle, FALSE, FALSE, 0);
264
273
  gtk_widget_show (toggle);
356
365
  else
357
366
    {
358
367
      gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
359
 
      gimp_progress_init (_("Sobel Edge Detecting..."));
 
368
      gimp_progress_init (_("Sobel edge detecting"));
360
369
      width  = x2 - x1;
361
370
      height = y2 - y1;
362
371
    }
446
455
        {
447
456
          gimp_pixel_rgn_set_row (&destPR, dest, x1, row, width);
448
457
 
449
 
          if ((row % 5) == 0)
 
458
          if ((row % 20) == 0)
450
459
            gimp_progress_update ((double) row / (double) (y2 - y1));
451
460
        }
452
461
    }