gimplayer_pdb.c 30.7 KB
Newer Older
1
/* LIBGIMP - The GIMP Library
2
 * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
3 4
 *
 * gimplayer_pdb.c
Manish Singh's avatar
Manish Singh committed
5 6
 *
 * This library is free software; you can redistribute it and/or
Marc Lehmann's avatar
Marc Lehmann committed
7
 * modify it under the terms of the GNU Lesser General Public
Manish Singh's avatar
Manish Singh committed
8
 * License as published by the Free Software Foundation; either
9 10 11 12 13
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
14
 * Lesser General Public License for more details.
Manish Singh's avatar
Manish Singh committed
15
 *
Marc Lehmann's avatar
Marc Lehmann committed
16
 * You should have received a copy of the GNU Lesser General Public
17 18 19
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
20 21
 */

22
/* NOTE: This file is auto-generated by pdbgen.pl */
Elliot Lee's avatar
Elliot Lee committed
23

Sven Neumann's avatar
Sven Neumann committed
24 25
#include "config.h"

26
#include "gimp.h"
Elliot Lee's avatar
Elliot Lee committed
27

28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
/**
 * _gimp_layer_new:
 * @image_ID: The image to which to add the layer.
 * @width: The layer width.
 * @height: The layer height.
 * @type: The layer type.
 * @name: The layer name.
 * @opacity: The layer opacity.
 * @mode: The layer combination mode.
 *
 * Create a new layer.
 *
 * This procedure creates a new layer with the specified width, height,
 * and type. Name, opacity, and mode are also supplied parameters. The
 * new layer still needs to be added to the image, as this is not
43
 * automatic. Add the new layer with the gimp_image_add_layer()
44 45 46 47 48
 * command. Other attributes such as layer mask modes, and offsets
 * should be set with explicit procedure calls.
 *
 * Returns: The newly created layer.
 */
Elliot Lee's avatar
Elliot Lee committed
49
gint32
50
_gimp_layer_new (gint32                image_ID,
51 52 53 54 55 56
                 gint                  width,
                 gint                  height,
                 GimpImageType         type,
                 const gchar          *name,
                 gdouble               opacity,
                 GimpLayerModeEffects  mode)
Elliot Lee's avatar
Elliot Lee committed
57
{
58
  GimpParam *return_vals;
59
  gint nreturn_vals;
60
  gint32 layer_ID = -1;
Elliot Lee's avatar
Elliot Lee committed
61

62
  return_vals = gimp_run_procedure ("gimp-layer-new",
63 64 65 66 67 68 69 70 71
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_INT32, width,
                                    GIMP_PDB_INT32, height,
                                    GIMP_PDB_INT32, type,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_FLOAT, opacity,
                                    GIMP_PDB_INT32, mode,
                                    GIMP_PDB_END);
72 73

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
Elliot Lee's avatar
Elliot Lee committed
74 75 76 77 78 79 80
    layer_ID = return_vals[1].data.d_layer;

  gimp_destroy_params (return_vals, nreturn_vals);

  return layer_ID;
}

81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
/**
 * gimp_layer_new_from_visible:
 * @image_ID: The source image from where the content is copied.
 * @dest_image_ID: The destination image to which to add the layer.
 * @name: The layer name.
 *
 * Create a new layer from what is visible in an image.
 *
 * This procedure creates a new layer from what is visible in the given
 * image. The new layer still needs to be added to the destination
 * image, as this is not automatic. Add the new layer with the
 * gimp_image_add_layer() command. Other attributes such as layer mask
 * modes, and offsets should be set with explicit procedure calls.
 *
 * Returns: The newly created layer.
 *
 * Since: GIMP 2.6
 */
gint32
gimp_layer_new_from_visible (gint32       image_ID,
                             gint32       dest_image_ID,
                             const gchar *name)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gint32 layer_ID = -1;

  return_vals = gimp_run_procedure ("gimp-layer-new-from-visible",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_IMAGE, dest_image_ID,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_END);

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    layer_ID = return_vals[1].data.d_layer;

  gimp_destroy_params (return_vals, nreturn_vals);

  return layer_ID;
}

123 124 125 126 127 128 129 130 131 132
/**
 * gimp_layer_new_from_drawable:
 * @drawable_ID: The source drawable from where the new layer is copied.
 * @dest_image_ID: The destination image to which to add the layer.
 *
 * Create a new layer by copying an existing drawable.
 *
 * This procedure creates a new layer as a copy of the specified
 * drawable. The new layer still needs to be added to the image, as
 * this is not automatic. Add the new layer with the
133
 * gimp_image_add_layer() command. Other attributes such as layer mask
134 135 136 137 138 139
 * modes, and offsets should be set with explicit procedure calls.
 *
 * Returns: The newly copied layer.
 */
gint32
gimp_layer_new_from_drawable (gint32 drawable_ID,
140
                              gint32 dest_image_ID)
141 142 143 144 145
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gint32 layer_copy_ID = -1;

146
  return_vals = gimp_run_procedure ("gimp-layer-new-from-drawable",
147 148 149 150
                                    &nreturn_vals,
                                    GIMP_PDB_DRAWABLE, drawable_ID,
                                    GIMP_PDB_IMAGE, dest_image_ID,
                                    GIMP_PDB_END);
151 152 153 154 155 156 157 158 159

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    layer_copy_ID = return_vals[1].data.d_layer;

  gimp_destroy_params (return_vals, nreturn_vals);

  return layer_copy_ID;
}

160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
/**
 * _gimp_layer_copy:
 * @layer_ID: The layer to copy.
 * @add_alpha: Add an alpha channel to the copied layer.
 *
 * Copy a layer.
 *
 * This procedure copies the specified layer and returns the copy. The
 * newly copied layer is for use within the original layer's image. It
 * should not be subsequently added to any other image. The copied
 * layer can optionally have an added alpha channel. This is useful if
 * the background layer in an image is being copied and added to the
 * same image.
 *
 * Returns: The newly copied layer.
 */
Elliot Lee's avatar
Elliot Lee committed
176
gint32
177
_gimp_layer_copy (gint32   layer_ID,
178
                  gboolean add_alpha)
Elliot Lee's avatar
Elliot Lee committed
179
{
180
  GimpParam *return_vals;
181
  gint nreturn_vals;
182
  gint32 layer_copy_ID = -1;
Elliot Lee's avatar
Elliot Lee committed
183

184
  return_vals = gimp_run_procedure ("gimp-layer-copy",
185 186 187 188
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_INT32, add_alpha,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
189

190
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
191
    layer_copy_ID = return_vals[1].data.d_layer;
Elliot Lee's avatar
Elliot Lee committed
192 193 194

  gimp_destroy_params (return_vals, nreturn_vals);

195
  return layer_copy_ID;
Elliot Lee's avatar
Elliot Lee committed
196 197
}

198
/**
199 200
 * gimp_layer_add_alpha:
 * @layer_ID: The layer.
201
 *
202
 * Add an alpha channel to the layer if it doesn't already have one.
203
 *
204 205
 * This procedure adds an additional component to the specified layer
 * if it does not already possess an alpha channel. An alpha channel
206 207 208
 * makes it possible to clear and erase to transparency, instead of the
 * background color. This transforms layers of type RGB to RGBA, GRAY
 * to GRAYA, and INDEXED to INDEXEDA.
209
 *
210
 * Returns: TRUE on success.
211
 */
212 213
gboolean
gimp_layer_add_alpha (gint32 layer_ID)
Elliot Lee's avatar
Elliot Lee committed
214
{
215
  GimpParam *return_vals;
216
  gint nreturn_vals;
217
  gboolean success = TRUE;
Elliot Lee's avatar
Elliot Lee committed
218

219
  return_vals = gimp_run_procedure ("gimp-layer-add-alpha",
220 221 222
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
223

224
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
225

Elliot Lee's avatar
Elliot Lee committed
226
  gimp_destroy_params (return_vals, nreturn_vals);
227

228
  return success;
Elliot Lee's avatar
Elliot Lee committed
229 230
}

231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
/**
 * gimp_layer_flatten:
 * @layer_ID: The layer.
 *
 * Remove the alpha channel from the layer if it has one.
 *
 * This procedure removes the alpha channel from a layer, blending all
 * (partially) transparent pixels in the layer against the background
 * color. This transforms layers of type RGBA to RGB, GRAYA to GRAY,
 * and INDEXEDA to INDEXED.
 *
 * Returns: TRUE on success.
 *
 * Since: GIMP 2.4
 */
gboolean
gimp_layer_flatten (gint32 layer_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

  return_vals = gimp_run_procedure ("gimp-layer-flatten",
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_END);

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

265 266 267 268 269 270 271 272 273
/**
 * gimp_layer_scale:
 * @layer_ID: The layer.
 * @new_width: New layer width.
 * @new_height: New layer height.
 * @local_origin: Use a local origin (as opposed to the image origin).
 *
 * Scale the layer to the specified extents.
 *
274
 * This procedure scales the layer so that its new width and height are
275
 * equal to the supplied parameters. The 'local-origin' parameter
276 277 278 279 280 281
 * specifies whether to scale from the center of the layer, or from the
 * image origin. This operation only works if the layer has been added
 * to an image.
 *
 * Returns: TRUE on success.
 */
282
gboolean
283
gimp_layer_scale (gint32   layer_ID,
284 285 286
                  gint     new_width,
                  gint     new_height,
                  gboolean local_origin)
Elliot Lee's avatar
Elliot Lee committed
287
{
288
  GimpParam *return_vals;
289
  gint nreturn_vals;
290
  gboolean success = TRUE;
Elliot Lee's avatar
Elliot Lee committed
291

292
  return_vals = gimp_run_procedure ("gimp-layer-scale",
293 294 295 296 297 298
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_INT32, new_width,
                                    GIMP_PDB_INT32, new_height,
                                    GIMP_PDB_INT32, local_origin,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
299

300 301
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

Elliot Lee's avatar
Elliot Lee committed
302
  gimp_destroy_params (return_vals, nreturn_vals);
303 304

  return success;
Elliot Lee's avatar
Elliot Lee committed
305 306
}

307 308 309 310 311
/**
 * gimp_layer_resize:
 * @layer_ID: The layer.
 * @new_width: New layer width.
 * @new_height: New layer height.
312 313
 * @offx: x offset between upper left corner of old and new layers: (old - new).
 * @offy: y offset between upper left corner of old and new layers: (old - new).
314 315 316
 *
 * Resize the layer to the specified extents.
 *
317
 * This procedure resizes the layer so that its new width and height
318 319 320 321 322 323
 * are equal to the supplied parameters. Offsets are also provided
 * which describe the position of the previous layer's content. This
 * operation only works if the layer has been added to an image.
 *
 * Returns: TRUE on success.
 */
324
gboolean
325
gimp_layer_resize (gint32 layer_ID,
326 327 328 329
                   gint   new_width,
                   gint   new_height,
                   gint   offx,
                   gint   offy)
Elliot Lee's avatar
Elliot Lee committed
330
{
331
  GimpParam *return_vals;
332
  gint nreturn_vals;
333
  gboolean success = TRUE;
Elliot Lee's avatar
Elliot Lee committed
334

335
  return_vals = gimp_run_procedure ("gimp-layer-resize",
336 337 338 339 340 341 342
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_INT32, new_width,
                                    GIMP_PDB_INT32, new_height,
                                    GIMP_PDB_INT32, offx,
                                    GIMP_PDB_INT32, offy,
                                    GIMP_PDB_END);
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_layer_resize_to_image_size:
 * @layer_ID: The layer to resize.
 *
 * Resize a layer to the image size.
 *
 * This procedure resizes the layer so that it's new width and height
 * are equal to the width and height of its image container.
 *
 * Returns: TRUE on success.
 */
gboolean
gimp_layer_resize_to_image_size (gint32 layer_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

369
  return_vals = gimp_run_procedure ("gimp-layer-resize-to-image-size",
370 371 372
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
373

374 375
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

Elliot Lee's avatar
Elliot Lee committed
376
  gimp_destroy_params (return_vals, nreturn_vals);
377 378

  return success;
Elliot Lee's avatar
Elliot Lee committed
379 380
}

381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
/**
 * gimp_layer_translate:
 * @layer_ID: The layer.
 * @offx: Offset in x direction.
 * @offy: Offset in y direction.
 *
 * Translate the layer by the specified offsets.
 *
 * This procedure translates the layer by the amounts specified in the
 * x and y arguments. These can be negative, and are considered offsets
 * from the current position. This command only works if the layer has
 * been added to an image. All additional layers contained in the image
 * which have the linked flag set to TRUE w ill also be translated by
 * the specified offsets.
 *
 * Returns: TRUE on success.
 */
398
gboolean
399
gimp_layer_translate (gint32 layer_ID,
400 401
                      gint   offx,
                      gint   offy)
Elliot Lee's avatar
Elliot Lee committed
402
{
403
  GimpParam *return_vals;
404
  gint nreturn_vals;
405
  gboolean success = TRUE;
Elliot Lee's avatar
Elliot Lee committed
406

407
  return_vals = gimp_run_procedure ("gimp-layer-translate",
408 409 410 411 412
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_INT32, offx,
                                    GIMP_PDB_INT32, offy,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
413

414 415
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

Elliot Lee's avatar
Elliot Lee committed
416
  gimp_destroy_params (return_vals, nreturn_vals);
417 418

  return success;
Elliot Lee's avatar
Elliot Lee committed
419 420
}

421
/**
422
 * gimp_layer_set_offsets:
423
 * @layer_ID: The layer.
424 425
 * @offx: Offset in x direction.
 * @offy: Offset in y direction.
426
 *
427
 * Set the layer offsets.
428
 *
429 430 431
 * This procedure sets the offsets for the specified layer. The offsets
 * are relative to the image origin and can be any values. This
 * operation is valid only on layers which have been added to an image.
432 433 434
 *
 * Returns: TRUE on success.
 */
435
gboolean
436
gimp_layer_set_offsets (gint32 layer_ID,
437 438
                        gint   offx,
                        gint   offy)
Elliot Lee's avatar
Elliot Lee committed
439
{
440
  GimpParam *return_vals;
441
  gint nreturn_vals;
442
  gboolean success = TRUE;
Elliot Lee's avatar
Elliot Lee committed
443

444
  return_vals = gimp_run_procedure ("gimp-layer-set-offsets",
445 446 447 448 449
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_INT32, offx,
                                    GIMP_PDB_INT32, offy,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
450

451 452
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

Elliot Lee's avatar
Elliot Lee committed
453
  gimp_destroy_params (return_vals, nreturn_vals);
454 455

  return success;
Elliot Lee's avatar
Elliot Lee committed
456 457
}

458
/**
459 460 461
 * gimp_layer_create_mask:
 * @layer_ID: The layer to which to add the mask.
 * @mask_type: The type of mask.
462
 *
463
 * Create a layer mask for the specified specified layer.
464
 *
465 466
 * This procedure creates a layer mask for the specified layer. Layer
 * masks serve as an additional alpha channel for a layer. A number of
467
 * different types of masks are allowed for initialisation: completely
468 469 470 471 472 473
 * white masks (which will leave the layer fully visible), completely
 * black masks (which will give the layer complete transparency, the
 * layer's already existing alpha channel (which will leave the layer
 * fully visible, but which may be more useful than a white mask), the
 * current selection or a grayscale copy of the layer. The layer mask
 * still needs to be added to the layer. This can be done with a call
474
 * to gimp_layer_add_mask().
475
 *
476
 * Returns: The newly created mask.
477
 */
478 479
gint32
gimp_layer_create_mask (gint32          layer_ID,
480
                        GimpAddMaskType mask_type)
Elliot Lee's avatar
Elliot Lee committed
481
{
482
  GimpParam *return_vals;
483
  gint nreturn_vals;
484
  gint32 mask_ID = -1;
Elliot Lee's avatar
Elliot Lee committed
485

486
  return_vals = gimp_run_procedure ("gimp-layer-create-mask",
487 488 489 490
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_INT32, mask_type,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
491

492 493
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    mask_ID = return_vals[1].data.d_layer_mask;
494

Elliot Lee's avatar
Elliot Lee committed
495
  gimp_destroy_params (return_vals, nreturn_vals);
496

497
  return mask_ID;
Elliot Lee's avatar
Elliot Lee committed
498 499
}

500
/**
501
 * gimp_layer_get_mask:
502 503 504 505 506 507 508 509 510
 * @layer_ID: The layer.
 *
 * Get the specified layer's mask if it exists.
 *
 * This procedure returns the specified layer's mask, or -1 if none
 * exists.
 *
 * Returns: The layer mask.
 */
Elliot Lee's avatar
Elliot Lee committed
511
gint32
512
gimp_layer_get_mask (gint32 layer_ID)
Elliot Lee's avatar
Elliot Lee committed
513
{
514
  GimpParam *return_vals;
515
  gint nreturn_vals;
516
  gint32 mask_ID = -1;
Elliot Lee's avatar
Elliot Lee committed
517

518
  return_vals = gimp_run_procedure ("gimp-layer-get-mask",
519 520 521
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
522

523
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
524
    mask_ID = return_vals[1].data.d_layer_mask;
Elliot Lee's avatar
Elliot Lee committed
525 526 527 528 529 530

  gimp_destroy_params (return_vals, nreturn_vals);

  return mask_ID;
}

531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
/**
 * gimp_layer_from_mask:
 * @mask_ID: Mask for which to return the layer.
 *
 * Get the specified mask's layer.
 *
 * This procedure returns the specified mask's layer , or -1 if none
 * exists.
 *
 * Returns: The mask's layer.
 *
 * Since: GIMP 2.2
 */
gint32
gimp_layer_from_mask (gint32 mask_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gint32 layer_ID = -1;

551
  return_vals = gimp_run_procedure ("gimp-layer-from-mask",
552 553 554
                                    &nreturn_vals,
                                    GIMP_PDB_CHANNEL, mask_ID,
                                    GIMP_PDB_END);
555 556 557 558 559 560 561 562 563

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    layer_ID = return_vals[1].data.d_layer;

  gimp_destroy_params (return_vals, nreturn_vals);

  return layer_ID;
}

564 565
/**
 * gimp_layer_add_mask:
566 567
 * @layer_ID: The layer to receive the mask.
 * @mask_ID: The mask to add to the layer.
568 569 570 571 572 573 574
 *
 * Add a layer mask to the specified layer.
 *
 * This procedure adds a layer mask to the specified layer. Layer masks
 * serve as an additional alpha channel for a layer. This procedure
 * will fail if a number of prerequisites aren't met. The layer cannot
 * already have a layer mask. The specified mask must exist and have
575 576 577
 * the same dimensions as the layer. The layer must have been created
 * for use with the specified image and the mask must have been created
 * with the procedure 'gimp-layer-create-mask'.
578 579 580 581 582
 *
 * Returns: TRUE on success.
 */
gboolean
gimp_layer_add_mask (gint32 layer_ID,
583
                     gint32 mask_ID)
584 585 586 587 588
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

589
  return_vals = gimp_run_procedure ("gimp-layer-add-mask",
590 591 592 593
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_CHANNEL, mask_ID,
                                    GIMP_PDB_END);
594 595 596 597 598 599 600 601 602 603

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_layer_remove_mask:
604 605
 * @layer_ID: The layer from which to remove mask.
 * @mode: Removal mode.
606 607 608 609 610 611 612 613 614 615
 *
 * Remove the specified layer mask from the layer.
 *
 * This procedure removes the specified layer mask from the layer. If
 * the mask doesn't exist, an error is returned.
 *
 * Returns: TRUE on success.
 */
gboolean
gimp_layer_remove_mask (gint32            layer_ID,
616
                        GimpMaskApplyMode mode)
617 618 619 620 621
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

622
  return_vals = gimp_run_procedure ("gimp-layer-remove-mask",
623 624 625 626
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_INT32, mode,
                                    GIMP_PDB_END);
627 628 629 630 631 632 633 634

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

635 636 637 638 639 640 641 642 643 644
/**
 * gimp_layer_is_floating_sel:
 * @layer_ID: The layer.
 *
 * Is the specified layer a floating selection?
 *
 * This procedure returns whether the layer is a floating selection.
 * Floating selections are special cases of layers which are attached
 * to a specific drawable.
 *
645
 * Returns: TRUE if the layer is a floating selection.
646
 */
647
gboolean
648
gimp_layer_is_floating_sel (gint32 layer_ID)
Elliot Lee's avatar
Elliot Lee committed
649
{
650
  GimpParam *return_vals;
651
  gint nreturn_vals;
652
  gboolean is_floating_sel = FALSE;
Elliot Lee's avatar
Elliot Lee committed
653

654
  return_vals = gimp_run_procedure ("gimp-layer-is-floating-sel",
655 656 657
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
658

659
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
660
    is_floating_sel = return_vals[1].data.d_int32;
Elliot Lee's avatar
Elliot Lee committed
661 662 663

  gimp_destroy_params (return_vals, nreturn_vals);

664
  return is_floating_sel;
Elliot Lee's avatar
Elliot Lee committed
665 666
}

667
/**
668
 * gimp_layer_get_lock_alpha:
669 670
 * @layer_ID: The layer.
 *
671
 * Get the lock alpha channel setting of the specified layer.
672
 *
673
 * This procedure returns the specified layer's lock alpha channel
674 675
 * setting.
 *
676
 * Returns: The layer's lock alpha channel setting.
677
 */
678
gboolean
679
gimp_layer_get_lock_alpha (gint32 layer_ID)
Elliot Lee's avatar
Elliot Lee committed
680
{
681
  GimpParam *return_vals;
682
  gint nreturn_vals;
683
  gboolean lock_alpha = FALSE;
Elliot Lee's avatar
Elliot Lee committed
684

685
  return_vals = gimp_run_procedure ("gimp-layer-get-lock-alpha",
686 687 688
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
689

690
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
691
    lock_alpha = return_vals[1].data.d_int32;
Elliot Lee's avatar
Elliot Lee committed
692 693 694

  gimp_destroy_params (return_vals, nreturn_vals);

695
  return lock_alpha;
Elliot Lee's avatar
Elliot Lee committed
696 697
}

698
/**
699
 * gimp_layer_set_lock_alpha:
700
 * @layer_ID: The layer.
701
 * @lock_alpha: The new layer's lock alpha channel setting.
702
 *
703
 * Set the lock alpha channel setting of the specified layer.
704
 *
705
 * This procedure sets the specified layer's lock alpha channel
706 707 708 709
 * setting.
 *
 * Returns: TRUE on success.
 */
710
gboolean
711
gimp_layer_set_lock_alpha (gint32   layer_ID,
712
                           gboolean lock_alpha)
Elliot Lee's avatar
Elliot Lee committed
713
{
714
  GimpParam *return_vals;
715
  gint nreturn_vals;
716
  gboolean success = TRUE;
Elliot Lee's avatar
Elliot Lee committed
717

718
  return_vals = gimp_run_procedure ("gimp-layer-set-lock-alpha",
719 720 721 722
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_INT32, lock_alpha,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
723

724 725
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

Elliot Lee's avatar
Elliot Lee committed
726
  gimp_destroy_params (return_vals, nreturn_vals);
727 728

  return success;
Elliot Lee's avatar
Elliot Lee committed
729 730
}

731 732 733 734
/**
 * gimp_layer_get_apply_mask:
 * @layer_ID: The layer.
 *
735
 * Get the apply mask setting of the specified layer.
736
 *
737
 * This procedure returns the specified layer's apply mask setting. If
738 739
 * the value is TRUE, then the layer mask for this layer is currently
 * being composited with the layer's alpha channel.
740
 *
741
 * Returns: The layer's apply mask setting.
742 743 744 745 746 747 748 749
 */
gboolean
gimp_layer_get_apply_mask (gint32 layer_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean apply_mask = FALSE;

750
  return_vals = gimp_run_procedure ("gimp-layer-get-apply-mask",
751 752 753
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_END);
754 755 756 757 758 759 760 761 762 763 764 765

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    apply_mask = return_vals[1].data.d_int32;

  gimp_destroy_params (return_vals, nreturn_vals);

  return apply_mask;
}

/**
 * gimp_layer_set_apply_mask:
 * @layer_ID: The layer.
766
 * @apply_mask: The new layer's apply mask setting.
767
 *
768
 * Set the apply mask setting of the specified layer.
769
 *
770 771 772 773
 * This procedure sets the specified layer's apply mask setting. This
 * controls whether the layer's mask is currently affecting the alpha
 * channel. If there is no layer mask, this function will return an
 * error.
774 775 776 777 778
 *
 * Returns: TRUE on success.
 */
gboolean
gimp_layer_set_apply_mask (gint32   layer_ID,
779
                           gboolean apply_mask)
780 781 782 783 784
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

785
  return_vals = gimp_run_procedure ("gimp-layer-set-apply-mask",
786 787 788 789
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_INT32, apply_mask,
                                    GIMP_PDB_END);
790 791 792 793 794 795 796 797 798 799 800 801

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_layer_get_show_mask:
 * @layer_ID: The layer.
 *
802
 * Get the show mask setting of the specified layer.
803
 *
804
 * This procedure returns the specified layer's show mask setting. This
805 806 807
 * controls whether the layer or its mask is visible. TRUE indicates
 * that the mask should be visible. If the layer has no mask, then this
 * function returns an error.
808
 *
809
 * Returns: The layer's show mask setting.
810 811 812 813 814 815 816 817
 */
gboolean
gimp_layer_get_show_mask (gint32 layer_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean show_mask = FALSE;

818
  return_vals = gimp_run_procedure ("gimp-layer-get-show-mask",
819 820 821
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_END);
822 823 824 825 826 827 828 829 830 831 832 833

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    show_mask = return_vals[1].data.d_int32;

  gimp_destroy_params (return_vals, nreturn_vals);

  return show_mask;
}

/**
 * gimp_layer_set_show_mask:
 * @layer_ID: The layer.
834
 * @show_mask: The new layer's show mask setting.
835
 *
836
 * Set the show mask setting of the specified layer.
837
 *
838
 * This procedure sets the specified layer's show mask setting. This
839 840 841
 * controls whether the layer or its mask is visible. TRUE indicates
 * that the mask should be visible. If there is no layer mask, this
 * function will return an error.
842 843 844 845 846
 *
 * Returns: TRUE on success.
 */
gboolean
gimp_layer_set_show_mask (gint32   layer_ID,
847
                          gboolean show_mask)
848 849 850 851 852
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

853
  return_vals = gimp_run_procedure ("gimp-layer-set-show-mask",
854 855 856 857
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_INT32, show_mask,
                                    GIMP_PDB_END);
858 859 860 861 862 863 864 865 866 867 868 869

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_layer_get_edit_mask:
 * @layer_ID: The layer.
 *
870
 * Get the edit mask setting of the specified layer.
871
 *
872
 * This procedure returns the specified layer's edit mask setting. If
873 874
 * the value is TRUE, then the layer mask for this layer is currently
 * active, and not the layer.
875
 *
876
 * Returns: The layer's edit mask setting.
877 878 879 880 881 882 883 884
 */
gboolean
gimp_layer_get_edit_mask (gint32 layer_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean edit_mask = FALSE;

885
  return_vals = gimp_run_procedure ("gimp-layer-get-edit-mask",
886 887 888
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_END);
889 890 891 892 893 894 895 896 897 898 899 900

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    edit_mask = return_vals[1].data.d_int32;

  gimp_destroy_params (return_vals, nreturn_vals);

  return edit_mask;
}

/**
 * gimp_layer_set_edit_mask:
 * @layer_ID: The layer.
901
 * @edit_mask: The new layer's edit mask setting.
902
 *
903
 * Set the edit mask setting of the specified layer.
904
 *
905 906 907 908
 * This procedure sets the specified layer's edit mask setting. This
 * controls whether the layer or it's mask is currently active for
 * editing. If the specified layer has no layer mask, then this
 * procedure will return an error.
909 910 911 912 913
 *
 * Returns: TRUE on success.
 */
gboolean
gimp_layer_set_edit_mask (gint32   layer_ID,
914
                          gboolean edit_mask)
915 916 917 918 919
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

920
  return_vals = gimp_run_procedure ("gimp-layer-set-edit-mask",
921 922 923 924
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_INT32, edit_mask,
                                    GIMP_PDB_END);
925 926 927 928 929 930 931 932

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

933 934 935 936 937 938 939 940 941 942
/**
 * gimp_layer_get_opacity:
 * @layer_ID: The layer.
 *
 * Get the opacity of the specified layer.
 *
 * This procedure returns the specified layer's opacity.
 *
 * Returns: The layer opacity.
 */
943 944 945
gdouble
gimp_layer_get_opacity (gint32 layer_ID)
{
946
  GimpParam *return_vals;
947
  gint nreturn_vals;
948
  gdouble opacity = 0.0;
949

950
  return_vals = gimp_run_procedure ("gimp-layer-get-opacity",
951 952 953
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
954

955
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
956 957
    opacity = return_vals[1].data.d_float;

Elliot Lee's avatar
Elliot Lee committed
958
  gimp_destroy_params (return_vals, nreturn_vals);
959 960

  return opacity;
Elliot Lee's avatar
Elliot Lee committed
961 962
}

963 964 965 966 967 968 969 970 971 972 973
/**
 * gimp_layer_set_opacity:
 * @layer_ID: The layer.
 * @opacity: The new layer opacity.
 *
 * Set the opacity of the specified layer.
 *
 * This procedure sets the specified layer's opacity.
 *
 * Returns: TRUE on success.
 */
974
gboolean
Elliot Lee's avatar
Elliot Lee committed
975
gimp_layer_set_opacity (gint32  layer_ID,
976
                        gdouble opacity)
Elliot Lee's avatar
Elliot Lee committed
977
{
978
  GimpParam *return_vals;
979
  gint nreturn_vals;
980
  gboolean success = TRUE;
Elliot Lee's avatar
Elliot Lee committed
981

982
  return_vals = gimp_run_procedure ("gimp-layer-set-opacity",
983 984 985 986
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_FLOAT, opacity,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
987

988 989
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

Elliot Lee's avatar
Elliot Lee committed
990
  gimp_destroy_params (return_vals, nreturn_vals);
991 992

  return success;
Elliot Lee's avatar
Elliot Lee committed
993 994
}

995 996 997 998 999 1000 1001 1002 1003 1004
/**
 * gimp_layer_get_mode:
 * @layer_ID: The layer.
 *
 * Get the combination mode of the specified layer.
 *
 * This procedure returns the specified layer's combination mode.
 *
 * Returns: The layer combination mode.
 */
1005 1006
GimpLayerModeEffects
gimp_layer_get_mode (gint32 layer_ID)
Elliot Lee's avatar
Elliot Lee committed
1007
{
1008
  GimpParam *return_vals;
1009
  gint nreturn_vals;
1010
  GimpLayerModeEffects mode = 0;
Elliot Lee's avatar
Elliot Lee committed
1011

1012
  return_vals = gimp_run_procedure ("gimp-layer-get-mode",
1013 1014 1015
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
1016

1017
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
1018 1019
    mode = return_vals[1].data.d_int32;

Elliot Lee's avatar
Elliot Lee committed
1020
  gimp_destroy_params (return_vals, nreturn_vals);
1021 1022

  return mode;
Elliot Lee's avatar
Elliot Lee committed
1023 1024
}

1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035
/**
 * gimp_layer_set_mode:
 * @layer_ID: The layer.
 * @mode: The new layer combination mode.
 *
 * Set the combination mode of the specified layer.
 *
 * This procedure sets the specified layer's combination mode.
 *
 * Returns: TRUE on success.
 */
1036
gboolean
1037
gimp_layer_set_mode (gint32               layer_ID,
1038
                     GimpLayerModeEffects mode)
Elliot Lee's avatar
Elliot Lee committed
1039
{
1040
  GimpParam *return_vals;
1041
  gint nreturn_vals;
1042
  gboolean success = TRUE;
Elliot Lee's avatar
Elliot Lee committed
1043

1044
  return_vals = gimp_run_procedure ("gimp-layer-set-mode",
1045 1046 1047 1048
                                    &nreturn_vals,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_INT32, mode,
                                    GIMP_PDB_END);
1049

1050 1051
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

1052
  gimp_destroy_params (return_vals, nreturn_vals);
1053 1054

  return success;
1055
}