1 /* LIBGIMP - The GIMP Library
2  * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
3  *
4  * gimpimage_pdb.c
5  *
6  * This library is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
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  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
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 
23 #include "config.h"
24 
25 #include <string.h>
26 
27 #include "gimp.h"
28 
29 
30 /**
31  * SECTION: gimpimage
32  * @title: gimpimage
33  * @short_description: Operations on complete images.
34  *
35  * Operations on complete images: creation, resizing/rescaling, and
36  * operations involving multiple layers.
37  **/
38 
39 
40 /**
41  * gimp_image_is_valid:
42  * @image_ID: The image to check.
43  *
44  * Returns TRUE if the image is valid.
45  *
46  * This procedure checks if the given image ID is valid and refers to
47  * an existing image.
48  *
49  * Returns: Whether the image ID is valid.
50  *
51  * Since: 2.4
52  **/
53 gboolean
gimp_image_is_valid(gint32 image_ID)54 gimp_image_is_valid (gint32 image_ID)
55 {
56   GimpParam *return_vals;
57   gint nreturn_vals;
58   gboolean valid = FALSE;
59 
60   return_vals = gimp_run_procedure ("gimp-image-is-valid",
61                                     &nreturn_vals,
62                                     GIMP_PDB_IMAGE, image_ID,
63                                     GIMP_PDB_END);
64 
65   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
66     valid = return_vals[1].data.d_int32;
67 
68   gimp_destroy_params (return_vals, nreturn_vals);
69 
70   return valid;
71 }
72 
73 /**
74  * gimp_image_list:
75  * @num_images: The number of images currently open.
76  *
77  * Returns the list of images currently open.
78  *
79  * This procedure returns the list of images currently open in GIMP.
80  *
81  * Returns: The list of images currently open. The returned value must
82  * be freed with g_free().
83  **/
84 gint *
gimp_image_list(gint * num_images)85 gimp_image_list (gint *num_images)
86 {
87   GimpParam *return_vals;
88   gint nreturn_vals;
89   gint *image_ids = NULL;
90 
91   return_vals = gimp_run_procedure ("gimp-image-list",
92                                     &nreturn_vals,
93                                     GIMP_PDB_END);
94 
95   *num_images = 0;
96 
97   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
98     {
99       *num_images = return_vals[1].data.d_int32;
100       image_ids = g_new (gint32, *num_images);
101       memcpy (image_ids,
102               return_vals[2].data.d_int32array,
103               *num_images * sizeof (gint32));
104     }
105 
106   gimp_destroy_params (return_vals, nreturn_vals);
107 
108   return image_ids;
109 }
110 
111 /**
112  * gimp_image_new:
113  * @width: The width of the image.
114  * @height: The height of the image.
115  * @type: The type of image.
116  *
117  * Creates a new image with the specified width, height, and type.
118  *
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  * If your image's type if INDEXED, a colormap must also be added with
127  * gimp_image_set_colormap(). An indexed image without a colormap will
128  * output unexpected colors.
129  *
130  * Returns: The ID of the newly created image.
131  **/
132 gint32
gimp_image_new(gint width,gint height,GimpImageBaseType type)133 gimp_image_new (gint              width,
134                 gint              height,
135                 GimpImageBaseType type)
136 {
137   GimpParam *return_vals;
138   gint nreturn_vals;
139   gint32 image_ID = -1;
140 
141   return_vals = gimp_run_procedure ("gimp-image-new",
142                                     &nreturn_vals,
143                                     GIMP_PDB_INT32, width,
144                                     GIMP_PDB_INT32, height,
145                                     GIMP_PDB_INT32, type,
146                                     GIMP_PDB_END);
147 
148   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
149     image_ID = return_vals[1].data.d_image;
150 
151   gimp_destroy_params (return_vals, nreturn_vals);
152 
153   return image_ID;
154 }
155 
156 /**
157  * gimp_image_new_with_precision:
158  * @width: The width of the image.
159  * @height: The height of the image.
160  * @type: The type of image.
161  * @precision: The precision.
162  *
163  * Creates a new image with the specified width, height, type and
164  * precision.
165  *
166  * Creates a new image, undisplayed with the specified extents, type
167  * and precision. Indexed images can only be created at
168  * GIMP_PRECISION_U8_GAMMA precision. See gimp_image_new() for further
169  * details.
170  *
171  * Returns: The ID of the newly created image.
172  *
173  * Since: 2.10
174  **/
175 gint32
gimp_image_new_with_precision(gint width,gint height,GimpImageBaseType type,GimpPrecision precision)176 gimp_image_new_with_precision (gint              width,
177                                gint              height,
178                                GimpImageBaseType type,
179                                GimpPrecision     precision)
180 {
181   GimpParam *return_vals;
182   gint nreturn_vals;
183   gint32 image_ID = -1;
184 
185   return_vals = gimp_run_procedure ("gimp-image-new-with-precision",
186                                     &nreturn_vals,
187                                     GIMP_PDB_INT32, width,
188                                     GIMP_PDB_INT32, height,
189                                     GIMP_PDB_INT32, type,
190                                     GIMP_PDB_INT32, precision,
191                                     GIMP_PDB_END);
192 
193   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
194     image_ID = return_vals[1].data.d_image;
195 
196   gimp_destroy_params (return_vals, nreturn_vals);
197 
198   return image_ID;
199 }
200 
201 /**
202  * gimp_image_duplicate:
203  * @image_ID: The image.
204  *
205  * Duplicate the specified image
206  *
207  * This procedure duplicates the specified image, copying all layers,
208  * channels, and image information.
209  *
210  * Returns: The new, duplicated image.
211  **/
212 gint32
gimp_image_duplicate(gint32 image_ID)213 gimp_image_duplicate (gint32 image_ID)
214 {
215   GimpParam *return_vals;
216   gint nreturn_vals;
217   gint32 new_image_ID = -1;
218 
219   return_vals = gimp_run_procedure ("gimp-image-duplicate",
220                                     &nreturn_vals,
221                                     GIMP_PDB_IMAGE, image_ID,
222                                     GIMP_PDB_END);
223 
224   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
225     new_image_ID = return_vals[1].data.d_image;
226 
227   gimp_destroy_params (return_vals, nreturn_vals);
228 
229   return new_image_ID;
230 }
231 
232 /**
233  * gimp_image_delete:
234  * @image_ID: The image.
235  *
236  * Delete the specified image.
237  *
238  * If there are no displays associated with this image it will be
239  * deleted. This means that you can not delete an image through the PDB
240  * that was created by the user. If the associated display was however
241  * created through the PDB and you know the display ID, you may delete
242  * the display. Removal of the last associated display will then delete
243  * the image.
244  *
245  * Returns: TRUE on success.
246  **/
247 gboolean
gimp_image_delete(gint32 image_ID)248 gimp_image_delete (gint32 image_ID)
249 {
250   GimpParam *return_vals;
251   gint nreturn_vals;
252   gboolean success = TRUE;
253 
254   return_vals = gimp_run_procedure ("gimp-image-delete",
255                                     &nreturn_vals,
256                                     GIMP_PDB_IMAGE, image_ID,
257                                     GIMP_PDB_END);
258 
259   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
260 
261   gimp_destroy_params (return_vals, nreturn_vals);
262 
263   return success;
264 }
265 
266 /**
267  * gimp_image_base_type:
268  * @image_ID: The image.
269  *
270  * Get the base type of the image.
271  *
272  * This procedure returns the image's base type. Layers in the image
273  * must be of this subtype, but can have an optional alpha channel.
274  *
275  * Returns: The image's base type.
276  **/
277 GimpImageBaseType
gimp_image_base_type(gint32 image_ID)278 gimp_image_base_type (gint32 image_ID)
279 {
280   GimpParam *return_vals;
281   gint nreturn_vals;
282   GimpImageBaseType base_type = 0;
283 
284   return_vals = gimp_run_procedure ("gimp-image-base-type",
285                                     &nreturn_vals,
286                                     GIMP_PDB_IMAGE, image_ID,
287                                     GIMP_PDB_END);
288 
289   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
290     base_type = return_vals[1].data.d_int32;
291 
292   gimp_destroy_params (return_vals, nreturn_vals);
293 
294   return base_type;
295 }
296 
297 /**
298  * gimp_image_get_precision:
299  * @image_ID: The image.
300  *
301  * Get the precision of the image.
302  *
303  * This procedure returns the image's precision.
304  *
305  * Returns: The image's precision.
306  *
307  * Since: 2.10
308  **/
309 GimpPrecision
gimp_image_get_precision(gint32 image_ID)310 gimp_image_get_precision (gint32 image_ID)
311 {
312   GimpParam *return_vals;
313   gint nreturn_vals;
314   GimpPrecision precision = 0;
315 
316   return_vals = gimp_run_procedure ("gimp-image-get-precision",
317                                     &nreturn_vals,
318                                     GIMP_PDB_IMAGE, image_ID,
319                                     GIMP_PDB_END);
320 
321   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
322     precision = return_vals[1].data.d_int32;
323 
324   gimp_destroy_params (return_vals, nreturn_vals);
325 
326   return precision;
327 }
328 
329 /**
330  * gimp_image_get_default_new_layer_mode:
331  * @image_ID: The image.
332  *
333  * Get the default mode for newly created layers of this image.
334  *
335  * Returns the default mode for newly created layers of this image.
336  *
337  * Returns: The layer mode.
338  *
339  * Since: 2.10
340  **/
341 GimpLayerMode
gimp_image_get_default_new_layer_mode(gint32 image_ID)342 gimp_image_get_default_new_layer_mode (gint32 image_ID)
343 {
344   GimpParam *return_vals;
345   gint nreturn_vals;
346   GimpLayerMode mode = 0;
347 
348   return_vals = gimp_run_procedure ("gimp-image-get-default-new-layer-mode",
349                                     &nreturn_vals,
350                                     GIMP_PDB_IMAGE, image_ID,
351                                     GIMP_PDB_END);
352 
353   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
354     mode = return_vals[1].data.d_int32;
355 
356   gimp_destroy_params (return_vals, nreturn_vals);
357 
358   return mode;
359 }
360 
361 /**
362  * gimp_image_width:
363  * @image_ID: The image.
364  *
365  * Return the width of the image
366  *
367  * This procedure returns the image's width. This value is independent
368  * of any of the layers in this image. This is the \"canvas\" width.
369  *
370  * Returns: The image's width.
371  **/
372 gint
gimp_image_width(gint32 image_ID)373 gimp_image_width (gint32 image_ID)
374 {
375   GimpParam *return_vals;
376   gint nreturn_vals;
377   gint width = 0;
378 
379   return_vals = gimp_run_procedure ("gimp-image-width",
380                                     &nreturn_vals,
381                                     GIMP_PDB_IMAGE, image_ID,
382                                     GIMP_PDB_END);
383 
384   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
385     width = return_vals[1].data.d_int32;
386 
387   gimp_destroy_params (return_vals, nreturn_vals);
388 
389   return width;
390 }
391 
392 /**
393  * gimp_image_height:
394  * @image_ID: The image.
395  *
396  * Return the height of the image
397  *
398  * This procedure returns the image's height. This value is independent
399  * of any of the layers in this image. This is the \"canvas\" height.
400  *
401  * Returns: The image's height.
402  **/
403 gint
gimp_image_height(gint32 image_ID)404 gimp_image_height (gint32 image_ID)
405 {
406   GimpParam *return_vals;
407   gint nreturn_vals;
408   gint height = 0;
409 
410   return_vals = gimp_run_procedure ("gimp-image-height",
411                                     &nreturn_vals,
412                                     GIMP_PDB_IMAGE, image_ID,
413                                     GIMP_PDB_END);
414 
415   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
416     height = return_vals[1].data.d_int32;
417 
418   gimp_destroy_params (return_vals, nreturn_vals);
419 
420   return height;
421 }
422 
423 /**
424  * gimp_image_free_shadow:
425  * @image_ID: The image.
426  *
427  * Deprecated: Use gimp_drawable_free_shadow() instead.
428  *
429  * Returns: TRUE on success.
430  **/
431 gboolean
gimp_image_free_shadow(gint32 image_ID)432 gimp_image_free_shadow (gint32 image_ID)
433 {
434   GimpParam *return_vals;
435   gint nreturn_vals;
436   gboolean success = TRUE;
437 
438   return_vals = gimp_run_procedure ("gimp-image-free-shadow",
439                                     &nreturn_vals,
440                                     GIMP_PDB_IMAGE, image_ID,
441                                     GIMP_PDB_END);
442 
443   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
444 
445   gimp_destroy_params (return_vals, nreturn_vals);
446 
447   return success;
448 }
449 
450 /**
451  * gimp_image_get_layers:
452  * @image_ID: The image.
453  * @num_layers: The number of layers contained in the image.
454  *
455  * Returns the list of layers contained in the specified image.
456  *
457  * This procedure returns the list of layers contained in the specified
458  * image. The order of layers is from topmost to bottommost.
459  *
460  * Returns: The list of layers contained in the image. The returned
461  * value must be freed with g_free().
462  **/
463 gint *
gimp_image_get_layers(gint32 image_ID,gint * num_layers)464 gimp_image_get_layers (gint32  image_ID,
465                        gint   *num_layers)
466 {
467   GimpParam *return_vals;
468   gint nreturn_vals;
469   gint *layer_ids = NULL;
470 
471   return_vals = gimp_run_procedure ("gimp-image-get-layers",
472                                     &nreturn_vals,
473                                     GIMP_PDB_IMAGE, image_ID,
474                                     GIMP_PDB_END);
475 
476   *num_layers = 0;
477 
478   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
479     {
480       *num_layers = return_vals[1].data.d_int32;
481       layer_ids = g_new (gint32, *num_layers);
482       memcpy (layer_ids,
483               return_vals[2].data.d_int32array,
484               *num_layers * sizeof (gint32));
485     }
486 
487   gimp_destroy_params (return_vals, nreturn_vals);
488 
489   return layer_ids;
490 }
491 
492 /**
493  * gimp_image_get_channels:
494  * @image_ID: The image.
495  * @num_channels: The number of channels contained in the image.
496  *
497  * Returns the list of channels contained in the specified image.
498  *
499  * This procedure returns the list of channels contained in the
500  * specified image. This does not include the selection mask, or layer
501  * masks. The order is from topmost to bottommost. Note that
502  * \"channels\" are custom channels and do not include the image's
503  * color components.
504  *
505  * Returns: The list of channels contained in the image. The returned
506  * value must be freed with g_free().
507  **/
508 gint *
gimp_image_get_channels(gint32 image_ID,gint * num_channels)509 gimp_image_get_channels (gint32  image_ID,
510                          gint   *num_channels)
511 {
512   GimpParam *return_vals;
513   gint nreturn_vals;
514   gint *channel_ids = NULL;
515 
516   return_vals = gimp_run_procedure ("gimp-image-get-channels",
517                                     &nreturn_vals,
518                                     GIMP_PDB_IMAGE, image_ID,
519                                     GIMP_PDB_END);
520 
521   *num_channels = 0;
522 
523   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
524     {
525       *num_channels = return_vals[1].data.d_int32;
526       channel_ids = g_new (gint32, *num_channels);
527       memcpy (channel_ids,
528               return_vals[2].data.d_int32array,
529               *num_channels * sizeof (gint32));
530     }
531 
532   gimp_destroy_params (return_vals, nreturn_vals);
533 
534   return channel_ids;
535 }
536 
537 /**
538  * gimp_image_get_vectors:
539  * @image_ID: The image.
540  * @num_vectors: The number of vectors contained in the image.
541  *
542  * Returns the list of vectors contained in the specified image.
543  *
544  * This procedure returns the list of vectors contained in the
545  * specified image.
546  *
547  * Returns: The list of vectors contained in the image. The returned
548  * value must be freed with g_free().
549  *
550  * Since: 2.4
551  **/
552 gint *
gimp_image_get_vectors(gint32 image_ID,gint * num_vectors)553 gimp_image_get_vectors (gint32  image_ID,
554                         gint   *num_vectors)
555 {
556   GimpParam *return_vals;
557   gint nreturn_vals;
558   gint *vector_ids = NULL;
559 
560   return_vals = gimp_run_procedure ("gimp-image-get-vectors",
561                                     &nreturn_vals,
562                                     GIMP_PDB_IMAGE, image_ID,
563                                     GIMP_PDB_END);
564 
565   *num_vectors = 0;
566 
567   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
568     {
569       *num_vectors = return_vals[1].data.d_int32;
570       vector_ids = g_new (gint32, *num_vectors);
571       memcpy (vector_ids,
572               return_vals[2].data.d_int32array,
573               *num_vectors * sizeof (gint32));
574     }
575 
576   gimp_destroy_params (return_vals, nreturn_vals);
577 
578   return vector_ids;
579 }
580 
581 /**
582  * gimp_image_get_active_drawable:
583  * @image_ID: The image.
584  *
585  * Get the image's active drawable
586  *
587  * This procedure returns the ID of the image's active drawable. This
588  * can be either a layer, a channel, or a layer mask. The active
589  * drawable is specified by the active image channel. If that is -1,
590  * then by the active image layer. If the active image layer has a
591  * layer mask and the layer mask is in edit mode, then the layer mask
592  * is the active drawable.
593  *
594  * Returns: The active drawable.
595  **/
596 gint32
gimp_image_get_active_drawable(gint32 image_ID)597 gimp_image_get_active_drawable (gint32 image_ID)
598 {
599   GimpParam *return_vals;
600   gint nreturn_vals;
601   gint32 drawable_ID = -1;
602 
603   return_vals = gimp_run_procedure ("gimp-image-get-active-drawable",
604                                     &nreturn_vals,
605                                     GIMP_PDB_IMAGE, image_ID,
606                                     GIMP_PDB_END);
607 
608   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
609     drawable_ID = return_vals[1].data.d_drawable;
610 
611   gimp_destroy_params (return_vals, nreturn_vals);
612 
613   return drawable_ID;
614 }
615 
616 /**
617  * gimp_image_unset_active_channel:
618  * @image_ID: The image.
619  *
620  * Unsets the active channel in the specified image.
621  *
622  * If an active channel exists, it is unset. There then exists no
623  * active channel, and if desired, one can be set through a call to
624  * 'Set Active Channel'. No error is returned in the case of no
625  * existing active channel.
626  *
627  * Returns: TRUE on success.
628  **/
629 gboolean
gimp_image_unset_active_channel(gint32 image_ID)630 gimp_image_unset_active_channel (gint32 image_ID)
631 {
632   GimpParam *return_vals;
633   gint nreturn_vals;
634   gboolean success = TRUE;
635 
636   return_vals = gimp_run_procedure ("gimp-image-unset-active-channel",
637                                     &nreturn_vals,
638                                     GIMP_PDB_IMAGE, image_ID,
639                                     GIMP_PDB_END);
640 
641   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
642 
643   gimp_destroy_params (return_vals, nreturn_vals);
644 
645   return success;
646 }
647 
648 /**
649  * gimp_image_get_floating_sel:
650  * @image_ID: The image.
651  *
652  * Return the floating selection of the image.
653  *
654  * This procedure returns the image's floating selection, if it exists.
655  * If it doesn't exist, -1 is returned as the layer ID.
656  *
657  * Returns: The image's floating selection.
658  **/
659 gint32
gimp_image_get_floating_sel(gint32 image_ID)660 gimp_image_get_floating_sel (gint32 image_ID)
661 {
662   GimpParam *return_vals;
663   gint nreturn_vals;
664   gint32 floating_sel_ID = -1;
665 
666   return_vals = gimp_run_procedure ("gimp-image-get-floating-sel",
667                                     &nreturn_vals,
668                                     GIMP_PDB_IMAGE, image_ID,
669                                     GIMP_PDB_END);
670 
671   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
672     floating_sel_ID = return_vals[1].data.d_layer;
673 
674   gimp_destroy_params (return_vals, nreturn_vals);
675 
676   return floating_sel_ID;
677 }
678 
679 /**
680  * gimp_image_floating_sel_attached_to:
681  * @image_ID: The image.
682  *
683  * Return the drawable the floating selection is attached to.
684  *
685  * This procedure returns the drawable the image's floating selection
686  * is attached to, if it exists. If it doesn't exist, -1 is returned as
687  * the drawable ID.
688  *
689  * Returns: The drawable the floating selection is attached to.
690  **/
691 gint32
gimp_image_floating_sel_attached_to(gint32 image_ID)692 gimp_image_floating_sel_attached_to (gint32 image_ID)
693 {
694   GimpParam *return_vals;
695   gint nreturn_vals;
696   gint32 drawable_ID = -1;
697 
698   return_vals = gimp_run_procedure ("gimp-image-floating-sel-attached-to",
699                                     &nreturn_vals,
700                                     GIMP_PDB_IMAGE, image_ID,
701                                     GIMP_PDB_END);
702 
703   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
704     drawable_ID = return_vals[1].data.d_drawable;
705 
706   gimp_destroy_params (return_vals, nreturn_vals);
707 
708   return drawable_ID;
709 }
710 
711 /**
712  * gimp_image_pick_color:
713  * @image_ID: The image.
714  * @drawable_ID: The drawable to pick from.
715  * @x: x coordinate of upper-left corner of rectangle.
716  * @y: y coordinate of upper-left corner of rectangle.
717  * @sample_merged: Use the composite image, not the drawable.
718  * @sample_average: Average the color of all the pixels in a specified radius.
719  * @average_radius: The radius of pixels to average.
720  * @color: The return color.
721  *
722  * Determine the color at the given drawable coordinates
723  *
724  * This tool determines the color at the specified coordinates. The
725  * returned color is an RGB triplet even for grayscale and indexed
726  * drawables. If the coordinates lie outside of the extents of the
727  * specified drawable, then an error is returned. If the drawable has
728  * an alpha channel, the algorithm examines the alpha value of the
729  * drawable at the coordinates. If the alpha value is completely
730  * transparent (0), then an error is returned. If the sample_merged
731  * parameter is TRUE, the data of the composite image will be used
732  * instead of that for the specified drawable. This is equivalent to
733  * sampling for colors after merging all visible layers. In the case of
734  * a merged sampling, the supplied drawable is ignored.
735  *
736  * Returns: TRUE on success.
737  **/
738 gboolean
gimp_image_pick_color(gint32 image_ID,gint32 drawable_ID,gdouble x,gdouble y,gboolean sample_merged,gboolean sample_average,gdouble average_radius,GimpRGB * color)739 gimp_image_pick_color (gint32    image_ID,
740                        gint32    drawable_ID,
741                        gdouble   x,
742                        gdouble   y,
743                        gboolean  sample_merged,
744                        gboolean  sample_average,
745                        gdouble   average_radius,
746                        GimpRGB  *color)
747 {
748   GimpParam *return_vals;
749   gint nreturn_vals;
750   gboolean success = TRUE;
751 
752   return_vals = gimp_run_procedure ("gimp-image-pick-color",
753                                     &nreturn_vals,
754                                     GIMP_PDB_IMAGE, image_ID,
755                                     GIMP_PDB_DRAWABLE, drawable_ID,
756                                     GIMP_PDB_FLOAT, x,
757                                     GIMP_PDB_FLOAT, y,
758                                     GIMP_PDB_INT32, sample_merged,
759                                     GIMP_PDB_INT32, sample_average,
760                                     GIMP_PDB_FLOAT, average_radius,
761                                     GIMP_PDB_END);
762 
763   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
764 
765   if (success)
766     *color = return_vals[1].data.d_color;
767 
768   gimp_destroy_params (return_vals, nreturn_vals);
769 
770   return success;
771 }
772 
773 /**
774  * gimp_image_pick_correlate_layer:
775  * @image_ID: The image.
776  * @x: The x coordinate for the pick.
777  * @y: The y coordinate for the pick.
778  *
779  * Find the layer visible at the specified coordinates.
780  *
781  * This procedure finds the layer which is visible at the specified
782  * coordinates. Layers which do not qualify are those whose extents do
783  * not pass within the specified coordinates, or which are transparent
784  * at the specified coordinates. This procedure will return -1 if no
785  * layer is found.
786  *
787  * Returns: The layer found at the specified coordinates.
788  **/
789 gint32
gimp_image_pick_correlate_layer(gint32 image_ID,gint x,gint y)790 gimp_image_pick_correlate_layer (gint32 image_ID,
791                                  gint   x,
792                                  gint   y)
793 {
794   GimpParam *return_vals;
795   gint nreturn_vals;
796   gint32 layer_ID = -1;
797 
798   return_vals = gimp_run_procedure ("gimp-image-pick-correlate-layer",
799                                     &nreturn_vals,
800                                     GIMP_PDB_IMAGE, image_ID,
801                                     GIMP_PDB_INT32, x,
802                                     GIMP_PDB_INT32, y,
803                                     GIMP_PDB_END);
804 
805   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
806     layer_ID = return_vals[1].data.d_layer;
807 
808   gimp_destroy_params (return_vals, nreturn_vals);
809 
810   return layer_ID;
811 }
812 
813 /**
814  * gimp_image_add_layer:
815  * @image_ID: The image.
816  * @layer_ID: The layer.
817  * @position: The layer position.
818  *
819  * Deprecated: Use gimp_image_insert_layer() instead.
820  *
821  * Returns: TRUE on success.
822  **/
823 gboolean
gimp_image_add_layer(gint32 image_ID,gint32 layer_ID,gint position)824 gimp_image_add_layer (gint32 image_ID,
825                       gint32 layer_ID,
826                       gint   position)
827 {
828   GimpParam *return_vals;
829   gint nreturn_vals;
830   gboolean success = TRUE;
831 
832   return_vals = gimp_run_procedure ("gimp-image-add-layer",
833                                     &nreturn_vals,
834                                     GIMP_PDB_IMAGE, image_ID,
835                                     GIMP_PDB_LAYER, layer_ID,
836                                     GIMP_PDB_INT32, position,
837                                     GIMP_PDB_END);
838 
839   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
840 
841   gimp_destroy_params (return_vals, nreturn_vals);
842 
843   return success;
844 }
845 
846 /**
847  * gimp_image_insert_layer:
848  * @image_ID: The image.
849  * @layer_ID: The layer.
850  * @parent_ID: The parent layer.
851  * @position: The layer position.
852  *
853  * Add the specified layer to the image.
854  *
855  * This procedure adds the specified layer to the image at the given
856  * position. If the specified parent is a valid layer group (See
857  * gimp_item_is_group() and gimp_layer_group_new()) then the layer is
858  * added inside the group. If the parent is 0, the layer is added
859  * inside the main stack, outside of any group. The position argument
860  * specifies the location of the layer inside the stack (or the group,
861  * if a valid parent was supplied), starting from the top (0) and
862  * increasing. If the position is specified as -1 and the parent is
863  * specified as 0, then the layer is inserted above the active layer,
864  * or inside the group if the active layer is a layer group. The layer
865  * type must be compatible with the image base type.
866  *
867  * Returns: TRUE on success.
868  **/
869 gboolean
gimp_image_insert_layer(gint32 image_ID,gint32 layer_ID,gint32 parent_ID,gint position)870 gimp_image_insert_layer (gint32 image_ID,
871                          gint32 layer_ID,
872                          gint32 parent_ID,
873                          gint   position)
874 {
875   GimpParam *return_vals;
876   gint nreturn_vals;
877   gboolean success = TRUE;
878 
879   return_vals = gimp_run_procedure ("gimp-image-insert-layer",
880                                     &nreturn_vals,
881                                     GIMP_PDB_IMAGE, image_ID,
882                                     GIMP_PDB_LAYER, layer_ID,
883                                     GIMP_PDB_LAYER, parent_ID,
884                                     GIMP_PDB_INT32, position,
885                                     GIMP_PDB_END);
886 
887   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
888 
889   gimp_destroy_params (return_vals, nreturn_vals);
890 
891   return success;
892 }
893 
894 /**
895  * gimp_image_remove_layer:
896  * @image_ID: The image.
897  * @layer_ID: The layer.
898  *
899  * Remove the specified layer from the image.
900  *
901  * This procedure removes the specified layer from the image. If the
902  * layer doesn't exist, an error is returned. If there are no layers
903  * left in the image, this call will fail. If this layer is the last
904  * layer remaining, the image will become empty and have no active
905  * layer.
906  *
907  * Returns: TRUE on success.
908  **/
909 gboolean
gimp_image_remove_layer(gint32 image_ID,gint32 layer_ID)910 gimp_image_remove_layer (gint32 image_ID,
911                          gint32 layer_ID)
912 {
913   GimpParam *return_vals;
914   gint nreturn_vals;
915   gboolean success = TRUE;
916 
917   return_vals = gimp_run_procedure ("gimp-image-remove-layer",
918                                     &nreturn_vals,
919                                     GIMP_PDB_IMAGE, image_ID,
920                                     GIMP_PDB_LAYER, layer_ID,
921                                     GIMP_PDB_END);
922 
923   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
924 
925   gimp_destroy_params (return_vals, nreturn_vals);
926 
927   return success;
928 }
929 
930 /**
931  * gimp_image_freeze_layers:
932  * @image_ID: The image.
933  *
934  * Freeze the image's layer list.
935  *
936  * This procedure freezes the layer list of the image, suppressing any
937  * updates to the Layers dialog in response to changes to the image's
938  * layers. This can significantly improve performance while applying
939  * changes affecting the layer list.
940  *
941  * Each call to gimp_image_freeze_layers() should be matched by a
942  * corresponding call to gimp_image_thaw_layers(), undoing its effects.
943  *
944  * Returns: TRUE on success.
945  *
946  * Since: 2.10.2
947  **/
948 gboolean
gimp_image_freeze_layers(gint32 image_ID)949 gimp_image_freeze_layers (gint32 image_ID)
950 {
951   GimpParam *return_vals;
952   gint nreturn_vals;
953   gboolean success = TRUE;
954 
955   return_vals = gimp_run_procedure ("gimp-image-freeze-layers",
956                                     &nreturn_vals,
957                                     GIMP_PDB_IMAGE, image_ID,
958                                     GIMP_PDB_END);
959 
960   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
961 
962   gimp_destroy_params (return_vals, nreturn_vals);
963 
964   return success;
965 }
966 
967 /**
968  * gimp_image_thaw_layers:
969  * @image_ID: The image.
970  *
971  * Thaw the image's layer list.
972  *
973  * This procedure thaws the layer list of the image, re-enabling
974  * updates to the Layers dialog.
975  *
976  * This procedure should match a corresponding call to
977  * gimp_image_freeze_layers().
978  *
979  * Returns: TRUE on success.
980  *
981  * Since: 2.10.2
982  **/
983 gboolean
gimp_image_thaw_layers(gint32 image_ID)984 gimp_image_thaw_layers (gint32 image_ID)
985 {
986   GimpParam *return_vals;
987   gint nreturn_vals;
988   gboolean success = TRUE;
989 
990   return_vals = gimp_run_procedure ("gimp-image-thaw-layers",
991                                     &nreturn_vals,
992                                     GIMP_PDB_IMAGE, image_ID,
993                                     GIMP_PDB_END);
994 
995   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
996 
997   gimp_destroy_params (return_vals, nreturn_vals);
998 
999   return success;
1000 }
1001 
1002 /**
1003  * gimp_image_add_channel:
1004  * @image_ID: The image.
1005  * @channel_ID: The channel.
1006  * @position: The channel position.
1007  *
1008  * Deprecated: Use gimp_image_insert_channel() instead.
1009  *
1010  * Returns: TRUE on success.
1011  **/
1012 gboolean
gimp_image_add_channel(gint32 image_ID,gint32 channel_ID,gint position)1013 gimp_image_add_channel (gint32 image_ID,
1014                         gint32 channel_ID,
1015                         gint   position)
1016 {
1017   GimpParam *return_vals;
1018   gint nreturn_vals;
1019   gboolean success = TRUE;
1020 
1021   return_vals = gimp_run_procedure ("gimp-image-add-channel",
1022                                     &nreturn_vals,
1023                                     GIMP_PDB_IMAGE, image_ID,
1024                                     GIMP_PDB_CHANNEL, channel_ID,
1025                                     GIMP_PDB_INT32, position,
1026                                     GIMP_PDB_END);
1027 
1028   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1029 
1030   gimp_destroy_params (return_vals, nreturn_vals);
1031 
1032   return success;
1033 }
1034 
1035 /**
1036  * gimp_image_insert_channel:
1037  * @image_ID: The image.
1038  * @channel_ID: The channel.
1039  * @parent_ID: The parent channel.
1040  * @position: The channel position.
1041  *
1042  * Add the specified channel to the image.
1043  *
1044  * This procedure adds the specified channel to the image at the given
1045  * position. Since channel groups are not currently supported, the
1046  * parent argument must always be 0. The position argument specifies
1047  * the location of the channel inside the stack, starting from the top
1048  * (0) and increasing. If the position is specified as -1, then the
1049  * channel is inserted above the active channel.
1050  *
1051  * Returns: TRUE on success.
1052  **/
1053 gboolean
gimp_image_insert_channel(gint32 image_ID,gint32 channel_ID,gint32 parent_ID,gint position)1054 gimp_image_insert_channel (gint32 image_ID,
1055                            gint32 channel_ID,
1056                            gint32 parent_ID,
1057                            gint   position)
1058 {
1059   GimpParam *return_vals;
1060   gint nreturn_vals;
1061   gboolean success = TRUE;
1062 
1063   return_vals = gimp_run_procedure ("gimp-image-insert-channel",
1064                                     &nreturn_vals,
1065                                     GIMP_PDB_IMAGE, image_ID,
1066                                     GIMP_PDB_CHANNEL, channel_ID,
1067                                     GIMP_PDB_CHANNEL, parent_ID,
1068                                     GIMP_PDB_INT32, position,
1069                                     GIMP_PDB_END);
1070 
1071   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1072 
1073   gimp_destroy_params (return_vals, nreturn_vals);
1074 
1075   return success;
1076 }
1077 
1078 /**
1079  * gimp_image_remove_channel:
1080  * @image_ID: The image.
1081  * @channel_ID: The channel.
1082  *
1083  * Remove the specified channel from the image.
1084  *
1085  * This procedure removes the specified channel from the image. If the
1086  * channel doesn't exist, an error is returned.
1087  *
1088  * Returns: TRUE on success.
1089  **/
1090 gboolean
gimp_image_remove_channel(gint32 image_ID,gint32 channel_ID)1091 gimp_image_remove_channel (gint32 image_ID,
1092                            gint32 channel_ID)
1093 {
1094   GimpParam *return_vals;
1095   gint nreturn_vals;
1096   gboolean success = TRUE;
1097 
1098   return_vals = gimp_run_procedure ("gimp-image-remove-channel",
1099                                     &nreturn_vals,
1100                                     GIMP_PDB_IMAGE, image_ID,
1101                                     GIMP_PDB_CHANNEL, channel_ID,
1102                                     GIMP_PDB_END);
1103 
1104   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1105 
1106   gimp_destroy_params (return_vals, nreturn_vals);
1107 
1108   return success;
1109 }
1110 
1111 /**
1112  * gimp_image_freeze_channels:
1113  * @image_ID: The image.
1114  *
1115  * Freeze the image's channel list.
1116  *
1117  * This procedure freezes the channel list of the image, suppressing
1118  * any updates to the Channels dialog in response to changes to the
1119  * image's channels. This can significantly improve performance while
1120  * applying changes affecting the channel list.
1121  *
1122  * Each call to gimp_image_freeze_channels() should be matched by a
1123  * corresponding call to gimp_image_thaw_channels(), undoing its
1124  * effects.
1125  *
1126  * Returns: TRUE on success.
1127  *
1128  * Since: 2.10.2
1129  **/
1130 gboolean
gimp_image_freeze_channels(gint32 image_ID)1131 gimp_image_freeze_channels (gint32 image_ID)
1132 {
1133   GimpParam *return_vals;
1134   gint nreturn_vals;
1135   gboolean success = TRUE;
1136 
1137   return_vals = gimp_run_procedure ("gimp-image-freeze-channels",
1138                                     &nreturn_vals,
1139                                     GIMP_PDB_IMAGE, image_ID,
1140                                     GIMP_PDB_END);
1141 
1142   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1143 
1144   gimp_destroy_params (return_vals, nreturn_vals);
1145 
1146   return success;
1147 }
1148 
1149 /**
1150  * gimp_image_thaw_channels:
1151  * @image_ID: The image.
1152  *
1153  * Thaw the image's channel list.
1154  *
1155  * This procedure thaws the channel list of the image, re-enabling
1156  * updates to the Channels dialog.
1157  *
1158  * This procedure should match a corresponding call to
1159  * gimp_image_freeze_channels().
1160  *
1161  * Returns: TRUE on success.
1162  *
1163  * Since: 2.10.2
1164  **/
1165 gboolean
gimp_image_thaw_channels(gint32 image_ID)1166 gimp_image_thaw_channels (gint32 image_ID)
1167 {
1168   GimpParam *return_vals;
1169   gint nreturn_vals;
1170   gboolean success = TRUE;
1171 
1172   return_vals = gimp_run_procedure ("gimp-image-thaw-channels",
1173                                     &nreturn_vals,
1174                                     GIMP_PDB_IMAGE, image_ID,
1175                                     GIMP_PDB_END);
1176 
1177   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1178 
1179   gimp_destroy_params (return_vals, nreturn_vals);
1180 
1181   return success;
1182 }
1183 
1184 /**
1185  * gimp_image_add_vectors:
1186  * @image_ID: The image.
1187  * @vectors_ID: The vectors object.
1188  * @position: The vectors objects position.
1189  *
1190  * Deprecated: Use gimp_image_insert_vectors() instead.
1191  *
1192  * Returns: TRUE on success.
1193  **/
1194 gboolean
gimp_image_add_vectors(gint32 image_ID,gint32 vectors_ID,gint position)1195 gimp_image_add_vectors (gint32 image_ID,
1196                         gint32 vectors_ID,
1197                         gint   position)
1198 {
1199   GimpParam *return_vals;
1200   gint nreturn_vals;
1201   gboolean success = TRUE;
1202 
1203   return_vals = gimp_run_procedure ("gimp-image-add-vectors",
1204                                     &nreturn_vals,
1205                                     GIMP_PDB_IMAGE, image_ID,
1206                                     GIMP_PDB_VECTORS, vectors_ID,
1207                                     GIMP_PDB_INT32, position,
1208                                     GIMP_PDB_END);
1209 
1210   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1211 
1212   gimp_destroy_params (return_vals, nreturn_vals);
1213 
1214   return success;
1215 }
1216 
1217 /**
1218  * gimp_image_insert_vectors:
1219  * @image_ID: The image.
1220  * @vectors_ID: The vectors.
1221  * @parent_ID: The parent vectors.
1222  * @position: The vectors position.
1223  *
1224  * Add the specified vectors to the image.
1225  *
1226  * This procedure adds the specified vectors to the image at the given
1227  * position. Since vectors groups are not currently supported, the
1228  * parent argument must always be 0. The position argument specifies
1229  * the location of the vectors inside the stack, starting from the top
1230  * (0) and increasing. If the position is specified as -1, then the
1231  * vectors is inserted above the active vectors.
1232  *
1233  * Returns: TRUE on success.
1234  **/
1235 gboolean
gimp_image_insert_vectors(gint32 image_ID,gint32 vectors_ID,gint32 parent_ID,gint position)1236 gimp_image_insert_vectors (gint32 image_ID,
1237                            gint32 vectors_ID,
1238                            gint32 parent_ID,
1239                            gint   position)
1240 {
1241   GimpParam *return_vals;
1242   gint nreturn_vals;
1243   gboolean success = TRUE;
1244 
1245   return_vals = gimp_run_procedure ("gimp-image-insert-vectors",
1246                                     &nreturn_vals,
1247                                     GIMP_PDB_IMAGE, image_ID,
1248                                     GIMP_PDB_VECTORS, vectors_ID,
1249                                     GIMP_PDB_VECTORS, parent_ID,
1250                                     GIMP_PDB_INT32, position,
1251                                     GIMP_PDB_END);
1252 
1253   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1254 
1255   gimp_destroy_params (return_vals, nreturn_vals);
1256 
1257   return success;
1258 }
1259 
1260 /**
1261  * gimp_image_remove_vectors:
1262  * @image_ID: The image.
1263  * @vectors_ID: The vectors object.
1264  *
1265  * Remove the specified path from the image.
1266  *
1267  * This procedure removes the specified path from the image. If the
1268  * path doesn't exist, an error is returned.
1269  *
1270  * Returns: TRUE on success.
1271  *
1272  * Since: 2.4
1273  **/
1274 gboolean
gimp_image_remove_vectors(gint32 image_ID,gint32 vectors_ID)1275 gimp_image_remove_vectors (gint32 image_ID,
1276                            gint32 vectors_ID)
1277 {
1278   GimpParam *return_vals;
1279   gint nreturn_vals;
1280   gboolean success = TRUE;
1281 
1282   return_vals = gimp_run_procedure ("gimp-image-remove-vectors",
1283                                     &nreturn_vals,
1284                                     GIMP_PDB_IMAGE, image_ID,
1285                                     GIMP_PDB_VECTORS, vectors_ID,
1286                                     GIMP_PDB_END);
1287 
1288   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1289 
1290   gimp_destroy_params (return_vals, nreturn_vals);
1291 
1292   return success;
1293 }
1294 
1295 /**
1296  * gimp_image_freeze_vectors:
1297  * @image_ID: The image.
1298  *
1299  * Freeze the image's vectors list.
1300  *
1301  * This procedure freezes the vectors list of the image, suppressing
1302  * any updates to the Paths dialog in response to changes to the
1303  * image's vectors. This can significantly improve performance while
1304  * applying changes affecting the vectors list.
1305  *
1306  * Each call to gimp_image_freeze_vectors() should be matched by a
1307  * corresponding call to gimp_image_thaw_vectors(), undoing its
1308  * effects.
1309  *
1310  * Returns: TRUE on success.
1311  *
1312  * Since: 2.10.2
1313  **/
1314 gboolean
gimp_image_freeze_vectors(gint32 image_ID)1315 gimp_image_freeze_vectors (gint32 image_ID)
1316 {
1317   GimpParam *return_vals;
1318   gint nreturn_vals;
1319   gboolean success = TRUE;
1320 
1321   return_vals = gimp_run_procedure ("gimp-image-freeze-vectors",
1322                                     &nreturn_vals,
1323                                     GIMP_PDB_IMAGE, image_ID,
1324                                     GIMP_PDB_END);
1325 
1326   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1327 
1328   gimp_destroy_params (return_vals, nreturn_vals);
1329 
1330   return success;
1331 }
1332 
1333 /**
1334  * gimp_image_thaw_vectors:
1335  * @image_ID: The image.
1336  *
1337  * Thaw the image's vectors list.
1338  *
1339  * This procedure thaws the vectors list of the image, re-enabling
1340  * updates to the Paths dialog.
1341  *
1342  * This procedure should match a corresponding call to
1343  * gimp_image_freeze_vectors().
1344  *
1345  * Returns: TRUE on success.
1346  *
1347  * Since: 2.10.2
1348  **/
1349 gboolean
gimp_image_thaw_vectors(gint32 image_ID)1350 gimp_image_thaw_vectors (gint32 image_ID)
1351 {
1352   GimpParam *return_vals;
1353   gint nreturn_vals;
1354   gboolean success = TRUE;
1355 
1356   return_vals = gimp_run_procedure ("gimp-image-thaw-vectors",
1357                                     &nreturn_vals,
1358                                     GIMP_PDB_IMAGE, image_ID,
1359                                     GIMP_PDB_END);
1360 
1361   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1362 
1363   gimp_destroy_params (return_vals, nreturn_vals);
1364 
1365   return success;
1366 }
1367 
1368 /**
1369  * gimp_image_get_item_position:
1370  * @image_ID: The image.
1371  * @item_ID: The item.
1372  *
1373  * Returns the position of the item in its level of its item tree.
1374  *
1375  * This procedure determines the position of the specified item in its
1376  * level in its item tree in the image. If the item doesn't exist in
1377  * the image, or the item is not part of an item tree, an error is
1378  * returned.
1379  *
1380  * Returns: The position of the item in its level in the item tree.
1381  *
1382  * Since: 2.8
1383  **/
1384 gint
gimp_image_get_item_position(gint32 image_ID,gint32 item_ID)1385 gimp_image_get_item_position (gint32 image_ID,
1386                               gint32 item_ID)
1387 {
1388   GimpParam *return_vals;
1389   gint nreturn_vals;
1390   gint position = 0;
1391 
1392   return_vals = gimp_run_procedure ("gimp-image-get-item-position",
1393                                     &nreturn_vals,
1394                                     GIMP_PDB_IMAGE, image_ID,
1395                                     GIMP_PDB_ITEM, item_ID,
1396                                     GIMP_PDB_END);
1397 
1398   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
1399     position = return_vals[1].data.d_int32;
1400 
1401   gimp_destroy_params (return_vals, nreturn_vals);
1402 
1403   return position;
1404 }
1405 
1406 /**
1407  * gimp_image_raise_item:
1408  * @image_ID: The image.
1409  * @item_ID: The item to raise.
1410  *
1411  * Raise the specified item in its level in its item tree
1412  *
1413  * This procedure raises the specified item one step in the item tree.
1414  * The procedure call will fail if there is no item above it.
1415  *
1416  * Returns: TRUE on success.
1417  *
1418  * Since: 2.8
1419  **/
1420 gboolean
gimp_image_raise_item(gint32 image_ID,gint32 item_ID)1421 gimp_image_raise_item (gint32 image_ID,
1422                        gint32 item_ID)
1423 {
1424   GimpParam *return_vals;
1425   gint nreturn_vals;
1426   gboolean success = TRUE;
1427 
1428   return_vals = gimp_run_procedure ("gimp-image-raise-item",
1429                                     &nreturn_vals,
1430                                     GIMP_PDB_IMAGE, image_ID,
1431                                     GIMP_PDB_ITEM, item_ID,
1432                                     GIMP_PDB_END);
1433 
1434   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1435 
1436   gimp_destroy_params (return_vals, nreturn_vals);
1437 
1438   return success;
1439 }
1440 
1441 /**
1442  * gimp_image_lower_item:
1443  * @image_ID: The image.
1444  * @item_ID: The item to lower.
1445  *
1446  * Lower the specified item in its level in its item tree
1447  *
1448  * This procedure lowers the specified item one step in the item tree.
1449  * The procedure call will fail if there is no item below it.
1450  *
1451  * Returns: TRUE on success.
1452  *
1453  * Since: 2.8
1454  **/
1455 gboolean
gimp_image_lower_item(gint32 image_ID,gint32 item_ID)1456 gimp_image_lower_item (gint32 image_ID,
1457                        gint32 item_ID)
1458 {
1459   GimpParam *return_vals;
1460   gint nreturn_vals;
1461   gboolean success = TRUE;
1462 
1463   return_vals = gimp_run_procedure ("gimp-image-lower-item",
1464                                     &nreturn_vals,
1465                                     GIMP_PDB_IMAGE, image_ID,
1466                                     GIMP_PDB_ITEM, item_ID,
1467                                     GIMP_PDB_END);
1468 
1469   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1470 
1471   gimp_destroy_params (return_vals, nreturn_vals);
1472 
1473   return success;
1474 }
1475 
1476 /**
1477  * gimp_image_raise_item_to_top:
1478  * @image_ID: The image.
1479  * @item_ID: The item to raise to top.
1480  *
1481  * Raise the specified item to the top of its level in its item tree
1482  *
1483  * This procedure raises the specified item to top of its level in the
1484  * item tree. It will not move the item if there is no item above it.
1485  *
1486  * Returns: TRUE on success.
1487  *
1488  * Since: 2.8
1489  **/
1490 gboolean
gimp_image_raise_item_to_top(gint32 image_ID,gint32 item_ID)1491 gimp_image_raise_item_to_top (gint32 image_ID,
1492                               gint32 item_ID)
1493 {
1494   GimpParam *return_vals;
1495   gint nreturn_vals;
1496   gboolean success = TRUE;
1497 
1498   return_vals = gimp_run_procedure ("gimp-image-raise-item-to-top",
1499                                     &nreturn_vals,
1500                                     GIMP_PDB_IMAGE, image_ID,
1501                                     GIMP_PDB_ITEM, item_ID,
1502                                     GIMP_PDB_END);
1503 
1504   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1505 
1506   gimp_destroy_params (return_vals, nreturn_vals);
1507 
1508   return success;
1509 }
1510 
1511 /**
1512  * gimp_image_lower_item_to_bottom:
1513  * @image_ID: The image.
1514  * @item_ID: The item to lower to bottom.
1515  *
1516  * Lower the specified item to the bottom of its level in its item tree
1517  *
1518  * This procedure lowers the specified item to bottom of its level in
1519  * the item tree. It will not move the layer if there is no layer below
1520  * it.
1521  *
1522  * Returns: TRUE on success.
1523  *
1524  * Since: 2.8
1525  **/
1526 gboolean
gimp_image_lower_item_to_bottom(gint32 image_ID,gint32 item_ID)1527 gimp_image_lower_item_to_bottom (gint32 image_ID,
1528                                  gint32 item_ID)
1529 {
1530   GimpParam *return_vals;
1531   gint nreturn_vals;
1532   gboolean success = TRUE;
1533 
1534   return_vals = gimp_run_procedure ("gimp-image-lower-item-to-bottom",
1535                                     &nreturn_vals,
1536                                     GIMP_PDB_IMAGE, image_ID,
1537                                     GIMP_PDB_ITEM, item_ID,
1538                                     GIMP_PDB_END);
1539 
1540   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1541 
1542   gimp_destroy_params (return_vals, nreturn_vals);
1543 
1544   return success;
1545 }
1546 
1547 /**
1548  * gimp_image_reorder_item:
1549  * @image_ID: The image.
1550  * @item_ID: The item to reorder.
1551  * @parent_ID: The new parent item.
1552  * @position: The new position of the item.
1553  *
1554  * Reorder the specified item within its item tree
1555  *
1556  * This procedure reorders the specified item within its item tree.
1557  *
1558  * Returns: TRUE on success.
1559  *
1560  * Since: 2.8
1561  **/
1562 gboolean
gimp_image_reorder_item(gint32 image_ID,gint32 item_ID,gint32 parent_ID,gint position)1563 gimp_image_reorder_item (gint32 image_ID,
1564                          gint32 item_ID,
1565                          gint32 parent_ID,
1566                          gint   position)
1567 {
1568   GimpParam *return_vals;
1569   gint nreturn_vals;
1570   gboolean success = TRUE;
1571 
1572   return_vals = gimp_run_procedure ("gimp-image-reorder-item",
1573                                     &nreturn_vals,
1574                                     GIMP_PDB_IMAGE, image_ID,
1575                                     GIMP_PDB_ITEM, item_ID,
1576                                     GIMP_PDB_ITEM, parent_ID,
1577                                     GIMP_PDB_INT32, position,
1578                                     GIMP_PDB_END);
1579 
1580   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1581 
1582   gimp_destroy_params (return_vals, nreturn_vals);
1583 
1584   return success;
1585 }
1586 
1587 /**
1588  * gimp_image_flatten:
1589  * @image_ID: The image.
1590  *
1591  * Flatten all visible layers into a single layer. Discard all
1592  * invisible layers.
1593  *
1594  * This procedure combines the visible layers in a manner analogous to
1595  * merging with the CLIP_TO_IMAGE merge type. Non-visible layers are
1596  * discarded, and the resulting image is stripped of its alpha channel.
1597  *
1598  * Returns: The resulting layer.
1599  **/
1600 gint32
gimp_image_flatten(gint32 image_ID)1601 gimp_image_flatten (gint32 image_ID)
1602 {
1603   GimpParam *return_vals;
1604   gint nreturn_vals;
1605   gint32 layer_ID = -1;
1606 
1607   return_vals = gimp_run_procedure ("gimp-image-flatten",
1608                                     &nreturn_vals,
1609                                     GIMP_PDB_IMAGE, image_ID,
1610                                     GIMP_PDB_END);
1611 
1612   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
1613     layer_ID = return_vals[1].data.d_layer;
1614 
1615   gimp_destroy_params (return_vals, nreturn_vals);
1616 
1617   return layer_ID;
1618 }
1619 
1620 /**
1621  * gimp_image_merge_visible_layers:
1622  * @image_ID: The image.
1623  * @merge_type: The type of merge.
1624  *
1625  * Merge the visible image layers into one.
1626  *
1627  * This procedure combines the visible layers into a single layer using
1628  * the specified merge type. A merge type of EXPAND_AS_NECESSARY
1629  * expands the final layer to encompass the areas of the visible
1630  * layers. A merge type of CLIP_TO_IMAGE clips the final layer to the
1631  * extents of the image. A merge type of CLIP_TO_BOTTOM_LAYER clips the
1632  * final layer to the size of the bottommost layer.
1633  *
1634  * Returns: The resulting layer.
1635  **/
1636 gint32
gimp_image_merge_visible_layers(gint32 image_ID,GimpMergeType merge_type)1637 gimp_image_merge_visible_layers (gint32        image_ID,
1638                                  GimpMergeType merge_type)
1639 {
1640   GimpParam *return_vals;
1641   gint nreturn_vals;
1642   gint32 layer_ID = -1;
1643 
1644   return_vals = gimp_run_procedure ("gimp-image-merge-visible-layers",
1645                                     &nreturn_vals,
1646                                     GIMP_PDB_IMAGE, image_ID,
1647                                     GIMP_PDB_INT32, merge_type,
1648                                     GIMP_PDB_END);
1649 
1650   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
1651     layer_ID = return_vals[1].data.d_layer;
1652 
1653   gimp_destroy_params (return_vals, nreturn_vals);
1654 
1655   return layer_ID;
1656 }
1657 
1658 /**
1659  * gimp_image_merge_down:
1660  * @image_ID: The image.
1661  * @merge_layer_ID: The layer to merge down from.
1662  * @merge_type: The type of merge.
1663  *
1664  * Merge the layer passed and the first visible layer below.
1665  *
1666  * This procedure combines the passed layer and the first visible layer
1667  * below it using the specified merge type. A merge type of
1668  * EXPAND_AS_NECESSARY expands the final layer to encompass the areas
1669  * of the visible layers. A merge type of CLIP_TO_IMAGE clips the final
1670  * layer to the extents of the image. A merge type of
1671  * CLIP_TO_BOTTOM_LAYER clips the final layer to the size of the
1672  * bottommost layer.
1673  *
1674  * Returns: The resulting layer.
1675  **/
1676 gint32
gimp_image_merge_down(gint32 image_ID,gint32 merge_layer_ID,GimpMergeType merge_type)1677 gimp_image_merge_down (gint32        image_ID,
1678                        gint32        merge_layer_ID,
1679                        GimpMergeType merge_type)
1680 {
1681   GimpParam *return_vals;
1682   gint nreturn_vals;
1683   gint32 layer_ID = -1;
1684 
1685   return_vals = gimp_run_procedure ("gimp-image-merge-down",
1686                                     &nreturn_vals,
1687                                     GIMP_PDB_IMAGE, image_ID,
1688                                     GIMP_PDB_LAYER, merge_layer_ID,
1689                                     GIMP_PDB_INT32, merge_type,
1690                                     GIMP_PDB_END);
1691 
1692   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
1693     layer_ID = return_vals[1].data.d_layer;
1694 
1695   gimp_destroy_params (return_vals, nreturn_vals);
1696 
1697   return layer_ID;
1698 }
1699 
1700 /**
1701  * gimp_image_merge_layer_group:
1702  * @image_ID: The image.
1703  * @layer_group_ID: The layer group to merge.
1704  *
1705  * Merge the passed layer group's layers into one normal layer.
1706  *
1707  * This procedure combines the layers of the passed layer group into a
1708  * single normal layer, replacing the group.
1709  *
1710  * Returns: The resulting layer.
1711  *
1712  * Since: 2.10.14
1713  **/
1714 gint32
gimp_image_merge_layer_group(gint32 image_ID,gint32 layer_group_ID)1715 gimp_image_merge_layer_group (gint32 image_ID,
1716                               gint32 layer_group_ID)
1717 {
1718   GimpParam *return_vals;
1719   gint nreturn_vals;
1720   gint32 layer_ID = -1;
1721 
1722   return_vals = gimp_run_procedure ("gimp-image-merge-layer-group",
1723                                     &nreturn_vals,
1724                                     GIMP_PDB_IMAGE, image_ID,
1725                                     GIMP_PDB_LAYER, layer_group_ID,
1726                                     GIMP_PDB_END);
1727 
1728   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
1729     layer_ID = return_vals[1].data.d_layer;
1730 
1731   gimp_destroy_params (return_vals, nreturn_vals);
1732 
1733   return layer_ID;
1734 }
1735 
1736 /**
1737  * _gimp_image_get_colormap:
1738  * @image_ID: The image.
1739  * @num_bytes: Number of bytes in the colormap array.
1740  *
1741  * Returns the image's colormap
1742  *
1743  * This procedure returns an actual pointer to the image's colormap, as
1744  * well as the number of bytes contained in the colormap. The actual
1745  * number of colors in the transmitted colormap will be 'num-bytes' /
1746  * 3. If the image is not in Indexed color mode, no colormap is
1747  * returned.
1748  *
1749  * Returns: The image's colormap. The returned value must be freed with
1750  * g_free().
1751  **/
1752 guint8 *
_gimp_image_get_colormap(gint32 image_ID,gint * num_bytes)1753 _gimp_image_get_colormap (gint32  image_ID,
1754                           gint   *num_bytes)
1755 {
1756   GimpParam *return_vals;
1757   gint nreturn_vals;
1758   guint8 *colormap = NULL;
1759 
1760   return_vals = gimp_run_procedure ("gimp-image-get-colormap",
1761                                     &nreturn_vals,
1762                                     GIMP_PDB_IMAGE, image_ID,
1763                                     GIMP_PDB_END);
1764 
1765   *num_bytes = 0;
1766 
1767   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
1768     {
1769       *num_bytes = return_vals[1].data.d_int32;
1770       colormap = g_new (guint8, *num_bytes);
1771       memcpy (colormap,
1772               return_vals[2].data.d_int8array,
1773               *num_bytes * sizeof (guint8));
1774     }
1775 
1776   gimp_destroy_params (return_vals, nreturn_vals);
1777 
1778   return colormap;
1779 }
1780 
1781 /**
1782  * _gimp_image_set_colormap:
1783  * @image_ID: The image.
1784  * @num_bytes: Number of bytes in the colormap array.
1785  * @colormap: The new colormap values.
1786  *
1787  * Sets the entries in the image's colormap.
1788  *
1789  * This procedure sets the entries in the specified image's colormap.
1790  * The number of entries is specified by the 'num-bytes' parameter and
1791  * corresponds to the number of INT8 triples that must be contained in
1792  * the 'colormap' array. The actual number of colors in the transmitted
1793  * colormap is 'num-bytes' / 3.
1794  *
1795  * Returns: TRUE on success.
1796  **/
1797 gboolean
_gimp_image_set_colormap(gint32 image_ID,gint num_bytes,const guint8 * colormap)1798 _gimp_image_set_colormap (gint32        image_ID,
1799                           gint          num_bytes,
1800                           const guint8 *colormap)
1801 {
1802   GimpParam *return_vals;
1803   gint nreturn_vals;
1804   gboolean success = TRUE;
1805 
1806   return_vals = gimp_run_procedure ("gimp-image-set-colormap",
1807                                     &nreturn_vals,
1808                                     GIMP_PDB_IMAGE, image_ID,
1809                                     GIMP_PDB_INT32, num_bytes,
1810                                     GIMP_PDB_INT8ARRAY, colormap,
1811                                     GIMP_PDB_END);
1812 
1813   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1814 
1815   gimp_destroy_params (return_vals, nreturn_vals);
1816 
1817   return success;
1818 }
1819 
1820 /**
1821  * _gimp_image_get_metadata:
1822  * @image_ID: The image.
1823  *
1824  * Returns the image's metadata.
1825  *
1826  * Returns exif/iptc/xmp metadata from the image.
1827  *
1828  * Returns: The exif/ptc/xmp metadata as a string.
1829  **/
1830 gchar *
_gimp_image_get_metadata(gint32 image_ID)1831 _gimp_image_get_metadata (gint32 image_ID)
1832 {
1833   GimpParam *return_vals;
1834   gint nreturn_vals;
1835   gchar *metadata_string = NULL;
1836 
1837   return_vals = gimp_run_procedure ("gimp-image-get-metadata",
1838                                     &nreturn_vals,
1839                                     GIMP_PDB_IMAGE, image_ID,
1840                                     GIMP_PDB_END);
1841 
1842   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
1843     metadata_string = g_strdup (return_vals[1].data.d_string);
1844 
1845   gimp_destroy_params (return_vals, nreturn_vals);
1846 
1847   return metadata_string;
1848 }
1849 
1850 /**
1851  * _gimp_image_set_metadata:
1852  * @image_ID: The image.
1853  * @metadata_string: The exif/ptc/xmp metadata as a string.
1854  *
1855  * Set the image's metadata.
1856  *
1857  * Sets exif/iptc/xmp metadata on the image.
1858  *
1859  * Returns: TRUE on success.
1860  **/
1861 gboolean
_gimp_image_set_metadata(gint32 image_ID,const gchar * metadata_string)1862 _gimp_image_set_metadata (gint32       image_ID,
1863                           const gchar *metadata_string)
1864 {
1865   GimpParam *return_vals;
1866   gint nreturn_vals;
1867   gboolean success = TRUE;
1868 
1869   return_vals = gimp_run_procedure ("gimp-image-set-metadata",
1870                                     &nreturn_vals,
1871                                     GIMP_PDB_IMAGE, image_ID,
1872                                     GIMP_PDB_STRING, metadata_string,
1873                                     GIMP_PDB_END);
1874 
1875   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1876 
1877   gimp_destroy_params (return_vals, nreturn_vals);
1878 
1879   return success;
1880 }
1881 
1882 /**
1883  * gimp_image_clean_all:
1884  * @image_ID: The image.
1885  *
1886  * Set the image dirty count to 0.
1887  *
1888  * This procedure sets the specified image's dirty count to 0, allowing
1889  * operations to occur without having a 'dirtied' image. This is
1890  * especially useful for creating and loading images which should not
1891  * initially be considered dirty, even though layers must be created,
1892  * filled, and installed in the image. Note that save plug-ins must NOT
1893  * call this function themselves after saving the image.
1894  *
1895  * Returns: TRUE on success.
1896  **/
1897 gboolean
gimp_image_clean_all(gint32 image_ID)1898 gimp_image_clean_all (gint32 image_ID)
1899 {
1900   GimpParam *return_vals;
1901   gint nreturn_vals;
1902   gboolean success = TRUE;
1903 
1904   return_vals = gimp_run_procedure ("gimp-image-clean-all",
1905                                     &nreturn_vals,
1906                                     GIMP_PDB_IMAGE, image_ID,
1907                                     GIMP_PDB_END);
1908 
1909   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1910 
1911   gimp_destroy_params (return_vals, nreturn_vals);
1912 
1913   return success;
1914 }
1915 
1916 /**
1917  * gimp_image_is_dirty:
1918  * @image_ID: The image.
1919  *
1920  * Checks if the image has unsaved changes.
1921  *
1922  * This procedure checks the specified image's dirty count to see if it
1923  * needs to be saved. Note that saving the image does not automatically
1924  * set the dirty count to 0, you need to call gimp_image_clean_all()
1925  * after calling a save procedure to make the image clean.
1926  *
1927  * Returns: TRUE if the image has unsaved changes.
1928  **/
1929 gboolean
gimp_image_is_dirty(gint32 image_ID)1930 gimp_image_is_dirty (gint32 image_ID)
1931 {
1932   GimpParam *return_vals;
1933   gint nreturn_vals;
1934   gboolean dirty = FALSE;
1935 
1936   return_vals = gimp_run_procedure ("gimp-image-is-dirty",
1937                                     &nreturn_vals,
1938                                     GIMP_PDB_IMAGE, image_ID,
1939                                     GIMP_PDB_END);
1940 
1941   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
1942     dirty = return_vals[1].data.d_int32;
1943 
1944   gimp_destroy_params (return_vals, nreturn_vals);
1945 
1946   return dirty;
1947 }
1948 
1949 /**
1950  * _gimp_image_thumbnail:
1951  * @image_ID: The image.
1952  * @width: The requested thumbnail width.
1953  * @height: The requested thumbnail height.
1954  * @actual_width: The previews width.
1955  * @actual_height: The previews height.
1956  * @bpp: The previews bpp.
1957  * @thumbnail_data_count: The number of bytes in thumbnail data.
1958  * @thumbnail_data: The thumbnail data.
1959  *
1960  * Get a thumbnail of an image.
1961  *
1962  * This function gets data from which a thumbnail of an image preview
1963  * can be created. Maximum x or y dimension is 1024 pixels. The pixels
1964  * are returned in RGB[A] or GRAY[A] format. The bpp return value gives
1965  * the number of bits per pixel in the image.
1966  *
1967  * Returns: TRUE on success.
1968  **/
1969 gboolean
_gimp_image_thumbnail(gint32 image_ID,gint width,gint height,gint * actual_width,gint * actual_height,gint * bpp,gint * thumbnail_data_count,guint8 ** thumbnail_data)1970 _gimp_image_thumbnail (gint32   image_ID,
1971                        gint     width,
1972                        gint     height,
1973                        gint    *actual_width,
1974                        gint    *actual_height,
1975                        gint    *bpp,
1976                        gint    *thumbnail_data_count,
1977                        guint8 **thumbnail_data)
1978 {
1979   GimpParam *return_vals;
1980   gint nreturn_vals;
1981   gboolean success = TRUE;
1982 
1983   return_vals = gimp_run_procedure ("gimp-image-thumbnail",
1984                                     &nreturn_vals,
1985                                     GIMP_PDB_IMAGE, image_ID,
1986                                     GIMP_PDB_INT32, width,
1987                                     GIMP_PDB_INT32, height,
1988                                     GIMP_PDB_END);
1989 
1990   *actual_width = 0;
1991   *actual_height = 0;
1992   *bpp = 0;
1993   *thumbnail_data_count = 0;
1994   *thumbnail_data = NULL;
1995 
1996   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1997 
1998   if (success)
1999     {
2000       *actual_width = return_vals[1].data.d_int32;
2001       *actual_height = return_vals[2].data.d_int32;
2002       *bpp = return_vals[3].data.d_int32;
2003       *thumbnail_data_count = return_vals[4].data.d_int32;
2004       *thumbnail_data = g_new (guint8, *thumbnail_data_count);
2005       memcpy (*thumbnail_data,
2006               return_vals[5].data.d_int8array,
2007               *thumbnail_data_count * sizeof (guint8));
2008     }
2009 
2010   gimp_destroy_params (return_vals, nreturn_vals);
2011 
2012   return success;
2013 }
2014 
2015 /**
2016  * gimp_image_get_active_layer:
2017  * @image_ID: The image.
2018  *
2019  * Returns the specified image's active layer.
2020  *
2021  * If there is an active layer, its ID will be returned, otherwise, -1.
2022  * If a channel is currently active, then no layer will be. If a layer
2023  * mask is active, then this will return the associated layer.
2024  *
2025  * Returns: The active layer.
2026  **/
2027 gint32
gimp_image_get_active_layer(gint32 image_ID)2028 gimp_image_get_active_layer (gint32 image_ID)
2029 {
2030   GimpParam *return_vals;
2031   gint nreturn_vals;
2032   gint32 active_layer_ID = -1;
2033 
2034   return_vals = gimp_run_procedure ("gimp-image-get-active-layer",
2035                                     &nreturn_vals,
2036                                     GIMP_PDB_IMAGE, image_ID,
2037                                     GIMP_PDB_END);
2038 
2039   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2040     active_layer_ID = return_vals[1].data.d_layer;
2041 
2042   gimp_destroy_params (return_vals, nreturn_vals);
2043 
2044   return active_layer_ID;
2045 }
2046 
2047 /**
2048  * gimp_image_set_active_layer:
2049  * @image_ID: The image.
2050  * @active_layer_ID: The new image active layer.
2051  *
2052  * Sets the specified image's active layer.
2053  *
2054  * If the layer exists, it is set as the active layer in the image. Any
2055  * previous active layer or channel is set to inactive. An exception is
2056  * a previously existing floating selection, in which case this
2057  * procedure will return an execution error.
2058  *
2059  * Returns: TRUE on success.
2060  **/
2061 gboolean
gimp_image_set_active_layer(gint32 image_ID,gint32 active_layer_ID)2062 gimp_image_set_active_layer (gint32 image_ID,
2063                              gint32 active_layer_ID)
2064 {
2065   GimpParam *return_vals;
2066   gint nreturn_vals;
2067   gboolean success = TRUE;
2068 
2069   return_vals = gimp_run_procedure ("gimp-image-set-active-layer",
2070                                     &nreturn_vals,
2071                                     GIMP_PDB_IMAGE, image_ID,
2072                                     GIMP_PDB_LAYER, active_layer_ID,
2073                                     GIMP_PDB_END);
2074 
2075   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
2076 
2077   gimp_destroy_params (return_vals, nreturn_vals);
2078 
2079   return success;
2080 }
2081 
2082 /**
2083  * gimp_image_get_active_channel:
2084  * @image_ID: The image.
2085  *
2086  * Returns the specified image's active channel.
2087  *
2088  * If there is an active channel, this will return the channel ID,
2089  * otherwise, -1.
2090  *
2091  * Returns: The active channel.
2092  **/
2093 gint32
gimp_image_get_active_channel(gint32 image_ID)2094 gimp_image_get_active_channel (gint32 image_ID)
2095 {
2096   GimpParam *return_vals;
2097   gint nreturn_vals;
2098   gint32 active_channel_ID = -1;
2099 
2100   return_vals = gimp_run_procedure ("gimp-image-get-active-channel",
2101                                     &nreturn_vals,
2102                                     GIMP_PDB_IMAGE, image_ID,
2103                                     GIMP_PDB_END);
2104 
2105   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2106     active_channel_ID = return_vals[1].data.d_channel;
2107 
2108   gimp_destroy_params (return_vals, nreturn_vals);
2109 
2110   return active_channel_ID;
2111 }
2112 
2113 /**
2114  * gimp_image_set_active_channel:
2115  * @image_ID: The image.
2116  * @active_channel_ID: The new image active channel.
2117  *
2118  * Sets the specified image's active channel.
2119  *
2120  * If the channel exists, it is set as the active channel in the image.
2121  * Any previous active channel or layer is set to inactive. An
2122  * exception is a previously existing floating selection, in which case
2123  * this procedure will return an execution error.
2124  *
2125  * Returns: TRUE on success.
2126  **/
2127 gboolean
gimp_image_set_active_channel(gint32 image_ID,gint32 active_channel_ID)2128 gimp_image_set_active_channel (gint32 image_ID,
2129                                gint32 active_channel_ID)
2130 {
2131   GimpParam *return_vals;
2132   gint nreturn_vals;
2133   gboolean success = TRUE;
2134 
2135   return_vals = gimp_run_procedure ("gimp-image-set-active-channel",
2136                                     &nreturn_vals,
2137                                     GIMP_PDB_IMAGE, image_ID,
2138                                     GIMP_PDB_CHANNEL, active_channel_ID,
2139                                     GIMP_PDB_END);
2140 
2141   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
2142 
2143   gimp_destroy_params (return_vals, nreturn_vals);
2144 
2145   return success;
2146 }
2147 
2148 /**
2149  * gimp_image_get_active_vectors:
2150  * @image_ID: The image.
2151  *
2152  * Returns the specified image's active vectors.
2153  *
2154  * If there is an active path, its ID will be returned, otherwise, -1.
2155  *
2156  * Returns: The active vectors.
2157  **/
2158 gint32
gimp_image_get_active_vectors(gint32 image_ID)2159 gimp_image_get_active_vectors (gint32 image_ID)
2160 {
2161   GimpParam *return_vals;
2162   gint nreturn_vals;
2163   gint32 active_vectors_ID = -1;
2164 
2165   return_vals = gimp_run_procedure ("gimp-image-get-active-vectors",
2166                                     &nreturn_vals,
2167                                     GIMP_PDB_IMAGE, image_ID,
2168                                     GIMP_PDB_END);
2169 
2170   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2171     active_vectors_ID = return_vals[1].data.d_vectors;
2172 
2173   gimp_destroy_params (return_vals, nreturn_vals);
2174 
2175   return active_vectors_ID;
2176 }
2177 
2178 /**
2179  * gimp_image_set_active_vectors:
2180  * @image_ID: The image.
2181  * @active_vectors_ID: The new image active vectors.
2182  *
2183  * Sets the specified image's active vectors.
2184  *
2185  * If the path exists, it is set as the active path in the image.
2186  *
2187  * Returns: TRUE on success.
2188  **/
2189 gboolean
gimp_image_set_active_vectors(gint32 image_ID,gint32 active_vectors_ID)2190 gimp_image_set_active_vectors (gint32 image_ID,
2191                                gint32 active_vectors_ID)
2192 {
2193   GimpParam *return_vals;
2194   gint nreturn_vals;
2195   gboolean success = TRUE;
2196 
2197   return_vals = gimp_run_procedure ("gimp-image-set-active-vectors",
2198                                     &nreturn_vals,
2199                                     GIMP_PDB_IMAGE, image_ID,
2200                                     GIMP_PDB_VECTORS, active_vectors_ID,
2201                                     GIMP_PDB_END);
2202 
2203   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
2204 
2205   gimp_destroy_params (return_vals, nreturn_vals);
2206 
2207   return success;
2208 }
2209 
2210 /**
2211  * gimp_image_get_selection:
2212  * @image_ID: The image.
2213  *
2214  * Returns the specified image's selection.
2215  *
2216  * This will always return a valid ID for a selection -- which is
2217  * represented as a channel internally.
2218  *
2219  * Returns: The selection channel.
2220  **/
2221 gint32
gimp_image_get_selection(gint32 image_ID)2222 gimp_image_get_selection (gint32 image_ID)
2223 {
2224   GimpParam *return_vals;
2225   gint nreturn_vals;
2226   gint32 selection_ID = -1;
2227 
2228   return_vals = gimp_run_procedure ("gimp-image-get-selection",
2229                                     &nreturn_vals,
2230                                     GIMP_PDB_IMAGE, image_ID,
2231                                     GIMP_PDB_END);
2232 
2233   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2234     selection_ID = return_vals[1].data.d_selection;
2235 
2236   gimp_destroy_params (return_vals, nreturn_vals);
2237 
2238   return selection_ID;
2239 }
2240 
2241 /**
2242  * gimp_image_get_component_active:
2243  * @image_ID: The image.
2244  * @component: The image component.
2245  *
2246  * Returns if the specified image's image component is active.
2247  *
2248  * This procedure returns if the specified image's image component
2249  * (i.e. Red, Green, Blue intensity channels in an RGB image) is active
2250  * or inactive -- whether or not it can be modified. If the specified
2251  * component is not valid for the image type, an error is returned.
2252  *
2253  * Returns: Component is active.
2254  **/
2255 gboolean
gimp_image_get_component_active(gint32 image_ID,GimpChannelType component)2256 gimp_image_get_component_active (gint32          image_ID,
2257                                  GimpChannelType component)
2258 {
2259   GimpParam *return_vals;
2260   gint nreturn_vals;
2261   gboolean active = FALSE;
2262 
2263   return_vals = gimp_run_procedure ("gimp-image-get-component-active",
2264                                     &nreturn_vals,
2265                                     GIMP_PDB_IMAGE, image_ID,
2266                                     GIMP_PDB_INT32, component,
2267                                     GIMP_PDB_END);
2268 
2269   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2270     active = return_vals[1].data.d_int32;
2271 
2272   gimp_destroy_params (return_vals, nreturn_vals);
2273 
2274   return active;
2275 }
2276 
2277 /**
2278  * gimp_image_set_component_active:
2279  * @image_ID: The image.
2280  * @component: The image component.
2281  * @active: Component is active.
2282  *
2283  * Sets if the specified image's image component is active.
2284  *
2285  * This procedure sets if the specified image's image component (i.e.
2286  * Red, Green, Blue intensity channels in an RGB image) is active or
2287  * inactive -- whether or not it can be modified. If the specified
2288  * component is not valid for the image type, an error is returned.
2289  *
2290  * Returns: TRUE on success.
2291  **/
2292 gboolean
gimp_image_set_component_active(gint32 image_ID,GimpChannelType component,gboolean active)2293 gimp_image_set_component_active (gint32          image_ID,
2294                                  GimpChannelType component,
2295                                  gboolean        active)
2296 {
2297   GimpParam *return_vals;
2298   gint nreturn_vals;
2299   gboolean success = TRUE;
2300 
2301   return_vals = gimp_run_procedure ("gimp-image-set-component-active",
2302                                     &nreturn_vals,
2303                                     GIMP_PDB_IMAGE, image_ID,
2304                                     GIMP_PDB_INT32, component,
2305                                     GIMP_PDB_INT32, active,
2306                                     GIMP_PDB_END);
2307 
2308   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
2309 
2310   gimp_destroy_params (return_vals, nreturn_vals);
2311 
2312   return success;
2313 }
2314 
2315 /**
2316  * gimp_image_get_component_visible:
2317  * @image_ID: The image.
2318  * @component: The image component.
2319  *
2320  * Returns if the specified image's image component is visible.
2321  *
2322  * This procedure returns if the specified image's image component
2323  * (i.e. Red, Green, Blue intensity channels in an RGB image) is
2324  * visible or invisible -- whether or not it can be seen. If the
2325  * specified component is not valid for the image type, an error is
2326  * returned.
2327  *
2328  * Returns: Component is visible.
2329  **/
2330 gboolean
gimp_image_get_component_visible(gint32 image_ID,GimpChannelType component)2331 gimp_image_get_component_visible (gint32          image_ID,
2332                                   GimpChannelType component)
2333 {
2334   GimpParam *return_vals;
2335   gint nreturn_vals;
2336   gboolean visible = FALSE;
2337 
2338   return_vals = gimp_run_procedure ("gimp-image-get-component-visible",
2339                                     &nreturn_vals,
2340                                     GIMP_PDB_IMAGE, image_ID,
2341                                     GIMP_PDB_INT32, component,
2342                                     GIMP_PDB_END);
2343 
2344   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2345     visible = return_vals[1].data.d_int32;
2346 
2347   gimp_destroy_params (return_vals, nreturn_vals);
2348 
2349   return visible;
2350 }
2351 
2352 /**
2353  * gimp_image_set_component_visible:
2354  * @image_ID: The image.
2355  * @component: The image component.
2356  * @visible: Component is visible.
2357  *
2358  * Sets if the specified image's image component is visible.
2359  *
2360  * This procedure sets if the specified image's image component (i.e.
2361  * Red, Green, Blue intensity channels in an RGB image) is visible or
2362  * invisible -- whether or not it can be seen. If the specified
2363  * component is not valid for the image type, an error is returned.
2364  *
2365  * Returns: TRUE on success.
2366  **/
2367 gboolean
gimp_image_set_component_visible(gint32 image_ID,GimpChannelType component,gboolean visible)2368 gimp_image_set_component_visible (gint32          image_ID,
2369                                   GimpChannelType component,
2370                                   gboolean        visible)
2371 {
2372   GimpParam *return_vals;
2373   gint nreturn_vals;
2374   gboolean success = TRUE;
2375 
2376   return_vals = gimp_run_procedure ("gimp-image-set-component-visible",
2377                                     &nreturn_vals,
2378                                     GIMP_PDB_IMAGE, image_ID,
2379                                     GIMP_PDB_INT32, component,
2380                                     GIMP_PDB_INT32, visible,
2381                                     GIMP_PDB_END);
2382 
2383   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
2384 
2385   gimp_destroy_params (return_vals, nreturn_vals);
2386 
2387   return success;
2388 }
2389 
2390 /**
2391  * gimp_image_get_filename:
2392  * @image_ID: The image.
2393  *
2394  * Returns the specified image's filename.
2395  *
2396  * This procedure returns the specified image's filename in the
2397  * filesystem encoding. The image has a filename only if it was loaded
2398  * or imported from a file or has since been saved or exported.
2399  * Otherwise, this function returns %NULL. See also
2400  * gimp_image_get_uri().
2401  *
2402  * Returns: The filename. The returned value must be freed with
2403  * g_free().
2404  **/
2405 gchar *
gimp_image_get_filename(gint32 image_ID)2406 gimp_image_get_filename (gint32 image_ID)
2407 {
2408   GimpParam *return_vals;
2409   gint nreturn_vals;
2410   gchar *filename = NULL;
2411 
2412   return_vals = gimp_run_procedure ("gimp-image-get-filename",
2413                                     &nreturn_vals,
2414                                     GIMP_PDB_IMAGE, image_ID,
2415                                     GIMP_PDB_END);
2416 
2417   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2418     filename = g_strdup (return_vals[1].data.d_string);
2419 
2420   gimp_destroy_params (return_vals, nreturn_vals);
2421 
2422   return filename;
2423 }
2424 
2425 /**
2426  * gimp_image_set_filename:
2427  * @image_ID: The image.
2428  * @filename: The new image filename.
2429  *
2430  * Sets the specified image's filename.
2431  *
2432  * This procedure sets the specified image's filename. The filename
2433  * should be in the filesystem encoding.
2434  *
2435  * Returns: TRUE on success.
2436  **/
2437 gboolean
gimp_image_set_filename(gint32 image_ID,const gchar * filename)2438 gimp_image_set_filename (gint32       image_ID,
2439                          const gchar *filename)
2440 {
2441   GimpParam *return_vals;
2442   gint nreturn_vals;
2443   gboolean success = TRUE;
2444 
2445   return_vals = gimp_run_procedure ("gimp-image-set-filename",
2446                                     &nreturn_vals,
2447                                     GIMP_PDB_IMAGE, image_ID,
2448                                     GIMP_PDB_STRING, filename,
2449                                     GIMP_PDB_END);
2450 
2451   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
2452 
2453   gimp_destroy_params (return_vals, nreturn_vals);
2454 
2455   return success;
2456 }
2457 
2458 /**
2459  * gimp_image_get_uri:
2460  * @image_ID: The image.
2461  *
2462  * Returns the URI for the specified image.
2463  *
2464  * This procedure returns the URI associated with the specified image.
2465  * The image has an URI only if it was loaded or imported from a file
2466  * or has since been saved or exported. Otherwise, this function
2467  * returns %NULL. See also gimp-image-get-imported-uri to get the URI
2468  * of the current file if it was imported from a non-GIMP file format
2469  * and not yet saved, or gimp-image-get-exported-uri if the image has
2470  * been exported to a non-GIMP file format.
2471  *
2472  * Returns: The URI. The returned value must be freed with g_free().
2473  *
2474  * Since: 2.8
2475  **/
2476 gchar *
gimp_image_get_uri(gint32 image_ID)2477 gimp_image_get_uri (gint32 image_ID)
2478 {
2479   GimpParam *return_vals;
2480   gint nreturn_vals;
2481   gchar *uri = NULL;
2482 
2483   return_vals = gimp_run_procedure ("gimp-image-get-uri",
2484                                     &nreturn_vals,
2485                                     GIMP_PDB_IMAGE, image_ID,
2486                                     GIMP_PDB_END);
2487 
2488   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2489     uri = g_strdup (return_vals[1].data.d_string);
2490 
2491   gimp_destroy_params (return_vals, nreturn_vals);
2492 
2493   return uri;
2494 }
2495 
2496 /**
2497  * gimp_image_get_xcf_uri:
2498  * @image_ID: The image.
2499  *
2500  * Returns the XCF URI for the specified image.
2501  *
2502  * This procedure returns the XCF URI associated with the image. If
2503  * there is no such URI, this procedure returns %NULL.
2504  *
2505  * Returns: The imported URI. The returned value must be freed with
2506  * g_free().
2507  *
2508  * Since: 2.8
2509  **/
2510 gchar *
gimp_image_get_xcf_uri(gint32 image_ID)2511 gimp_image_get_xcf_uri (gint32 image_ID)
2512 {
2513   GimpParam *return_vals;
2514   gint nreturn_vals;
2515   gchar *uri = NULL;
2516 
2517   return_vals = gimp_run_procedure ("gimp-image-get-xcf-uri",
2518                                     &nreturn_vals,
2519                                     GIMP_PDB_IMAGE, image_ID,
2520                                     GIMP_PDB_END);
2521 
2522   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2523     uri = g_strdup (return_vals[1].data.d_string);
2524 
2525   gimp_destroy_params (return_vals, nreturn_vals);
2526 
2527   return uri;
2528 }
2529 
2530 /**
2531  * gimp_image_get_imported_uri:
2532  * @image_ID: The image.
2533  *
2534  * Returns the imported URI for the specified image.
2535  *
2536  * This procedure returns the URI associated with the specified image
2537  * if the image was imported from a non-native Gimp format. If the
2538  * image was not imported, or has since been saved in the native Gimp
2539  * format, this procedure returns %NULL.
2540  *
2541  * Returns: The imported URI. The returned value must be freed with
2542  * g_free().
2543  *
2544  * Since: 2.8
2545  **/
2546 gchar *
gimp_image_get_imported_uri(gint32 image_ID)2547 gimp_image_get_imported_uri (gint32 image_ID)
2548 {
2549   GimpParam *return_vals;
2550   gint nreturn_vals;
2551   gchar *uri = NULL;
2552 
2553   return_vals = gimp_run_procedure ("gimp-image-get-imported-uri",
2554                                     &nreturn_vals,
2555                                     GIMP_PDB_IMAGE, image_ID,
2556                                     GIMP_PDB_END);
2557 
2558   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2559     uri = g_strdup (return_vals[1].data.d_string);
2560 
2561   gimp_destroy_params (return_vals, nreturn_vals);
2562 
2563   return uri;
2564 }
2565 
2566 /**
2567  * gimp_image_get_exported_uri:
2568  * @image_ID: The image.
2569  *
2570  * Returns the exported URI for the specified image.
2571  *
2572  * This procedure returns the URI associated with the specified image
2573  * if the image was exported a non-native GIMP format. If the image was
2574  * not exported, this procedure returns %NULL.
2575  *
2576  * Returns: The exported URI. The returned value must be freed with
2577  * g_free().
2578  *
2579  * Since: 2.8
2580  **/
2581 gchar *
gimp_image_get_exported_uri(gint32 image_ID)2582 gimp_image_get_exported_uri (gint32 image_ID)
2583 {
2584   GimpParam *return_vals;
2585   gint nreturn_vals;
2586   gchar *uri = NULL;
2587 
2588   return_vals = gimp_run_procedure ("gimp-image-get-exported-uri",
2589                                     &nreturn_vals,
2590                                     GIMP_PDB_IMAGE, image_ID,
2591                                     GIMP_PDB_END);
2592 
2593   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2594     uri = g_strdup (return_vals[1].data.d_string);
2595 
2596   gimp_destroy_params (return_vals, nreturn_vals);
2597 
2598   return uri;
2599 }
2600 
2601 /**
2602  * gimp_image_get_name:
2603  * @image_ID: The image.
2604  *
2605  * Returns the specified image's name.
2606  *
2607  * This procedure returns the image's name. If the image has a filename
2608  * or an URI, then the returned name contains the filename's or URI's
2609  * base name (the last component of the path). Otherwise it is the
2610  * translated string \"Untitled\". The returned name is formatted like
2611  * the image name in the image window title, it may contain '[]',
2612  * '(imported)' etc. and should only be used to label user interface
2613  * elements. Never use it to construct filenames.
2614  *
2615  * Returns: The name. The returned value must be freed with g_free().
2616  **/
2617 gchar *
gimp_image_get_name(gint32 image_ID)2618 gimp_image_get_name (gint32 image_ID)
2619 {
2620   GimpParam *return_vals;
2621   gint nreturn_vals;
2622   gchar *name = NULL;
2623 
2624   return_vals = gimp_run_procedure ("gimp-image-get-name",
2625                                     &nreturn_vals,
2626                                     GIMP_PDB_IMAGE, image_ID,
2627                                     GIMP_PDB_END);
2628 
2629   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2630     name = g_strdup (return_vals[1].data.d_string);
2631 
2632   gimp_destroy_params (return_vals, nreturn_vals);
2633 
2634   return name;
2635 }
2636 
2637 /**
2638  * gimp_image_get_resolution:
2639  * @image_ID: The image.
2640  * @xresolution: The resolution in the x-axis, in dots per inch.
2641  * @yresolution: The resolution in the y-axis, in dots per inch.
2642  *
2643  * Returns the specified image's resolution.
2644  *
2645  * This procedure returns the specified image's resolution in dots per
2646  * inch. This value is independent of any of the layers in this image.
2647  *
2648  * Returns: TRUE on success.
2649  **/
2650 gboolean
gimp_image_get_resolution(gint32 image_ID,gdouble * xresolution,gdouble * yresolution)2651 gimp_image_get_resolution (gint32   image_ID,
2652                            gdouble *xresolution,
2653                            gdouble *yresolution)
2654 {
2655   GimpParam *return_vals;
2656   gint nreturn_vals;
2657   gboolean success = TRUE;
2658 
2659   return_vals = gimp_run_procedure ("gimp-image-get-resolution",
2660                                     &nreturn_vals,
2661                                     GIMP_PDB_IMAGE, image_ID,
2662                                     GIMP_PDB_END);
2663 
2664   *xresolution = 0.0;
2665   *yresolution = 0.0;
2666 
2667   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
2668 
2669   if (success)
2670     {
2671       *xresolution = return_vals[1].data.d_float;
2672       *yresolution = return_vals[2].data.d_float;
2673     }
2674 
2675   gimp_destroy_params (return_vals, nreturn_vals);
2676 
2677   return success;
2678 }
2679 
2680 /**
2681  * gimp_image_set_resolution:
2682  * @image_ID: The image.
2683  * @xresolution: The new image resolution in the x-axis, in dots per inch.
2684  * @yresolution: The new image resolution in the y-axis, in dots per inch.
2685  *
2686  * Sets the specified image's resolution.
2687  *
2688  * This procedure sets the specified image's resolution in dots per
2689  * inch. This value is independent of any of the layers in this image.
2690  * No scaling or resizing is performed.
2691  *
2692  * Returns: TRUE on success.
2693  **/
2694 gboolean
gimp_image_set_resolution(gint32 image_ID,gdouble xresolution,gdouble yresolution)2695 gimp_image_set_resolution (gint32  image_ID,
2696                            gdouble xresolution,
2697                            gdouble yresolution)
2698 {
2699   GimpParam *return_vals;
2700   gint nreturn_vals;
2701   gboolean success = TRUE;
2702 
2703   return_vals = gimp_run_procedure ("gimp-image-set-resolution",
2704                                     &nreturn_vals,
2705                                     GIMP_PDB_IMAGE, image_ID,
2706                                     GIMP_PDB_FLOAT, xresolution,
2707                                     GIMP_PDB_FLOAT, yresolution,
2708                                     GIMP_PDB_END);
2709 
2710   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
2711 
2712   gimp_destroy_params (return_vals, nreturn_vals);
2713 
2714   return success;
2715 }
2716 
2717 /**
2718  * gimp_image_get_unit:
2719  * @image_ID: The image.
2720  *
2721  * Returns the specified image's unit.
2722  *
2723  * This procedure returns the specified image's unit. This value is
2724  * independent of any of the layers in this image. See the
2725  * gimp_unit_*() procedure definitions for the valid range of unit IDs
2726  * and a description of the unit system.
2727  *
2728  * Returns: The unit.
2729  **/
2730 GimpUnit
gimp_image_get_unit(gint32 image_ID)2731 gimp_image_get_unit (gint32 image_ID)
2732 {
2733   GimpParam *return_vals;
2734   gint nreturn_vals;
2735   GimpUnit unit = 0;
2736 
2737   return_vals = gimp_run_procedure ("gimp-image-get-unit",
2738                                     &nreturn_vals,
2739                                     GIMP_PDB_IMAGE, image_ID,
2740                                     GIMP_PDB_END);
2741 
2742   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2743     unit = return_vals[1].data.d_unit;
2744 
2745   gimp_destroy_params (return_vals, nreturn_vals);
2746 
2747   return unit;
2748 }
2749 
2750 /**
2751  * gimp_image_set_unit:
2752  * @image_ID: The image.
2753  * @unit: The new image unit.
2754  *
2755  * Sets the specified image's unit.
2756  *
2757  * This procedure sets the specified image's unit. No scaling or
2758  * resizing is performed. This value is independent of any of the
2759  * layers in this image. See the gimp_unit_*() procedure definitions
2760  * for the valid range of unit IDs and a description of the unit
2761  * system.
2762  *
2763  * Returns: TRUE on success.
2764  **/
2765 gboolean
gimp_image_set_unit(gint32 image_ID,GimpUnit unit)2766 gimp_image_set_unit (gint32   image_ID,
2767                      GimpUnit unit)
2768 {
2769   GimpParam *return_vals;
2770   gint nreturn_vals;
2771   gboolean success = TRUE;
2772 
2773   return_vals = gimp_run_procedure ("gimp-image-set-unit",
2774                                     &nreturn_vals,
2775                                     GIMP_PDB_IMAGE, image_ID,
2776                                     GIMP_PDB_INT32, unit,
2777                                     GIMP_PDB_END);
2778 
2779   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
2780 
2781   gimp_destroy_params (return_vals, nreturn_vals);
2782 
2783   return success;
2784 }
2785 
2786 /**
2787  * gimp_image_get_tattoo_state:
2788  * @image_ID: The image.
2789  *
2790  * Returns the tattoo state associated with the image.
2791  *
2792  * This procedure returns the tattoo state of the image. Use only by
2793  * save/load plug-ins that wish to preserve an images tattoo state.
2794  * Using this function at other times will produce unexpected results.
2795  *
2796  * Returns: The tattoo state.
2797  **/
2798 gint
gimp_image_get_tattoo_state(gint32 image_ID)2799 gimp_image_get_tattoo_state (gint32 image_ID)
2800 {
2801   GimpParam *return_vals;
2802   gint nreturn_vals;
2803   gint tattoo_state = 0;
2804 
2805   return_vals = gimp_run_procedure ("gimp-image-get-tattoo-state",
2806                                     &nreturn_vals,
2807                                     GIMP_PDB_IMAGE, image_ID,
2808                                     GIMP_PDB_END);
2809 
2810   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2811     tattoo_state = return_vals[1].data.d_tattoo;
2812 
2813   gimp_destroy_params (return_vals, nreturn_vals);
2814 
2815   return tattoo_state;
2816 }
2817 
2818 /**
2819  * gimp_image_set_tattoo_state:
2820  * @image_ID: The image.
2821  * @tattoo_state: The new image tattoo state.
2822  *
2823  * Set the tattoo state associated with the image.
2824  *
2825  * This procedure sets the tattoo state of the image. Use only by
2826  * save/load plug-ins that wish to preserve an images tattoo state.
2827  * Using this function at other times will produce unexpected results.
2828  * A full check of uniqueness of states in layers, channels and paths
2829  * will be performed by this procedure and a execution failure will be
2830  * returned if this fails. A failure will also be returned if the new
2831  * tattoo state value is less than the maximum tattoo value from all of
2832  * the tattoos from the paths, layers and channels. After the image
2833  * data has been loaded and all the tattoos have been set then this is
2834  * the last procedure that should be called. If effectively does a
2835  * status check on the tattoo values that have been set to make sure
2836  * that all is OK.
2837  *
2838  * Returns: TRUE on success.
2839  **/
2840 gboolean
gimp_image_set_tattoo_state(gint32 image_ID,gint tattoo_state)2841 gimp_image_set_tattoo_state (gint32 image_ID,
2842                              gint   tattoo_state)
2843 {
2844   GimpParam *return_vals;
2845   gint nreturn_vals;
2846   gboolean success = TRUE;
2847 
2848   return_vals = gimp_run_procedure ("gimp-image-set-tattoo-state",
2849                                     &nreturn_vals,
2850                                     GIMP_PDB_IMAGE, image_ID,
2851                                     GIMP_PDB_INT32, tattoo_state,
2852                                     GIMP_PDB_END);
2853 
2854   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
2855 
2856   gimp_destroy_params (return_vals, nreturn_vals);
2857 
2858   return success;
2859 }
2860 
2861 /**
2862  * gimp_image_get_layer_by_tattoo:
2863  * @image_ID: The image.
2864  * @tattoo: The tattoo of the layer to find.
2865  *
2866  * Find a layer with a given tattoo in an image.
2867  *
2868  * This procedure returns the layer with the given tattoo in the
2869  * specified image.
2870  *
2871  * Returns: The layer with the specified tattoo.
2872  **/
2873 gint32
gimp_image_get_layer_by_tattoo(gint32 image_ID,gint tattoo)2874 gimp_image_get_layer_by_tattoo (gint32 image_ID,
2875                                 gint   tattoo)
2876 {
2877   GimpParam *return_vals;
2878   gint nreturn_vals;
2879   gint32 layer_ID = -1;
2880 
2881   return_vals = gimp_run_procedure ("gimp-image-get-layer-by-tattoo",
2882                                     &nreturn_vals,
2883                                     GIMP_PDB_IMAGE, image_ID,
2884                                     GIMP_PDB_INT32, tattoo,
2885                                     GIMP_PDB_END);
2886 
2887   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2888     layer_ID = return_vals[1].data.d_layer;
2889 
2890   gimp_destroy_params (return_vals, nreturn_vals);
2891 
2892   return layer_ID;
2893 }
2894 
2895 /**
2896  * gimp_image_get_channel_by_tattoo:
2897  * @image_ID: The image.
2898  * @tattoo: The tattoo of the channel to find.
2899  *
2900  * Find a channel with a given tattoo in an image.
2901  *
2902  * This procedure returns the channel with the given tattoo in the
2903  * specified image.
2904  *
2905  * Returns: The channel with the specified tattoo.
2906  **/
2907 gint32
gimp_image_get_channel_by_tattoo(gint32 image_ID,gint tattoo)2908 gimp_image_get_channel_by_tattoo (gint32 image_ID,
2909                                   gint   tattoo)
2910 {
2911   GimpParam *return_vals;
2912   gint nreturn_vals;
2913   gint32 channel_ID = -1;
2914 
2915   return_vals = gimp_run_procedure ("gimp-image-get-channel-by-tattoo",
2916                                     &nreturn_vals,
2917                                     GIMP_PDB_IMAGE, image_ID,
2918                                     GIMP_PDB_INT32, tattoo,
2919                                     GIMP_PDB_END);
2920 
2921   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2922     channel_ID = return_vals[1].data.d_channel;
2923 
2924   gimp_destroy_params (return_vals, nreturn_vals);
2925 
2926   return channel_ID;
2927 }
2928 
2929 /**
2930  * gimp_image_get_vectors_by_tattoo:
2931  * @image_ID: The image.
2932  * @tattoo: The tattoo of the vectors to find.
2933  *
2934  * Find a vectors with a given tattoo in an image.
2935  *
2936  * This procedure returns the vectors with the given tattoo in the
2937  * specified image.
2938  *
2939  * Returns: The vectors with the specified tattoo.
2940  *
2941  * Since: 2.6
2942  **/
2943 gint32
gimp_image_get_vectors_by_tattoo(gint32 image_ID,gint tattoo)2944 gimp_image_get_vectors_by_tattoo (gint32 image_ID,
2945                                   gint   tattoo)
2946 {
2947   GimpParam *return_vals;
2948   gint nreturn_vals;
2949   gint32 vectors_ID = -1;
2950 
2951   return_vals = gimp_run_procedure ("gimp-image-get-vectors-by-tattoo",
2952                                     &nreturn_vals,
2953                                     GIMP_PDB_IMAGE, image_ID,
2954                                     GIMP_PDB_INT32, tattoo,
2955                                     GIMP_PDB_END);
2956 
2957   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2958     vectors_ID = return_vals[1].data.d_vectors;
2959 
2960   gimp_destroy_params (return_vals, nreturn_vals);
2961 
2962   return vectors_ID;
2963 }
2964 
2965 /**
2966  * gimp_image_get_layer_by_name:
2967  * @image_ID: The image.
2968  * @name: The name of the layer to find.
2969  *
2970  * Find a layer with a given name in an image.
2971  *
2972  * This procedure returns the layer with the given name in the
2973  * specified image.
2974  *
2975  * Returns: The layer with the specified name.
2976  *
2977  * Since: 2.8
2978  **/
2979 gint32
gimp_image_get_layer_by_name(gint32 image_ID,const gchar * name)2980 gimp_image_get_layer_by_name (gint32       image_ID,
2981                               const gchar *name)
2982 {
2983   GimpParam *return_vals;
2984   gint nreturn_vals;
2985   gint32 layer_ID = -1;
2986 
2987   return_vals = gimp_run_procedure ("gimp-image-get-layer-by-name",
2988                                     &nreturn_vals,
2989                                     GIMP_PDB_IMAGE, image_ID,
2990                                     GIMP_PDB_STRING, name,
2991                                     GIMP_PDB_END);
2992 
2993   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
2994     layer_ID = return_vals[1].data.d_layer;
2995 
2996   gimp_destroy_params (return_vals, nreturn_vals);
2997 
2998   return layer_ID;
2999 }
3000 
3001 /**
3002  * gimp_image_get_channel_by_name:
3003  * @image_ID: The image.
3004  * @name: The name of the channel to find.
3005  *
3006  * Find a channel with a given name in an image.
3007  *
3008  * This procedure returns the channel with the given name in the
3009  * specified image.
3010  *
3011  * Returns: The channel with the specified name.
3012  *
3013  * Since: 2.8
3014  **/
3015 gint32
gimp_image_get_channel_by_name(gint32 image_ID,const gchar * name)3016 gimp_image_get_channel_by_name (gint32       image_ID,
3017                                 const gchar *name)
3018 {
3019   GimpParam *return_vals;
3020   gint nreturn_vals;
3021   gint32 channel_ID = -1;
3022 
3023   return_vals = gimp_run_procedure ("gimp-image-get-channel-by-name",
3024                                     &nreturn_vals,
3025                                     GIMP_PDB_IMAGE, image_ID,
3026                                     GIMP_PDB_STRING, name,
3027                                     GIMP_PDB_END);
3028 
3029   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
3030     channel_ID = return_vals[1].data.d_channel;
3031 
3032   gimp_destroy_params (return_vals, nreturn_vals);
3033 
3034   return channel_ID;
3035 }
3036 
3037 /**
3038  * gimp_image_get_vectors_by_name:
3039  * @image_ID: The image.
3040  * @name: The name of the vectors to find.
3041  *
3042  * Find a vectors with a given name in an image.
3043  *
3044  * This procedure returns the vectors with the given name in the
3045  * specified image.
3046  *
3047  * Returns: The vectors with the specified name.
3048  *
3049  * Since: 2.8
3050  **/
3051 gint32
gimp_image_get_vectors_by_name(gint32 image_ID,const gchar * name)3052 gimp_image_get_vectors_by_name (gint32       image_ID,
3053                                 const gchar *name)
3054 {
3055   GimpParam *return_vals;
3056   gint nreturn_vals;
3057   gint32 vectors_ID = -1;
3058 
3059   return_vals = gimp_run_procedure ("gimp-image-get-vectors-by-name",
3060                                     &nreturn_vals,
3061                                     GIMP_PDB_IMAGE, image_ID,
3062                                     GIMP_PDB_STRING, name,
3063                                     GIMP_PDB_END);
3064 
3065   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
3066     vectors_ID = return_vals[1].data.d_vectors;
3067 
3068   gimp_destroy_params (return_vals, nreturn_vals);
3069 
3070   return vectors_ID;
3071 }
3072 
3073 /**
3074  * gimp_image_attach_parasite:
3075  * @image_ID: The image.
3076  * @parasite: The parasite to attach to an image.
3077  *
3078  * Add a parasite to an image.
3079  *
3080  * This procedure attaches a parasite to an image. It has no return
3081  * values.
3082  *
3083  * Returns: TRUE on success.
3084  *
3085  * Since: 2.8
3086  **/
3087 gboolean
gimp_image_attach_parasite(gint32 image_ID,const GimpParasite * parasite)3088 gimp_image_attach_parasite (gint32              image_ID,
3089                             const GimpParasite *parasite)
3090 {
3091   GimpParam *return_vals;
3092   gint nreturn_vals;
3093   gboolean success = TRUE;
3094 
3095   return_vals = gimp_run_procedure ("gimp-image-attach-parasite",
3096                                     &nreturn_vals,
3097                                     GIMP_PDB_IMAGE, image_ID,
3098                                     GIMP_PDB_PARASITE, parasite,
3099                                     GIMP_PDB_END);
3100 
3101   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
3102 
3103   gimp_destroy_params (return_vals, nreturn_vals);
3104 
3105   return success;
3106 }
3107 
3108 /**
3109  * gimp_image_detach_parasite:
3110  * @image_ID: The image.
3111  * @name: The name of the parasite to detach from an image.
3112  *
3113  * Removes a parasite from an image.
3114  *
3115  * This procedure detaches a parasite from an image. It has no return
3116  * values.
3117  *
3118  * Returns: TRUE on success.
3119  *
3120  * Since: 2.8
3121  **/
3122 gboolean
gimp_image_detach_parasite(gint32 image_ID,const gchar * name)3123 gimp_image_detach_parasite (gint32       image_ID,
3124                             const gchar *name)
3125 {
3126   GimpParam *return_vals;
3127   gint nreturn_vals;
3128   gboolean success = TRUE;
3129 
3130   return_vals = gimp_run_procedure ("gimp-image-detach-parasite",
3131                                     &nreturn_vals,
3132                                     GIMP_PDB_IMAGE, image_ID,
3133                                     GIMP_PDB_STRING, name,
3134                                     GIMP_PDB_END);
3135 
3136   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
3137 
3138   gimp_destroy_params (return_vals, nreturn_vals);
3139 
3140   return success;
3141 }
3142 
3143 /**
3144  * gimp_image_get_parasite:
3145  * @image_ID: The image.
3146  * @name: The name of the parasite to find.
3147  *
3148  * Look up a parasite in an image
3149  *
3150  * Finds and returns the parasite that was previously attached to an
3151  * image.
3152  *
3153  * Returns: The found parasite.
3154  *
3155  * Since: 2.8
3156  **/
3157 GimpParasite *
gimp_image_get_parasite(gint32 image_ID,const gchar * name)3158 gimp_image_get_parasite (gint32       image_ID,
3159                          const gchar *name)
3160 {
3161   GimpParam *return_vals;
3162   gint nreturn_vals;
3163   GimpParasite *parasite = NULL;
3164 
3165   return_vals = gimp_run_procedure ("gimp-image-get-parasite",
3166                                     &nreturn_vals,
3167                                     GIMP_PDB_IMAGE, image_ID,
3168                                     GIMP_PDB_STRING, name,
3169                                     GIMP_PDB_END);
3170 
3171   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
3172     parasite = gimp_parasite_copy (&return_vals[1].data.d_parasite);
3173 
3174   gimp_destroy_params (return_vals, nreturn_vals);
3175 
3176   return parasite;
3177 }
3178 
3179 /**
3180  * gimp_image_get_parasite_list:
3181  * @image_ID: The image.
3182  * @num_parasites: The number of attached parasites.
3183  *
3184  * List all parasites.
3185  *
3186  * Returns a list of all currently attached parasites.
3187  *
3188  * Returns: The names of currently attached parasites. The returned
3189  * value must be freed with g_strfreev().
3190  *
3191  * Since: 2.8
3192  **/
3193 gchar **
gimp_image_get_parasite_list(gint32 image_ID,gint * num_parasites)3194 gimp_image_get_parasite_list (gint32  image_ID,
3195                               gint   *num_parasites)
3196 {
3197   GimpParam *return_vals;
3198   gint nreturn_vals;
3199   gchar **parasites = NULL;
3200   gint i;
3201 
3202   return_vals = gimp_run_procedure ("gimp-image-get-parasite-list",
3203                                     &nreturn_vals,
3204                                     GIMP_PDB_IMAGE, image_ID,
3205                                     GIMP_PDB_END);
3206 
3207   *num_parasites = 0;
3208 
3209   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
3210     {
3211       *num_parasites = return_vals[1].data.d_int32;
3212       if (*num_parasites > 0)
3213         {
3214           parasites = g_new0 (gchar *, *num_parasites + 1);
3215           for (i = 0; i < *num_parasites; i++)
3216             parasites[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
3217         }
3218     }
3219 
3220   gimp_destroy_params (return_vals, nreturn_vals);
3221 
3222   return parasites;
3223 }
3224