selection_cmds.c 25.8 KB
Newer Older
Elliot Lee's avatar
Elliot Lee committed
1
/* The GIMP -- an image manipulation program
Manish Singh's avatar
Manish Singh committed
2
 * Copyright (C) 1995-2000 Spencer Kimball and Peter Mattis
Elliot Lee's avatar
Elliot Lee committed
3 4 5 6 7 8 9 10 11 12 13 14 15
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Elliot Lee's avatar
Elliot Lee committed
17 18
 */

Manish Singh's avatar
Manish Singh committed
19
/* NOTE: This file is autogenerated by pdbgen.pl. */
Elliot Lee's avatar
Elliot Lee committed
20

21 22 23
#include "config.h"


24
#include <glib-object.h>
25

26 27
#include "libgimpbase/gimpbasetypes.h"

28
#include "pdb-types.h"
Manish Singh's avatar
Manish Singh committed
29
#include "procedural_db.h"
Elliot Lee's avatar
Elliot Lee committed
30

31
#include "core/core-enums.h"
32
#include "core/gimpchannel.h"
Michael Natterer's avatar
Michael Natterer committed
33
#include "core/gimpdrawable.h"
34 35 36
#include "core/gimpimage-mask.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
Manish Singh's avatar
Manish Singh committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

static ProcRecord selection_bounds_proc;
static ProcRecord selection_value_proc;
static ProcRecord selection_is_empty_proc;
static ProcRecord selection_translate_proc;
static ProcRecord selection_float_proc;
static ProcRecord selection_clear_proc;
static ProcRecord selection_invert_proc;
static ProcRecord selection_sharpen_proc;
static ProcRecord selection_all_proc;
static ProcRecord selection_none_proc;
static ProcRecord selection_feather_proc;
static ProcRecord selection_border_proc;
static ProcRecord selection_grow_proc;
static ProcRecord selection_shrink_proc;
static ProcRecord selection_layer_alpha_proc;
static ProcRecord selection_load_proc;
static ProcRecord selection_save_proc;
55
static ProcRecord selection_combine_proc;
Manish Singh's avatar
Manish Singh committed
56 57

void
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
register_selection_procs (Gimp *gimp)
{
  procedural_db_register (gimp, &selection_bounds_proc);
  procedural_db_register (gimp, &selection_value_proc);
  procedural_db_register (gimp, &selection_is_empty_proc);
  procedural_db_register (gimp, &selection_translate_proc);
  procedural_db_register (gimp, &selection_float_proc);
  procedural_db_register (gimp, &selection_clear_proc);
  procedural_db_register (gimp, &selection_invert_proc);
  procedural_db_register (gimp, &selection_sharpen_proc);
  procedural_db_register (gimp, &selection_all_proc);
  procedural_db_register (gimp, &selection_none_proc);
  procedural_db_register (gimp, &selection_feather_proc);
  procedural_db_register (gimp, &selection_border_proc);
  procedural_db_register (gimp, &selection_grow_proc);
  procedural_db_register (gimp, &selection_shrink_proc);
  procedural_db_register (gimp, &selection_layer_alpha_proc);
  procedural_db_register (gimp, &selection_load_proc);
  procedural_db_register (gimp, &selection_save_proc);
  procedural_db_register (gimp, &selection_combine_proc);
Manish Singh's avatar
Manish Singh committed
78
}
Elliot Lee's avatar
Elliot Lee committed
79 80

static Argument *
81 82
selection_bounds_invoker (Gimp     *gimp,
                          Argument *args)
Elliot Lee's avatar
Elliot Lee committed
83
{
Manish Singh's avatar
Manish Singh committed
84 85 86
  gboolean success = TRUE;
  Argument *return_args;
  GimpImage *gimage;
Manish Singh's avatar
Manish Singh committed
87
  gboolean non_empty = FALSE;
Manish Singh's avatar
Manish Singh committed
88 89 90 91
  gint32 x1;
  gint32 y1;
  gint32 x2;
  gint32 y2;
Elliot Lee's avatar
Elliot Lee committed
92

93
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
94
  if (! GIMP_IS_IMAGE (gimage))
Manish Singh's avatar
Manish Singh committed
95
    success = FALSE;
Elliot Lee's avatar
Elliot Lee committed
96 97

  if (success)
98
    non_empty = gimp_image_mask_bounds (gimage, &x1, &y1, &x2, &y2);
Elliot Lee's avatar
Elliot Lee committed
99

Manish Singh's avatar
Manish Singh committed
100
  return_args = procedural_db_return_args (&selection_bounds_proc, success);
Elliot Lee's avatar
Elliot Lee committed
101 102 103 104 105 106 107 108 109 110 111 112 113

  if (success)
    {
      return_args[1].value.pdb_int = non_empty;
      return_args[2].value.pdb_int = x1;
      return_args[3].value.pdb_int = y1;
      return_args[4].value.pdb_int = x2;
      return_args[5].value.pdb_int = y2;
    }

  return return_args;
}

Manish Singh's avatar
Manish Singh committed
114
static ProcArg selection_bounds_inargs[] =
Elliot Lee's avatar
Elliot Lee committed
115
{
Manish Singh's avatar
Manish Singh committed
116
  {
117
    GIMP_PDB_IMAGE,
Elliot Lee's avatar
Elliot Lee committed
118
    "image",
Manish Singh's avatar
Manish Singh committed
119
    "The image"
Elliot Lee's avatar
Elliot Lee committed
120 121 122
  }
};

Manish Singh's avatar
Manish Singh committed
123
static ProcArg selection_bounds_outargs[] =
Elliot Lee's avatar
Elliot Lee committed
124
{
Manish Singh's avatar
Manish Singh committed
125
  {
126
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
127 128
    "non_empty",
    "True if there is a selection"
Elliot Lee's avatar
Elliot Lee committed
129
  },
Manish Singh's avatar
Manish Singh committed
130
  {
131
    GIMP_PDB_INT32,
Elliot Lee's avatar
Elliot Lee committed
132 133 134
    "x1",
    "x coordinate of upper left corner of selection bounds"
  },
Manish Singh's avatar
Manish Singh committed
135
  {
136
    GIMP_PDB_INT32,
Elliot Lee's avatar
Elliot Lee committed
137 138 139
    "y1",
    "y coordinate of upper left corner of selection bounds"
  },
Manish Singh's avatar
Manish Singh committed
140
  {
141
    GIMP_PDB_INT32,
Elliot Lee's avatar
Elliot Lee committed
142 143 144
    "x2",
    "x coordinate of lower right corner of selection bounds"
  },
Manish Singh's avatar
Manish Singh committed
145
  {
146
    GIMP_PDB_INT32,
Elliot Lee's avatar
Elliot Lee committed
147 148 149 150 151
    "y2",
    "y coordinate of lower right corner of selection bounds"
  }
};

Manish Singh's avatar
Manish Singh committed
152
static ProcRecord selection_bounds_proc =
Elliot Lee's avatar
Elliot Lee committed
153 154
{
  "gimp_selection_bounds",
Manish Singh's avatar
Manish Singh committed
155
  "Find the bounding box of the current selection.",
156
  "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).",
Elliot Lee's avatar
Elliot Lee committed
157 158 159
  "Spencer Kimball & Peter Mattis",
  "Spencer Kimball & Peter Mattis",
  "1995-1996",
160
  GIMP_INTERNAL,
Elliot Lee's avatar
Elliot Lee committed
161
  1,
Manish Singh's avatar
Manish Singh committed
162
  selection_bounds_inargs,
Elliot Lee's avatar
Elliot Lee committed
163
  5,
Manish Singh's avatar
Manish Singh committed
164 165
  selection_bounds_outargs,
  { { selection_bounds_invoker } }
Elliot Lee's avatar
Elliot Lee committed
166 167 168
};

static Argument *
169 170
selection_value_invoker (Gimp     *gimp,
                         Argument *args)
Elliot Lee's avatar
Elliot Lee committed
171
{
Manish Singh's avatar
Manish Singh committed
172 173 174 175 176
  gboolean success = TRUE;
  Argument *return_args;
  GimpImage *gimage;
  gint32 x;
  gint32 y;
Elliot Lee's avatar
Elliot Lee committed
177

178
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
179
  if (! GIMP_IS_IMAGE (gimage))
Manish Singh's avatar
Manish Singh committed
180
    success = FALSE;
Elliot Lee's avatar
Elliot Lee committed
181

Manish Singh's avatar
Manish Singh committed
182 183 184
  x = args[1].value.pdb_int;

  y = args[2].value.pdb_int;
Elliot Lee's avatar
Elliot Lee committed
185

Manish Singh's avatar
Manish Singh committed
186
  return_args = procedural_db_return_args (&selection_value_proc, success);
Elliot Lee's avatar
Elliot Lee committed
187 188

  if (success)
189
    return_args[1].value.pdb_int = gimp_image_mask_value (gimage, x, y);
Elliot Lee's avatar
Elliot Lee committed
190 191 192 193

  return return_args;
}

Manish Singh's avatar
Manish Singh committed
194
static ProcArg selection_value_inargs[] =
Elliot Lee's avatar
Elliot Lee committed
195
{
Manish Singh's avatar
Manish Singh committed
196
  {
197
    GIMP_PDB_IMAGE,
Elliot Lee's avatar
Elliot Lee committed
198
    "image",
Manish Singh's avatar
Manish Singh committed
199
    "The image"
Elliot Lee's avatar
Elliot Lee committed
200
  },
Manish Singh's avatar
Manish Singh committed
201
  {
202
    GIMP_PDB_INT32,
Elliot Lee's avatar
Elliot Lee committed
203 204 205
    "x",
    "x coordinate of value"
  },
Manish Singh's avatar
Manish Singh committed
206
  {
207
    GIMP_PDB_INT32,
Elliot Lee's avatar
Elliot Lee committed
208 209 210 211 212
    "y",
    "y coordinate of value"
  }
};

Manish Singh's avatar
Manish Singh committed
213
static ProcArg selection_value_outargs[] =
Elliot Lee's avatar
Elliot Lee committed
214
{
Manish Singh's avatar
Manish Singh committed
215
  {
216
    GIMP_PDB_INT32,
Elliot Lee's avatar
Elliot Lee committed
217
    "value",
Manish Singh's avatar
Manish Singh committed
218
    "Value of the selection: (0 <= value <= 255)"
Elliot Lee's avatar
Elliot Lee committed
219 220 221
  }
};

Manish Singh's avatar
Manish Singh committed
222
static ProcRecord selection_value_proc =
Elliot Lee's avatar
Elliot Lee committed
223 224
{
  "gimp_selection_value",
Manish Singh's avatar
Manish Singh committed
225 226
  "Find the value of the selection at the specified coordinates.",
  "This procedure returns the value of the selection at the specified coordinates. If the coordinates lie out of bounds, 0 is returned.",
Elliot Lee's avatar
Elliot Lee committed
227 228 229
  "Spencer Kimball & Peter Mattis",
  "Spencer Kimball & Peter Mattis",
  "1995-1996",
230
  GIMP_INTERNAL,
Elliot Lee's avatar
Elliot Lee committed
231
  3,
Manish Singh's avatar
Manish Singh committed
232
  selection_value_inargs,
Elliot Lee's avatar
Elliot Lee committed
233
  1,
Manish Singh's avatar
Manish Singh committed
234 235
  selection_value_outargs,
  { { selection_value_invoker } }
Elliot Lee's avatar
Elliot Lee committed
236 237 238
};

static Argument *
239 240
selection_is_empty_invoker (Gimp     *gimp,
                            Argument *args)
Elliot Lee's avatar
Elliot Lee committed
241
{
Manish Singh's avatar
Manish Singh committed
242 243 244
  gboolean success = TRUE;
  Argument *return_args;
  GimpImage *gimage;
Elliot Lee's avatar
Elliot Lee committed
245

246
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
247
  if (! GIMP_IS_IMAGE (gimage))
Manish Singh's avatar
Manish Singh committed
248
    success = FALSE;
Elliot Lee's avatar
Elliot Lee committed
249

Manish Singh's avatar
Manish Singh committed
250
  return_args = procedural_db_return_args (&selection_is_empty_proc, success);
Elliot Lee's avatar
Elliot Lee committed
251 252

  if (success)
253
    return_args[1].value.pdb_int = gimp_image_mask_is_empty (gimage);
Elliot Lee's avatar
Elliot Lee committed
254 255 256 257

  return return_args;
}

Manish Singh's avatar
Manish Singh committed
258
static ProcArg selection_is_empty_inargs[] =
Elliot Lee's avatar
Elliot Lee committed
259
{
Manish Singh's avatar
Manish Singh committed
260
  {
261
    GIMP_PDB_IMAGE,
Elliot Lee's avatar
Elliot Lee committed
262
    "image",
Manish Singh's avatar
Manish Singh committed
263
    "The image"
Elliot Lee's avatar
Elliot Lee committed
264 265 266
  }
};

Manish Singh's avatar
Manish Singh committed
267
static ProcArg selection_is_empty_outargs[] =
Elliot Lee's avatar
Elliot Lee committed
268
{
Manish Singh's avatar
Manish Singh committed
269
  {
270
    GIMP_PDB_INT32,
Elliot Lee's avatar
Elliot Lee committed
271
    "is_empty",
Manish Singh's avatar
Manish Singh committed
272
    "Is the selection empty?"
Elliot Lee's avatar
Elliot Lee committed
273 274 275
  }
};

Manish Singh's avatar
Manish Singh committed
276
static ProcRecord selection_is_empty_proc =
Elliot Lee's avatar
Elliot Lee committed
277 278
{
  "gimp_selection_is_empty",
279
  "Determine whether the selection is empty.",
Elliot Lee's avatar
Elliot Lee committed
280 281 282 283
  "This procedure returns non-zero if the selection for the specified image is not empty.",
  "Spencer Kimball & Peter Mattis",
  "Spencer Kimball & Peter Mattis",
  "1995-1996",
284
  GIMP_INTERNAL,
Elliot Lee's avatar
Elliot Lee committed
285
  1,
Manish Singh's avatar
Manish Singh committed
286
  selection_is_empty_inargs,
Elliot Lee's avatar
Elliot Lee committed
287
  1,
Manish Singh's avatar
Manish Singh committed
288 289
  selection_is_empty_outargs,
  { { selection_is_empty_invoker } }
Elliot Lee's avatar
Elliot Lee committed
290 291 292
};

static Argument *
293 294
selection_translate_invoker (Gimp     *gimp,
                             Argument *args)
Elliot Lee's avatar
Elliot Lee committed
295
{
Manish Singh's avatar
Manish Singh committed
296 297 298 299 300
  gboolean success = TRUE;
  GimpImage *gimage;
  gint32 offx;
  gint32 offy;

301
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
302
  if (! GIMP_IS_IMAGE (gimage))
Manish Singh's avatar
Manish Singh committed
303 304 305 306 307
    success = FALSE;

  offx = args[1].value.pdb_int;

  offy = args[2].value.pdb_int;
Elliot Lee's avatar
Elliot Lee committed
308 309

  if (success)
310
    gimp_image_mask_translate (gimage, offx, offy, TRUE);
Elliot Lee's avatar
Elliot Lee committed
311

Manish Singh's avatar
Manish Singh committed
312
  return procedural_db_return_args (&selection_translate_proc, success);
Elliot Lee's avatar
Elliot Lee committed
313 314
}

Manish Singh's avatar
Manish Singh committed
315
static ProcArg selection_translate_inargs[] =
Elliot Lee's avatar
Elliot Lee committed
316
{
Manish Singh's avatar
Manish Singh committed
317
  {
318
    GIMP_PDB_IMAGE,
Elliot Lee's avatar
Elliot Lee committed
319
    "image",
Manish Singh's avatar
Manish Singh committed
320
    "The image"
Elliot Lee's avatar
Elliot Lee committed
321
  },
Manish Singh's avatar
Manish Singh committed
322
  {
323
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
324
    "offx",
Elliot Lee's avatar
Elliot Lee committed
325 326
    "x offset for translation"
  },
Manish Singh's avatar
Manish Singh committed
327
  {
328
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
329
    "offy",
Elliot Lee's avatar
Elliot Lee committed
330 331 332 333
    "y offset for translation"
  }
};

Manish Singh's avatar
Manish Singh committed
334
static ProcRecord selection_translate_proc =
Elliot Lee's avatar
Elliot Lee committed
335 336
{
  "gimp_selection_translate",
Manish Singh's avatar
Manish Singh committed
337 338
  "Translate the selection by the specified offsets.",
  "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.",
Elliot Lee's avatar
Elliot Lee committed
339 340 341
  "Spencer Kimball & Peter Mattis",
  "Spencer Kimball & Peter Mattis",
  "1995-1996",
342
  GIMP_INTERNAL,
Elliot Lee's avatar
Elliot Lee committed
343
  3,
Manish Singh's avatar
Manish Singh committed
344
  selection_translate_inargs,
Elliot Lee's avatar
Elliot Lee committed
345 346
  0,
  NULL,
Manish Singh's avatar
Manish Singh committed
347
  { { selection_translate_invoker } }
Elliot Lee's avatar
Elliot Lee committed
348 349 350
};

static Argument *
351 352
selection_float_invoker (Gimp     *gimp,
                         Argument *args)
Elliot Lee's avatar
Elliot Lee committed
353
{
Manish Singh's avatar
Manish Singh committed
354 355
  gboolean success = TRUE;
  Argument *return_args;
356
  GimpDrawable *drawable;
Manish Singh's avatar
Manish Singh committed
357 358 359 360
  gint32 offx;
  gint32 offy;
  GimpLayer *layer = NULL;
  GimpImage *gimage;
Elliot Lee's avatar
Elliot Lee committed
361

362
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
363
  if (! GIMP_IS_DRAWABLE (drawable))
Manish Singh's avatar
Manish Singh committed
364 365 366 367 368
    success = FALSE;

  offx = args[1].value.pdb_int;

  offy = args[2].value.pdb_int;
Elliot Lee's avatar
Elliot Lee committed
369

370 371
  if (success)
    {
372
      gimage = gimp_item_get_image (GIMP_ITEM (drawable));
373
      layer = gimp_image_mask_float (gimage, drawable, offx, offy);
Manish Singh's avatar
Manish Singh committed
374
      success = layer != NULL;
Elliot Lee's avatar
Elliot Lee committed
375 376
    }

Manish Singh's avatar
Manish Singh committed
377
  return_args = procedural_db_return_args (&selection_float_proc, success);
Elliot Lee's avatar
Elliot Lee committed
378 379

  if (success)
380
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (layer));
Elliot Lee's avatar
Elliot Lee committed
381 382 383 384

  return return_args;
}

Manish Singh's avatar
Manish Singh committed
385
static ProcArg selection_float_inargs[] =
Elliot Lee's avatar
Elliot Lee committed
386
{
Manish Singh's avatar
Manish Singh committed
387
  {
388
    GIMP_PDB_DRAWABLE,
Elliot Lee's avatar
Elliot Lee committed
389
    "drawable",
Manish Singh's avatar
Manish Singh committed
390
    "The drawable from which to float selection"
Elliot Lee's avatar
Elliot Lee committed
391
  },
Manish Singh's avatar
Manish Singh committed
392
  {
393
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
394
    "offx",
Elliot Lee's avatar
Elliot Lee committed
395 396
    "x offset for translation"
  },
Manish Singh's avatar
Manish Singh committed
397
  {
398
    GIMP_PDB_INT32,
Manish Singh's avatar
Manish Singh committed
399
    "offy",
Elliot Lee's avatar
Elliot Lee committed
400 401 402 403
    "y offset for translation"
  }
};

Manish Singh's avatar
Manish Singh committed
404
static ProcArg selection_float_outargs[] =
Elliot Lee's avatar
Elliot Lee committed
405
{
Manish Singh's avatar
Manish Singh committed
406
  {
407
    GIMP_PDB_LAYER,
Elliot Lee's avatar
Elliot Lee committed
408
    "layer",
Manish Singh's avatar
Manish Singh committed
409
    "The floated layer"
Elliot Lee's avatar
Elliot Lee committed
410 411 412
  }
};

Manish Singh's avatar
Manish Singh committed
413
static ProcRecord selection_float_proc =
Elliot Lee's avatar
Elliot Lee committed
414 415
{
  "gimp_selection_float",
Manish Singh's avatar
Manish Singh committed
416 417
  "Float the selection from the specified drawable with initial offsets as specified.",
  "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.",
Elliot Lee's avatar
Elliot Lee committed
418 419 420
  "Spencer Kimball & Peter Mattis",
  "Spencer Kimball & Peter Mattis",
  "1995-1996",
421
  GIMP_INTERNAL,
422
  3,
Manish Singh's avatar
Manish Singh committed
423
  selection_float_inargs,
Elliot Lee's avatar
Elliot Lee committed
424
  1,
Manish Singh's avatar
Manish Singh committed
425 426
  selection_float_outargs,
  { { selection_float_invoker } }
Elliot Lee's avatar
Elliot Lee committed
427 428 429
};

static Argument *
430 431
selection_clear_invoker (Gimp     *gimp,
                         Argument *args)
Elliot Lee's avatar
Elliot Lee committed
432
{
Manish Singh's avatar
Manish Singh committed
433 434 435
  gboolean success = TRUE;
  GimpImage *gimage;

436
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
437
  if (! GIMP_IS_IMAGE (gimage))
Manish Singh's avatar
Manish Singh committed
438
    success = FALSE;
Elliot Lee's avatar
Elliot Lee committed
439 440

  if (success)
441
    gimp_image_mask_clear (gimage, NULL);
Elliot Lee's avatar
Elliot Lee committed
442

Manish Singh's avatar
Manish Singh committed
443
  return procedural_db_return_args (&selection_clear_proc, success);
Elliot Lee's avatar
Elliot Lee committed
444 445
}

Manish Singh's avatar
Manish Singh committed
446
static ProcArg selection_clear_inargs[] =
Elliot Lee's avatar
Elliot Lee committed
447
{
Manish Singh's avatar
Manish Singh committed
448
  {
449
    GIMP_PDB_IMAGE,
Elliot Lee's avatar
Elliot Lee committed
450
    "image",
Manish Singh's avatar
Manish Singh committed
451
    "The image"
Elliot Lee's avatar
Elliot Lee committed
452 453 454
  }
};

Manish Singh's avatar
Manish Singh committed
455
static ProcRecord selection_clear_proc =
Elliot Lee's avatar
Elliot Lee committed
456 457
{
  "gimp_selection_clear",
Manish Singh's avatar
Manish Singh committed
458
  "Set the selection to none, clearing all previous content.",
Elliot Lee's avatar
Elliot Lee committed
459 460 461 462
  "This procedure sets the selection mask to empty, assigning the value 0 to every pixel in the selection channel.",
  "Spencer Kimball & Peter Mattis",
  "Spencer Kimball & Peter Mattis",
  "1995-1996",
463
  GIMP_INTERNAL,
Elliot Lee's avatar
Elliot Lee committed
464
  1,
Manish Singh's avatar
Manish Singh committed
465
  selection_clear_inargs,
Elliot Lee's avatar
Elliot Lee committed
466 467
  0,
  NULL,
Manish Singh's avatar
Manish Singh committed
468
  { { selection_clear_invoker } }
Elliot Lee's avatar
Elliot Lee committed
469 470 471
};

static Argument *
472 473
selection_invert_invoker (Gimp     *gimp,
                          Argument *args)
Elliot Lee's avatar
Elliot Lee committed
474
{
Manish Singh's avatar
Manish Singh committed
475 476 477
  gboolean success = TRUE;
  GimpImage *gimage;

478
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
479
  if (! GIMP_IS_IMAGE (gimage))
Manish Singh's avatar
Manish Singh committed
480
    success = FALSE;
Elliot Lee's avatar
Elliot Lee committed
481 482

  if (success)
483
    gimp_image_mask_invert (gimage);
Elliot Lee's avatar
Elliot Lee committed
484

Manish Singh's avatar
Manish Singh committed
485
  return procedural_db_return_args (&selection_invert_proc, success);
Elliot Lee's avatar
Elliot Lee committed
486 487
}

Manish Singh's avatar
Manish Singh committed
488
static ProcArg selection_invert_inargs[] =
Elliot Lee's avatar
Elliot Lee committed
489
{
Manish Singh's avatar
Manish Singh committed
490
  {
491
    GIMP_PDB_IMAGE,
Elliot Lee's avatar
Elliot Lee committed
492
    "image",
Manish Singh's avatar
Manish Singh committed
493
    "The image"
Elliot Lee's avatar
Elliot Lee committed
494 495 496
  }
};

Manish Singh's avatar
Manish Singh committed
497
static ProcRecord selection_invert_proc =
Elliot Lee's avatar
Elliot Lee committed
498 499
{
  "gimp_selection_invert",
Manish Singh's avatar
Manish Singh committed
500 501
  "Invert the selection mask.",
  "This procedure inverts the selection mask. For every pixel in the selection channel, its new value is calculated as (255 - old_value).",
Elliot Lee's avatar
Elliot Lee committed
502 503 504
  "Spencer Kimball & Peter Mattis",
  "Spencer Kimball & Peter Mattis",
  "1995-1996",
505
  GIMP_INTERNAL,
Elliot Lee's avatar
Elliot Lee committed
506
  1,
Manish Singh's avatar
Manish Singh committed
507
  selection_invert_inargs,
Elliot Lee's avatar
Elliot Lee committed
508 509
  0,
  NULL,
Manish Singh's avatar
Manish Singh committed
510
  { { selection_invert_invoker } }
Elliot Lee's avatar
Elliot Lee committed
511 512 513
};

static Argument *
514 515
selection_sharpen_invoker (Gimp     *gimp,
                           Argument *args)
Elliot Lee's avatar
Elliot Lee committed
516
{
Manish Singh's avatar
Manish Singh committed
517 518 519
  gboolean success = TRUE;
  GimpImage *gimage;

520
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
521
  if (! GIMP_IS_IMAGE (gimage))
Manish Singh's avatar
Manish Singh committed
522
    success = FALSE;
Elliot Lee's avatar
Elliot Lee committed
523 524

  if (success)
525
    gimp_image_mask_sharpen (gimage);
Elliot Lee's avatar
Elliot Lee committed
526

Manish Singh's avatar
Manish Singh committed
527
  return procedural_db_return_args (&selection_sharpen_proc, success);
Elliot Lee's avatar
Elliot Lee committed
528 529
}

Manish Singh's avatar
Manish Singh committed
530
static ProcArg selection_sharpen_inargs[] =
Elliot Lee's avatar
Elliot Lee committed
531
{
Manish Singh's avatar
Manish Singh committed
532
  {
533
    GIMP_PDB_IMAGE,
Elliot Lee's avatar
Elliot Lee committed
534
    "image",
Manish Singh's avatar
Manish Singh committed
535
    "The image"
Elliot Lee's avatar
Elliot Lee committed
536 537 538
  }
};

Manish Singh's avatar
Manish Singh committed
539
static ProcRecord selection_sharpen_proc =
Elliot Lee's avatar
Elliot Lee committed
540 541
{
  "gimp_selection_sharpen",
Manish Singh's avatar
Manish Singh committed
542 543
  "Sharpen the selection mask.",
  "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.",
Elliot Lee's avatar
Elliot Lee committed
544 545 546
  "Spencer Kimball & Peter Mattis",
  "Spencer Kimball & Peter Mattis",
  "1995-1996",
547
  GIMP_INTERNAL,
Elliot Lee's avatar
Elliot Lee committed
548
  1,
Manish Singh's avatar
Manish Singh committed
549
  selection_sharpen_inargs,
Elliot Lee's avatar
Elliot Lee committed
550 551
  0,
  NULL,
Manish Singh's avatar
Manish Singh committed
552
  { { selection_sharpen_invoker } }
Elliot Lee's avatar
Elliot Lee committed
553 554 555
};

static Argument *
556 557
selection_all_invoker (Gimp     *gimp,
                       Argument *args)
Elliot Lee's avatar
Elliot Lee committed
558
{
Manish Singh's avatar
Manish Singh committed
559 560 561
  gboolean success = TRUE;
  GimpImage *gimage;

562
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
563
  if (! GIMP_IS_IMAGE (gimage))
Manish Singh's avatar
Manish Singh committed
564
    success = FALSE;
Elliot Lee's avatar
Elliot Lee committed
565 566

  if (success)
567
    gimp_image_mask_all (gimage);
Elliot Lee's avatar
Elliot Lee committed
568

Manish Singh's avatar
Manish Singh committed
569
  return procedural_db_return_args (&selection_all_proc, success);
Elliot Lee's avatar
Elliot Lee committed
570 571
}

Manish Singh's avatar
Manish Singh committed
572
static ProcArg selection_all_inargs[] =
Elliot Lee's avatar
Elliot Lee committed
573
{
Manish Singh's avatar
Manish Singh committed
574
  {
575
    GIMP_PDB_IMAGE,
Elliot Lee's avatar
Elliot Lee committed
576
    "image",
Manish Singh's avatar
Manish Singh committed
577
    "The image"
Elliot Lee's avatar
Elliot Lee committed
578 579 580
  }
};

Manish Singh's avatar
Manish Singh committed
581
static ProcRecord selection_all_proc =
Elliot Lee's avatar
Elliot Lee committed
582 583
{
  "gimp_selection_all",
Manish Singh's avatar
Manish Singh committed
584 585
  "Select all of the image.",
  "This procedure sets the selection mask to completely encompass the image. Every pixel in the selection channel is set to 255.",
Elliot Lee's avatar
Elliot Lee committed
586 587 588
  "Spencer Kimball & Peter Mattis",
  "Spencer Kimball & Peter Mattis",
  "1995-1996",
589
  GIMP_INTERNAL,
Elliot Lee's avatar
Elliot Lee committed
590
  1,
Manish Singh's avatar
Manish Singh committed
591
  selection_all_inargs,
Elliot Lee's avatar
Elliot Lee committed
592 593
  0,
  NULL,
Manish Singh's avatar
Manish Singh committed
594
  { { selection_all_invoker } }
Elliot Lee's avatar
Elliot Lee committed
595 596 597
};

static Argument *
598 599
selection_none_invoker (Gimp     *gimp,
                        Argument *args)
Elliot Lee's avatar
Elliot Lee committed
600
{
Manish Singh's avatar
Manish Singh committed
601 602 603
  gboolean success = TRUE;
  GimpImage *gimage;

604
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
605
  if (! GIMP_IS_IMAGE (gimage))
Manish Singh's avatar
Manish Singh committed
606
    success = FALSE;
Elliot Lee's avatar
Elliot Lee committed
607 608

  if (success)
609
    gimp_image_mask_clear (gimage, NULL);
Elliot Lee's avatar
Elliot Lee committed
610

Manish Singh's avatar
Manish Singh committed
611
  return procedural_db_return_args (&selection_none_proc, success);
Elliot Lee's avatar
Elliot Lee committed
612 613
}

Manish Singh's avatar
Manish Singh committed
614
static ProcArg selection_none_inargs[] =
Elliot Lee's avatar
Elliot Lee committed
615
{
Manish Singh's avatar
Manish Singh committed
616
  {
617
    GIMP_PDB_IMAGE,
Elliot Lee's avatar
Elliot Lee committed
618
    "image",
Manish Singh's avatar
Manish Singh committed
619
    "The image"
Elliot Lee's avatar
Elliot Lee committed
620 621 622
  }
};

Manish Singh's avatar
Manish Singh committed
623
static ProcRecord selection_none_proc =
Elliot Lee's avatar
Elliot Lee committed
624 625
{
  "gimp_selection_none",
Manish Singh's avatar
Manish Singh committed
626 627
  "Deselect the entire image.",
  "This procedure deselects the entire image. Every pixel in the selection channel is set to 0.",
Elliot Lee's avatar
Elliot Lee committed
628 629 630
  "Spencer Kimball & Peter Mattis",
  "Spencer Kimball & Peter Mattis",
  "1995-1996",
631
  GIMP_INTERNAL,
Elliot Lee's avatar
Elliot Lee committed
632
  1,
Manish Singh's avatar
Manish Singh committed
633
  selection_none_inargs,
Elliot Lee's avatar
Elliot Lee committed
634 635
  0,
  NULL,
Manish Singh's avatar
Manish Singh committed
636
  { { selection_none_invoker } }
Elliot Lee's avatar
Elliot Lee committed
637 638 639
};

static Argument *
640 641
selection_feather_invoker (Gimp     *gimp,
                           Argument *args)
Elliot Lee's avatar
Elliot Lee committed
642
{
Manish Singh's avatar
Manish Singh committed
643 644 645
  gboolean success = TRUE;
  GimpImage *gimage;
  gdouble radius;
Elliot Lee's avatar
Elliot Lee committed
646

647
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
648
  if (! GIMP_IS_IMAGE (gimage))
Manish Singh's avatar
Manish Singh committed
649 650 651
    success = FALSE;

  radius = args[1].value.pdb_float;
Marc Lehmann's avatar
Marc Lehmann committed
652
  if (radius < 0.0)
Manish Singh's avatar
Manish Singh committed
653
    success = FALSE;
Elliot Lee's avatar
Elliot Lee committed
654 655

  if (success)
656
    gimp_image_mask_feather (gimage, radius, radius);
Elliot Lee's avatar
Elliot Lee committed
657

Manish Singh's avatar
Manish Singh committed
658
  return procedural_db_return_args (&selection_feather_proc, success);
Elliot Lee's avatar
Elliot Lee committed
659 660
}

Manish Singh's avatar
Manish Singh committed
661
static ProcArg selection_feather_inargs[] =
Elliot Lee's avatar
Elliot Lee committed
662
{
Manish Singh's avatar
Manish Singh committed
663
  {
664
    GIMP_PDB_IMAGE,
Elliot Lee's avatar
Elliot Lee committed
665
    "image",
Manish Singh's avatar
Manish Singh committed
666
    "The image"
Elliot Lee's avatar
Elliot Lee committed
667
  },
Manish Singh's avatar
Manish Singh committed
668
  {
669
    GIMP_PDB_FLOAT,
Elliot Lee's avatar
Elliot Lee committed
670
    "radius",
Manish Singh's avatar
Manish Singh committed
671
    "Radius of feather (in pixels)"
Elliot Lee's avatar
Elliot Lee committed
672 673 674
  }
};

Manish Singh's avatar
Manish Singh committed
675
static ProcRecord selection_feather_proc =
Elliot Lee's avatar
Elliot Lee committed
676 677 678
{
  "gimp_selection_feather",
  "Feather the image's selection",
Manish Singh's avatar
Manish Singh committed
679
  "This procedure feathers the selection. Feathering is implemented using a gaussian blur.",
Elliot Lee's avatar
Elliot Lee committed
680 681 682
  "Spencer Kimball & Peter Mattis",
  "Spencer Kimball & Peter Mattis",
  "1995-1996",
683
  GIMP_INTERNAL,
Elliot Lee's avatar
Elliot Lee committed
684
  2,
Manish Singh's avatar
Manish Singh committed
685
  selection_feather_inargs,
Elliot Lee's avatar
Elliot Lee committed
686 687
  0,
  NULL,
Manish Singh's avatar
Manish Singh committed
688
  { { selection_feather_invoker } }
Elliot Lee's avatar
Elliot Lee committed
689 690 691
};

static Argument *
692 693
selection_border_invoker (Gimp     *gimp,
                          Argument *args)
Elliot Lee's avatar
Elliot Lee committed
694
{
Manish Singh's avatar
Manish Singh committed
695 696 697
  gboolean success = TRUE;
  GimpImage *gimage;
  gint32 radius;
Elliot Lee's avatar
Elliot Lee committed
698

699
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
700
  if (! GIMP_IS_IMAGE (gimage))
Manish Singh's avatar
Manish Singh committed
701 702 703
    success = FALSE;

  radius = args[1].value.pdb_int;
Marc Lehmann's avatar
Marc Lehmann committed
704
  if (radius < 0)
Manish Singh's avatar
Manish Singh committed
705
    success = FALSE;
Elliot Lee's avatar
Elliot Lee committed
706 707

  if (success)
708
    gimp_image_mask_border (gimage, radius, radius);
Elliot Lee's avatar
Elliot Lee committed
709

Manish Singh's avatar
Manish Singh committed
710
  return procedural_db_return_args (&selection_border_proc, success);
Elliot Lee's avatar
Elliot Lee committed
711 712
}

Manish Singh's avatar
Manish Singh committed
713
static ProcArg selection_border_inargs[] =
Elliot Lee's avatar
Elliot Lee committed
714
{
Manish Singh's avatar
Manish Singh committed
715
  {
716
    GIMP_PDB_IMAGE,
Elliot Lee's avatar
Elliot Lee committed
717
    "image",
Manish Singh's avatar
Manish Singh committed
718
    "The image"
Elliot Lee's avatar
Elliot Lee committed
719
  },
Manish Singh's avatar
Manish Singh committed
720
  {
721
    GIMP_PDB_INT32,
Elliot Lee's avatar
Elliot Lee committed
722
    "radius",
Manish Singh's avatar
Manish Singh committed
723
    "Radius of border (in pixels)"
Elliot Lee's avatar
Elliot Lee committed
724 725 726
  }
};

Manish Singh's avatar
Manish Singh committed
727
static ProcRecord selection_border_proc =
Elliot Lee's avatar
Elliot Lee committed
728 729 730
{
  "gimp_selection_border",
  "Border the image's selection",
Manish Singh's avatar
Manish Singh committed
731
  "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.",
Elliot Lee's avatar
Elliot Lee committed
732 733 734
  "Spencer Kimball & Peter Mattis",
  "Spencer Kimball & Peter Mattis",
  "1995-1996",
735
  GIMP_INTERNAL,
Elliot Lee's avatar
Elliot Lee committed
736
  2,
Manish Singh's avatar
Manish Singh committed
737
  selection_border_inargs,
Elliot Lee's avatar
Elliot Lee committed
738 739
  0,
  NULL,
Manish Singh's avatar
Manish Singh committed
740
  { { selection_border_invoker } }
Elliot Lee's avatar
Elliot Lee committed
741 742 743
};

static Argument *
744 745
selection_grow_invoker (Gimp     *gimp,
                        Argument *args)
Elliot Lee's avatar
Elliot Lee committed
746
{
Manish Singh's avatar
Manish Singh committed
747 748 749 750
  gboolean success = TRUE;
  GimpImage *gimage;
  gint32 steps;

751
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);