1
/* The GIMP -- an image manipulation program
1
/* GIMP - The GNU Image Manipulation Program
2
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
4
* This program is free software; you can redistribute it and/or modify
24
24
#include <stdlib.h>
25
25
#include <string.h>
29
27
#include <libgimp/gimp.h>
30
28
#include <libgimp/gimpui.h>
32
30
#include "libgimp/stdplugins-intl.h"
33
#define PLUG_IN_PROC "plug-in-sobel"
34
#define PLUG_IN_BINARY "sobel"
37
39
gboolean horizontal;
95
static GimpParamDef args[] =
97
static const GimpParamDef args[] =
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)" }
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 "
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);
161
163
/* First acquire information with a dialog */
162
164
if (! sobel_dialog (drawable))
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);
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));
222
224
GtkWidget *toggle;
225
gimp_ui_init ("sobel", FALSE);
227
gimp_ui_init (PLUG_IN_BINARY, FALSE);
227
dialog = gimp_dialog_new (_("Sobel Edge Detection"), "sobel",
229
dialog = gimp_dialog_new (_("Sobel Edge Detection"), PLUG_IN_BINARY,
229
gimp_standard_help_func, "plug-in-sobel",
231
gimp_standard_help_func, PLUG_IN_PROC,
231
233
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
232
234
GTK_STOCK_OK, GTK_RESPONSE_OK,
238
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
243
gimp_window_set_transient (GTK_WINDOW (dialog));
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),
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),
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);
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"));
361
370
height = y2 - y1;