1 /* LIBGIMP - The GIMP Library
2  * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
3  *
4  * gimplayer_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 "gimp.h"
26 
27 
28 /**
29  * SECTION: gimplayer
30  * @title: gimplayer
31  * @short_description: Operations on a single layer.
32  *
33  * Operations on a single layer.
34  **/
35 
36 
37 /**
38  * _gimp_layer_new:
39  * @image_ID: The image to which to add the layer.
40  * @width: The layer width.
41  * @height: The layer height.
42  * @type: The layer type.
43  * @name: The layer name.
44  * @opacity: The layer opacity.
45  * @mode: The layer combination mode.
46  *
47  * Create a new layer.
48  *
49  * This procedure creates a new layer with the specified width, height,
50  * and type. Name, opacity, and mode are also supplied parameters. The
51  * new layer still needs to be added to the image, as this is not
52  * automatic. Add the new layer with the gimp_image_insert_layer()
53  * command. Other attributes such as layer mask modes, and offsets
54  * should be set with explicit procedure calls.
55  *
56  * Returns: The newly created layer.
57  **/
58 gint32
_gimp_layer_new(gint32 image_ID,gint width,gint height,GimpImageType type,const gchar * name,gdouble opacity,GimpLayerMode mode)59 _gimp_layer_new (gint32         image_ID,
60                  gint           width,
61                  gint           height,
62                  GimpImageType  type,
63                  const gchar   *name,
64                  gdouble        opacity,
65                  GimpLayerMode  mode)
66 {
67   GimpParam *return_vals;
68   gint nreturn_vals;
69   gint32 layer_ID = -1;
70 
71   return_vals = gimp_run_procedure ("gimp-layer-new",
72                                     &nreturn_vals,
73                                     GIMP_PDB_IMAGE, image_ID,
74                                     GIMP_PDB_INT32, width,
75                                     GIMP_PDB_INT32, height,
76                                     GIMP_PDB_INT32, type,
77                                     GIMP_PDB_STRING, name,
78                                     GIMP_PDB_FLOAT, opacity,
79                                     GIMP_PDB_INT32, mode,
80                                     GIMP_PDB_END);
81 
82   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
83     layer_ID = return_vals[1].data.d_layer;
84 
85   gimp_destroy_params (return_vals, nreturn_vals);
86 
87   return layer_ID;
88 }
89 
90 /**
91  * gimp_layer_new_from_visible:
92  * @image_ID: The source image from where the content is copied.
93  * @dest_image_ID: The destination image to which to add the layer.
94  * @name: The layer name.
95  *
96  * Create a new layer from what is visible in an image.
97  *
98  * This procedure creates a new layer from what is visible in the given
99  * image. The new layer still needs to be added to the destination
100  * image, as this is not automatic. Add the new layer with the
101  * gimp_image_insert_layer() command. Other attributes such as layer
102  * mask modes, and offsets should be set with explicit procedure calls.
103  *
104  * Returns: The newly created layer.
105  *
106  * Since: 2.6
107  **/
108 gint32
gimp_layer_new_from_visible(gint32 image_ID,gint32 dest_image_ID,const gchar * name)109 gimp_layer_new_from_visible (gint32       image_ID,
110                              gint32       dest_image_ID,
111                              const gchar *name)
112 {
113   GimpParam *return_vals;
114   gint nreturn_vals;
115   gint32 layer_ID = -1;
116 
117   return_vals = gimp_run_procedure ("gimp-layer-new-from-visible",
118                                     &nreturn_vals,
119                                     GIMP_PDB_IMAGE, image_ID,
120                                     GIMP_PDB_IMAGE, dest_image_ID,
121                                     GIMP_PDB_STRING, name,
122                                     GIMP_PDB_END);
123 
124   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
125     layer_ID = return_vals[1].data.d_layer;
126 
127   gimp_destroy_params (return_vals, nreturn_vals);
128 
129   return layer_ID;
130 }
131 
132 /**
133  * gimp_layer_new_from_drawable:
134  * @drawable_ID: The source drawable from where the new layer is copied.
135  * @dest_image_ID: The destination image to which to add the layer.
136  *
137  * Create a new layer by copying an existing drawable.
138  *
139  * This procedure creates a new layer as a copy of the specified
140  * drawable. The new layer still needs to be added to the image, as
141  * this is not automatic. Add the new layer with the
142  * gimp_image_insert_layer() command. Other attributes such as layer
143  * mask modes, and offsets should be set with explicit procedure calls.
144  *
145  * Returns: The newly copied layer.
146  **/
147 gint32
gimp_layer_new_from_drawable(gint32 drawable_ID,gint32 dest_image_ID)148 gimp_layer_new_from_drawable (gint32 drawable_ID,
149                               gint32 dest_image_ID)
150 {
151   GimpParam *return_vals;
152   gint nreturn_vals;
153   gint32 layer_copy_ID = -1;
154 
155   return_vals = gimp_run_procedure ("gimp-layer-new-from-drawable",
156                                     &nreturn_vals,
157                                     GIMP_PDB_DRAWABLE, drawable_ID,
158                                     GIMP_PDB_IMAGE, dest_image_ID,
159                                     GIMP_PDB_END);
160 
161   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
162     layer_copy_ID = return_vals[1].data.d_layer;
163 
164   gimp_destroy_params (return_vals, nreturn_vals);
165 
166   return layer_copy_ID;
167 }
168 
169 /**
170  * gimp_layer_group_new:
171  * @image_ID: The image to which to add the layer group.
172  *
173  * Create a new layer group.
174  *
175  * This procedure creates a new layer group. Attributes such as layer
176  * mode and opacity should be set with explicit procedure calls. Add
177  * the new layer group (which is a kind of layer) with the
178  * gimp_image_insert_layer() command.
179  * Other procedures useful with layer groups:
180  * gimp_image_reorder_item(), gimp_item_get_parent(),
181  * gimp_item_get_children(), gimp_item_is_group().
182  *
183  * Returns: The newly created layer group.
184  *
185  * Since: 2.8
186  **/
187 gint32
gimp_layer_group_new(gint32 image_ID)188 gimp_layer_group_new (gint32 image_ID)
189 {
190   GimpParam *return_vals;
191   gint nreturn_vals;
192   gint32 layer_group_ID = -1;
193 
194   return_vals = gimp_run_procedure ("gimp-layer-group-new",
195                                     &nreturn_vals,
196                                     GIMP_PDB_IMAGE, image_ID,
197                                     GIMP_PDB_END);
198 
199   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
200     layer_group_ID = return_vals[1].data.d_layer;
201 
202   gimp_destroy_params (return_vals, nreturn_vals);
203 
204   return layer_group_ID;
205 }
206 
207 /**
208  * _gimp_layer_copy:
209  * @layer_ID: The layer to copy.
210  * @add_alpha: Add an alpha channel to the copied layer.
211  *
212  * Copy a layer.
213  *
214  * This procedure copies the specified layer and returns the copy. The
215  * newly copied layer is for use within the original layer's image. It
216  * should not be subsequently added to any other image. The copied
217  * layer can optionally have an added alpha channel. This is useful if
218  * the background layer in an image is being copied and added to the
219  * same image.
220  *
221  * Returns: The newly copied layer.
222  **/
223 gint32
_gimp_layer_copy(gint32 layer_ID,gboolean add_alpha)224 _gimp_layer_copy (gint32   layer_ID,
225                   gboolean add_alpha)
226 {
227   GimpParam *return_vals;
228   gint nreturn_vals;
229   gint32 layer_copy_ID = -1;
230 
231   return_vals = gimp_run_procedure ("gimp-layer-copy",
232                                     &nreturn_vals,
233                                     GIMP_PDB_LAYER, layer_ID,
234                                     GIMP_PDB_INT32, add_alpha,
235                                     GIMP_PDB_END);
236 
237   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
238     layer_copy_ID = return_vals[1].data.d_layer;
239 
240   gimp_destroy_params (return_vals, nreturn_vals);
241 
242   return layer_copy_ID;
243 }
244 
245 /**
246  * gimp_layer_add_alpha:
247  * @layer_ID: The layer.
248  *
249  * Add an alpha channel to the layer if it doesn't already have one.
250  *
251  * This procedure adds an additional component to the specified layer
252  * if it does not already possess an alpha channel. An alpha channel
253  * makes it possible to clear and erase to transparency, instead of the
254  * background color. This transforms layers of type RGB to RGBA, GRAY
255  * to GRAYA, and INDEXED to INDEXEDA.
256  *
257  * Returns: TRUE on success.
258  **/
259 gboolean
gimp_layer_add_alpha(gint32 layer_ID)260 gimp_layer_add_alpha (gint32 layer_ID)
261 {
262   GimpParam *return_vals;
263   gint nreturn_vals;
264   gboolean success = TRUE;
265 
266   return_vals = gimp_run_procedure ("gimp-layer-add-alpha",
267                                     &nreturn_vals,
268                                     GIMP_PDB_LAYER, layer_ID,
269                                     GIMP_PDB_END);
270 
271   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
272 
273   gimp_destroy_params (return_vals, nreturn_vals);
274 
275   return success;
276 }
277 
278 /**
279  * gimp_layer_flatten:
280  * @layer_ID: The layer.
281  *
282  * Remove the alpha channel from the layer if it has one.
283  *
284  * This procedure removes the alpha channel from a layer, blending all
285  * (partially) transparent pixels in the layer against the background
286  * color. This transforms layers of type RGBA to RGB, GRAYA to GRAY,
287  * and INDEXEDA to INDEXED.
288  *
289  * Returns: TRUE on success.
290  *
291  * Since: 2.4
292  **/
293 gboolean
gimp_layer_flatten(gint32 layer_ID)294 gimp_layer_flatten (gint32 layer_ID)
295 {
296   GimpParam *return_vals;
297   gint nreturn_vals;
298   gboolean success = TRUE;
299 
300   return_vals = gimp_run_procedure ("gimp-layer-flatten",
301                                     &nreturn_vals,
302                                     GIMP_PDB_LAYER, layer_ID,
303                                     GIMP_PDB_END);
304 
305   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
306 
307   gimp_destroy_params (return_vals, nreturn_vals);
308 
309   return success;
310 }
311 
312 /**
313  * gimp_layer_scale:
314  * @layer_ID: The layer.
315  * @new_width: New layer width.
316  * @new_height: New layer height.
317  * @local_origin: Use a local origin (as opposed to the image origin).
318  *
319  * Scale the layer using the default interpolation method.
320  *
321  * This procedure scales the layer so that its new width and height are
322  * equal to the supplied parameters. The 'local-origin' parameter
323  * specifies whether to scale from the center of the layer, or from the
324  * image origin. This operation only works if the layer has been added
325  * to an image. The interpolation method used can be set with
326  * gimp_context_set_interpolation().
327  *
328  * Returns: TRUE on success.
329  **/
330 gboolean
gimp_layer_scale(gint32 layer_ID,gint new_width,gint new_height,gboolean local_origin)331 gimp_layer_scale (gint32   layer_ID,
332                   gint     new_width,
333                   gint     new_height,
334                   gboolean local_origin)
335 {
336   GimpParam *return_vals;
337   gint nreturn_vals;
338   gboolean success = TRUE;
339 
340   return_vals = gimp_run_procedure ("gimp-layer-scale",
341                                     &nreturn_vals,
342                                     GIMP_PDB_LAYER, layer_ID,
343                                     GIMP_PDB_INT32, new_width,
344                                     GIMP_PDB_INT32, new_height,
345                                     GIMP_PDB_INT32, local_origin,
346                                     GIMP_PDB_END);
347 
348   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
349 
350   gimp_destroy_params (return_vals, nreturn_vals);
351 
352   return success;
353 }
354 
355 /**
356  * gimp_layer_scale_full:
357  * @layer_ID: The layer.
358  * @new_width: New layer width.
359  * @new_height: New layer height.
360  * @local_origin: Use a local origin (as opposed to the image origin).
361  * @interpolation: Type of interpolation.
362  *
363  * Deprecated: Use gimp_layer_scale() instead.
364  *
365  * Returns: TRUE on success.
366  *
367  * Since: 2.6
368  **/
369 gboolean
gimp_layer_scale_full(gint32 layer_ID,gint new_width,gint new_height,gboolean local_origin,GimpInterpolationType interpolation)370 gimp_layer_scale_full (gint32                layer_ID,
371                        gint                  new_width,
372                        gint                  new_height,
373                        gboolean              local_origin,
374                        GimpInterpolationType interpolation)
375 {
376   GimpParam *return_vals;
377   gint nreturn_vals;
378   gboolean success = TRUE;
379 
380   return_vals = gimp_run_procedure ("gimp-layer-scale-full",
381                                     &nreturn_vals,
382                                     GIMP_PDB_LAYER, layer_ID,
383                                     GIMP_PDB_INT32, new_width,
384                                     GIMP_PDB_INT32, new_height,
385                                     GIMP_PDB_INT32, local_origin,
386                                     GIMP_PDB_INT32, interpolation,
387                                     GIMP_PDB_END);
388 
389   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
390 
391   gimp_destroy_params (return_vals, nreturn_vals);
392 
393   return success;
394 }
395 
396 /**
397  * gimp_layer_resize:
398  * @layer_ID: The layer.
399  * @new_width: New layer width.
400  * @new_height: New layer height.
401  * @offx: x offset between upper left corner of old and new layers: (old - new).
402  * @offy: y offset between upper left corner of old and new layers: (old - new).
403  *
404  * Resize the layer to the specified extents.
405  *
406  * This procedure resizes the layer so that its new width and height
407  * are equal to the supplied parameters. Offsets are also provided
408  * which describe the position of the previous layer's content. This
409  * operation only works if the layer has been added to an image.
410  *
411  * Returns: TRUE on success.
412  **/
413 gboolean
gimp_layer_resize(gint32 layer_ID,gint new_width,gint new_height,gint offx,gint offy)414 gimp_layer_resize (gint32 layer_ID,
415                    gint   new_width,
416                    gint   new_height,
417                    gint   offx,
418                    gint   offy)
419 {
420   GimpParam *return_vals;
421   gint nreturn_vals;
422   gboolean success = TRUE;
423 
424   return_vals = gimp_run_procedure ("gimp-layer-resize",
425                                     &nreturn_vals,
426                                     GIMP_PDB_LAYER, layer_ID,
427                                     GIMP_PDB_INT32, new_width,
428                                     GIMP_PDB_INT32, new_height,
429                                     GIMP_PDB_INT32, offx,
430                                     GIMP_PDB_INT32, offy,
431                                     GIMP_PDB_END);
432 
433   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
434 
435   gimp_destroy_params (return_vals, nreturn_vals);
436 
437   return success;
438 }
439 
440 /**
441  * gimp_layer_resize_to_image_size:
442  * @layer_ID: The layer to resize.
443  *
444  * Resize a layer to the image size.
445  *
446  * This procedure resizes the layer so that it's new width and height
447  * are equal to the width and height of its image container.
448  *
449  * Returns: TRUE on success.
450  **/
451 gboolean
gimp_layer_resize_to_image_size(gint32 layer_ID)452 gimp_layer_resize_to_image_size (gint32 layer_ID)
453 {
454   GimpParam *return_vals;
455   gint nreturn_vals;
456   gboolean success = TRUE;
457 
458   return_vals = gimp_run_procedure ("gimp-layer-resize-to-image-size",
459                                     &nreturn_vals,
460                                     GIMP_PDB_LAYER, layer_ID,
461                                     GIMP_PDB_END);
462 
463   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
464 
465   gimp_destroy_params (return_vals, nreturn_vals);
466 
467   return success;
468 }
469 
470 /**
471  * gimp_layer_translate:
472  * @layer_ID: The layer.
473  * @offx: Offset in x direction.
474  * @offy: Offset in y direction.
475  *
476  * Translate the layer by the specified offsets.
477  *
478  * This procedure translates the layer by the amounts specified in the
479  * x and y arguments. These can be negative, and are considered offsets
480  * from the current position. This command only works if the layer has
481  * been added to an image. All additional layers contained in the image
482  * which have the linked flag set to TRUE w ill also be translated by
483  * the specified offsets.
484  *
485  * Deprecated: Use gimp_item_transform_translate() instead.
486  *
487  * Returns: TRUE on success.
488  **/
489 gboolean
gimp_layer_translate(gint32 layer_ID,gint offx,gint offy)490 gimp_layer_translate (gint32 layer_ID,
491                       gint   offx,
492                       gint   offy)
493 {
494   GimpParam *return_vals;
495   gint nreturn_vals;
496   gboolean success = TRUE;
497 
498   return_vals = gimp_run_procedure ("gimp-layer-translate",
499                                     &nreturn_vals,
500                                     GIMP_PDB_LAYER, layer_ID,
501                                     GIMP_PDB_INT32, offx,
502                                     GIMP_PDB_INT32, offy,
503                                     GIMP_PDB_END);
504 
505   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
506 
507   gimp_destroy_params (return_vals, nreturn_vals);
508 
509   return success;
510 }
511 
512 /**
513  * gimp_layer_set_offsets:
514  * @layer_ID: The layer.
515  * @offx: Offset in x direction.
516  * @offy: Offset in y direction.
517  *
518  * Set the layer offsets.
519  *
520  * This procedure sets the offsets for the specified layer. The offsets
521  * are relative to the image origin and can be any values. This
522  * operation is valid only on layers which have been added to an image.
523  *
524  * Returns: TRUE on success.
525  **/
526 gboolean
gimp_layer_set_offsets(gint32 layer_ID,gint offx,gint offy)527 gimp_layer_set_offsets (gint32 layer_ID,
528                         gint   offx,
529                         gint   offy)
530 {
531   GimpParam *return_vals;
532   gint nreturn_vals;
533   gboolean success = TRUE;
534 
535   return_vals = gimp_run_procedure ("gimp-layer-set-offsets",
536                                     &nreturn_vals,
537                                     GIMP_PDB_LAYER, layer_ID,
538                                     GIMP_PDB_INT32, offx,
539                                     GIMP_PDB_INT32, offy,
540                                     GIMP_PDB_END);
541 
542   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
543 
544   gimp_destroy_params (return_vals, nreturn_vals);
545 
546   return success;
547 }
548 
549 /**
550  * gimp_layer_create_mask:
551  * @layer_ID: The layer to which to add the mask.
552  * @mask_type: The type of mask.
553  *
554  * Create a layer mask for the specified layer.
555  *
556  * This procedure creates a layer mask for the specified layer.
557  * Layer masks serve as an additional alpha channel for a layer.
558  * Different types of masks are allowed for initialisation:
559  * - white mask (leaves the layer fully visible);
560  * - black mask (gives the layer complete transparency);
561  * - the layer's alpha channel (either a copy, or a transfer, which
562  * leaves the layer fully visible, but which may be more useful than a
563  * white mask);
564  * - the current selection;
565  * - a grayscale copy of the layer;
566  * - or a copy of the active channel.
567  *
568  * The layer mask still needs to be added to the layer. This can be
569  * done with a call to gimp_layer_add_mask().
570  *
571  * gimp_layer_create_mask() will fail if there are no active channels
572  * on the image, when called with 'ADD-CHANNEL-MASK'. It will return a
573  * black mask when called with 'ADD-ALPHA-MASK' or
574  * 'ADD-ALPHA-TRANSFER-MASK' on a layer with no alpha channels, or with
575  * 'ADD-SELECTION-MASK' when there is no selection on the image.
576  *
577  * Returns: The newly created mask.
578  **/
579 gint32
gimp_layer_create_mask(gint32 layer_ID,GimpAddMaskType mask_type)580 gimp_layer_create_mask (gint32          layer_ID,
581                         GimpAddMaskType mask_type)
582 {
583   GimpParam *return_vals;
584   gint nreturn_vals;
585   gint32 mask_ID = -1;
586 
587   return_vals = gimp_run_procedure ("gimp-layer-create-mask",
588                                     &nreturn_vals,
589                                     GIMP_PDB_LAYER, layer_ID,
590                                     GIMP_PDB_INT32, mask_type,
591                                     GIMP_PDB_END);
592 
593   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
594     mask_ID = return_vals[1].data.d_layer_mask;
595 
596   gimp_destroy_params (return_vals, nreturn_vals);
597 
598   return mask_ID;
599 }
600 
601 /**
602  * gimp_layer_get_mask:
603  * @layer_ID: The layer.
604  *
605  * Get the specified layer's mask if it exists.
606  *
607  * This procedure returns the specified layer's mask, or -1 if none
608  * exists.
609  *
610  * Returns: The layer mask.
611  **/
612 gint32
gimp_layer_get_mask(gint32 layer_ID)613 gimp_layer_get_mask (gint32 layer_ID)
614 {
615   GimpParam *return_vals;
616   gint nreturn_vals;
617   gint32 mask_ID = -1;
618 
619   return_vals = gimp_run_procedure ("gimp-layer-get-mask",
620                                     &nreturn_vals,
621                                     GIMP_PDB_LAYER, layer_ID,
622                                     GIMP_PDB_END);
623 
624   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
625     mask_ID = return_vals[1].data.d_layer_mask;
626 
627   gimp_destroy_params (return_vals, nreturn_vals);
628 
629   return mask_ID;
630 }
631 
632 /**
633  * gimp_layer_from_mask:
634  * @mask_ID: Mask for which to return the layer.
635  *
636  * Get the specified mask's layer.
637  *
638  * This procedure returns the specified mask's layer , or -1 if none
639  * exists.
640  *
641  * Returns: The mask's layer.
642  *
643  * Since: 2.2
644  **/
645 gint32
gimp_layer_from_mask(gint32 mask_ID)646 gimp_layer_from_mask (gint32 mask_ID)
647 {
648   GimpParam *return_vals;
649   gint nreturn_vals;
650   gint32 layer_ID = -1;
651 
652   return_vals = gimp_run_procedure ("gimp-layer-from-mask",
653                                     &nreturn_vals,
654                                     GIMP_PDB_CHANNEL, mask_ID,
655                                     GIMP_PDB_END);
656 
657   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
658     layer_ID = return_vals[1].data.d_layer;
659 
660   gimp_destroy_params (return_vals, nreturn_vals);
661 
662   return layer_ID;
663 }
664 
665 /**
666  * gimp_layer_add_mask:
667  * @layer_ID: The layer to receive the mask.
668  * @mask_ID: The mask to add to the layer.
669  *
670  * Add a layer mask to the specified layer.
671  *
672  * This procedure adds a layer mask to the specified layer. Layer masks
673  * serve as an additional alpha channel for a layer. This procedure
674  * will fail if a number of prerequisites aren't met. The layer cannot
675  * already have a layer mask. The specified mask must exist and have
676  * the same dimensions as the layer. The layer must have been created
677  * for use with the specified image and the mask must have been created
678  * with the procedure 'gimp-layer-create-mask'.
679  *
680  * Returns: TRUE on success.
681  **/
682 gboolean
gimp_layer_add_mask(gint32 layer_ID,gint32 mask_ID)683 gimp_layer_add_mask (gint32 layer_ID,
684                      gint32 mask_ID)
685 {
686   GimpParam *return_vals;
687   gint nreturn_vals;
688   gboolean success = TRUE;
689 
690   return_vals = gimp_run_procedure ("gimp-layer-add-mask",
691                                     &nreturn_vals,
692                                     GIMP_PDB_LAYER, layer_ID,
693                                     GIMP_PDB_CHANNEL, mask_ID,
694                                     GIMP_PDB_END);
695 
696   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
697 
698   gimp_destroy_params (return_vals, nreturn_vals);
699 
700   return success;
701 }
702 
703 /**
704  * gimp_layer_remove_mask:
705  * @layer_ID: The layer from which to remove mask.
706  * @mode: Removal mode.
707  *
708  * Remove the specified layer mask from the layer.
709  *
710  * This procedure removes the specified layer mask from the layer. If
711  * the mask doesn't exist, an error is returned.
712  *
713  * Returns: TRUE on success.
714  **/
715 gboolean
gimp_layer_remove_mask(gint32 layer_ID,GimpMaskApplyMode mode)716 gimp_layer_remove_mask (gint32            layer_ID,
717                         GimpMaskApplyMode mode)
718 {
719   GimpParam *return_vals;
720   gint nreturn_vals;
721   gboolean success = TRUE;
722 
723   return_vals = gimp_run_procedure ("gimp-layer-remove-mask",
724                                     &nreturn_vals,
725                                     GIMP_PDB_LAYER, layer_ID,
726                                     GIMP_PDB_INT32, mode,
727                                     GIMP_PDB_END);
728 
729   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
730 
731   gimp_destroy_params (return_vals, nreturn_vals);
732 
733   return success;
734 }
735 
736 /**
737  * gimp_layer_is_floating_sel:
738  * @layer_ID: The layer.
739  *
740  * Is the specified layer a floating selection?
741  *
742  * This procedure returns whether the layer is a floating selection.
743  * Floating selections are special cases of layers which are attached
744  * to a specific drawable.
745  *
746  * Returns: TRUE if the layer is a floating selection.
747  **/
748 gboolean
gimp_layer_is_floating_sel(gint32 layer_ID)749 gimp_layer_is_floating_sel (gint32 layer_ID)
750 {
751   GimpParam *return_vals;
752   gint nreturn_vals;
753   gboolean is_floating_sel = FALSE;
754 
755   return_vals = gimp_run_procedure ("gimp-layer-is-floating-sel",
756                                     &nreturn_vals,
757                                     GIMP_PDB_LAYER, layer_ID,
758                                     GIMP_PDB_END);
759 
760   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
761     is_floating_sel = return_vals[1].data.d_int32;
762 
763   gimp_destroy_params (return_vals, nreturn_vals);
764 
765   return is_floating_sel;
766 }
767 
768 /**
769  * gimp_layer_get_lock_alpha:
770  * @layer_ID: The layer.
771  *
772  * Get the lock alpha channel setting of the specified layer.
773  *
774  * This procedure returns the specified layer's lock alpha channel
775  * setting.
776  *
777  * Returns: The layer's lock alpha channel setting.
778  **/
779 gboolean
gimp_layer_get_lock_alpha(gint32 layer_ID)780 gimp_layer_get_lock_alpha (gint32 layer_ID)
781 {
782   GimpParam *return_vals;
783   gint nreturn_vals;
784   gboolean lock_alpha = FALSE;
785 
786   return_vals = gimp_run_procedure ("gimp-layer-get-lock-alpha",
787                                     &nreturn_vals,
788                                     GIMP_PDB_LAYER, layer_ID,
789                                     GIMP_PDB_END);
790 
791   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
792     lock_alpha = return_vals[1].data.d_int32;
793 
794   gimp_destroy_params (return_vals, nreturn_vals);
795 
796   return lock_alpha;
797 }
798 
799 /**
800  * gimp_layer_set_lock_alpha:
801  * @layer_ID: The layer.
802  * @lock_alpha: The new layer's lock alpha channel setting.
803  *
804  * Set the lock alpha channel setting of the specified layer.
805  *
806  * This procedure sets the specified layer's lock alpha channel
807  * setting.
808  *
809  * Returns: TRUE on success.
810  **/
811 gboolean
gimp_layer_set_lock_alpha(gint32 layer_ID,gboolean lock_alpha)812 gimp_layer_set_lock_alpha (gint32   layer_ID,
813                            gboolean lock_alpha)
814 {
815   GimpParam *return_vals;
816   gint nreturn_vals;
817   gboolean success = TRUE;
818 
819   return_vals = gimp_run_procedure ("gimp-layer-set-lock-alpha",
820                                     &nreturn_vals,
821                                     GIMP_PDB_LAYER, layer_ID,
822                                     GIMP_PDB_INT32, lock_alpha,
823                                     GIMP_PDB_END);
824 
825   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
826 
827   gimp_destroy_params (return_vals, nreturn_vals);
828 
829   return success;
830 }
831 
832 /**
833  * gimp_layer_get_apply_mask:
834  * @layer_ID: The layer.
835  *
836  * Get the apply mask setting of the specified layer.
837  *
838  * This procedure returns the specified layer's apply mask setting. If
839  * the value is TRUE, then the layer mask for this layer is currently
840  * being composited with the layer's alpha channel.
841  *
842  * Returns: The layer's apply mask setting.
843  **/
844 gboolean
gimp_layer_get_apply_mask(gint32 layer_ID)845 gimp_layer_get_apply_mask (gint32 layer_ID)
846 {
847   GimpParam *return_vals;
848   gint nreturn_vals;
849   gboolean apply_mask = FALSE;
850 
851   return_vals = gimp_run_procedure ("gimp-layer-get-apply-mask",
852                                     &nreturn_vals,
853                                     GIMP_PDB_LAYER, layer_ID,
854                                     GIMP_PDB_END);
855 
856   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
857     apply_mask = return_vals[1].data.d_int32;
858 
859   gimp_destroy_params (return_vals, nreturn_vals);
860 
861   return apply_mask;
862 }
863 
864 /**
865  * gimp_layer_set_apply_mask:
866  * @layer_ID: The layer.
867  * @apply_mask: The new layer's apply mask setting.
868  *
869  * Set the apply mask setting of the specified layer.
870  *
871  * This procedure sets the specified layer's apply mask setting. This
872  * controls whether the layer's mask is currently affecting the alpha
873  * channel. If there is no layer mask, this function will return an
874  * error.
875  *
876  * Returns: TRUE on success.
877  **/
878 gboolean
gimp_layer_set_apply_mask(gint32 layer_ID,gboolean apply_mask)879 gimp_layer_set_apply_mask (gint32   layer_ID,
880                            gboolean apply_mask)
881 {
882   GimpParam *return_vals;
883   gint nreturn_vals;
884   gboolean success = TRUE;
885 
886   return_vals = gimp_run_procedure ("gimp-layer-set-apply-mask",
887                                     &nreturn_vals,
888                                     GIMP_PDB_LAYER, layer_ID,
889                                     GIMP_PDB_INT32, apply_mask,
890                                     GIMP_PDB_END);
891 
892   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
893 
894   gimp_destroy_params (return_vals, nreturn_vals);
895 
896   return success;
897 }
898 
899 /**
900  * gimp_layer_get_show_mask:
901  * @layer_ID: The layer.
902  *
903  * Get the show mask setting of the specified layer.
904  *
905  * This procedure returns the specified layer's show mask setting. This
906  * controls whether the layer or its mask is visible. TRUE indicates
907  * that the mask should be visible. If the layer has no mask, then this
908  * function returns an error.
909  *
910  * Returns: The layer's show mask setting.
911  **/
912 gboolean
gimp_layer_get_show_mask(gint32 layer_ID)913 gimp_layer_get_show_mask (gint32 layer_ID)
914 {
915   GimpParam *return_vals;
916   gint nreturn_vals;
917   gboolean show_mask = FALSE;
918 
919   return_vals = gimp_run_procedure ("gimp-layer-get-show-mask",
920                                     &nreturn_vals,
921                                     GIMP_PDB_LAYER, layer_ID,
922                                     GIMP_PDB_END);
923 
924   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
925     show_mask = return_vals[1].data.d_int32;
926 
927   gimp_destroy_params (return_vals, nreturn_vals);
928 
929   return show_mask;
930 }
931 
932 /**
933  * gimp_layer_set_show_mask:
934  * @layer_ID: The layer.
935  * @show_mask: The new layer's show mask setting.
936  *
937  * Set the show mask setting of the specified layer.
938  *
939  * This procedure sets the specified layer's show mask setting. This
940  * controls whether the layer or its mask is visible. TRUE indicates
941  * that the mask should be visible. If there is no layer mask, this
942  * function will return an error.
943  *
944  * Returns: TRUE on success.
945  **/
946 gboolean
gimp_layer_set_show_mask(gint32 layer_ID,gboolean show_mask)947 gimp_layer_set_show_mask (gint32   layer_ID,
948                           gboolean show_mask)
949 {
950   GimpParam *return_vals;
951   gint nreturn_vals;
952   gboolean success = TRUE;
953 
954   return_vals = gimp_run_procedure ("gimp-layer-set-show-mask",
955                                     &nreturn_vals,
956                                     GIMP_PDB_LAYER, layer_ID,
957                                     GIMP_PDB_INT32, show_mask,
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_layer_get_edit_mask:
969  * @layer_ID: The layer.
970  *
971  * Get the edit mask setting of the specified layer.
972  *
973  * This procedure returns the specified layer's edit mask setting. If
974  * the value is TRUE, then the layer mask for this layer is currently
975  * active, and not the layer.
976  *
977  * Returns: The layer's edit mask setting.
978  **/
979 gboolean
gimp_layer_get_edit_mask(gint32 layer_ID)980 gimp_layer_get_edit_mask (gint32 layer_ID)
981 {
982   GimpParam *return_vals;
983   gint nreturn_vals;
984   gboolean edit_mask = FALSE;
985 
986   return_vals = gimp_run_procedure ("gimp-layer-get-edit-mask",
987                                     &nreturn_vals,
988                                     GIMP_PDB_LAYER, layer_ID,
989                                     GIMP_PDB_END);
990 
991   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
992     edit_mask = return_vals[1].data.d_int32;
993 
994   gimp_destroy_params (return_vals, nreturn_vals);
995 
996   return edit_mask;
997 }
998 
999 /**
1000  * gimp_layer_set_edit_mask:
1001  * @layer_ID: The layer.
1002  * @edit_mask: The new layer's edit mask setting.
1003  *
1004  * Set the edit mask setting of the specified layer.
1005  *
1006  * This procedure sets the specified layer's edit mask setting. This
1007  * controls whether the layer or it's mask is currently active for
1008  * editing. If the specified layer has no layer mask, then this
1009  * procedure will return an error.
1010  *
1011  * Returns: TRUE on success.
1012  **/
1013 gboolean
gimp_layer_set_edit_mask(gint32 layer_ID,gboolean edit_mask)1014 gimp_layer_set_edit_mask (gint32   layer_ID,
1015                           gboolean edit_mask)
1016 {
1017   GimpParam *return_vals;
1018   gint nreturn_vals;
1019   gboolean success = TRUE;
1020 
1021   return_vals = gimp_run_procedure ("gimp-layer-set-edit-mask",
1022                                     &nreturn_vals,
1023                                     GIMP_PDB_LAYER, layer_ID,
1024                                     GIMP_PDB_INT32, edit_mask,
1025                                     GIMP_PDB_END);
1026 
1027   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1028 
1029   gimp_destroy_params (return_vals, nreturn_vals);
1030 
1031   return success;
1032 }
1033 
1034 /**
1035  * gimp_layer_get_opacity:
1036  * @layer_ID: The layer.
1037  *
1038  * Get the opacity of the specified layer.
1039  *
1040  * This procedure returns the specified layer's opacity.
1041  *
1042  * Returns: The layer opacity.
1043  **/
1044 gdouble
gimp_layer_get_opacity(gint32 layer_ID)1045 gimp_layer_get_opacity (gint32 layer_ID)
1046 {
1047   GimpParam *return_vals;
1048   gint nreturn_vals;
1049   gdouble opacity = 0.0;
1050 
1051   return_vals = gimp_run_procedure ("gimp-layer-get-opacity",
1052                                     &nreturn_vals,
1053                                     GIMP_PDB_LAYER, layer_ID,
1054                                     GIMP_PDB_END);
1055 
1056   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
1057     opacity = return_vals[1].data.d_float;
1058 
1059   gimp_destroy_params (return_vals, nreturn_vals);
1060 
1061   return opacity;
1062 }
1063 
1064 /**
1065  * gimp_layer_set_opacity:
1066  * @layer_ID: The layer.
1067  * @opacity: The new layer opacity.
1068  *
1069  * Set the opacity of the specified layer.
1070  *
1071  * This procedure sets the specified layer's opacity.
1072  *
1073  * Returns: TRUE on success.
1074  **/
1075 gboolean
gimp_layer_set_opacity(gint32 layer_ID,gdouble opacity)1076 gimp_layer_set_opacity (gint32  layer_ID,
1077                         gdouble opacity)
1078 {
1079   GimpParam *return_vals;
1080   gint nreturn_vals;
1081   gboolean success = TRUE;
1082 
1083   return_vals = gimp_run_procedure ("gimp-layer-set-opacity",
1084                                     &nreturn_vals,
1085                                     GIMP_PDB_LAYER, layer_ID,
1086                                     GIMP_PDB_FLOAT, opacity,
1087                                     GIMP_PDB_END);
1088 
1089   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1090 
1091   gimp_destroy_params (return_vals, nreturn_vals);
1092 
1093   return success;
1094 }
1095 
1096 /**
1097  * gimp_layer_get_mode:
1098  * @layer_ID: The layer.
1099  *
1100  * Get the combination mode of the specified layer.
1101  *
1102  * This procedure returns the specified layer's combination mode.
1103  *
1104  * Returns: The layer combination mode.
1105  **/
1106 GimpLayerMode
gimp_layer_get_mode(gint32 layer_ID)1107 gimp_layer_get_mode (gint32 layer_ID)
1108 {
1109   GimpParam *return_vals;
1110   gint nreturn_vals;
1111   GimpLayerMode mode = 0;
1112 
1113   return_vals = gimp_run_procedure ("gimp-layer-get-mode",
1114                                     &nreturn_vals,
1115                                     GIMP_PDB_LAYER, layer_ID,
1116                                     GIMP_PDB_END);
1117 
1118   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
1119     mode = return_vals[1].data.d_int32;
1120 
1121   gimp_destroy_params (return_vals, nreturn_vals);
1122 
1123   return mode;
1124 }
1125 
1126 /**
1127  * gimp_layer_set_mode:
1128  * @layer_ID: The layer.
1129  * @mode: The new layer combination mode.
1130  *
1131  * Set the combination mode of the specified layer.
1132  *
1133  * This procedure sets the specified layer's combination mode.
1134  *
1135  * Returns: TRUE on success.
1136  **/
1137 gboolean
gimp_layer_set_mode(gint32 layer_ID,GimpLayerMode mode)1138 gimp_layer_set_mode (gint32        layer_ID,
1139                      GimpLayerMode mode)
1140 {
1141   GimpParam *return_vals;
1142   gint nreturn_vals;
1143   gboolean success = TRUE;
1144 
1145   return_vals = gimp_run_procedure ("gimp-layer-set-mode",
1146                                     &nreturn_vals,
1147                                     GIMP_PDB_LAYER, layer_ID,
1148                                     GIMP_PDB_INT32, mode,
1149                                     GIMP_PDB_END);
1150 
1151   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1152 
1153   gimp_destroy_params (return_vals, nreturn_vals);
1154 
1155   return success;
1156 }
1157 
1158 /**
1159  * gimp_layer_get_blend_space:
1160  * @layer_ID: The layer.
1161  *
1162  * Get the blend space of the specified layer.
1163  *
1164  * This procedure returns the specified layer's blend space.
1165  *
1166  * Returns: The layer blend space.
1167  *
1168  * Since: 2.10
1169  **/
1170 GimpLayerColorSpace
gimp_layer_get_blend_space(gint32 layer_ID)1171 gimp_layer_get_blend_space (gint32 layer_ID)
1172 {
1173   GimpParam *return_vals;
1174   gint nreturn_vals;
1175   GimpLayerColorSpace blend_space = 0;
1176 
1177   return_vals = gimp_run_procedure ("gimp-layer-get-blend-space",
1178                                     &nreturn_vals,
1179                                     GIMP_PDB_LAYER, layer_ID,
1180                                     GIMP_PDB_END);
1181 
1182   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
1183     blend_space = return_vals[1].data.d_int32;
1184 
1185   gimp_destroy_params (return_vals, nreturn_vals);
1186 
1187   return blend_space;
1188 }
1189 
1190 /**
1191  * gimp_layer_set_blend_space:
1192  * @layer_ID: The layer.
1193  * @blend_space: The new layer blend space.
1194  *
1195  * Set the blend space of the specified layer.
1196  *
1197  * This procedure sets the specified layer's blend space.
1198  *
1199  * Returns: TRUE on success.
1200  *
1201  * Since: 2.10
1202  **/
1203 gboolean
gimp_layer_set_blend_space(gint32 layer_ID,GimpLayerColorSpace blend_space)1204 gimp_layer_set_blend_space (gint32              layer_ID,
1205                             GimpLayerColorSpace blend_space)
1206 {
1207   GimpParam *return_vals;
1208   gint nreturn_vals;
1209   gboolean success = TRUE;
1210 
1211   return_vals = gimp_run_procedure ("gimp-layer-set-blend-space",
1212                                     &nreturn_vals,
1213                                     GIMP_PDB_LAYER, layer_ID,
1214                                     GIMP_PDB_INT32, blend_space,
1215                                     GIMP_PDB_END);
1216 
1217   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1218 
1219   gimp_destroy_params (return_vals, nreturn_vals);
1220 
1221   return success;
1222 }
1223 
1224 /**
1225  * gimp_layer_get_composite_space:
1226  * @layer_ID: The layer.
1227  *
1228  * Get the composite space of the specified layer.
1229  *
1230  * This procedure returns the specified layer's composite space.
1231  *
1232  * Returns: The layer composite space.
1233  *
1234  * Since: 2.10
1235  **/
1236 GimpLayerColorSpace
gimp_layer_get_composite_space(gint32 layer_ID)1237 gimp_layer_get_composite_space (gint32 layer_ID)
1238 {
1239   GimpParam *return_vals;
1240   gint nreturn_vals;
1241   GimpLayerColorSpace composite_space = 0;
1242 
1243   return_vals = gimp_run_procedure ("gimp-layer-get-composite-space",
1244                                     &nreturn_vals,
1245                                     GIMP_PDB_LAYER, layer_ID,
1246                                     GIMP_PDB_END);
1247 
1248   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
1249     composite_space = return_vals[1].data.d_int32;
1250 
1251   gimp_destroy_params (return_vals, nreturn_vals);
1252 
1253   return composite_space;
1254 }
1255 
1256 /**
1257  * gimp_layer_set_composite_space:
1258  * @layer_ID: The layer.
1259  * @composite_space: The new layer composite space.
1260  *
1261  * Set the composite space of the specified layer.
1262  *
1263  * This procedure sets the specified layer's composite space.
1264  *
1265  * Returns: TRUE on success.
1266  *
1267  * Since: 2.10
1268  **/
1269 gboolean
gimp_layer_set_composite_space(gint32 layer_ID,GimpLayerColorSpace composite_space)1270 gimp_layer_set_composite_space (gint32              layer_ID,
1271                                 GimpLayerColorSpace composite_space)
1272 {
1273   GimpParam *return_vals;
1274   gint nreturn_vals;
1275   gboolean success = TRUE;
1276 
1277   return_vals = gimp_run_procedure ("gimp-layer-set-composite-space",
1278                                     &nreturn_vals,
1279                                     GIMP_PDB_LAYER, layer_ID,
1280                                     GIMP_PDB_INT32, composite_space,
1281                                     GIMP_PDB_END);
1282 
1283   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1284 
1285   gimp_destroy_params (return_vals, nreturn_vals);
1286 
1287   return success;
1288 }
1289 
1290 /**
1291  * gimp_layer_get_composite_mode:
1292  * @layer_ID: The layer.
1293  *
1294  * Get the composite mode of the specified layer.
1295  *
1296  * This procedure returns the specified layer's composite mode.
1297  *
1298  * Returns: The layer composite mode.
1299  *
1300  * Since: 2.10
1301  **/
1302 GimpLayerCompositeMode
gimp_layer_get_composite_mode(gint32 layer_ID)1303 gimp_layer_get_composite_mode (gint32 layer_ID)
1304 {
1305   GimpParam *return_vals;
1306   gint nreturn_vals;
1307   GimpLayerCompositeMode composite_mode = 0;
1308 
1309   return_vals = gimp_run_procedure ("gimp-layer-get-composite-mode",
1310                                     &nreturn_vals,
1311                                     GIMP_PDB_LAYER, layer_ID,
1312                                     GIMP_PDB_END);
1313 
1314   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
1315     composite_mode = return_vals[1].data.d_int32;
1316 
1317   gimp_destroy_params (return_vals, nreturn_vals);
1318 
1319   return composite_mode;
1320 }
1321 
1322 /**
1323  * gimp_layer_set_composite_mode:
1324  * @layer_ID: The layer.
1325  * @composite_mode: The new layer composite mode.
1326  *
1327  * Set the composite mode of the specified layer.
1328  *
1329  * This procedure sets the specified layer's composite mode.
1330  *
1331  * Returns: TRUE on success.
1332  *
1333  * Since: 2.10
1334  **/
1335 gboolean
gimp_layer_set_composite_mode(gint32 layer_ID,GimpLayerCompositeMode composite_mode)1336 gimp_layer_set_composite_mode (gint32                 layer_ID,
1337                                GimpLayerCompositeMode composite_mode)
1338 {
1339   GimpParam *return_vals;
1340   gint nreturn_vals;
1341   gboolean success = TRUE;
1342 
1343   return_vals = gimp_run_procedure ("gimp-layer-set-composite-mode",
1344                                     &nreturn_vals,
1345                                     GIMP_PDB_LAYER, layer_ID,
1346                                     GIMP_PDB_INT32, composite_mode,
1347                                     GIMP_PDB_END);
1348 
1349   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
1350 
1351   gimp_destroy_params (return_vals, nreturn_vals);
1352 
1353   return success;
1354 }
1355