~ubuntu-branches/ubuntu/hoary/gimp/hoary

« back to all changes in this revision

Viewing changes to libgimp/gimplayer_pdb.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-04-04 14:51:23 UTC
  • Revision ID: james.westby@ubuntu.com-20050404145123-9py049eeelfymur8
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 2 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, write to the
 
18
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
19
 * Boston, MA 02111-1307, USA.
 
20
 */
 
21
 
 
22
/* NOTE: This file is autogenerated by pdbgen.pl */
 
23
 
 
24
#include "config.h"
 
25
 
 
26
#include "gimp.h"
 
27
 
 
28
/**
 
29
 * _gimp_layer_new:
 
30
 * @image_ID: The image to which to add the layer.
 
31
 * @width: The layer width.
 
32
 * @height: The layer height.
 
33
 * @type: The layer type.
 
34
 * @name: The layer name.
 
35
 * @opacity: The layer opacity.
 
36
 * @mode: The layer combination mode.
 
37
 *
 
38
 * Create a new layer.
 
39
 *
 
40
 * This procedure creates a new layer with the specified width, height,
 
41
 * and type. Name, opacity, and mode are also supplied parameters. The
 
42
 * new layer still needs to be added to the image, as this is not
 
43
 * automatic. Add the new layer with the 'gimp_image_add_layer'
 
44
 * command. Other attributes such as layer mask modes, and offsets
 
45
 * should be set with explicit procedure calls.
 
46
 *
 
47
 * Returns: The newly created layer.
 
48
 */
 
49
gint32
 
50
_gimp_layer_new (gint32                image_ID,
 
51
                 gint                  width,
 
52
                 gint                  height,
 
53
                 GimpImageType         type,
 
54
                 const gchar          *name,
 
55
                 gdouble               opacity,
 
56
                 GimpLayerModeEffects  mode)
 
57
{
 
58
  GimpParam *return_vals;
 
59
  gint nreturn_vals;
 
60
  gint32 layer_ID = -1;
 
61
 
 
62
  return_vals = gimp_run_procedure ("gimp_layer_new",
 
63
                                    &nreturn_vals,
 
64
                                    GIMP_PDB_IMAGE, image_ID,
 
65
                                    GIMP_PDB_INT32, width,
 
66
                                    GIMP_PDB_INT32, height,
 
67
                                    GIMP_PDB_INT32, type,
 
68
                                    GIMP_PDB_STRING, name,
 
69
                                    GIMP_PDB_FLOAT, opacity,
 
70
                                    GIMP_PDB_INT32, mode,
 
71
                                    GIMP_PDB_END);
 
72
 
 
73
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
74
    layer_ID = return_vals[1].data.d_layer;
 
75
 
 
76
  gimp_destroy_params (return_vals, nreturn_vals);
 
77
 
 
78
  return layer_ID;
 
79
}
 
80
 
 
81
/**
 
82
 * gimp_layer_new_from_drawable:
 
83
 * @drawable_ID: The source drawable from where the new layer is copied.
 
84
 * @dest_image_ID: The destination image to which to add the layer.
 
85
 *
 
86
 * Create a new layer by copying an existing drawable.
 
87
 *
 
88
 * This procedure creates a new layer as a copy of the specified
 
89
 * drawable. The new layer still needs to be added to the image, as
 
90
 * this is not automatic. Add the new layer with the
 
91
 * 'gimp_image_add_layer' command. Other attributes such as layer mask
 
92
 * modes, and offsets should be set with explicit procedure calls.
 
93
 *
 
94
 * Returns: The newly copied layer.
 
95
 */
 
96
gint32
 
97
gimp_layer_new_from_drawable (gint32 drawable_ID,
 
98
                              gint32 dest_image_ID)
 
99
{
 
100
  GimpParam *return_vals;
 
101
  gint nreturn_vals;
 
102
  gint32 layer_copy_ID = -1;
 
103
 
 
104
  return_vals = gimp_run_procedure ("gimp_layer_new_from_drawable",
 
105
                                    &nreturn_vals,
 
106
                                    GIMP_PDB_DRAWABLE, drawable_ID,
 
107
                                    GIMP_PDB_IMAGE, dest_image_ID,
 
108
                                    GIMP_PDB_END);
 
109
 
 
110
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
111
    layer_copy_ID = return_vals[1].data.d_layer;
 
112
 
 
113
  gimp_destroy_params (return_vals, nreturn_vals);
 
114
 
 
115
  return layer_copy_ID;
 
116
}
 
117
 
 
118
/**
 
119
 * _gimp_layer_copy:
 
120
 * @layer_ID: The layer to copy.
 
121
 * @add_alpha: Add an alpha channel to the copied layer.
 
122
 *
 
123
 * Copy a layer.
 
124
 *
 
125
 * This procedure copies the specified layer and returns the copy. The
 
126
 * newly copied layer is for use within the original layer's image. It
 
127
 * should not be subsequently added to any other image. The copied
 
128
 * layer can optionally have an added alpha channel. This is useful if
 
129
 * the background layer in an image is being copied and added to the
 
130
 * same image.
 
131
 *
 
132
 * Returns: The newly copied layer.
 
133
 */
 
134
gint32
 
135
_gimp_layer_copy (gint32   layer_ID,
 
136
                  gboolean add_alpha)
 
137
{
 
138
  GimpParam *return_vals;
 
139
  gint nreturn_vals;
 
140
  gint32 layer_copy_ID = -1;
 
141
 
 
142
  return_vals = gimp_run_procedure ("gimp_layer_copy",
 
143
                                    &nreturn_vals,
 
144
                                    GIMP_PDB_LAYER, layer_ID,
 
145
                                    GIMP_PDB_INT32, add_alpha,
 
146
                                    GIMP_PDB_END);
 
147
 
 
148
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
149
    layer_copy_ID = return_vals[1].data.d_layer;
 
150
 
 
151
  gimp_destroy_params (return_vals, nreturn_vals);
 
152
 
 
153
  return layer_copy_ID;
 
154
}
 
155
 
 
156
/**
 
157
 * gimp_layer_add_alpha:
 
158
 * @layer_ID: The layer.
 
159
 *
 
160
 * Add an alpha channel to the layer if it doesn't already have one.
 
161
 *
 
162
 * This procedure adds an additional component to the specified layer
 
163
 * if it does not already possess an alpha channel. An alpha channel
 
164
 * makes it possible to move a layer from the bottom of the layer stack
 
165
 * and to clear and erase to transparency, instead of the background
 
166
 * color. This transforms images of type RGB to RGBA, GRAY to GRAYA,
 
167
 * and INDEXED to INDEXEDA.
 
168
 *
 
169
 * Returns: TRUE on success.
 
170
 */
 
171
gboolean
 
172
gimp_layer_add_alpha (gint32 layer_ID)
 
173
{
 
174
  GimpParam *return_vals;
 
175
  gint nreturn_vals;
 
176
  gboolean success = TRUE;
 
177
 
 
178
  return_vals = gimp_run_procedure ("gimp_layer_add_alpha",
 
179
                                    &nreturn_vals,
 
180
                                    GIMP_PDB_LAYER, layer_ID,
 
181
                                    GIMP_PDB_END);
 
182
 
 
183
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
184
 
 
185
  gimp_destroy_params (return_vals, nreturn_vals);
 
186
 
 
187
  return success;
 
188
}
 
189
 
 
190
/**
 
191
 * gimp_layer_scale:
 
192
 * @layer_ID: The layer.
 
193
 * @new_width: New layer width.
 
194
 * @new_height: New layer height.
 
195
 * @local_origin: Use a local origin (as opposed to the image origin).
 
196
 *
 
197
 * Scale the layer to the specified extents.
 
198
 *
 
199
 * This procedure scales the layer so that it's new width and height
 
200
 * are equal to the supplied parameters. The \"local_origin\" parameter
 
201
 * specifies whether to scale from the center of the layer, or from the
 
202
 * image origin. This operation only works if the layer has been added
 
203
 * to an image.
 
204
 *
 
205
 * Returns: TRUE on success.
 
206
 */
 
207
gboolean
 
208
gimp_layer_scale (gint32   layer_ID,
 
209
                  gint     new_width,
 
210
                  gint     new_height,
 
211
                  gboolean local_origin)
 
212
{
 
213
  GimpParam *return_vals;
 
214
  gint nreturn_vals;
 
215
  gboolean success = TRUE;
 
216
 
 
217
  return_vals = gimp_run_procedure ("gimp_layer_scale",
 
218
                                    &nreturn_vals,
 
219
                                    GIMP_PDB_LAYER, layer_ID,
 
220
                                    GIMP_PDB_INT32, new_width,
 
221
                                    GIMP_PDB_INT32, new_height,
 
222
                                    GIMP_PDB_INT32, local_origin,
 
223
                                    GIMP_PDB_END);
 
224
 
 
225
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
226
 
 
227
  gimp_destroy_params (return_vals, nreturn_vals);
 
228
 
 
229
  return success;
 
230
}
 
231
 
 
232
/**
 
233
 * gimp_layer_resize:
 
234
 * @layer_ID: The layer.
 
235
 * @new_width: New layer width.
 
236
 * @new_height: New layer height.
 
237
 * @offx: x offset between upper left corner of old and new layers: (old - new).
 
238
 * @offy: y offset between upper left corner of old and new layers: (old - new).
 
239
 *
 
240
 * Resize the layer to the specified extents.
 
241
 *
 
242
 * This procedure resizes the layer so that it's new width and height
 
243
 * are equal to the supplied parameters. Offsets are also provided
 
244
 * which describe the position of the previous layer's content. This
 
245
 * operation only works if the layer has been added to an image.
 
246
 *
 
247
 * Returns: TRUE on success.
 
248
 */
 
249
gboolean
 
250
gimp_layer_resize (gint32 layer_ID,
 
251
                   gint   new_width,
 
252
                   gint   new_height,
 
253
                   gint   offx,
 
254
                   gint   offy)
 
255
{
 
256
  GimpParam *return_vals;
 
257
  gint nreturn_vals;
 
258
  gboolean success = TRUE;
 
259
 
 
260
  return_vals = gimp_run_procedure ("gimp_layer_resize",
 
261
                                    &nreturn_vals,
 
262
                                    GIMP_PDB_LAYER, layer_ID,
 
263
                                    GIMP_PDB_INT32, new_width,
 
264
                                    GIMP_PDB_INT32, new_height,
 
265
                                    GIMP_PDB_INT32, offx,
 
266
                                    GIMP_PDB_INT32, offy,
 
267
                                    GIMP_PDB_END);
 
268
 
 
269
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
270
 
 
271
  gimp_destroy_params (return_vals, nreturn_vals);
 
272
 
 
273
  return success;
 
274
}
 
275
 
 
276
/**
 
277
 * gimp_layer_resize_to_image_size:
 
278
 * @layer_ID: The layer to resize.
 
279
 *
 
280
 * Resize a layer to the image size.
 
281
 *
 
282
 * This procedure resizes the layer so that it's new width and height
 
283
 * are equal to the width and height of its image container.
 
284
 *
 
285
 * Returns: TRUE on success.
 
286
 */
 
287
gboolean
 
288
gimp_layer_resize_to_image_size (gint32 layer_ID)
 
289
{
 
290
  GimpParam *return_vals;
 
291
  gint nreturn_vals;
 
292
  gboolean success = TRUE;
 
293
 
 
294
  return_vals = gimp_run_procedure ("gimp_layer_resize_to_image_size",
 
295
                                    &nreturn_vals,
 
296
                                    GIMP_PDB_LAYER, layer_ID,
 
297
                                    GIMP_PDB_END);
 
298
 
 
299
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
300
 
 
301
  gimp_destroy_params (return_vals, nreturn_vals);
 
302
 
 
303
  return success;
 
304
}
 
305
 
 
306
/**
 
307
 * gimp_layer_translate:
 
308
 * @layer_ID: The layer.
 
309
 * @offx: Offset in x direction.
 
310
 * @offy: Offset in y direction.
 
311
 *
 
312
 * Translate the layer by the specified offsets.
 
313
 *
 
314
 * This procedure translates the layer by the amounts specified in the
 
315
 * x and y arguments. These can be negative, and are considered offsets
 
316
 * from the current position. This command only works if the layer has
 
317
 * been added to an image. All additional layers contained in the image
 
318
 * which have the linked flag set to TRUE w ill also be translated by
 
319
 * the specified offsets.
 
320
 *
 
321
 * Returns: TRUE on success.
 
322
 */
 
323
gboolean
 
324
gimp_layer_translate (gint32 layer_ID,
 
325
                      gint   offx,
 
326
                      gint   offy)
 
327
{
 
328
  GimpParam *return_vals;
 
329
  gint nreturn_vals;
 
330
  gboolean success = TRUE;
 
331
 
 
332
  return_vals = gimp_run_procedure ("gimp_layer_translate",
 
333
                                    &nreturn_vals,
 
334
                                    GIMP_PDB_LAYER, layer_ID,
 
335
                                    GIMP_PDB_INT32, offx,
 
336
                                    GIMP_PDB_INT32, offy,
 
337
                                    GIMP_PDB_END);
 
338
 
 
339
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
340
 
 
341
  gimp_destroy_params (return_vals, nreturn_vals);
 
342
 
 
343
  return success;
 
344
}
 
345
 
 
346
/**
 
347
 * gimp_layer_set_offsets:
 
348
 * @layer_ID: The layer.
 
349
 * @offx: Offset in x direction.
 
350
 * @offy: Offset in y direction.
 
351
 *
 
352
 * Set the layer offsets.
 
353
 *
 
354
 * This procedure sets the offsets for the specified layer. The offsets
 
355
 * are relative to the image origin and can be any values. This
 
356
 * operation is valid only on layers which have been added to an image.
 
357
 *
 
358
 * Returns: TRUE on success.
 
359
 */
 
360
gboolean
 
361
gimp_layer_set_offsets (gint32 layer_ID,
 
362
                        gint   offx,
 
363
                        gint   offy)
 
364
{
 
365
  GimpParam *return_vals;
 
366
  gint nreturn_vals;
 
367
  gboolean success = TRUE;
 
368
 
 
369
  return_vals = gimp_run_procedure ("gimp_layer_set_offsets",
 
370
                                    &nreturn_vals,
 
371
                                    GIMP_PDB_LAYER, layer_ID,
 
372
                                    GIMP_PDB_INT32, offx,
 
373
                                    GIMP_PDB_INT32, offy,
 
374
                                    GIMP_PDB_END);
 
375
 
 
376
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
377
 
 
378
  gimp_destroy_params (return_vals, nreturn_vals);
 
379
 
 
380
  return success;
 
381
}
 
382
 
 
383
/**
 
384
 * gimp_layer_create_mask:
 
385
 * @layer_ID: The layer to which to add the mask.
 
386
 * @mask_type: The type of mask.
 
387
 *
 
388
 * Create a layer mask for the specified specified layer.
 
389
 *
 
390
 * This procedure creates a layer mask for the specified layer. Layer
 
391
 * masks serve as an additional alpha channel for a layer. A number of
 
392
 * ifferent types of masks are allowed for initialisation: completely
 
393
 * white masks (which will leave the layer fully visible), completely
 
394
 * black masks (which will give the layer complete transparency, the
 
395
 * layer's already existing alpha channel (which will leave the layer
 
396
 * fully visible, but which may be more useful than a white mask), the
 
397
 * current selection or a grayscale copy of the layer. The layer mask
 
398
 * still needs to be added to the layer. This can be done with a call
 
399
 * to 'gimp_layer_add_mask'.
 
400
 *
 
401
 * Returns: The newly created mask.
 
402
 */
 
403
gint32
 
404
gimp_layer_create_mask (gint32          layer_ID,
 
405
                        GimpAddMaskType mask_type)
 
406
{
 
407
  GimpParam *return_vals;
 
408
  gint nreturn_vals;
 
409
  gint32 mask_ID = -1;
 
410
 
 
411
  return_vals = gimp_run_procedure ("gimp_layer_create_mask",
 
412
                                    &nreturn_vals,
 
413
                                    GIMP_PDB_LAYER, layer_ID,
 
414
                                    GIMP_PDB_INT32, mask_type,
 
415
                                    GIMP_PDB_END);
 
416
 
 
417
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
418
    mask_ID = return_vals[1].data.d_layer_mask;
 
419
 
 
420
  gimp_destroy_params (return_vals, nreturn_vals);
 
421
 
 
422
  return mask_ID;
 
423
}
 
424
 
 
425
/**
 
426
 * gimp_layer_get_mask:
 
427
 * @layer_ID: The layer.
 
428
 *
 
429
 * Get the specified layer's mask if it exists.
 
430
 *
 
431
 * This procedure returns the specified layer's mask, or -1 if none
 
432
 * exists.
 
433
 *
 
434
 * Returns: The layer mask.
 
435
 */
 
436
gint32
 
437
gimp_layer_get_mask (gint32 layer_ID)
 
438
{
 
439
  GimpParam *return_vals;
 
440
  gint nreturn_vals;
 
441
  gint32 mask_ID = -1;
 
442
 
 
443
  return_vals = gimp_run_procedure ("gimp_layer_get_mask",
 
444
                                    &nreturn_vals,
 
445
                                    GIMP_PDB_LAYER, layer_ID,
 
446
                                    GIMP_PDB_END);
 
447
 
 
448
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
449
    mask_ID = return_vals[1].data.d_channel;
 
450
 
 
451
  gimp_destroy_params (return_vals, nreturn_vals);
 
452
 
 
453
  return mask_ID;
 
454
}
 
455
 
 
456
/**
 
457
 * gimp_layer_from_mask:
 
458
 * @mask_ID: Mask for which to return the layer.
 
459
 *
 
460
 * Get the specified mask's layer.
 
461
 *
 
462
 * This procedure returns the specified mask's layer , or -1 if none
 
463
 * exists.
 
464
 *
 
465
 * Returns: The mask's layer.
 
466
 *
 
467
 * Since: GIMP 2.2
 
468
 */
 
469
gint32
 
470
gimp_layer_from_mask (gint32 mask_ID)
 
471
{
 
472
  GimpParam *return_vals;
 
473
  gint nreturn_vals;
 
474
  gint32 layer_ID = -1;
 
475
 
 
476
  return_vals = gimp_run_procedure ("gimp_layer_from_mask",
 
477
                                    &nreturn_vals,
 
478
                                    GIMP_PDB_CHANNEL, mask_ID,
 
479
                                    GIMP_PDB_END);
 
480
 
 
481
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
482
    layer_ID = return_vals[1].data.d_layer;
 
483
 
 
484
  gimp_destroy_params (return_vals, nreturn_vals);
 
485
 
 
486
  return layer_ID;
 
487
}
 
488
 
 
489
/**
 
490
 * gimp_layer_add_mask:
 
491
 * @layer_ID: The layer to receive the mask.
 
492
 * @mask_ID: The mask to add to the layer.
 
493
 *
 
494
 * Add a layer mask to the specified layer.
 
495
 *
 
496
 * This procedure adds a layer mask to the specified layer. Layer masks
 
497
 * serve as an additional alpha channel for a layer. This procedure
 
498
 * will fail if a number of prerequisites aren't met. The layer cannot
 
499
 * already have a layer mask. The specified mask must exist and have
 
500
 * the same dimensions as the layer. Both the mask and the layer must
 
501
 * have been created for use with the specified image.
 
502
 *
 
503
 * Returns: TRUE on success.
 
504
 */
 
505
gboolean
 
506
gimp_layer_add_mask (gint32 layer_ID,
 
507
                     gint32 mask_ID)
 
508
{
 
509
  GimpParam *return_vals;
 
510
  gint nreturn_vals;
 
511
  gboolean success = TRUE;
 
512
 
 
513
  return_vals = gimp_run_procedure ("gimp_layer_add_mask",
 
514
                                    &nreturn_vals,
 
515
                                    GIMP_PDB_LAYER, layer_ID,
 
516
                                    GIMP_PDB_CHANNEL, mask_ID,
 
517
                                    GIMP_PDB_END);
 
518
 
 
519
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
520
 
 
521
  gimp_destroy_params (return_vals, nreturn_vals);
 
522
 
 
523
  return success;
 
524
}
 
525
 
 
526
/**
 
527
 * gimp_layer_remove_mask:
 
528
 * @layer_ID: The layer from which to remove mask.
 
529
 * @mode: Removal mode.
 
530
 *
 
531
 * Remove the specified layer mask from the layer.
 
532
 *
 
533
 * This procedure removes the specified layer mask from the layer. If
 
534
 * the mask doesn't exist, an error is returned.
 
535
 *
 
536
 * Returns: TRUE on success.
 
537
 */
 
538
gboolean
 
539
gimp_layer_remove_mask (gint32            layer_ID,
 
540
                        GimpMaskApplyMode mode)
 
541
{
 
542
  GimpParam *return_vals;
 
543
  gint nreturn_vals;
 
544
  gboolean success = TRUE;
 
545
 
 
546
  return_vals = gimp_run_procedure ("gimp_layer_remove_mask",
 
547
                                    &nreturn_vals,
 
548
                                    GIMP_PDB_LAYER, layer_ID,
 
549
                                    GIMP_PDB_INT32, mode,
 
550
                                    GIMP_PDB_END);
 
551
 
 
552
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
553
 
 
554
  gimp_destroy_params (return_vals, nreturn_vals);
 
555
 
 
556
  return success;
 
557
}
 
558
 
 
559
/**
 
560
 * gimp_layer_is_floating_sel:
 
561
 * @layer_ID: The layer.
 
562
 *
 
563
 * Is the specified layer a floating selection?
 
564
 *
 
565
 * This procedure returns whether the layer is a floating selection.
 
566
 * Floating selections are special cases of layers which are attached
 
567
 * to a specific drawable.
 
568
 *
 
569
 * Returns: Non-zero if the layer is a floating selection.
 
570
 */
 
571
gboolean
 
572
gimp_layer_is_floating_sel (gint32 layer_ID)
 
573
{
 
574
  GimpParam *return_vals;
 
575
  gint nreturn_vals;
 
576
  gboolean is_floating_sel = FALSE;
 
577
 
 
578
  return_vals = gimp_run_procedure ("gimp_layer_is_floating_sel",
 
579
                                    &nreturn_vals,
 
580
                                    GIMP_PDB_LAYER, layer_ID,
 
581
                                    GIMP_PDB_END);
 
582
 
 
583
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
584
    is_floating_sel = return_vals[1].data.d_int32;
 
585
 
 
586
  gimp_destroy_params (return_vals, nreturn_vals);
 
587
 
 
588
  return is_floating_sel;
 
589
}
 
590
 
 
591
/**
 
592
 * gimp_layer_get_preserve_trans:
 
593
 * @layer_ID: The layer.
 
594
 *
 
595
 * Get the preserve transperancy setting of the specified layer.
 
596
 *
 
597
 * This procedure returns the specified layer's preserve transperancy
 
598
 * setting.
 
599
 *
 
600
 * Returns: The layer's preserve transperancy setting.
 
601
 */
 
602
gboolean
 
603
gimp_layer_get_preserve_trans (gint32 layer_ID)
 
604
{
 
605
  GimpParam *return_vals;
 
606
  gint nreturn_vals;
 
607
  gboolean preserve_trans = FALSE;
 
608
 
 
609
  return_vals = gimp_run_procedure ("gimp_layer_get_preserve_trans",
 
610
                                    &nreturn_vals,
 
611
                                    GIMP_PDB_LAYER, layer_ID,
 
612
                                    GIMP_PDB_END);
 
613
 
 
614
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
615
    preserve_trans = return_vals[1].data.d_int32;
 
616
 
 
617
  gimp_destroy_params (return_vals, nreturn_vals);
 
618
 
 
619
  return preserve_trans;
 
620
}
 
621
 
 
622
/**
 
623
 * gimp_layer_set_preserve_trans:
 
624
 * @layer_ID: The layer.
 
625
 * @preserve_trans: The new layer's preserve transperancy setting.
 
626
 *
 
627
 * Set the preserve transperancy setting of the specified layer.
 
628
 *
 
629
 * This procedure sets the specified layer's preserve transperancy
 
630
 * setting.
 
631
 *
 
632
 * Returns: TRUE on success.
 
633
 */
 
634
gboolean
 
635
gimp_layer_set_preserve_trans (gint32   layer_ID,
 
636
                               gboolean preserve_trans)
 
637
{
 
638
  GimpParam *return_vals;
 
639
  gint nreturn_vals;
 
640
  gboolean success = TRUE;
 
641
 
 
642
  return_vals = gimp_run_procedure ("gimp_layer_set_preserve_trans",
 
643
                                    &nreturn_vals,
 
644
                                    GIMP_PDB_LAYER, layer_ID,
 
645
                                    GIMP_PDB_INT32, preserve_trans,
 
646
                                    GIMP_PDB_END);
 
647
 
 
648
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
649
 
 
650
  gimp_destroy_params (return_vals, nreturn_vals);
 
651
 
 
652
  return success;
 
653
}
 
654
 
 
655
/**
 
656
 * gimp_layer_get_apply_mask:
 
657
 * @layer_ID: The layer.
 
658
 *
 
659
 * Get the apply mask of the specified layer.
 
660
 *
 
661
 * This procedure returns the specified layer's apply mask. If the
 
662
 * value is non-zero, then the layer mask for this layer is currently
 
663
 * being composited with the layer's alpha channel.
 
664
 *
 
665
 * Returns: The layer apply mask.
 
666
 */
 
667
gboolean
 
668
gimp_layer_get_apply_mask (gint32 layer_ID)
 
669
{
 
670
  GimpParam *return_vals;
 
671
  gint nreturn_vals;
 
672
  gboolean apply_mask = FALSE;
 
673
 
 
674
  return_vals = gimp_run_procedure ("gimp_layer_get_apply_mask",
 
675
                                    &nreturn_vals,
 
676
                                    GIMP_PDB_LAYER, layer_ID,
 
677
                                    GIMP_PDB_END);
 
678
 
 
679
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
680
    apply_mask = return_vals[1].data.d_int32;
 
681
 
 
682
  gimp_destroy_params (return_vals, nreturn_vals);
 
683
 
 
684
  return apply_mask;
 
685
}
 
686
 
 
687
/**
 
688
 * gimp_layer_set_apply_mask:
 
689
 * @layer_ID: The layer.
 
690
 * @apply_mask: The new layer apply mask.
 
691
 *
 
692
 * Set the apply mask of the specified layer.
 
693
 *
 
694
 * This procedure sets the specified layer's apply mask. This controls
 
695
 * whether the layer's mask is currently affecting the alpha channel.
 
696
 * If there is no layer mask, this function will return an error.
 
697
 *
 
698
 * Returns: TRUE on success.
 
699
 */
 
700
gboolean
 
701
gimp_layer_set_apply_mask (gint32   layer_ID,
 
702
                           gboolean apply_mask)
 
703
{
 
704
  GimpParam *return_vals;
 
705
  gint nreturn_vals;
 
706
  gboolean success = TRUE;
 
707
 
 
708
  return_vals = gimp_run_procedure ("gimp_layer_set_apply_mask",
 
709
                                    &nreturn_vals,
 
710
                                    GIMP_PDB_LAYER, layer_ID,
 
711
                                    GIMP_PDB_INT32, apply_mask,
 
712
                                    GIMP_PDB_END);
 
713
 
 
714
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
715
 
 
716
  gimp_destroy_params (return_vals, nreturn_vals);
 
717
 
 
718
  return success;
 
719
}
 
720
 
 
721
/**
 
722
 * gimp_layer_get_show_mask:
 
723
 * @layer_ID: The layer.
 
724
 *
 
725
 * Get the show mask of the specified layer.
 
726
 *
 
727
 * This procedure returns the specified layer's show mask. If the value
 
728
 * is non-zero, then the layer mask for this layer is currently being
 
729
 * shown instead of the layer.
 
730
 *
 
731
 * Returns: The layer show mask.
 
732
 */
 
733
gboolean
 
734
gimp_layer_get_show_mask (gint32 layer_ID)
 
735
{
 
736
  GimpParam *return_vals;
 
737
  gint nreturn_vals;
 
738
  gboolean show_mask = FALSE;
 
739
 
 
740
  return_vals = gimp_run_procedure ("gimp_layer_get_show_mask",
 
741
                                    &nreturn_vals,
 
742
                                    GIMP_PDB_LAYER, layer_ID,
 
743
                                    GIMP_PDB_END);
 
744
 
 
745
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
746
    show_mask = return_vals[1].data.d_int32;
 
747
 
 
748
  gimp_destroy_params (return_vals, nreturn_vals);
 
749
 
 
750
  return show_mask;
 
751
}
 
752
 
 
753
/**
 
754
 * gimp_layer_set_show_mask:
 
755
 * @layer_ID: The layer.
 
756
 * @show_mask: The new layer show mask.
 
757
 *
 
758
 * Set the show mask of the specified layer.
 
759
 *
 
760
 * This procedure sets the specified layer's show mask. This controls
 
761
 * whether the layer or it's mask is visible. Non-zero values indicate
 
762
 * that the mask should be visible. If the layer has no mask, then this
 
763
 * function returns an error.
 
764
 *
 
765
 * Returns: TRUE on success.
 
766
 */
 
767
gboolean
 
768
gimp_layer_set_show_mask (gint32   layer_ID,
 
769
                          gboolean show_mask)
 
770
{
 
771
  GimpParam *return_vals;
 
772
  gint nreturn_vals;
 
773
  gboolean success = TRUE;
 
774
 
 
775
  return_vals = gimp_run_procedure ("gimp_layer_set_show_mask",
 
776
                                    &nreturn_vals,
 
777
                                    GIMP_PDB_LAYER, layer_ID,
 
778
                                    GIMP_PDB_INT32, show_mask,
 
779
                                    GIMP_PDB_END);
 
780
 
 
781
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
782
 
 
783
  gimp_destroy_params (return_vals, nreturn_vals);
 
784
 
 
785
  return success;
 
786
}
 
787
 
 
788
/**
 
789
 * gimp_layer_get_edit_mask:
 
790
 * @layer_ID: The layer.
 
791
 *
 
792
 * Get the show mask of the specified layer.
 
793
 *
 
794
 * This procedure returns the specified layer's show mask. If the value
 
795
 * is non-zero, then the layer mask for this layer is currently active,
 
796
 * and not the layer.
 
797
 *
 
798
 * Returns: The layer show mask.
 
799
 */
 
800
gboolean
 
801
gimp_layer_get_edit_mask (gint32 layer_ID)
 
802
{
 
803
  GimpParam *return_vals;
 
804
  gint nreturn_vals;
 
805
  gboolean edit_mask = FALSE;
 
806
 
 
807
  return_vals = gimp_run_procedure ("gimp_layer_get_edit_mask",
 
808
                                    &nreturn_vals,
 
809
                                    GIMP_PDB_LAYER, layer_ID,
 
810
                                    GIMP_PDB_END);
 
811
 
 
812
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
813
    edit_mask = return_vals[1].data.d_int32;
 
814
 
 
815
  gimp_destroy_params (return_vals, nreturn_vals);
 
816
 
 
817
  return edit_mask;
 
818
}
 
819
 
 
820
/**
 
821
 * gimp_layer_set_edit_mask:
 
822
 * @layer_ID: The layer.
 
823
 * @edit_mask: The new layer show mask.
 
824
 *
 
825
 * Set the show mask of the specified layer.
 
826
 *
 
827
 * This procedure sets the specified layer's show mask. This controls
 
828
 * whether the layer or it's mask is currently active for editing. If
 
829
 * the specified layer has no layer mask, then this procedure will
 
830
 * return an error.
 
831
 *
 
832
 * Returns: TRUE on success.
 
833
 */
 
834
gboolean
 
835
gimp_layer_set_edit_mask (gint32   layer_ID,
 
836
                          gboolean edit_mask)
 
837
{
 
838
  GimpParam *return_vals;
 
839
  gint nreturn_vals;
 
840
  gboolean success = TRUE;
 
841
 
 
842
  return_vals = gimp_run_procedure ("gimp_layer_set_edit_mask",
 
843
                                    &nreturn_vals,
 
844
                                    GIMP_PDB_LAYER, layer_ID,
 
845
                                    GIMP_PDB_INT32, edit_mask,
 
846
                                    GIMP_PDB_END);
 
847
 
 
848
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
849
 
 
850
  gimp_destroy_params (return_vals, nreturn_vals);
 
851
 
 
852
  return success;
 
853
}
 
854
 
 
855
/**
 
856
 * gimp_layer_get_opacity:
 
857
 * @layer_ID: The layer.
 
858
 *
 
859
 * Get the opacity of the specified layer.
 
860
 *
 
861
 * This procedure returns the specified layer's opacity.
 
862
 *
 
863
 * Returns: The layer opacity.
 
864
 */
 
865
gdouble
 
866
gimp_layer_get_opacity (gint32 layer_ID)
 
867
{
 
868
  GimpParam *return_vals;
 
869
  gint nreturn_vals;
 
870
  gdouble opacity = 0;
 
871
 
 
872
  return_vals = gimp_run_procedure ("gimp_layer_get_opacity",
 
873
                                    &nreturn_vals,
 
874
                                    GIMP_PDB_LAYER, layer_ID,
 
875
                                    GIMP_PDB_END);
 
876
 
 
877
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
878
    opacity = return_vals[1].data.d_float;
 
879
 
 
880
  gimp_destroy_params (return_vals, nreturn_vals);
 
881
 
 
882
  return opacity;
 
883
}
 
884
 
 
885
/**
 
886
 * gimp_layer_set_opacity:
 
887
 * @layer_ID: The layer.
 
888
 * @opacity: The new layer opacity.
 
889
 *
 
890
 * Set the opacity of the specified layer.
 
891
 *
 
892
 * This procedure sets the specified layer's opacity.
 
893
 *
 
894
 * Returns: TRUE on success.
 
895
 */
 
896
gboolean
 
897
gimp_layer_set_opacity (gint32  layer_ID,
 
898
                        gdouble opacity)
 
899
{
 
900
  GimpParam *return_vals;
 
901
  gint nreturn_vals;
 
902
  gboolean success = TRUE;
 
903
 
 
904
  return_vals = gimp_run_procedure ("gimp_layer_set_opacity",
 
905
                                    &nreturn_vals,
 
906
                                    GIMP_PDB_LAYER, layer_ID,
 
907
                                    GIMP_PDB_FLOAT, opacity,
 
908
                                    GIMP_PDB_END);
 
909
 
 
910
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
911
 
 
912
  gimp_destroy_params (return_vals, nreturn_vals);
 
913
 
 
914
  return success;
 
915
}
 
916
 
 
917
/**
 
918
 * gimp_layer_get_mode:
 
919
 * @layer_ID: The layer.
 
920
 *
 
921
 * Get the combination mode of the specified layer.
 
922
 *
 
923
 * This procedure returns the specified layer's combination mode.
 
924
 *
 
925
 * Returns: The layer combination mode.
 
926
 */
 
927
GimpLayerModeEffects
 
928
gimp_layer_get_mode (gint32 layer_ID)
 
929
{
 
930
  GimpParam *return_vals;
 
931
  gint nreturn_vals;
 
932
  GimpLayerModeEffects mode = 0;
 
933
 
 
934
  return_vals = gimp_run_procedure ("gimp_layer_get_mode",
 
935
                                    &nreturn_vals,
 
936
                                    GIMP_PDB_LAYER, layer_ID,
 
937
                                    GIMP_PDB_END);
 
938
 
 
939
  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
 
940
    mode = return_vals[1].data.d_int32;
 
941
 
 
942
  gimp_destroy_params (return_vals, nreturn_vals);
 
943
 
 
944
  return mode;
 
945
}
 
946
 
 
947
/**
 
948
 * gimp_layer_set_mode:
 
949
 * @layer_ID: The layer.
 
950
 * @mode: The new layer combination mode.
 
951
 *
 
952
 * Set the combination mode of the specified layer.
 
953
 *
 
954
 * This procedure sets the specified layer's combination mode.
 
955
 *
 
956
 * Returns: TRUE on success.
 
957
 */
 
958
gboolean
 
959
gimp_layer_set_mode (gint32               layer_ID,
 
960
                     GimpLayerModeEffects mode)
 
961
{
 
962
  GimpParam *return_vals;
 
963
  gint nreturn_vals;
 
964
  gboolean success = TRUE;
 
965
 
 
966
  return_vals = gimp_run_procedure ("gimp_layer_set_mode",
 
967
                                    &nreturn_vals,
 
968
                                    GIMP_PDB_LAYER, layer_ID,
 
969
                                    GIMP_PDB_INT32, mode,
 
970
                                    GIMP_PDB_END);
 
971
 
 
972
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
 
973
 
 
974
  gimp_destroy_params (return_vals, nreturn_vals);
 
975
 
 
976
  return success;
 
977
}