gimpimage_pdb.c 87 KB
Newer Older
1
/* LIBGIMP - The GIMP Library
2
 * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
Manish Singh's avatar
Manish Singh committed
3
 *
4 5
 * gimpimage_pdb.c
 *
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
 * version 3 of the License, or (at your option) any later version.
10 11 12 13
 *
 * 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
 * License along with this library.  If not, see
18
 * <https://www.gnu.org/licenses/>.
19 20
 */

21
/* NOTE: This file is auto-generated by pdbgen.pl */
22

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

25 26
#include <string.h>

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

29 30 31 32 33 34 35 36 37 38 39

/**
 * SECTION: gimpimage
 * @title: gimpimage
 * @short_description: Operations on complete images.
 *
 * Operations on complete images: creation, resizing/rescaling, and
 * operations involving multiple layers.
 **/


40 41 42 43 44 45 46 47 48 49 50
/**
 * gimp_image_is_valid:
 * @image_ID: The image to check.
 *
 * Returns TRUE if the image is valid.
 *
 * This procedure checks if the given image ID is valid and refers to
 * an existing image.
 *
 * Returns: Whether the image ID is valid.
 *
51
 * Since: 2.4
52
 **/
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
gboolean
gimp_image_is_valid (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean valid = FALSE;

  return_vals = gimp_run_procedure ("gimp-image-is-valid",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return valid;
}

73 74 75 76 77 78
/**
 * gimp_image_list:
 * @num_images: The number of images currently open.
 *
 * Returns the list of images currently open.
 *
79
 * This procedure returns the list of images currently open in GIMP.
80
 *
81 82
 * Returns: The list of images currently open. The returned value must
 * be freed with g_free().
83
 **/
84 85 86
gint *
gimp_image_list (gint *num_images)
{
87
  GimpParam *return_vals;
88 89 90
  gint nreturn_vals;
  gint *image_ids = NULL;

91
  return_vals = gimp_run_procedure ("gimp-image-list",
92 93
                                    &nreturn_vals,
                                    GIMP_PDB_END);
94 95 96

  *num_images = 0;

97
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
98 99 100
    {
      *num_images = return_vals[1].data.d_int32;
      image_ids = g_new (gint32, *num_images);
101 102 103
      memcpy (image_ids,
              return_vals[2].data.d_int32array,
              *num_images * sizeof (gint32));
104 105 106 107 108 109
    }

  gimp_destroy_params (return_vals, nreturn_vals);

  return image_ids;
}
Elliot Lee's avatar
Elliot Lee committed
110

111 112 113 114 115 116 117 118
/**
 * gimp_image_new:
 * @width: The width of the image.
 * @height: The height of the image.
 * @type: The type of image.
 *
 * Creates a new image with the specified width, height, and type.
 *
119
 * Creates a new image, undisplayed, with the specified extents and
120
 * type. A layer should be created and added before this image is
121
 * displayed, or subsequent calls to gimp_display_new() with this image
122
 * as an argument will fail. Layers can be created using the
123
 * gimp_layer_new() commands. They can be added to an image using the
124
 * gimp_image_insert_layer() command.
125
 *
126 127 128
 * If your image's type if INDEXED, a colormap must also be added with
 * gimp_image_set_colormap(). An indexed image without a colormap will
 * output unexpected colors.
129 130
 *
 * Returns: The ID of the newly created image.
131
 **/
Elliot Lee's avatar
Elliot Lee committed
132
gint32
133
gimp_image_new (gint              width,
134 135
                gint              height,
                GimpImageBaseType type)
Elliot Lee's avatar
Elliot Lee committed
136
{
137
  GimpParam *return_vals;
138
  gint nreturn_vals;
139
  gint32 image_ID = -1;
Elliot Lee's avatar
Elliot Lee committed
140

141
  return_vals = gimp_run_procedure ("gimp-image-new",
142 143 144 145 146
                                    &nreturn_vals,
                                    GIMP_PDB_INT32, width,
                                    GIMP_PDB_INT32, height,
                                    GIMP_PDB_INT32, type,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
147

148
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
Elliot Lee's avatar
Elliot Lee committed
149 150 151 152 153 154 155
    image_ID = return_vals[1].data.d_image;

  gimp_destroy_params (return_vals, nreturn_vals);

  return image_ID;
}

156 157 158 159 160 161 162 163 164 165 166 167
/**
 * gimp_image_new_with_precision:
 * @width: The width of the image.
 * @height: The height of the image.
 * @type: The type of image.
 * @precision: The precision.
 *
 * Creates a new image with the specified width, height, type and
 * precision.
 *
 * Creates a new image, undisplayed with the specified extents, type
 * and precision. Indexed images can only be created at
168 169
 * GIMP_PRECISION_U8_NON_LINEAR precision. See gimp_image_new() for
 * further details.
170 171 172
 *
 * Returns: The ID of the newly created image.
 *
173
 * Since: 2.10
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
 **/
gint32
gimp_image_new_with_precision (gint              width,
                               gint              height,
                               GimpImageBaseType type,
                               GimpPrecision     precision)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gint32 image_ID = -1;

  return_vals = gimp_run_procedure ("gimp-image-new-with-precision",
                                    &nreturn_vals,
                                    GIMP_PDB_INT32, width,
                                    GIMP_PDB_INT32, height,
                                    GIMP_PDB_INT32, type,
                                    GIMP_PDB_INT32, precision,
                                    GIMP_PDB_END);

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    image_ID = return_vals[1].data.d_image;

  gimp_destroy_params (return_vals, nreturn_vals);

  return image_ID;
}

201 202 203 204 205 206 207 208 209 210
/**
 * gimp_image_duplicate:
 * @image_ID: The image.
 *
 * Duplicate the specified image
 *
 * This procedure duplicates the specified image, copying all layers,
 * channels, and image information.
 *
 * Returns: The new, duplicated image.
211
 **/
212 213 214 215 216 217 218
gint32
gimp_image_duplicate (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gint32 new_image_ID = -1;

219
  return_vals = gimp_run_procedure ("gimp-image-duplicate",
220 221 222
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);
223 224 225 226 227 228 229 230 231

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    new_image_ID = return_vals[1].data.d_image;

  gimp_destroy_params (return_vals, nreturn_vals);

  return new_image_ID;
}

232 233 234 235 236 237 238 239 240 241 242 243 244 245
/**
 * gimp_image_delete:
 * @image_ID: The image.
 *
 * Delete the specified image.
 *
 * If there are no displays associated with this image it will be
 * deleted. This means that you can not delete an image through the PDB
 * that was created by the user. If the associated display was however
 * created through the PDB and you know the display ID, you may delete
 * the display. Removal of the last associated display will then delete
 * the image.
 *
 * Returns: TRUE on success.
246
 **/
247 248 249 250 251 252 253
gboolean
gimp_image_delete (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

254
  return_vals = gimp_run_procedure ("gimp-image-delete",
255 256 257
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_image_base_type:
 * @image_ID: The image.
 *
 * Get the base type of the image.
 *
 * This procedure returns the image's base type. Layers in the image
 * must be of this subtype, but can have an optional alpha channel.
 *
 * Returns: The image's base type.
276
 **/
277 278 279 280 281 282 283
GimpImageBaseType
gimp_image_base_type (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  GimpImageBaseType base_type = 0;

284
  return_vals = gimp_run_procedure ("gimp-image-base-type",
285 286 287
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);
288 289 290 291 292 293 294 295 296

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return base_type;
}

297 298 299 300 301 302 303 304 305 306
/**
 * gimp_image_get_precision:
 * @image_ID: The image.
 *
 * Get the precision of the image.
 *
 * This procedure returns the image's precision.
 *
 * Returns: The image's precision.
 *
307
 * Since: 2.10
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
 **/
GimpPrecision
gimp_image_get_precision (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  GimpPrecision precision = 0;

  return_vals = gimp_run_procedure ("gimp-image-get-precision",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return precision;
}

329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
/**
 * gimp_image_get_default_new_layer_mode:
 * @image_ID: The image.
 *
 * Get the default mode for newly created layers of this image.
 *
 * Returns the default mode for newly created layers of this image.
 *
 * Returns: The layer mode.
 *
 * Since: 2.10
 **/
GimpLayerMode
gimp_image_get_default_new_layer_mode (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  GimpLayerMode mode = 0;

  return_vals = gimp_run_procedure ("gimp-image-get-default-new-layer-mode",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return mode;
}

361 362 363 364 365 366 367 368 369 370
/**
 * gimp_image_width:
 * @image_ID: The image.
 *
 * Return the width of the image
 *
 * This procedure returns the image's width. This value is independent
 * of any of the layers in this image. This is the \"canvas\" width.
 *
 * Returns: The image's width.
371
 **/
372 373 374 375 376 377 378
gint
gimp_image_width (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gint width = 0;

379
  return_vals = gimp_run_procedure ("gimp-image-width",
380 381 382
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return width;
}

/**
 * gimp_image_height:
 * @image_ID: The image.
 *
 * Return the height of the image
 *
 * This procedure returns the image's height. This value is independent
 * of any of the layers in this image. This is the \"canvas\" height.
 *
 * Returns: The image's height.
402
 **/
403 404 405 406 407 408 409
gint
gimp_image_height (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gint height = 0;

410
  return_vals = gimp_run_procedure ("gimp-image-height",
411 412 413
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);
414 415 416 417 418 419 420 421 422

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return height;
}

423 424 425 426 427 428 429 430 431 432
/**
 * gimp_image_get_layers:
 * @image_ID: The image.
 * @num_layers: The number of layers contained in the image.
 *
 * Returns the list of layers contained in the specified image.
 *
 * This procedure returns the list of layers contained in the specified
 * image. The order of layers is from topmost to bottommost.
 *
433 434
 * Returns: The list of layers contained in the image. The returned
 * value must be freed with g_free().
435
 **/
436 437
gint *
gimp_image_get_layers (gint32  image_ID,
438
                       gint   *num_layers)
Elliot Lee's avatar
Elliot Lee committed
439
{
440
  GimpParam *return_vals;
441
  gint nreturn_vals;
442
  gint *layer_ids = NULL;
Elliot Lee's avatar
Elliot Lee committed
443

444
  return_vals = gimp_run_procedure ("gimp-image-get-layers",
445 446 447
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
448

449 450
  *num_layers = 0;

451
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
452 453 454
    {
      *num_layers = return_vals[1].data.d_int32;
      layer_ids = g_new (gint32, *num_layers);
455 456 457
      memcpy (layer_ids,
              return_vals[2].data.d_int32array,
              *num_layers * sizeof (gint32));
458
    }
Elliot Lee's avatar
Elliot Lee committed
459 460 461

  gimp_destroy_params (return_vals, nreturn_vals);

462
  return layer_ids;
Elliot Lee's avatar
Elliot Lee committed
463 464
}

465 466 467 468 469 470 471 472 473
/**
 * gimp_image_get_channels:
 * @image_ID: The image.
 * @num_channels: The number of channels contained in the image.
 *
 * Returns the list of channels contained in the specified image.
 *
 * This procedure returns the list of channels contained in the
 * specified image. This does not include the selection mask, or layer
474 475 476
 * masks. The order is from topmost to bottommost. Note that
 * \"channels\" are custom channels and do not include the image's
 * color components.
477
 *
478 479
 * Returns: The list of channels contained in the image. The returned
 * value must be freed with g_free().
480
 **/
481 482
gint *
gimp_image_get_channels (gint32  image_ID,
483
                         gint   *num_channels)
Elliot Lee's avatar
Elliot Lee committed
484
{
485
  GimpParam *return_vals;
486
  gint nreturn_vals;
487
  gint *channel_ids = NULL;
Elliot Lee's avatar
Elliot Lee committed
488

489
  return_vals = gimp_run_procedure ("gimp-image-get-channels",
490 491 492
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
493

494 495
  *num_channels = 0;

496
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
497 498 499
    {
      *num_channels = return_vals[1].data.d_int32;
      channel_ids = g_new (gint32, *num_channels);
500 501 502
      memcpy (channel_ids,
              return_vals[2].data.d_int32array,
              *num_channels * sizeof (gint32));
503
    }
Elliot Lee's avatar
Elliot Lee committed
504 505 506

  gimp_destroy_params (return_vals, nreturn_vals);

507 508 509
  return channel_ids;
}

510 511 512 513 514 515 516 517 518 519
/**
 * gimp_image_get_vectors:
 * @image_ID: The image.
 * @num_vectors: The number of vectors contained in the image.
 *
 * Returns the list of vectors contained in the specified image.
 *
 * This procedure returns the list of vectors contained in the
 * specified image.
 *
520 521
 * Returns: The list of vectors contained in the image. The returned
 * value must be freed with g_free().
522
 *
523
 * Since: 2.4
524
 **/
525 526
gint *
gimp_image_get_vectors (gint32  image_ID,
527
                        gint   *num_vectors)
528 529 530 531 532
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gint *vector_ids = NULL;

533
  return_vals = gimp_run_procedure ("gimp-image-get-vectors",
534 535 536
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);
537 538 539 540 541 542 543

  *num_vectors = 0;

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    {
      *num_vectors = return_vals[1].data.d_int32;
      vector_ids = g_new (gint32, *num_vectors);
544 545 546
      memcpy (vector_ids,
              return_vals[2].data.d_int32array,
              *num_vectors * sizeof (gint32));
547 548 549 550 551 552 553
    }

  gimp_destroy_params (return_vals, nreturn_vals);

  return vector_ids;
}

554
/**
555
 * gimp_image_get_active_drawable:
556 557 558 559 560 561 562 563 564 565 566 567
 * @image_ID: The image.
 *
 * Get the image's active drawable
 *
 * This procedure returns the ID of the image's active drawable. This
 * can be either a layer, a channel, or a layer mask. The active
 * drawable is specified by the active image channel. If that is -1,
 * then by the active image layer. If the active image layer has a
 * layer mask and the layer mask is in edit mode, then the layer mask
 * is the active drawable.
 *
 * Returns: The active drawable.
568
 **/
569
gint32
570
gimp_image_get_active_drawable (gint32 image_ID)
571 572 573 574 575
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gint32 drawable_ID = -1;

576
  return_vals = gimp_run_procedure ("gimp-image-get-active-drawable",
577 578 579
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);
580 581 582 583 584 585 586 587 588

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    drawable_ID = return_vals[1].data.d_drawable;

  gimp_destroy_params (return_vals, nreturn_vals);

  return drawable_ID;
}

589 590 591 592 593 594 595 596 597 598 599 600
/**
 * gimp_image_unset_active_channel:
 * @image_ID: The image.
 *
 * Unsets the active channel in the specified image.
 *
 * If an active channel exists, it is unset. There then exists no
 * active channel, and if desired, one can be set through a call to
 * 'Set Active Channel'. No error is returned in the case of no
 * existing active channel.
 *
 * Returns: TRUE on success.
601
 **/
602
gboolean
603 604
gimp_image_unset_active_channel (gint32 image_ID)
{
605
  GimpParam *return_vals;
606
  gint nreturn_vals;
607
  gboolean success = TRUE;
608

609
  return_vals = gimp_run_procedure ("gimp-image-unset-active-channel",
610 611 612
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);
613

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

616
  gimp_destroy_params (return_vals, nreturn_vals);
617 618

  return success;
Elliot Lee's avatar
Elliot Lee committed
619 620
}

621 622 623 624 625 626 627 628 629 630
/**
 * gimp_image_get_floating_sel:
 * @image_ID: The image.
 *
 * Return the floating selection of the image.
 *
 * This procedure returns the image's floating selection, if it exists.
 * If it doesn't exist, -1 is returned as the layer ID.
 *
 * Returns: The image's floating selection.
631
 **/
632 633 634 635 636 637 638
gint32
gimp_image_get_floating_sel (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gint32 floating_sel_ID = -1;

639
  return_vals = gimp_run_procedure ("gimp-image-get-floating-sel",
640 641 642
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return floating_sel_ID;
}

/**
 * gimp_image_floating_sel_attached_to:
 * @image_ID: The image.
 *
 * Return the drawable the floating selection is attached to.
 *
 * This procedure returns the drawable the image's floating selection
 * is attached to, if it exists. If it doesn't exist, -1 is returned as
 * the drawable ID.
 *
 * Returns: The drawable the floating selection is attached to.
663
 **/
664 665 666 667 668 669 670
gint32
gimp_image_floating_sel_attached_to (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gint32 drawable_ID = -1;

671
  return_vals = gimp_run_procedure ("gimp-image-floating-sel-attached-to",
672 673 674
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);
675 676 677 678 679 680 681 682 683

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    drawable_ID = return_vals[1].data.d_drawable;

  gimp_destroy_params (return_vals, nreturn_vals);

  return drawable_ID;
}

684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703
/**
 * gimp_image_pick_color:
 * @image_ID: The image.
 * @drawable_ID: The drawable to pick from.
 * @x: x coordinate of upper-left corner of rectangle.
 * @y: y coordinate of upper-left corner of rectangle.
 * @sample_merged: Use the composite image, not the drawable.
 * @sample_average: Average the color of all the pixels in a specified radius.
 * @average_radius: The radius of pixels to average.
 * @color: The return color.
 *
 * Determine the color at the given drawable coordinates
 *
 * This tool determines the color at the specified coordinates. The
 * returned color is an RGB triplet even for grayscale and indexed
 * drawables. If the coordinates lie outside of the extents of the
 * specified drawable, then an error is returned. If the drawable has
 * an alpha channel, the algorithm examines the alpha value of the
 * drawable at the coordinates. If the alpha value is completely
 * transparent (0), then an error is returned. If the sample_merged
704
 * parameter is TRUE, the data of the composite image will be used
705 706
 * instead of that for the specified drawable. This is equivalent to
 * sampling for colors after merging all visible layers. In the case of
707
 * a merged sampling, the supplied drawable is ignored.
708 709
 *
 * Returns: TRUE on success.
710
 **/
711 712
gboolean
gimp_image_pick_color (gint32    image_ID,
713 714 715 716 717 718 719
                       gint32    drawable_ID,
                       gdouble   x,
                       gdouble   y,
                       gboolean  sample_merged,
                       gboolean  sample_average,
                       gdouble   average_radius,
                       GimpRGB  *color)
720 721 722 723 724
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

725
  return_vals = gimp_run_procedure ("gimp-image-pick-color",
726 727 728 729 730 731 732 733 734
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_DRAWABLE, drawable_ID,
                                    GIMP_PDB_FLOAT, x,
                                    GIMP_PDB_FLOAT, y,
                                    GIMP_PDB_INT32, sample_merged,
                                    GIMP_PDB_INT32, sample_average,
                                    GIMP_PDB_FLOAT, average_radius,
                                    GIMP_PDB_END);
735 736 737 738 739 740 741 742 743 744 745

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

  if (success)
    *color = return_vals[1].data.d_color;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

746 747 748 749 750 751 752 753 754 755 756 757 758 759 760
/**
 * gimp_image_pick_correlate_layer:
 * @image_ID: The image.
 * @x: The x coordinate for the pick.
 * @y: The y coordinate for the pick.
 *
 * Find the layer visible at the specified coordinates.
 *
 * This procedure finds the layer which is visible at the specified
 * coordinates. Layers which do not qualify are those whose extents do
 * not pass within the specified coordinates, or which are transparent
 * at the specified coordinates. This procedure will return -1 if no
 * layer is found.
 *
 * Returns: The layer found at the specified coordinates.
761
 **/
Elliot Lee's avatar
Elliot Lee committed
762
gint32
763
gimp_image_pick_correlate_layer (gint32 image_ID,
764 765
                                 gint   x,
                                 gint   y)
Elliot Lee's avatar
Elliot Lee committed
766
{
767
  GimpParam *return_vals;
768
  gint nreturn_vals;
769
  gint32 layer_ID = -1;
Elliot Lee's avatar
Elliot Lee committed
770

771
  return_vals = gimp_run_procedure ("gimp-image-pick-correlate-layer",
772 773 774 775 776
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_INT32, x,
                                    GIMP_PDB_INT32, y,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
777

778
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
Elliot Lee's avatar
Elliot Lee committed
779 780 781 782 783 784 785
    layer_ID = return_vals[1].data.d_layer;

  gimp_destroy_params (return_vals, nreturn_vals);

  return layer_ID;
}

786 787 788 789 790 791 792 793 794 795
/**
 * gimp_image_insert_layer:
 * @image_ID: The image.
 * @layer_ID: The layer.
 * @parent_ID: The parent layer.
 * @position: The layer position.
 *
 * Add the specified layer to the image.
 *
 * This procedure adds the specified layer to the image at the given
796 797
 * position. If the specified parent is a valid layer group (See
 * gimp_item_is_group() and gimp_layer_group_new()) then the layer is
798
 * added inside the group. If the parent is 0, the layer is added
799 800 801 802
 * inside the main stack, outside of any group. The position argument
 * specifies the location of the layer inside the stack (or the group,
 * if a valid parent was supplied), starting from the top (0) and
 * increasing. If the position is specified as -1 and the parent is
803 804 805
 * specified as 0, then the layer is inserted above the active layer,
 * or inside the group if the active layer is a layer group. The layer
 * type must be compatible with the image base type.
806 807
 *
 * Returns: TRUE on success.
808
 **/
809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833
gboolean
gimp_image_insert_layer (gint32 image_ID,
                         gint32 layer_ID,
                         gint32 parent_ID,
                         gint   position)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

  return_vals = gimp_run_procedure ("gimp-image-insert-layer",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_LAYER, parent_ID,
                                    GIMP_PDB_INT32, position,
                                    GIMP_PDB_END);

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

834
/**
835
 * gimp_image_remove_layer:
836
 * @image_ID: The image.
837
 * @layer_ID: The layer.
838
 *
839
 * Remove the specified layer from the image.
840
 *
841 842 843 844 845
 * This procedure removes the specified layer from the image. If the
 * layer doesn't exist, an error is returned. If there are no layers
 * left in the image, this call will fail. If this layer is the last
 * layer remaining, the image will become empty and have no active
 * layer.
846 847
 *
 * Returns: TRUE on success.
848
 **/
849
gboolean
850
gimp_image_remove_layer (gint32 image_ID,
851
                         gint32 layer_ID)
Elliot Lee's avatar
Elliot Lee committed
852
{
853
  GimpParam *return_vals;
854
  gint nreturn_vals;
855
  gboolean success = TRUE;
Elliot Lee's avatar
Elliot Lee committed
856

857
  return_vals = gimp_run_procedure ("gimp-image-remove-layer",
858 859 860 861
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_LAYER, layer_ID,
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
862

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

Elliot Lee's avatar
Elliot Lee committed
865
  gimp_destroy_params (return_vals, nreturn_vals);
866 867

  return success;
Elliot Lee's avatar
Elliot Lee committed
868 869
}

870 871 872 873 874 875
/**
 * gimp_image_freeze_layers:
 * @image_ID: The image.
 *
 * Freeze the image's layer list.
 *
luz.paz's avatar
luz.paz committed
876
 * This procedure freezes the layer list of the image, suppressing any
877 878 879 880 881 882 883 884
 * updates to the Layers dialog in response to changes to the image's
 * layers. This can significantly improve performance while applying
 * changes affecting the layer list.
 *
 * Each call to gimp_image_freeze_layers() should be matched by a
 * corresponding call to gimp_image_thaw_layers(), undoing its effects.
 *
 * Returns: TRUE on success.
885
 *
886
 * Since: 2.10.2
887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919
 **/
gboolean
gimp_image_freeze_layers (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

  return_vals = gimp_run_procedure ("gimp-image-freeze-layers",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_image_thaw_layers:
 * @image_ID: The image.
 *
 * Thaw the image's layer list.
 *
 * This procedure thaws the layer list of the image, re-enabling
 * updates to the Layers dialog.
 *
 * This procedure should match a corresponding call to
 * gimp_image_freeze_layers().
 *
 * Returns: TRUE on success.
920
 *
921
 * Since: 2.10.2
922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941
 **/
gboolean
gimp_image_thaw_layers (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

  return_vals = gimp_run_procedure ("gimp-image-thaw-layers",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

942 943 944 945 946 947 948 949 950 951
/**
 * gimp_image_insert_channel:
 * @image_ID: The image.
 * @channel_ID: The channel.
 * @parent_ID: The parent channel.
 * @position: The channel position.
 *
 * Add the specified channel to the image.
 *
 * This procedure adds the specified channel to the image at the given
952
 * position. Since channel groups are not currently supported, the
953
 * parent argument must always be 0. The position argument specifies
954 955 956
 * the location of the channel inside the stack, starting from the top
 * (0) and increasing. If the position is specified as -1, then the
 * channel is inserted above the active channel.
957 958
 *
 * Returns: TRUE on success.
959
 **/
960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984
gboolean
gimp_image_insert_channel (gint32 image_ID,
                           gint32 channel_ID,
                           gint32 parent_ID,
                           gint   position)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

  return_vals = gimp_run_procedure ("gimp-image-insert-channel",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_CHANNEL, channel_ID,
                                    GIMP_PDB_CHANNEL, parent_ID,
                                    GIMP_PDB_INT32, position,
                                    GIMP_PDB_END);

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

985
/**
986
 * gimp_image_remove_channel:
987
 * @image_ID: The image.
988
 * @channel_ID: The channel.
989
 *
990
 * Remove the specified channel from the image.
991
 *
992 993
 * This procedure removes the specified channel from the image. If the
 * channel doesn't exist, an error is returned.
994 995
 *
 * Returns: TRUE on success.
996
 **/
997
gboolean
998 999
gimp_image_remove_channel (gint32 image_ID,
                           gint32 channel_ID)
Elliot Lee's avatar
Elliot Lee committed
1000
{
1001
  GimpParam *return_vals;
1002
  gint nreturn_vals;
1003
  gboolean success = TRUE;
Elliot Lee's avatar
Elliot Lee committed
1004

1005
  return_vals = gimp_run_procedure ("gimp-image-remove-channel",
1006 1007
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
1008
                                    GIMP_PDB_CHANNEL, channel_ID,
1009
                                    GIMP_PDB_END);
Elliot Lee's avatar
Elliot Lee committed
1010

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

Elliot Lee's avatar
Elliot Lee committed
1013
  gimp_destroy_params (return_vals, nreturn_vals);
1014 1015

  return success;
Elliot Lee's avatar
Elliot Lee committed
1016 1017
}

1018 1019 1020 1021 1022 1023
/**
 * gimp_image_freeze_channels:
 * @image_ID: The image.
 *
 * Freeze the image's channel list.
 *
1024 1025 1026 1027
 * This procedure freezes the channel list of the image, suppressing
 * any updates to the Channels dialog in response to changes to the
 * image's channels. This can significantly improve performance while
 * applying changes affecting the channel list.
1028 1029 1030 1031 1032 1033
 *
 * Each call to gimp_image_freeze_channels() should be matched by a
 * corresponding call to gimp_image_thaw_channels(), undoing its
 * effects.
 *
 * Returns: TRUE on success.
1034
 *
1035
 * Since: 2.10.2
1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064
 **/
gboolean
gimp_image_freeze_channels (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

  return_vals = gimp_run_procedure ("gimp-image-freeze-channels",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_image_thaw_channels:
 * @image_ID: The image.
 *
 * Thaw the image's channel list.
 *
 * This procedure thaws the channel list of the image, re-enabling
 * updates to the Channels dialog.
 *
luz.paz's avatar
luz.paz committed
1065
 * This procedure should match a corresponding call to
1066 1067 1068
 * gimp_image_freeze_channels().
 *
 * Returns: TRUE on success.
1069
 *
1070
 * Since: 2.10.2
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084
 **/
gboolean
gimp_image_thaw_channels (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

  return_vals = gimp_run_procedure ("gimp-image-thaw-channels",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);

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

Elliot Lee's avatar
Elliot Lee committed
1086
  gimp_destroy_params (return_vals, nreturn_vals);
1087 1088

  return success;
1089
}
1090

1091 1092 1093 1094 1095 1096 1097 1098 1099 1100
/**
 * gimp_image_insert_vectors:
 * @image_ID: The image.
 * @vectors_ID: The vectors.
 * @parent_ID: The parent vectors.
 * @position: The vectors position.
 *
 * Add the specified vectors to the image.
 *
 * This procedure adds the specified vectors to the image at the given
1101
 * position. Since vectors groups are not currently supported, the
1102
 * parent argument must always be 0. The position argument specifies
1103 1104 1105
 * the location of the vectors inside the stack, starting from the top
 * (0) and increasing. If the position is specified as -1, then the
 * vectors is inserted above the active vectors.
1106 1107
 *
 * Returns: TRUE on success.
1108
 **/
1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133
gboolean
gimp_image_insert_vectors (gint32 image_ID,
                           gint32 vectors_ID,
                           gint32 parent_ID,
                           gint   position)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

  return_vals = gimp_run_procedure ("gimp-image-insert-vectors",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_VECTORS, vectors_ID,
                                    GIMP_PDB_VECTORS, parent_ID,
                                    GIMP_PDB_INT32, position,
                                    GIMP_PDB_END);

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

1134
/**
1135
 * gimp_image_remove_vectors:
1136
 * @image_ID: The image.
1137
 * @vectors_ID: The vectors object.
1138
 *
1139
 * Remove the specified path from the image.
1140
 *
1141 1142
 * This procedure removes the specified path from the image. If the
 * path doesn't exist, an error is returned.
1143 1144
 *
 * Returns: TRUE on success.
1145
 *
1146
 * Since: 2.4
1147
 **/
1148
gboolean
1149 1150
gimp_image_remove_vectors (gint32 image_ID,
                           gint32 vectors_ID)
1151
{
1152
  GimpParam *return_vals;
1153
  gint nreturn_vals;
1154
  gboolean success = TRUE;
1155

1156
  return_vals = gimp_run_procedure ("gimp-image-remove-vectors",
1157 1158
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
1159
                                    GIMP_PDB_VECTORS, vectors_ID,
1160
                                    GIMP_PDB_END);
1161

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

1164
  gimp_destroy_params (return_vals, nreturn_vals);
1165 1166

  return success;
Elliot Lee's avatar
Elliot Lee committed
1167 1168
}

1169 1170 1171 1172 1173 1174
/**
 * gimp_image_freeze_vectors:
 * @image_ID: The image.
 *
 * Freeze the image's vectors list.
 *
1175 1176 1177 1178
 * This procedure freezes the vectors list of the image, suppressing
 * any updates to the Paths dialog in response to changes to the
 * image's vectors. This can significantly improve performance while
 * applying changes affecting the vectors list.
1179 1180 1181 1182 1183 1184
 *
 * Each call to gimp_image_freeze_vectors() should be matched by a
 * corresponding call to gimp_image_thaw_vectors(), undoing its
 * effects.
 *
 * Returns: TRUE on success.
1185
 *
1186
 * Since: 2.10.2
1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219
 **/
gboolean
gimp_image_freeze_vectors (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

  return_vals = gimp_run_procedure ("gimp-image-freeze-vectors",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_image_thaw_vectors:
 * @image_ID: The image.
 *
 * Thaw the image's vectors list.
 *
 * This procedure thaws the vectors list of the image, re-enabling
 * updates to the Paths dialog.
 *
 * This procedure should match a corresponding call to
 * gimp_image_freeze_vectors().
 *
 * Returns: TRUE on success.
1220
 *
1221
 * Since: 2.10.2
1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241
 **/
gboolean
gimp_image_thaw_vectors (gint32 image_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

  return_vals = gimp_run_procedure ("gimp-image-thaw-vectors",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

1242
/**
1243
 * gimp_image_get_item_position:
1244
 * @image_ID: The image.
1245
 * @item_ID: The item.
1246
 *
1247
 * Returns the position of the item in its level of its item tree.
1248
 *
1249 1250 1251 1252 1253 1254 1255
 * This procedure determines the position of the specified item in its
 * level in its item tree in the image. If the item doesn't exist in
 * the image, or the item is not part of an item tree, an error is
 * returned.
 *
 * Returns: The position of the item in its level in the item tree.
 *
1256
 * Since: 2.8
1257
 **/
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288
gint
gimp_image_get_item_position (gint32 image_ID,
                              gint32 item_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gint position = 0;

  return_vals = gimp_run_procedure ("gimp-image-get-item-position",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_ITEM, item_ID,
                                    GIMP_PDB_END);

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return position;
}

/**
 * gimp_image_raise_item:
 * @image_ID: The image.
 * @item_ID: The item to raise.
 *
 * Raise the specified item in its level in its item tree
 *
 * This procedure raises the specified item one step in the item tree.
 * The procecure call will fail if there is no item above it.
1289 1290
 *
 * Returns: TRUE on success.
1291
 *
1292
 * Since: 2.8
1293
 **/
1294
gboolean
1295 1296
gimp_image_raise_item (gint32 image_ID,
                       gint32 item_ID)
Elliot Lee's avatar
Elliot Lee committed
1297
{
1298
  GimpParam *return_vals;
1299
  gint nreturn_vals;
1300
  gboolean success = TRUE;
Elliot Lee's avatar
Elliot Lee committed
1301

1302
  return_vals = gimp_run_procedure ("gimp-image-raise-item",
1303 1304
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
1305
                                    GIMP_PDB_ITEM, item_ID,
1306
                                    GIMP_PDB_END);
1307

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

1310
  gimp_destroy_params (return_vals, nreturn_vals);
1311 1312

  return success;
1313 1314
}

1315
/**
1316
 * gimp_image_lower_item:
1317
 * @image_ID: The image.
1318
 * @item_ID: The item to lower.
1319
 *
1320
 * Lower the specified item in its level in its item tree
1321
 *
1322 1323
 * This procedure lowers the specified item one step in the item tree.
 * The procecure call will fail if there is no item below it.
1324 1325
 *
 * Returns: TRUE on success.
1326
 *
1327
 * Since: 2.8
1328
 **/
1329
gboolean
1330 1331
gimp_image_lower_item (gint32 image_ID,
                       gint32 item_ID)
1332 1333 1334 1335 1336
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

1337
  return_vals = gimp_run_procedure ("gimp-image-lower-item",
1338 1339
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
1340
                                    GIMP_PDB_ITEM, item_ID,
1341
                                    GIMP_PDB_END);
1342 1343 1344 1345 1346 1347 1348 1349 1350

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
1351
 * gimp_image_raise_item_to_top:
1352
 * @image_ID: The image.
1353
 * @item_ID: The item to raise to top.
1354
 *
1355
 * Raise the specified item to the top of its level in its item tree
1356
 *
1357 1358
 * This procedure raises the specified item to top of its level in the
 * item tree. It will not move the item if there is no item above it.
1359 1360
 *
 * Returns: TRUE on success.
1361
 *
1362
 * Since: 2.8
1363
 **/
1364
gboolean
1365 1366
gimp_image_raise_item_to_top (gint32 image_ID,
                              gint32 item_ID)
1367 1368 1369 1370 1371
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

1372
  return_vals = gimp_run_procedure ("gimp-image-raise-item-to-top",
1373 1374
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
1375
                                    GIMP_PDB_ITEM, item_ID,
1376
                                    GIMP_PDB_END);
1377 1378 1379 1380 1381 1382 1383 1384

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

1385
/**
1386
 * gimp_image_lower_item_to_bottom:
1387
 * @image_ID: The image.
1388
 * @item_ID: The item to lower to bottom.
1389
 *
1390
 * Lower the specified item to the bottom of its level in its item tree
1391
 *
1392 1393 1394
 * This procedure lowers the specified item to bottom of its level in
 * the item tree. It will not move the layer if there is no layer below
 * it.
1395
 *
1396 1397
 * Returns: TRUE on success.
 *
1398
 * Since: 2.8
1399
 **/
1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420
gboolean
gimp_image_lower_item_to_bottom (gint32 image_ID,
                                 gint32 item_ID)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

  return_vals = gimp_run_procedure ("gimp-image-lower-item-to-bottom",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_ITEM, item_ID,
                                    GIMP_PDB_END);

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

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433
/**
 * gimp_image_reorder_item:
 * @image_ID: The image.
 * @item_ID: The item to reorder.
 * @parent_ID: The new parent item.
 * @position: The new position of the item.
 *
 * Reorder the specified item within its item tree
 *
 * This procedure reorders the specified item within its item tree.
 *
 * Returns: TRUE on success.
 *
1434
 * Since: 2.8
1435
 **/
1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457
gboolean
gimp_image_reorder_item (gint32 image_ID,
                         gint32 item_ID,
                         gint32 parent_ID,
                         gint   position)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

  return_vals = gimp_run_procedure ("gimp-image-reorder-item",
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_ITEM, item_ID,
                                    GIMP_PDB_ITEM, parent_ID,
                                    GIMP_PDB_INT32, position,
                                    GIMP_PDB_END);

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

  gimp_destroy_params (return_vals, nreturn_vals);

1458
  return success;
Elliot Lee's avatar
Elliot Lee committed
1459 1460
}

1461
/**
1462
 * gimp_image_flatten:
1463 1464
 * @image_ID: The image.
 *
1465 1466
 * Flatten all visible layers into a single layer. Discard all
 * invisible layers.
1467
 *
1468 1469 1470
 * This procedure combines the visible layers in a manner analogous to
 * merging with the CLIP_TO_IMAGE merge type. Non-visible layers are
 * discarded, and the resulting image is stripped of its alpha channel.
1471
 *
1472
 * Returns: The resulting layer.
1473
 **/
1474 1475
gint32
gimp_image_flatten (gint32 image_ID)
1476
{
1477
  GimpParam *return_vals;
1478
  gint nreturn_vals;
1479
  gint32 layer_ID = -1;
1480

1481
  return_vals = gimp_run_procedure ("gimp-image-flatten",
1482 1483 1484
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_END);
1485

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

1489
  gimp_destroy_params (return_vals, nreturn_vals);
1490

1491
  return layer_ID;
Elliot Lee's avatar
Elliot Lee committed
1492 1493
}

1494
/**
1495
 * gimp_image_merge_visible_layers:
1496
 * @image_ID: The image.
1497
 * @merge_type: The type of merge.
1498
 *
1499
 * Merge the visible image layers into one.
1500
 *
1501 1502 1503 1504 1505 1506
 * This procedure combines the visible layers into a single layer using
 * the specified merge type. A merge type of EXPAND_AS_NECESSARY
 * expands the final layer to encompass the areas of the visible
 * layers. A merge type of CLIP_TO_IMAGE clips the final layer to the
 * extents of the image. A merge type of CLIP_TO_BOTTOM_LAYER clips the
 * final layer to the size of the bottommost layer.
1507
 *
1508
 * Returns: The resulting layer.
1509
 **/
1510 1511
gint32
gimp_image_merge_visible_layers (gint32        image_ID,
1512
                                 GimpMergeType merge_type)
1513 1514 1515
{
  GimpParam *return_vals;
  gint nreturn_vals;
1516
  gint32 layer_ID = -1;
1517

1518
  return_vals = gimp_run_procedure ("gimp-image-merge-visible-layers",
1519 1520 1521 1522
                                    &nreturn_vals,
                                    GIMP_PDB_IMAGE, image_ID,
                                    GIMP_PDB_INT32, merge_type,
                                    GIMP_PDB_END);
1523 1524

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

  gimp_destroy_params (return_vals, nreturn_vals);

1529
  return layer_ID;
1530 1531
}

1532
/**
1533
 * gimp_image_merge_down:
1534
 * @image_ID: The image.
1535 1536
 * @merge_layer_ID: The layer to merge down from.
 * @merge_type: The type of merge.
1537
 *
1538
 * Merge the layer passed and the first visible layer below.
1539
 *
1540 1541 1542 1543 1544 1545 1546
 * This procedure combines the passed layer and the first visible layer
 * below it using the specified merge type. A merge type of
 * EXPAND_AS_NECESSARY expands the final layer to encompass the areas
 * of the visible layers. A merge type of CLIP_TO_IMAGE clips the final
 * layer to the extents of the image. A merge type of
 * CLIP_TO_BOTTOM_LAYER clips the final layer to the size of the
 * bottommost layer.
1547
 *
1548
 * Returns: The resulting layer.
1549
 **/
Elliot Lee's avatar
Elliot Lee committed
1550
gint32
1551
gimp_image_merge_down (gint32        image_ID,
1552 1553
                       gint32        merge_layer_ID,
                       GimpMergeType merge_type)
Elliot Lee's avatar
Elliot Lee committed
1554
{
1555
  GimpParam *return_vals;
1556
  gint nreturn_vals;
1557
  gint32 layer_ID = -1;
Elliot Lee's avatar
Elliot Lee committed
1558