24
24
#include <glib-object.h>
26
26
#include "pdb-types.h"
27
#include "procedural_db.h"
28
#include "gimpprocedure.h"
29
#include "core/gimpparamspecs.h"
29
31
#include "core/gimpchannel-select.h"
30
32
#include "core/gimpchannel.h"
31
33
#include "core/gimpdrawable.h"
32
34
#include "core/gimpimage.h"
33
35
#include "core/gimplayer.h"
36
#include "core/gimppickable.h"
34
37
#include "core/gimpselection.h"
35
38
#include "gimp-intl.h"
37
static ProcRecord selection_bounds_proc;
38
static ProcRecord selection_value_proc;
39
static ProcRecord selection_is_empty_proc;
40
static ProcRecord selection_translate_proc;
41
static ProcRecord selection_float_proc;
42
static ProcRecord selection_invert_proc;
43
static ProcRecord selection_sharpen_proc;
44
static ProcRecord selection_all_proc;
45
static ProcRecord selection_none_proc;
46
static ProcRecord selection_feather_proc;
47
static ProcRecord selection_border_proc;
48
static ProcRecord selection_grow_proc;
49
static ProcRecord selection_shrink_proc;
50
static ProcRecord selection_layer_alpha_proc;
51
static ProcRecord selection_load_proc;
52
static ProcRecord selection_save_proc;
53
static ProcRecord selection_combine_proc;
56
register_selection_procs (Gimp *gimp)
58
procedural_db_register (gimp, &selection_bounds_proc);
59
procedural_db_register (gimp, &selection_value_proc);
60
procedural_db_register (gimp, &selection_is_empty_proc);
61
procedural_db_register (gimp, &selection_translate_proc);
62
procedural_db_register (gimp, &selection_float_proc);
63
procedural_db_register (gimp, &selection_invert_proc);
64
procedural_db_register (gimp, &selection_sharpen_proc);
65
procedural_db_register (gimp, &selection_all_proc);
66
procedural_db_register (gimp, &selection_none_proc);
67
procedural_db_register (gimp, &selection_feather_proc);
68
procedural_db_register (gimp, &selection_border_proc);
69
procedural_db_register (gimp, &selection_grow_proc);
70
procedural_db_register (gimp, &selection_shrink_proc);
71
procedural_db_register (gimp, &selection_layer_alpha_proc);
72
procedural_db_register (gimp, &selection_load_proc);
73
procedural_db_register (gimp, &selection_save_proc);
74
procedural_db_register (gimp, &selection_combine_proc);
78
selection_bounds_invoker (Gimp *gimp,
80
GimpProgress *progress,
40
#include "internal_procs.h"
44
selection_bounds_invoker (GimpProcedure *procedure,
47
GimpProgress *progress,
48
const GValueArray *args)
83
50
gboolean success = TRUE;
84
Argument *return_args;
51
GValueArray *return_vals;
86
53
gboolean non_empty = FALSE;
92
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
93
if (! GIMP_IS_IMAGE (gimage))
97
non_empty = gimp_channel_bounds (gimp_image_get_mask (gimage), &x1, &y1, &x2, &y2);
99
return_args = procedural_db_return_args (&selection_bounds_proc, success);
103
return_args[1].value.pdb_int = non_empty;
104
return_args[2].value.pdb_int = x1;
105
return_args[3].value.pdb_int = y1;
106
return_args[4].value.pdb_int = x2;
107
return_args[5].value.pdb_int = y2;
59
image = gimp_value_get_image (&args->values[0], gimp);
63
non_empty = gimp_channel_bounds (gimp_image_get_mask (image),
67
return_vals = gimp_procedure_get_return_values (procedure, success);
71
g_value_set_boolean (&return_vals->values[1], non_empty);
72
g_value_set_int (&return_vals->values[2], x1);
73
g_value_set_int (&return_vals->values[3], y1);
74
g_value_set_int (&return_vals->values[4], x2);
75
g_value_set_int (&return_vals->values[5], y2);
113
static ProcArg selection_bounds_inargs[] =
122
static ProcArg selection_bounds_outargs[] =
127
"True if there is a selection"
132
"x coordinate of upper left corner of selection bounds"
137
"y coordinate of upper left corner of selection bounds"
142
"x coordinate of lower right corner of selection bounds"
147
"y coordinate of lower right corner of selection bounds"
151
static ProcRecord selection_bounds_proc =
153
"gimp_selection_bounds",
154
"Find the bounding box of the current selection.",
155
"This procedure returns whether there is a selection for the specified image. If there is one, the upper left and lower right corners of the bounding box are returned. These coordinates are relative to the image. Please note that the pixel specified by the lower righthand coordinate of the bounding box is not part of the selection. The selection ends at the upper left corner of this pixel. This means the width of the selection can be calculated as (x2 - x1), its height as (y2 - y1).",
156
"Spencer Kimball & Peter Mattis",
157
"Spencer Kimball & Peter Mattis",
162
selection_bounds_inargs,
164
selection_bounds_outargs,
165
{ { selection_bounds_invoker } }
169
selection_value_invoker (Gimp *gimp,
170
GimpContext *context,
171
GimpProgress *progress,
82
selection_value_invoker (GimpProcedure *procedure,
85
GimpProgress *progress,
86
const GValueArray *args)
174
88
gboolean success = TRUE;
175
Argument *return_args;
89
GValueArray *return_vals;
180
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
181
if (! GIMP_IS_IMAGE (gimage))
184
x = args[1].value.pdb_int;
186
y = args[2].value.pdb_int;
188
return_args = procedural_db_return_args (&selection_value_proc, success);
191
return_args[1].value.pdb_int = gimp_channel_value (gimp_image_get_mask (gimage), x, y);
196
static ProcArg selection_value_inargs[] =
206
"x coordinate of value"
211
"y coordinate of value"
215
static ProcArg selection_value_outargs[] =
220
"Value of the selection: (0 <= value <= 255)"
224
static ProcRecord selection_value_proc =
226
"gimp_selection_value",
227
"Find the value of the selection at the specified coordinates.",
228
"This procedure returns the value of the selection at the specified coordinates. If the coordinates lie out of bounds, 0 is returned.",
229
"Spencer Kimball & Peter Mattis",
230
"Spencer Kimball & Peter Mattis",
235
selection_value_inargs,
237
selection_value_outargs,
238
{ { selection_value_invoker } }
242
selection_is_empty_invoker (Gimp *gimp,
243
GimpContext *context,
244
GimpProgress *progress,
247
gboolean success = TRUE;
248
Argument *return_args;
251
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
252
if (! GIMP_IS_IMAGE (gimage))
255
return_args = procedural_db_return_args (&selection_is_empty_proc, success);
258
return_args[1].value.pdb_int = gimp_channel_is_empty (gimp_image_get_mask (gimage));
263
static ProcArg selection_is_empty_inargs[] =
272
static ProcArg selection_is_empty_outargs[] =
277
"Is the selection empty?"
281
static ProcRecord selection_is_empty_proc =
283
"gimp_selection_is_empty",
284
"Determine whether the selection is empty.",
285
"This procedure returns non-zero if the selection for the specified image is not empty.",
286
"Spencer Kimball & Peter Mattis",
287
"Spencer Kimball & Peter Mattis",
292
selection_is_empty_inargs,
294
selection_is_empty_outargs,
295
{ { selection_is_empty_invoker } }
299
selection_translate_invoker (Gimp *gimp,
300
GimpContext *context,
301
GimpProgress *progress,
304
gboolean success = TRUE;
95
image = gimp_value_get_image (&args->values[0], gimp);
96
x = g_value_get_int (&args->values[1]);
97
y = g_value_get_int (&args->values[2]);
101
value = gimp_pickable_get_opacity_at (GIMP_PICKABLE (gimp_image_get_mask (image)), x, y);
104
return_vals = gimp_procedure_get_return_values (procedure, success);
107
g_value_set_int (&return_vals->values[1], value);
113
selection_is_empty_invoker (GimpProcedure *procedure,
115
GimpContext *context,
116
GimpProgress *progress,
117
const GValueArray *args)
119
gboolean success = TRUE;
120
GValueArray *return_vals;
122
gboolean is_empty = FALSE;
124
image = gimp_value_get_image (&args->values[0], gimp);
128
is_empty = gimp_channel_is_empty (gimp_image_get_mask (image));
131
return_vals = gimp_procedure_get_return_values (procedure, success);
134
g_value_set_boolean (&return_vals->values[1], is_empty);
140
selection_translate_invoker (GimpProcedure *procedure,
142
GimpContext *context,
143
GimpProgress *progress,
144
const GValueArray *args)
146
gboolean success = TRUE;
309
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
310
if (! GIMP_IS_IMAGE (gimage))
313
offx = args[1].value.pdb_int;
315
offy = args[2].value.pdb_int;
151
image = gimp_value_get_image (&args->values[0], gimp);
152
offx = g_value_get_int (&args->values[1]);
153
offy = g_value_get_int (&args->values[2]);
318
gimp_item_translate (GIMP_ITEM (gimp_image_get_mask (gimage)), offx, offy, TRUE);
157
gimp_item_translate (GIMP_ITEM (gimp_image_get_mask (image)),
320
return procedural_db_return_args (&selection_translate_proc, success);
161
return gimp_procedure_get_return_values (procedure, success);
323
static ProcArg selection_translate_inargs[] =
333
"x offset for translation"
338
"y offset for translation"
342
static ProcRecord selection_translate_proc =
344
"gimp_selection_translate",
345
"Translate the selection by the specified offsets.",
346
"This procedure actually translates the selection for the specified image by the specified offsets. Regions that are translated from beyond the bounds of the image are set to empty. Valid regions of the selection which are translated beyond the bounds of the image because of this call are lost.",
347
"Spencer Kimball & Peter Mattis",
348
"Spencer Kimball & Peter Mattis",
353
selection_translate_inargs,
356
{ { selection_translate_invoker } }
360
selection_float_invoker (Gimp *gimp,
361
GimpContext *context,
362
GimpProgress *progress,
165
selection_float_invoker (GimpProcedure *procedure,
167
GimpContext *context,
168
GimpProgress *progress,
169
const GValueArray *args)
365
171
gboolean success = TRUE;
366
Argument *return_args;
172
GValueArray *return_vals;
367
173
GimpDrawable *drawable;
370
176
GimpLayer *layer = NULL;
372
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
373
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
376
offx = args[1].value.pdb_int;
378
offy = args[2].value.pdb_int;
178
drawable = gimp_value_get_drawable (&args->values[0], gimp);
179
offx = g_value_get_int (&args->values[1]);
180
offy = g_value_get_int (&args->values[2]);
382
success = gimp_item_is_attached (GIMP_ITEM (drawable));
184
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
386
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
186
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
388
layer = gimp_selection_float (gimp_image_get_mask (gimage),
188
layer = gimp_selection_float (gimp_image_get_mask (image),
389
189
drawable, context, TRUE, offx, offy);
395
return_args = procedural_db_return_args (&selection_float_proc, success);
398
return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (layer));
403
static ProcArg selection_float_inargs[] =
408
"The drawable from which to float selection"
413
"x offset for translation"
418
"y offset for translation"
422
static ProcArg selection_float_outargs[] =
431
static ProcRecord selection_float_proc =
433
"gimp_selection_float",
434
"Float the selection from the specified drawable with initial offsets as specified.",
435
"This procedure determines the region of the specified drawable that lies beneath the current selection. The region is then cut from the drawable and the resulting data is made into a new layer which is instantiated as a floating selection. The offsets allow initial positioning of the new floating selection.",
436
"Spencer Kimball & Peter Mattis",
437
"Spencer Kimball & Peter Mattis",
442
selection_float_inargs,
444
selection_float_outargs,
445
{ { selection_float_invoker } }
449
selection_invert_invoker (Gimp *gimp,
450
GimpContext *context,
451
GimpProgress *progress,
454
gboolean success = TRUE;
457
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
458
if (! GIMP_IS_IMAGE (gimage))
462
gimp_channel_invert (gimp_image_get_mask (gimage), TRUE);
464
return procedural_db_return_args (&selection_invert_proc, success);
467
static ProcArg selection_invert_inargs[] =
476
static ProcRecord selection_invert_proc =
478
"gimp_selection_invert",
479
"Invert the selection mask.",
480
"This procedure inverts the selection mask. For every pixel in the selection channel, its new value is calculated as (255 - old_value).",
481
"Spencer Kimball & Peter Mattis",
482
"Spencer Kimball & Peter Mattis",
487
selection_invert_inargs,
490
{ { selection_invert_invoker } }
494
selection_sharpen_invoker (Gimp *gimp,
495
GimpContext *context,
496
GimpProgress *progress,
499
gboolean success = TRUE;
502
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
503
if (! GIMP_IS_IMAGE (gimage))
507
gimp_channel_sharpen (gimp_image_get_mask (gimage), TRUE);
509
return procedural_db_return_args (&selection_sharpen_proc, success);
512
static ProcArg selection_sharpen_inargs[] =
521
static ProcRecord selection_sharpen_proc =
523
"gimp_selection_sharpen",
524
"Sharpen the selection mask.",
525
"This procedure sharpens the selection mask. For every pixel in the selection channel, if the value is > 0, the new pixel is assigned a value of 255. This removes any \"anti-aliasing\" that might exist in the selection mask's boundary.",
526
"Spencer Kimball & Peter Mattis",
527
"Spencer Kimball & Peter Mattis",
532
selection_sharpen_inargs,
535
{ { selection_sharpen_invoker } }
539
selection_all_invoker (Gimp *gimp,
540
GimpContext *context,
541
GimpProgress *progress,
544
gboolean success = TRUE;
547
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
548
if (! GIMP_IS_IMAGE (gimage))
552
gimp_channel_all (gimp_image_get_mask (gimage), TRUE);
554
return procedural_db_return_args (&selection_all_proc, success);
557
static ProcArg selection_all_inargs[] =
566
static ProcRecord selection_all_proc =
568
"gimp_selection_all",
569
"Select all of the image.",
570
"This procedure sets the selection mask to completely encompass the image. Every pixel in the selection channel is set to 255.",
571
"Spencer Kimball & Peter Mattis",
572
"Spencer Kimball & Peter Mattis",
577
selection_all_inargs,
580
{ { selection_all_invoker } }
584
selection_none_invoker (Gimp *gimp,
585
GimpContext *context,
586
GimpProgress *progress,
589
gboolean success = TRUE;
592
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
593
if (! GIMP_IS_IMAGE (gimage))
597
gimp_channel_clear (gimp_image_get_mask (gimage), NULL, TRUE);
599
return procedural_db_return_args (&selection_none_proc, success);
602
static ProcArg selection_none_inargs[] =
611
static ProcRecord selection_none_proc =
613
"gimp_selection_none",
614
"Deselect the entire image.",
615
"This procedure deselects the entire image. Every pixel in the selection channel is set to 0.",
616
"Spencer Kimball & Peter Mattis",
617
"Spencer Kimball & Peter Mattis",
622
selection_none_inargs,
625
{ { selection_none_invoker } }
629
selection_feather_invoker (Gimp *gimp,
630
GimpContext *context,
631
GimpProgress *progress,
634
gboolean success = TRUE;
197
return_vals = gimp_procedure_get_return_values (procedure, success);
200
gimp_value_set_layer (&return_vals->values[1], layer);
206
selection_invert_invoker (GimpProcedure *procedure,
208
GimpContext *context,
209
GimpProgress *progress,
210
const GValueArray *args)
212
gboolean success = TRUE;
215
image = gimp_value_get_image (&args->values[0], gimp);
219
gimp_channel_invert (gimp_image_get_mask (image), TRUE);
222
return gimp_procedure_get_return_values (procedure, success);
226
selection_sharpen_invoker (GimpProcedure *procedure,
228
GimpContext *context,
229
GimpProgress *progress,
230
const GValueArray *args)
232
gboolean success = TRUE;
235
image = gimp_value_get_image (&args->values[0], gimp);
239
gimp_channel_sharpen (gimp_image_get_mask (image), TRUE);
242
return gimp_procedure_get_return_values (procedure, success);
246
selection_all_invoker (GimpProcedure *procedure,
248
GimpContext *context,
249
GimpProgress *progress,
250
const GValueArray *args)
252
gboolean success = TRUE;
255
image = gimp_value_get_image (&args->values[0], gimp);
259
gimp_channel_all (gimp_image_get_mask (image), TRUE);
262
return gimp_procedure_get_return_values (procedure, success);
266
selection_none_invoker (GimpProcedure *procedure,
268
GimpContext *context,
269
GimpProgress *progress,
270
const GValueArray *args)
272
gboolean success = TRUE;
275
image = gimp_value_get_image (&args->values[0], gimp);
279
gimp_channel_clear (gimp_image_get_mask (image), NULL, TRUE);
282
return gimp_procedure_get_return_values (procedure, success);
286
selection_feather_invoker (GimpProcedure *procedure,
288
GimpContext *context,
289
GimpProgress *progress,
290
const GValueArray *args)
292
gboolean success = TRUE;
638
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
639
if (! GIMP_IS_IMAGE (gimage))
642
radius = args[1].value.pdb_float;
647
gimp_channel_feather (gimp_image_get_mask (gimage), radius, radius, TRUE);
649
return procedural_db_return_args (&selection_feather_proc, success);
652
static ProcArg selection_feather_inargs[] =
662
"Radius of feather (in pixels)"
666
static ProcRecord selection_feather_proc =
668
"gimp_selection_feather",
669
"Feather the image's selection",
670
"This procedure feathers the selection. Feathering is implemented using a gaussian blur.",
671
"Spencer Kimball & Peter Mattis",
672
"Spencer Kimball & Peter Mattis",
677
selection_feather_inargs,
680
{ { selection_feather_invoker } }
684
selection_border_invoker (Gimp *gimp,
685
GimpContext *context,
686
GimpProgress *progress,
689
gboolean success = TRUE;
693
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
694
if (! GIMP_IS_IMAGE (gimage))
697
radius = args[1].value.pdb_int;
702
gimp_channel_border (gimp_image_get_mask (gimage), radius, radius, TRUE);
704
return procedural_db_return_args (&selection_border_proc, success);
707
static ProcArg selection_border_inargs[] =
717
"Radius of border (in pixels)"
721
static ProcRecord selection_border_proc =
723
"gimp_selection_border",
724
"Border the image's selection",
725
"This procedure borders the selection. Bordering creates a new selection which is defined along the boundary of the previous selection at every point within the specified radius.",
726
"Spencer Kimball & Peter Mattis",
727
"Spencer Kimball & Peter Mattis",
732
selection_border_inargs,
735
{ { selection_border_invoker } }
739
selection_grow_invoker (Gimp *gimp,
740
GimpContext *context,
741
GimpProgress *progress,
744
gboolean success = TRUE;
748
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
749
if (! GIMP_IS_IMAGE (gimage))
752
steps = args[1].value.pdb_int;
757
gimp_channel_grow (gimp_image_get_mask (gimage), steps, steps, TRUE);
759
return procedural_db_return_args (&selection_grow_proc, success);
762
static ProcArg selection_grow_inargs[] =
772
"Steps of grow (in pixels)"
776
static ProcRecord selection_grow_proc =
778
"gimp_selection_grow",
779
"Grow the image's selection",
780
"This procedure grows the selection. Growing involves expanding the boundary in all directions by the specified pixel amount.",
781
"Spencer Kimball & Peter Mattis",
782
"Spencer Kimball & Peter Mattis",
787
selection_grow_inargs,
790
{ { selection_grow_invoker } }
794
selection_shrink_invoker (Gimp *gimp,
795
GimpContext *context,
796
GimpProgress *progress,
799
gboolean success = TRUE;
803
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
804
if (! GIMP_IS_IMAGE (gimage))
807
radius = args[1].value.pdb_int;
812
gimp_channel_shrink (gimp_image_get_mask (gimage), radius, radius, FALSE, TRUE);
814
return procedural_db_return_args (&selection_shrink_proc, success);
817
static ProcArg selection_shrink_inargs[] =
827
"Radius of shrink (in pixels)"
831
static ProcRecord selection_shrink_proc =
833
"gimp_selection_shrink",
834
"Shrink the image's selection",
835
"This procedure shrinks the selection. Shrinking invovles trimming the existing selection boundary on all sides by the specified number of pixels.",
836
"Spencer Kimball & Peter Mattis",
837
"Spencer Kimball & Peter Mattis",
842
selection_shrink_inargs,
845
{ { selection_shrink_invoker } }
849
selection_layer_alpha_invoker (Gimp *gimp,
850
GimpContext *context,
851
GimpProgress *progress,
296
image = gimp_value_get_image (&args->values[0], gimp);
297
radius = g_value_get_double (&args->values[1]);
301
gimp_channel_feather (gimp_image_get_mask (image),
302
radius, radius, TRUE);
305
return gimp_procedure_get_return_values (procedure, success);
309
selection_border_invoker (GimpProcedure *procedure,
311
GimpContext *context,
312
GimpProgress *progress,
313
const GValueArray *args)
315
gboolean success = TRUE;
319
image = gimp_value_get_image (&args->values[0], gimp);
320
radius = g_value_get_int (&args->values[1]);
324
/* FIXME: "feather" and "edge-lock" hardcoded to TRUE */
325
gimp_channel_border (gimp_image_get_mask (image),
326
radius, radius, TRUE, TRUE, TRUE);
329
return gimp_procedure_get_return_values (procedure, success);
333
selection_grow_invoker (GimpProcedure *procedure,
335
GimpContext *context,
336
GimpProgress *progress,
337
const GValueArray *args)
339
gboolean success = TRUE;
343
image = gimp_value_get_image (&args->values[0], gimp);
344
steps = g_value_get_int (&args->values[1]);
348
gimp_channel_grow (gimp_image_get_mask (image),
352
return gimp_procedure_get_return_values (procedure, success);
356
selection_shrink_invoker (GimpProcedure *procedure,
358
GimpContext *context,
359
GimpProgress *progress,
360
const GValueArray *args)
362
gboolean success = TRUE;
366
image = gimp_value_get_image (&args->values[0], gimp);
367
steps = g_value_get_int (&args->values[1]);
371
gimp_channel_shrink (gimp_image_get_mask (image),
372
steps, steps, FALSE, TRUE);
375
return gimp_procedure_get_return_values (procedure, success);
379
selection_layer_alpha_invoker (GimpProcedure *procedure,
381
GimpContext *context,
382
GimpProgress *progress,
383
const GValueArray *args)
854
385
gboolean success = TRUE;
855
386
GimpLayer *layer;
858
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
859
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
388
layer = gimp_value_get_layer (&args->values[0], gimp);
864
gimage = gimp_item_get_image (GIMP_ITEM (layer));
865
gimp_channel_select_alpha (gimp_image_get_mask (gimage),
392
GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
394
gimp_channel_select_alpha (gimp_image_get_mask (image),
866
395
GIMP_DRAWABLE (layer),
867
396
GIMP_CHANNEL_OP_REPLACE, FALSE, 0.0, 0.0);
870
return procedural_db_return_args (&selection_layer_alpha_proc, success);
399
return gimp_procedure_get_return_values (procedure, success);
873
static ProcArg selection_layer_alpha_inargs[] =
882
static ProcRecord selection_layer_alpha_proc =
884
"gimp_selection_layer_alpha",
885
"Transfer the specified layer's alpha channel to the selection mask.",
886
"This procedure requires a layer with an alpha channel. The alpha channel information is used to create a selection mask such that for any pixel in the image defined in the specified layer, that layer pixel's alpha value is transferred to the selection mask. If the layer is undefined at a particular image pixel, the associated selection mask value is set to 0.",
887
"Spencer Kimball & Peter Mattis",
888
"Spencer Kimball & Peter Mattis",
893
selection_layer_alpha_inargs,
896
{ { selection_layer_alpha_invoker } }
900
selection_load_invoker (Gimp *gimp,
901
GimpContext *context,
902
GimpProgress *progress,
403
selection_load_invoker (GimpProcedure *procedure,
405
GimpContext *context,
406
GimpProgress *progress,
407
const GValueArray *args)
905
409
gboolean success = TRUE;
906
410
GimpChannel *channel;
908
channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
909
if (! (GIMP_IS_CHANNEL (channel) && ! gimp_item_is_removed (GIMP_ITEM (channel))))
412
channel = gimp_value_get_channel (&args->values[0], gimp);
915
417
gint off_x, off_y;
917
gimage = gimp_item_get_image (GIMP_ITEM (channel));
419
image = gimp_item_get_image (GIMP_ITEM (channel));
918
420
gimp_item_offsets (GIMP_ITEM (channel), &off_x, &off_y);
920
gimp_channel_select_channel (gimp_image_get_mask (gimage),
422
gimp_channel_select_channel (gimp_image_get_mask (image),
921
423
_("Channel to Selection"),
924
426
GIMP_CHANNEL_OP_REPLACE,
925
427
FALSE, 0.0, 0.0);
928
return procedural_db_return_args (&selection_load_proc, success);
430
return gimp_procedure_get_return_values (procedure, success);
931
static ProcArg selection_load_inargs[] =
940
static ProcRecord selection_load_proc =
942
"gimp_selection_load",
943
"Transfer the specified channel to the selection mask.",
944
"This procedure loads the specified channel into the selection mask.",
945
"Spencer Kimball & Peter Mattis",
946
"Spencer Kimball & Peter Mattis",
951
selection_load_inargs,
954
{ { selection_load_invoker } }
958
selection_save_invoker (Gimp *gimp,
959
GimpContext *context,
960
GimpProgress *progress,
434
selection_save_invoker (GimpProcedure *procedure,
436
GimpContext *context,
437
GimpProgress *progress,
438
const GValueArray *args)
963
440
gboolean success = TRUE;
964
Argument *return_args;
441
GValueArray *return_vals;
966
443
GimpChannel *channel = NULL;
968
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
969
if (! GIMP_IS_IMAGE (gimage))
973
success = (channel = gimp_selection_save (gimp_image_get_mask (gimage))) != NULL;
975
return_args = procedural_db_return_args (&selection_save_proc, success);
978
return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (channel));
445
image = gimp_value_get_image (&args->values[0], gimp);
449
channel = gimp_selection_save (gimp_image_get_mask (image));
455
return_vals = gimp_procedure_get_return_values (procedure, success);
458
gimp_value_set_channel (&return_vals->values[1], channel);
983
static ProcArg selection_save_inargs[] =
992
static ProcArg selection_save_outargs[] =
1001
static ProcRecord selection_save_proc =
1003
"gimp_selection_save",
1004
"Copy the selection mask to a new channel.",
1005
"This procedure copies the selection mask and stores the content in a new channel. The new channel is automatically inserted into the image's list of channels.",
1006
"Spencer Kimball & Peter Mattis",
1007
"Spencer Kimball & Peter Mattis",
1012
selection_save_inargs,
1014
selection_save_outargs,
1015
{ { selection_save_invoker } }
1019
selection_combine_invoker (Gimp *gimp,
1020
GimpContext *context,
1021
GimpProgress *progress,
464
selection_combine_invoker (GimpProcedure *procedure,
466
GimpContext *context,
467
GimpProgress *progress,
468
const GValueArray *args)
1024
470
gboolean success = TRUE;
1025
471
GimpChannel *channel;
1026
472
gint32 operation;
1028
channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
1029
if (! (GIMP_IS_CHANNEL (channel) && ! gimp_item_is_removed (GIMP_ITEM (channel))))
1032
operation = args[1].value.pdb_int;
1033
if (operation < GIMP_CHANNEL_OP_ADD || operation > GIMP_CHANNEL_OP_INTERSECT)
474
channel = gimp_value_get_channel (&args->values[0], gimp);
475
operation = g_value_get_enum (&args->values[1]);
1039
480
gint off_x, off_y;
1041
gimage = gimp_item_get_image (GIMP_ITEM (channel));
482
image = gimp_item_get_image (GIMP_ITEM (channel));
1042
483
gimp_item_offsets (GIMP_ITEM (channel), &off_x, &off_y);
1044
gimp_channel_select_channel (gimp_image_get_mask (gimage),
485
gimp_channel_select_channel (gimp_image_get_mask (image),
1045
486
_("Channel to Selection"),
1049
490
FALSE, 0.0, 0.0);
1052
return procedural_db_return_args (&selection_combine_proc, success);
1055
static ProcArg selection_combine_inargs[] =
1065
"The selection operation: { GIMP_CHANNEL_OP_ADD (0), GIMP_CHANNEL_OP_SUBTRACT (1), GIMP_CHANNEL_OP_REPLACE (2), GIMP_CHANNEL_OP_INTERSECT (3) }"
1069
static ProcRecord selection_combine_proc =
1071
"gimp_selection_combine",
1072
"Combines the specified channel with the selection mask.",
1073
"This procedure combines the specified channel into the selection mask.",
1074
"Spencer Kimball & Peter Mattis",
1075
"Spencer Kimball & Peter Mattis",
1080
selection_combine_inargs,
1083
{ { selection_combine_invoker } }
493
return gimp_procedure_get_return_values (procedure, success);
497
register_selection_procs (GimpPDB *pdb)
499
GimpProcedure *procedure;
502
* gimp-selection-bounds
504
procedure = gimp_procedure_new (selection_bounds_invoker);
505
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-bounds");
506
gimp_procedure_set_static_strings (procedure,
507
"gimp-selection-bounds",
508
"Find the bounding box of the current selection.",
509
"This procedure returns whether there is a selection for the specified image. If there is one, the upper left and lower right corners of the bounding box are returned. These coordinates are relative to the image. Please note that the pixel specified by the lower righthand coordinate of the bounding box is not part of the selection. The selection ends at the upper left corner of this pixel. This means the width of the selection can be calculated as (x2 - x1), its height as (y2 - y1).",
510
"Spencer Kimball & Peter Mattis",
511
"Spencer Kimball & Peter Mattis",
514
gimp_procedure_add_argument (procedure,
515
gimp_param_spec_image_id ("image",
519
GIMP_PARAM_READWRITE));
520
gimp_procedure_add_return_value (procedure,
521
g_param_spec_boolean ("non-empty",
523
"TRUE if there is a selection",
525
GIMP_PARAM_READWRITE));
526
gimp_procedure_add_return_value (procedure,
527
gimp_param_spec_int32 ("x1",
529
"x coordinate of upper left corner of selection bounds",
530
G_MININT32, G_MAXINT32, 0,
531
GIMP_PARAM_READWRITE));
532
gimp_procedure_add_return_value (procedure,
533
gimp_param_spec_int32 ("y1",
535
"y coordinate of upper left corner of selection bounds",
536
G_MININT32, G_MAXINT32, 0,
537
GIMP_PARAM_READWRITE));
538
gimp_procedure_add_return_value (procedure,
539
gimp_param_spec_int32 ("x2",
541
"x coordinate of lower right corner of selection bounds",
542
G_MININT32, G_MAXINT32, 0,
543
GIMP_PARAM_READWRITE));
544
gimp_procedure_add_return_value (procedure,
545
gimp_param_spec_int32 ("y2",
547
"y coordinate of lower right corner of selection bounds",
548
G_MININT32, G_MAXINT32, 0,
549
GIMP_PARAM_READWRITE));
550
gimp_pdb_register_procedure (pdb, procedure);
551
g_object_unref (procedure);
554
* gimp-selection-value
556
procedure = gimp_procedure_new (selection_value_invoker);
557
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-value");
558
gimp_procedure_set_static_strings (procedure,
559
"gimp-selection-value",
560
"Find the value of the selection at the specified coordinates.",
561
"This procedure returns the value of the selection at the specified coordinates. If the coordinates lie out of bounds, 0 is returned.",
562
"Spencer Kimball & Peter Mattis",
563
"Spencer Kimball & Peter Mattis",
566
gimp_procedure_add_argument (procedure,
567
gimp_param_spec_image_id ("image",
571
GIMP_PARAM_READWRITE));
572
gimp_procedure_add_argument (procedure,
573
gimp_param_spec_int32 ("x",
575
"x coordinate of value",
576
G_MININT32, G_MAXINT32, 0,
577
GIMP_PARAM_READWRITE));
578
gimp_procedure_add_argument (procedure,
579
gimp_param_spec_int32 ("y",
581
"y coordinate of value",
582
G_MININT32, G_MAXINT32, 0,
583
GIMP_PARAM_READWRITE));
584
gimp_procedure_add_return_value (procedure,
585
gimp_param_spec_int32 ("value",
587
"Value of the selection",
589
GIMP_PARAM_READWRITE));
590
gimp_pdb_register_procedure (pdb, procedure);
591
g_object_unref (procedure);
594
* gimp-selection-is-empty
596
procedure = gimp_procedure_new (selection_is_empty_invoker);
597
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-is-empty");
598
gimp_procedure_set_static_strings (procedure,
599
"gimp-selection-is-empty",
600
"Determine whether the selection is empty.",
601
"This procedure returns TRUE if the selection for the specified image is not empty.",
602
"Spencer Kimball & Peter Mattis",
603
"Spencer Kimball & Peter Mattis",
606
gimp_procedure_add_argument (procedure,
607
gimp_param_spec_image_id ("image",
611
GIMP_PARAM_READWRITE));
612
gimp_procedure_add_return_value (procedure,
613
g_param_spec_boolean ("is-empty",
615
"Is the selection empty?",
617
GIMP_PARAM_READWRITE));
618
gimp_pdb_register_procedure (pdb, procedure);
619
g_object_unref (procedure);
622
* gimp-selection-translate
624
procedure = gimp_procedure_new (selection_translate_invoker);
625
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-translate");
626
gimp_procedure_set_static_strings (procedure,
627
"gimp-selection-translate",
628
"Translate the selection by the specified offsets.",
629
"This procedure actually translates the selection for the specified image by the specified offsets. Regions that are translated from beyond the bounds of the image are set to empty. Valid regions of the selection which are translated beyond the bounds of the image because of this call are lost.",
630
"Spencer Kimball & Peter Mattis",
631
"Spencer Kimball & Peter Mattis",
634
gimp_procedure_add_argument (procedure,
635
gimp_param_spec_image_id ("image",
639
GIMP_PARAM_READWRITE));
640
gimp_procedure_add_argument (procedure,
641
gimp_param_spec_int32 ("offx",
643
"x offset for translation",
644
G_MININT32, G_MAXINT32, 0,
645
GIMP_PARAM_READWRITE));
646
gimp_procedure_add_argument (procedure,
647
gimp_param_spec_int32 ("offy",
649
"y offset for translation",
650
G_MININT32, G_MAXINT32, 0,
651
GIMP_PARAM_READWRITE));
652
gimp_pdb_register_procedure (pdb, procedure);
653
g_object_unref (procedure);
656
* gimp-selection-float
658
procedure = gimp_procedure_new (selection_float_invoker);
659
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-float");
660
gimp_procedure_set_static_strings (procedure,
661
"gimp-selection-float",
662
"Float the selection from the specified drawable with initial offsets as specified.",
663
"This procedure determines the region of the specified drawable that lies beneath the current selection. The region is then cut from the drawable and the resulting data is made into a new layer which is instantiated as a floating selection. The offsets allow initial positioning of the new floating selection.",
664
"Spencer Kimball & Peter Mattis",
665
"Spencer Kimball & Peter Mattis",
668
gimp_procedure_add_argument (procedure,
669
gimp_param_spec_drawable_id ("drawable",
671
"The drawable from which to float selection",
673
GIMP_PARAM_READWRITE));
674
gimp_procedure_add_argument (procedure,
675
gimp_param_spec_int32 ("offx",
677
"x offset for translation",
678
G_MININT32, G_MAXINT32, 0,
679
GIMP_PARAM_READWRITE));
680
gimp_procedure_add_argument (procedure,
681
gimp_param_spec_int32 ("offy",
683
"y offset for translation",
684
G_MININT32, G_MAXINT32, 0,
685
GIMP_PARAM_READWRITE));
686
gimp_procedure_add_return_value (procedure,
687
gimp_param_spec_layer_id ("layer",
691
GIMP_PARAM_READWRITE));
692
gimp_pdb_register_procedure (pdb, procedure);
693
g_object_unref (procedure);
696
* gimp-selection-invert
698
procedure = gimp_procedure_new (selection_invert_invoker);
699
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-invert");
700
gimp_procedure_set_static_strings (procedure,
701
"gimp-selection-invert",
702
"Invert the selection mask.",
703
"This procedure inverts the selection mask. For every pixel in the selection channel, its new value is calculated as (255 - old-value).",
704
"Spencer Kimball & Peter Mattis",
705
"Spencer Kimball & Peter Mattis",
708
gimp_procedure_add_argument (procedure,
709
gimp_param_spec_image_id ("image",
713
GIMP_PARAM_READWRITE));
714
gimp_pdb_register_procedure (pdb, procedure);
715
g_object_unref (procedure);
718
* gimp-selection-sharpen
720
procedure = gimp_procedure_new (selection_sharpen_invoker);
721
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-sharpen");
722
gimp_procedure_set_static_strings (procedure,
723
"gimp-selection-sharpen",
724
"Sharpen the selection mask.",
725
"This procedure sharpens the selection mask. For every pixel in the selection channel, if the value is > 127, the new pixel is assigned a value of 255. This removes any \"anti-aliasing\" that might exist in the selection mask's boundary.",
726
"Spencer Kimball & Peter Mattis",
727
"Spencer Kimball & Peter Mattis",
730
gimp_procedure_add_argument (procedure,
731
gimp_param_spec_image_id ("image",
735
GIMP_PARAM_READWRITE));
736
gimp_pdb_register_procedure (pdb, procedure);
737
g_object_unref (procedure);
742
procedure = gimp_procedure_new (selection_all_invoker);
743
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-all");
744
gimp_procedure_set_static_strings (procedure,
745
"gimp-selection-all",
746
"Select all of the image.",
747
"This procedure sets the selection mask to completely encompass the image. Every pixel in the selection channel is set to 255.",
748
"Spencer Kimball & Peter Mattis",
749
"Spencer Kimball & Peter Mattis",
752
gimp_procedure_add_argument (procedure,
753
gimp_param_spec_image_id ("image",
757
GIMP_PARAM_READWRITE));
758
gimp_pdb_register_procedure (pdb, procedure);
759
g_object_unref (procedure);
762
* gimp-selection-none
764
procedure = gimp_procedure_new (selection_none_invoker);
765
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-none");
766
gimp_procedure_set_static_strings (procedure,
767
"gimp-selection-none",
768
"Deselect the entire image.",
769
"This procedure deselects the entire image. Every pixel in the selection channel is set to 0.",
770
"Spencer Kimball & Peter Mattis",
771
"Spencer Kimball & Peter Mattis",
774
gimp_procedure_add_argument (procedure,
775
gimp_param_spec_image_id ("image",
779
GIMP_PARAM_READWRITE));
780
gimp_pdb_register_procedure (pdb, procedure);
781
g_object_unref (procedure);
784
* gimp-selection-feather
786
procedure = gimp_procedure_new (selection_feather_invoker);
787
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-feather");
788
gimp_procedure_set_static_strings (procedure,
789
"gimp-selection-feather",
790
"Feather the image's selection",
791
"This procedure feathers the selection. Feathering is implemented using a gaussian blur.",
792
"Spencer Kimball & Peter Mattis",
793
"Spencer Kimball & Peter Mattis",
796
gimp_procedure_add_argument (procedure,
797
gimp_param_spec_image_id ("image",
801
GIMP_PARAM_READWRITE));
802
gimp_procedure_add_argument (procedure,
803
g_param_spec_double ("radius",
805
"Radius of feather (in pixels)",
807
GIMP_PARAM_READWRITE));
808
gimp_pdb_register_procedure (pdb, procedure);
809
g_object_unref (procedure);
812
* gimp-selection-border
814
procedure = gimp_procedure_new (selection_border_invoker);
815
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-border");
816
gimp_procedure_set_static_strings (procedure,
817
"gimp-selection-border",
818
"Border the image's selection",
819
"This procedure borders the selection. Bordering creates a new selection which is defined along the boundary of the previous selection at every point within the specified radius.",
820
"Spencer Kimball & Peter Mattis",
821
"Spencer Kimball & Peter Mattis",
824
gimp_procedure_add_argument (procedure,
825
gimp_param_spec_image_id ("image",
829
GIMP_PARAM_READWRITE));
830
gimp_procedure_add_argument (procedure,
831
gimp_param_spec_int32 ("radius",
833
"Radius of border (in pixels)",
835
GIMP_PARAM_READWRITE));
836
gimp_pdb_register_procedure (pdb, procedure);
837
g_object_unref (procedure);
840
* gimp-selection-grow
842
procedure = gimp_procedure_new (selection_grow_invoker);
843
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-grow");
844
gimp_procedure_set_static_strings (procedure,
845
"gimp-selection-grow",
846
"Grow the image's selection",
847
"This procedure grows the selection. Growing involves expanding the boundary in all directions by the specified pixel amount.",
848
"Spencer Kimball & Peter Mattis",
849
"Spencer Kimball & Peter Mattis",
852
gimp_procedure_add_argument (procedure,
853
gimp_param_spec_image_id ("image",
857
GIMP_PARAM_READWRITE));
858
gimp_procedure_add_argument (procedure,
859
gimp_param_spec_int32 ("steps",
861
"Steps of grow (in pixels)",
863
GIMP_PARAM_READWRITE));
864
gimp_pdb_register_procedure (pdb, procedure);
865
g_object_unref (procedure);
868
* gimp-selection-shrink
870
procedure = gimp_procedure_new (selection_shrink_invoker);
871
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-shrink");
872
gimp_procedure_set_static_strings (procedure,
873
"gimp-selection-shrink",
874
"Shrink the image's selection",
875
"This procedure shrinks the selection. Shrinking invovles trimming the existing selection boundary on all sides by the specified number of pixels.",
876
"Spencer Kimball & Peter Mattis",
877
"Spencer Kimball & Peter Mattis",
880
gimp_procedure_add_argument (procedure,
881
gimp_param_spec_image_id ("image",
885
GIMP_PARAM_READWRITE));
886
gimp_procedure_add_argument (procedure,
887
gimp_param_spec_int32 ("steps",
889
"Steps of shrink (in pixels)",
891
GIMP_PARAM_READWRITE));
892
gimp_pdb_register_procedure (pdb, procedure);
893
g_object_unref (procedure);
896
* gimp-selection-layer-alpha
898
procedure = gimp_procedure_new (selection_layer_alpha_invoker);
899
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-layer-alpha");
900
gimp_procedure_set_static_strings (procedure,
901
"gimp-selection-layer-alpha",
902
"Transfer the specified layer's alpha channel to the selection mask.",
903
"This procedure requires a layer with an alpha channel. The alpha channel information is used to create a selection mask such that for any pixel in the image defined in the specified layer, that layer pixel's alpha value is transferred to the selection mask. If the layer is undefined at a particular image pixel, the associated selection mask value is set to 0.",
904
"Spencer Kimball & Peter Mattis",
905
"Spencer Kimball & Peter Mattis",
908
gimp_procedure_add_argument (procedure,
909
gimp_param_spec_layer_id ("layer",
913
GIMP_PARAM_READWRITE));
914
gimp_pdb_register_procedure (pdb, procedure);
915
g_object_unref (procedure);
918
* gimp-selection-load
920
procedure = gimp_procedure_new (selection_load_invoker);
921
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-load");
922
gimp_procedure_set_static_strings (procedure,
923
"gimp-selection-load",
924
"Transfer the specified channel to the selection mask.",
925
"This procedure loads the specified channel into the selection mask.",
926
"Spencer Kimball & Peter Mattis",
927
"Spencer Kimball & Peter Mattis",
930
gimp_procedure_add_argument (procedure,
931
gimp_param_spec_channel_id ("channel",
935
GIMP_PARAM_READWRITE));
936
gimp_pdb_register_procedure (pdb, procedure);
937
g_object_unref (procedure);
940
* gimp-selection-save
942
procedure = gimp_procedure_new (selection_save_invoker);
943
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-save");
944
gimp_procedure_set_static_strings (procedure,
945
"gimp-selection-save",
946
"Copy the selection mask to a new channel.",
947
"This procedure copies the selection mask and stores the content in a new channel. The new channel is automatically inserted into the image's list of channels.",
948
"Spencer Kimball & Peter Mattis",
949
"Spencer Kimball & Peter Mattis",
952
gimp_procedure_add_argument (procedure,
953
gimp_param_spec_image_id ("image",
957
GIMP_PARAM_READWRITE));
958
gimp_procedure_add_return_value (procedure,
959
gimp_param_spec_channel_id ("channel",
963
GIMP_PARAM_READWRITE));
964
gimp_pdb_register_procedure (pdb, procedure);
965
g_object_unref (procedure);
968
* gimp-selection-combine
970
procedure = gimp_procedure_new (selection_combine_invoker);
971
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-combine");
972
gimp_procedure_set_static_strings (procedure,
973
"gimp-selection-combine",
974
"Combines the specified channel with the selection mask.",
975
"This procedure combines the specified channel into the selection mask.",
976
"Spencer Kimball & Peter Mattis",
977
"Spencer Kimball & Peter Mattis",
980
gimp_procedure_add_argument (procedure,
981
gimp_param_spec_channel_id ("channel",
985
GIMP_PARAM_READWRITE));
986
gimp_procedure_add_argument (procedure,
987
g_param_spec_enum ("operation",
989
"The selection operation",
990
GIMP_TYPE_CHANNEL_OPS,
992
GIMP_PARAM_READWRITE));
993
gimp_pdb_register_procedure (pdb, procedure);
994
g_object_unref (procedure);