30
30
#include "config.h"
33
32
#include <stdlib.h>
34
33
#include <string.h>
38
35
#include <libgimp/gimp.h>
39
36
#include <libgimp/gimpui.h>
41
38
#include "libgimp/stdplugins-intl.h"
43
#define PLUG_IN_NAME "wind"
45
#define COMPARE_WIDTH 3
47
#define SCALE_WIDTH 200
48
#define MIN_THRESHOLD 0
49
#define MAX_THRESHOLD 50
50
#define MIN_STRENGTH 1
51
#define MAX_STRENGTH 50
41
#define PLUG_IN_PROC "plug-in-wind"
42
#define PLUG_IN_BINARY "wind"
44
#define COMPARE_WIDTH 3
46
#define SCALE_WIDTH 200
47
#define MIN_THRESHOLD 0
48
#define MAX_THRESHOLD 50
49
#define MIN_STRENGTH 1
50
#define MAX_STRENGTH 100
165
static GimpParamDef args[] =
164
static const GimpParamDef args[] =
167
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
166
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
168
167
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
169
168
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
170
169
{ GIMP_PDB_INT32, "threshold", "Controls where blending will be done >= 0" },
171
170
{ GIMP_PDB_INT32, "direction", "Left or Right: 0 or 1" },
172
171
{ GIMP_PDB_INT32, "strength", "Controls the extent of the blending > 1" },
173
{ GIMP_PDB_INT32, "alg", "WIND, BLAST" },
172
{ GIMP_PDB_INT32, "algorithm", "WIND, BLAST" },
174
173
{ GIMP_PDB_INT32, "edge", "LEADING, TRAILING, or BOTH" }
177
gimp_install_procedure ("plug_in_wind",
178
"Renders a wind effect.",
176
gimp_install_procedure (PLUG_IN_PROC,
177
N_("Smear image to give windblown effect"),
179
178
"Renders a wind effect.",
230
229
case GIMP_RUN_INTERACTIVE:
231
gimp_get_data ("plug_in_wind", &config);
230
gimp_get_data (PLUG_IN_PROC, &config);
232
231
if (! dialog_box (drawable))
234
233
status = GIMP_PDB_CANCEL;
239
238
status = GIMP_PDB_CALLING_ERROR;
242
gimp_set_data ("plug_in_wind", &config, sizeof (config_t));
241
gimp_set_data (PLUG_IN_PROC, &config, sizeof (config_t));
243
242
gimp_displays_flush ();
246
245
case GIMP_RUN_WITH_LAST_VALS:
247
gimp_get_data ("plug_in_wind", &config);
246
gimp_get_data (PLUG_IN_PROC, &config);
248
247
if (render_effect (drawable, NULL) == -1)
250
249
status = GIMP_PDB_EXECUTION_ERROR;
251
gimp_message ("An execution error occured.");
250
gimp_message ("An execution error occurred.");
315
gimp_progress_init (_("Rendering Blast..."));
316
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
321
gimp_pixel_rgn_init (&dest_region, drawable,
322
x1, y1, width, height, TRUE, TRUE);
314
if (gimp_drawable_mask_intersect (drawable->drawable_id,
317
gimp_progress_init (_("Rendering blast"));
322
gimp_pixel_rgn_init (&dest_region, drawable,
323
x1, y1, width, height, TRUE, TRUE);
325
329
gimp_pixel_rgn_init (&src_region, drawable,
438
gimp_progress_init (_("Rendering Wind..."));
439
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
444
gimp_pixel_rgn_init (&dest_region, drawable,
445
x1, y1, width, height, TRUE, TRUE);
442
if (gimp_drawable_mask_intersect (drawable->drawable_id, &x1, &y1, &x2, &y2))
444
gimp_progress_init (_("Rendering wind"));
449
gimp_pixel_rgn_init (&dest_region, drawable,
450
x1, y1, width, height, TRUE, TRUE);
448
456
gimp_pixel_rgn_init (&src_region, drawable,
711
719
sb + i + comp_stride,
716
724
target_colour_R = sb[i + comp_stride + 0];
717
725
target_colour_G = sb[i + comp_stride + 1];
718
726
target_colour_B = sb[i + comp_stride + 2];
720
728
target_colour_A = sb[i + comp_stride + 3];
721
729
blend_amt_R = target_colour_R - blend_colour_R;
722
730
blend_amt_G = target_colour_G - blend_colour_G;
723
731
blend_amt_B = target_colour_B - blend_colour_B;
725
733
blend_amt_A = target_colour_A - blend_colour_A;
726
734
denominator = n * n + n;
727
735
denominator = 2.0 / denominator;
740
748
gboolean has_alpha)
742
gint derivative_R, derivative_G, derivative_B, derivative_A;
743
gboolean return_value;
750
gint derivative_R, derivative_G, derivative_B, derivative_A;
745
752
get_derivative (pixel_R1, pixel_R2, edge, has_alpha,
746
753
&derivative_R, &derivative_G, &derivative_B, &derivative_A);
751
derivative_A) / 4) > threshold)
757
return_value = FALSE;
755
return (((derivative_R +
758
derivative_A) / 4) > threshold);
868
867
GtkWidget *edge3;
871
gimp_ui_init ("wind", TRUE);
870
gimp_ui_init (PLUG_IN_BINARY, TRUE);
873
dialog = gimp_dialog_new (_("Wind"), "wind",
872
dialog = gimp_dialog_new (_("Wind"), PLUG_IN_BINARY,
875
gimp_standard_help_func, "plug-in-wind",
874
gimp_standard_help_func, PLUG_IN_PROC,
877
876
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
878
877
GTK_STOCK_OK, GTK_RESPONSE_OK,
881
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
886
gimp_window_set_transient (GTK_WINDOW (dialog));
882
888
main_vbox = gtk_vbox_new (FALSE, 12);
883
889
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
884
890
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
997
1003
_("Higher values restrict the effect to fewer areas of the image"), NULL);
999
g_signal_connect (adj, "value_changed",
1005
g_signal_connect (adj, "value-changed",
1000
1006
G_CALLBACK (gimp_int_adjustment_update),
1001
1007
&config.threshold);
1003
g_signal_connect_swapped (adj, "value_changed",
1009
g_signal_connect_swapped (adj, "value-changed",
1004
1010
G_CALLBACK (gimp_preview_invalidate),
1016
1022
_("Higher values increase the magnitude of the effect"), NULL);
1018
g_signal_connect (adj, "value_changed",
1024
g_signal_connect (adj, "value-changed",
1019
1025
G_CALLBACK (gimp_int_adjustment_update),
1020
1026
&config.strength);
1022
g_signal_connect_swapped (adj, "value_changed",
1028
g_signal_connect_swapped (adj, "value-changed",
1023
1029
G_CALLBACK (gimp_preview_invalidate),