~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to tools/pdbgen/pdb/image.pdb

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# The GIMP -- an image manipulation program
 
1
# GIMP - The GNU Image Manipulation Program
2
2
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 
4
4
# This program is free software; you can redistribute it and/or modify
17
17
 
18
18
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
19
19
 
20
 
sub layer_arg () {{
21
 
    name => 'layer',
22
 
    type => 'layer',
23
 
    desc => 'The layer'
24
 
}}
25
 
 
26
 
sub channel_arg () {{
27
 
    name => 'channel',
28
 
    type => 'channel',
29
 
    desc => 'The channel'
30
 
}}
31
 
 
32
 
sub new_dim_args {
33
 
    foreach (qw(width height)) {
34
 
        push @inargs, { name => "new_$_",
35
 
                        type => '0 < int32',
36
 
                        desc => "New image $_: %%desc%%" }
37
 
    }
38
 
}
39
 
 
40
 
sub image_list_proc {
41
 
    my $type = shift;
42
 
 
43
 
    $blurb = "Returns the list of ${type}s contained in the specified image.";
44
 
 
45
 
    $help = <<HELP;
46
 
This procedure returns the list of ${type}s contained in the specified image.
 
20
sub image_is_valid {
 
21
    $blurb = 'Returns TRUE if the image is valid.';
 
22
 
 
23
    $help = <<'HELP';
 
24
This procedure checks if the given image ID is valid and refers to an
 
25
existing image.
47
26
HELP
48
27
 
49
 
    &std_pdb_misc;
 
28
    &neo_pdb_misc('2007', '2.4');
50
29
 
51
 
    @inargs = ( &std_image_arg );
 
30
    @inargs = (
 
31
        { name => 'image', type => 'image', no_validate => 1,
 
32
          desc => 'The image to check' }
 
33
    );
52
34
 
53
35
    @outargs = (
54
 
        { name => "${type}_ids", type => 'int32array', init => 1,
55
 
          desc => "The list of ${type}s contained in the image",
56
 
          array => { name => "num_${type}s", init => 1,
57
 
                     desc => "The number of ${type}s contained in the image" } }
 
36
        { name => 'valid', type => 'boolean',
 
37
          desc => 'Whether the image ID is valid' }
58
38
    );
59
39
 
60
40
    %invoke = (
61
 
        vars => [ 'GList *list = NULL', 'gint i' ],
62
 
        code => <<CODE
 
41
        code => <<'CODE'
63
42
{
64
 
  list = GIMP_LIST (gimage->${type}s)->list;
65
 
  num_${type}s = g_list_length (list);
66
 
 
67
 
  if (num_${type}s)
68
 
    {
69
 
      ${type}_ids = g_new (gint32, num_${type}s);
70
 
      for (i = 0; i < num_${type}s; i++, list = g_list_next (list))
71
 
        ${type}_ids[i] = gimp_item_get_ID (GIMP_ITEM (list->data));
72
 
    }
 
43
  valid = GIMP_IS_IMAGE (image);
73
44
}
74
45
CODE
75
46
    );
76
47
}
77
48
 
78
 
sub type_move {
79
 
    my ($type, $op, $pos) = @_;
80
 
    my $extra = "";
81
 
 
82
 
    if ($op =~ /_/) {
83
 
        ($op, $extra) = $op =~ /([^_]+)_(.*)/;
84
 
        $extra =~ s/_/ /g;
85
 
    }
86
 
 
87
 
    my $layer = "";
88
 
    $layer = ', or the layer has no alpha channel' if $type eq 'layer';
89
 
 
90
 
    $blurb = "\u$op the specified $type in the image's $type stack";
91
 
    $blurb .= " $extra of stack" if $extra;
92
 
 
93
 
    $help = <<HELP;
94
 
This procedure ${op}s the specified $type one step in the existing $type stack.
95
 
It will not move the $type if there is no $type $pos it$layer.
96
 
HELP
97
 
    $help =~ s/one step in/"$extra of"/e if $extra;
98
 
 
99
 
    @inargs = (
100
 
        &std_image_arg,
101
 
        &{"${type}_arg"}
102
 
    );
103
 
    $inargs[1]->{desc} .= " to $op $extra";
104
 
 
105
 
    if ($extra) {
106
 
        $extra =~ s/ /_/g;
107
 
        $extra = "_$extra";
108
 
    }
109
 
 
110
 
    %invoke = (
111
 
        code => "success = gimp_image_${op}_$type$extra (gimage, $type);"
112
 
    );
113
 
}
114
 
 
115
 
sub image_get_prop_proc {
116
 
    my ($prop, $type, $desc, $func) = @_;
117
 
 
118
 
    if ($desc =~ /\bis\b/) {
119
 
        $blurb = "Returns if the specified image's $desc.";
120
 
        $help = "This procedure returns if the specified image's $desc. ";
121
 
    } else {
122
 
        $blurb = "Returns the specified image's $desc.";
123
 
        $help = "This procedure returns the specified image's $desc. ";
124
 
    }
125
 
 
126
 
    &std_pdb_misc;
127
 
 
128
 
    @inargs = ( &std_image_arg );
129
 
 
130
 
    @outargs = (
131
 
        { name => $prop, type => $type,
132
 
          desc => "The $desc", no_declare => 1 }
133
 
    );
134
 
 
135
 
    my $alias = $func ? "gimp_image_get_$prop (gimage)" : "gimage->$prop";
136
 
    $alias = "g_strdup ($alias)" if $type eq 'string';
137
 
    $outargs[0]->{alias} .= "$alias";
138
 
}
139
 
 
140
 
sub image_set_prop_proc {
141
 
    my ($prop, $type, $desc, $func) = @_;
142
 
 
143
 
    if ($desc =~ /\bis\b/) {
144
 
        $blurb = "Sets if the specified image's $desc.";
145
 
        $help = "This procedure sets if the specified image's $desc. ";
146
 
    } else {
147
 
        $blurb = "Sets the specified image's $desc.";
148
 
        $help = "This procedure sets the specified image's $desc. ";
149
 
    }
150
 
 
151
 
    &std_pdb_misc;
152
 
 
153
 
    @inargs = (
154
 
        &std_image_arg,
155
 
        { name => $prop, type => $type,
156
 
          desc => "The new image $desc" }
157
 
    );
158
 
 
159
 
    if ($type =~ /float/) {
160
 
        $inargs[1]->{desc} .= ' (%%desc%%)';
161
 
    }
162
 
 
163
 
    $invoke{code} = $func ? "gimp_image_set_$prop (gimage, $prop);"
164
 
                          : "gimage->$prop = $prop;";
165
 
}
166
 
 
167
 
sub image_accessors {
168
 
    my ($prop, $type, $desc, $func, $extra) = @_;
169
 
    my (@extra, %extra); my $once = 0;
170
 
 
171
 
    ref($extra) ? (@extra = @$extra) : (@extra = ($extra, $extra));
172
 
    %extra = map { $once++ ? 'set' : 'get', $_ ? $_ : "" } @extra;
173
 
 
174
 
    foreach (sort keys %extra) {
175
 
        my $proc = "image_${_}_$prop";
176
 
 
177
 
        push @procs, $proc;
178
 
 
179
 
        eval <<SUB;
180
 
sub @{[ scalar caller ]}::$proc {
181
 
    \&image_${_}_prop_proc('$prop', '$type', '$desc', $func);
182
 
    $extra{$_}
183
 
}
184
 
SUB
185
 
    }
186
 
}
187
 
 
188
 
# The defs
189
 
 
190
49
sub image_list {
191
50
    $blurb = 'Returns the list of images currently open.';
192
51
 
194
53
This procedure returns the list of images currently open in the GIMP.
195
54
HELP
196
55
 
197
 
    &image_list_proc('image');
198
 
 
199
 
    undef @inargs;
200
 
 
201
 
    foreach ($blurb, $help, $outargs[0]->{desc}, $outargs[0]->{array}->{desc}) {
202
 
        s/contained.*/currently open/
203
 
    }
204
 
 
205
 
    $blurb .= '.';
206
 
    $help  .= ' in the GIMP.';
207
 
 
208
 
    for ($invoke{code}) {
209
 
        s/gimage->images/gimp->images/;
210
 
        s/ITEM/IMAGE/;
211
 
        s/gimp_item_get_ID/gimp_image_get_ID/;
212
 
    }
 
56
    &std_pdb_misc;
 
57
 
 
58
    @outargs = (
 
59
        { name => 'image_ids', type => 'int32array',
 
60
          desc => 'The list of images currently open',
 
61
          array => { name => 'num_images',
 
62
                     desc => 'The number of images currently open' } }
 
63
    );
 
64
 
 
65
    %invoke = (
 
66
        code => <<CODE
 
67
{
 
68
  GList *list = GIMP_LIST (gimp->images)->list;
 
69
 
 
70
  num_images = g_list_length (list);
 
71
 
 
72
  if (num_images)
 
73
    {
 
74
      gint i;
 
75
 
 
76
      image_ids = g_new (gint32, num_images);
 
77
 
 
78
      for (i = 0; i < num_images; i++, list = g_list_next (list))
 
79
        image_ids[i] = gimp_image_get_ID (GIMP_IMAGE (list->data));
 
80
    }
 
81
}
 
82
CODE
 
83
    );
213
84
}
214
85
 
215
86
sub image_new {
218
89
    $help = <<'HELP';
219
90
Creates a new image, undisplayed with the specified extents and type. A layer
220
91
should be created and added before this image is displayed, or subsequent calls
221
 
to 'gimp_display_new' with this image as an argument will fail. Layers can be
222
 
created using the 'gimp_layer_new' commands. They can be added to an image
223
 
using the 'gimp_image_add_layer' command.
 
92
to gimp_display_new() with this image as an argument will fail. Layers can be
 
93
created using the gimp_layer_new() commands. They can be added to an image
 
94
using the gimp_image_add_layer() command.
224
95
HELP
225
96
 
226
97
    &std_pdb_misc;
227
98
 
228
99
    @inargs = (
 
100
        { name => 'width', type => '1 <= int32',
 
101
          desc => 'The width of the image' },
 
102
        { name => 'height', type => '1 <= int32',
 
103
          desc => 'The height of the image' },
229
104
        { name => 'type', type => 'enum GimpImageBaseType',
230
 
          desc => 'The type of image: { %%desc%% }' }
 
105
          desc => 'The type of image' }
231
106
    );
232
107
 
233
 
    foreach (qw(height width)) {
234
 
        unshift @inargs, { name => $_, type => '0 < int32',
235
 
                           desc => "The $_ of the image" }
236
 
    }
237
 
 
238
108
    @outargs = (
239
 
        { name => 'image', type => 'image', init => 1,
 
109
        { name => 'image', type => 'image',
240
110
          desc => 'The ID of the newly created image' }
241
111
    );
242
112
 
244
114
        code => <<'CODE'
245
115
{
246
116
  image = gimp_create_image (gimp, width, height, type, FALSE);
247
 
  success = (image != NULL);
 
117
 
 
118
  if (! image)
 
119
    success = FALSE;
248
120
}
249
121
CODE
250
122
    );
261
133
    &std_pdb_misc;
262
134
    $date = '1997';
263
135
 
264
 
    @inargs = ( &std_image_arg );
 
136
    @inargs = (
 
137
        { name => 'image', type => 'image',
 
138
          desc => 'The image' }
 
139
    );
265
140
 
266
141
    @outargs = (
267
142
        { name => 'new_image', type => 'image',
268
 
          desc => 'The new, duplicated image', init => 1 }
 
143
          desc => 'The new, duplicated image' }
269
144
    );
270
145
 
271
146
    %invoke = (
272
147
        headers => [ qw("core/gimpimage-duplicate.h") ],
273
148
        code => <<'CODE'
274
 
success = (new_image = gimp_image_duplicate (gimage)) != NULL;
 
149
{
 
150
  new_image = gimp_image_duplicate (image);
 
151
 
 
152
  if (! new_image)
 
153
    success = FALSE;
 
154
}
275
155
CODE
276
156
    );
277
157
}
289
169
 
290
170
    &std_pdb_misc;
291
171
 
292
 
    @inargs = ( &std_image_arg );
 
172
    @inargs = (
 
173
        { name => 'image', type => 'image',
 
174
          desc => 'The image' }
 
175
    );
293
176
 
294
 
    %invoke = ( code => <<'CODE' );
 
177
    %invoke = (
 
178
        code => <<'CODE'
295
179
{
296
 
  if (gimage->disp_count == 0)
297
 
    g_object_unref (gimage);
 
180
  if (image->disp_count == 0)
 
181
    g_object_unref (image);
298
182
  else
299
183
    success = FALSE;
300
184
}
301
185
CODE
 
186
    );
302
187
}
303
188
 
304
189
sub image_resize {
316
201
 
317
202
    &std_pdb_misc;
318
203
 
319
 
    @inargs = ( &std_image_arg );
320
 
    &new_dim_args;
321
 
 
322
 
    foreach (qw(x y)) {
323
 
        push @inargs, { name => "off$_", type => 'int32',
324
 
                        desc => "$_ offset between upper left corner of old and
325
 
                                 new images: (new - old)" }
326
 
    }
 
204
    @inargs = (
 
205
        { name => 'image', type => 'image',
 
206
          desc => 'The image' },
 
207
        { name => 'new_width', type => '1 <= int32',
 
208
          desc => 'New image width' },
 
209
        { name => 'new_height', type => '1 <= int32',
 
210
          desc => 'New image height' },
 
211
        { name => 'offx', type => 'int32',
 
212
          desc => 'x offset between upper left corner of old and
 
213
                   new images: (new - old)' },
 
214
        { name => 'offy', type => 'int32',
 
215
          desc => 'y offset between upper left corner of old and
 
216
                   new images: (new - old)' }
 
217
    );
327
218
 
328
219
    %invoke = (
329
220
        headers => [ qw("core/gimpimage-resize.h") ],
330
221
        code => <<'CODE'
331
222
{
332
 
  gimp_image_resize (gimage, context,
 
223
  gimp_image_resize (image, context,
333
224
                     new_width, new_height, offx, offy, NULL);
334
225
}
335
226
CODE
346
237
new image area.
347
238
HELP
348
239
 
349
 
    $author = $copyright = 'Simon Budig';
350
 
    $date = '2004';
351
 
    
352
 
    $since = '2.2';
 
240
    &simon_pdb_misc('2004', '2.2');
353
241
 
354
 
    @inargs = ( &std_image_arg );
 
242
    @inargs = (
 
243
        { name => 'image', type => 'image',
 
244
          desc => 'The image' }
 
245
    );
355
246
 
356
247
    %invoke = (
357
248
        headers => [ qw("core/gimpimage-resize.h") ],
358
249
        code => <<'CODE'
359
250
{
360
 
  gimp_image_resize_to_layers (gimage, context, NULL);
 
251
  gimp_image_resize_to_layers (image, context, NULL);
361
252
}
362
253
CODE
363
254
    );
378
269
 
379
270
    &std_pdb_misc;
380
271
 
381
 
    @inargs = ( &std_image_arg );
382
 
    &new_dim_args;
 
272
    @inargs = (
 
273
        { name => 'image', type => 'image',
 
274
          desc => 'The image' },
 
275
        { name => 'new_width', type => '1 <= int32',
 
276
          desc => 'New image width' },
 
277
        { name => 'new_height', type => '1 <= int32',
 
278
          desc => 'New image height' }
 
279
    );
383
280
 
384
281
    %invoke = (
385
282
        headers => [ qw("config/gimpcoreconfig.h" "core/gimpimage-scale.h") ],
386
283
        code => <<'CODE'
387
284
{
388
 
  gimp_image_scale (gimage, new_width, new_height,
 
285
  gimp_image_scale (image, new_width, new_height,
389
286
                    gimp->config->interpolation_type,
390
287
                    NULL);
391
288
}
407
304
    &std_pdb_misc;
408
305
 
409
306
    @inargs = (
410
 
        &std_image_arg,
411
 
        { name => 'new_width', type => '0 < int32',
 
307
        { name => 'image', type => 'image',
 
308
          desc => 'The image' },
 
309
        { name => 'new_width', type => '1 <= int32',
412
310
          desc => 'New image width: (0 < new_width <= width)' },
413
 
        { name => 'new_height', type => '0 < int32',
 
311
        { name => 'new_height', type => '1 <= int32',
414
312
          desc => 'New image height: (0 < new_height <= height)' },
415
313
        { name => 'offx', type => '0 <= int32',
416
314
          desc => 'x offset: (0 <= offx <= (width - new_width))' },
422
320
        headers => [ qw("core/gimpimage-crop.h") ],
423
321
        code => <<'CODE'
424
322
{
425
 
  if (new_width  > gimage->width          ||
426
 
      new_height > gimage->height         ||
427
 
      offx > (gimage->width  - new_width) ||
428
 
      offy > (gimage->height - new_height))
 
323
  if (new_width  > image->width          ||
 
324
      new_height > image->height         ||
 
325
      offx > (image->width  - new_width) ||
 
326
      offy > (image->height - new_height))
429
327
    success = FALSE;
430
328
  else
431
 
    gimp_image_crop (gimage, context,
 
329
    gimp_image_crop (image, context,
432
330
                     offx, offy, offx + new_width, offy + new_height,
433
331
                     FALSE, TRUE);
434
332
}
446
344
    &std_pdb_misc;
447
345
 
448
346
    @inargs = (
449
 
        &std_image_arg,
450
 
        { name => 'flip_type', type => &std_orientation_enum,
451
 
          desc => 'Type of flip: %%desc%%' }
 
347
        { name => 'image', type => 'image',
 
348
          desc => 'The image' },
 
349
        { name => 'flip_type',
 
350
          type => 'enum GimpOrientationType (no GIMP_ORIENTATION_UNKNOWN)',
 
351
          desc => 'Type of flip' }
452
352
    );
453
353
 
454
354
    %invoke = (
455
355
        headers => [ qw("core/gimpimage-flip.h") ],
456
356
        code => <<'CODE'
457
357
{
458
 
  gimp_image_flip (gimage, context, flip_type, NULL);
 
358
  gimp_image_flip (image, context, flip_type, NULL);
459
359
}
460
360
CODE
461
361
    );
464
364
sub image_rotate {
465
365
    $blurb = 'Rotates the image by the specified degrees.';
466
366
    $help = 'This procedure rotates the image.';
467
 
    $author = $copyright = 'Michael Natterer';
468
 
    $date = '2003';
 
367
 
 
368
    &mitch_pdb_misc('2003');
469
369
 
470
370
    @inargs = (
471
 
        &std_image_arg,
 
371
        { name => 'image', type => 'image',
 
372
          desc => 'The image' },
472
373
        { name => 'rotate_type', type => 'enum GimpRotationType',
473
 
          desc => 'Angle of rotation: %%desc%%' }
 
374
          desc => 'Angle of rotation' }
474
375
    );
475
376
 
476
377
    %invoke = (
477
378
        headers => [ qw("core/gimpimage-rotate.h") ],
478
379
        code => <<'CODE'
479
380
{
480
 
  gimp_image_rotate (gimage, context, rotate_type, NULL);
 
381
  gimp_image_rotate (image, context, rotate_type, NULL);
481
382
}
482
383
CODE
483
384
    );
489
390
    $help = <<'HELP';
490
391
This procedure is intended as a memory saving device. If any shadow memory has
491
392
been allocated, it will be freed automatically on a call to
492
 
'gimp_image_delete'.
 
393
gimp_image_delete().
493
394
HELP
494
395
 
495
396
    &std_pdb_misc;
496
397
 
497
 
    @inargs = ( &std_image_arg );
 
398
    @inargs = (
 
399
        { name => 'image', type => 'image',
 
400
          desc => 'The image' }
 
401
    );
498
402
 
499
 
    %invoke = ( code => 'gimp_image_free_shadow (gimage);' );
 
403
    %invoke = (
 
404
        code => <<'CODE'
 
405
{
 
406
  gimp_image_free_shadow_tiles (image);
 
407
}
 
408
CODE
 
409
    );
500
410
}
501
411
 
502
412
sub image_get_layers {
503
 
    &image_list_proc('layer');
504
 
 
505
 
    $help .= 'The order of layers is from topmost to bottommost.';
 
413
    $blurb = 'Returns the list of layers contained in the specified image.';
 
414
 
 
415
    $help = <<HELP;
 
416
This procedure returns the list of layers contained in the specified image.
 
417
The order of layers is from topmost to bottommost.
 
418
HELP
 
419
 
 
420
    &std_pdb_misc;
 
421
 
 
422
    @inargs = (
 
423
        { name => 'image', type => 'image',
 
424
          desc => 'The image' }
 
425
    );
 
426
 
 
427
    @outargs = (
 
428
        { name => 'layer_ids', type => 'int32array',
 
429
          desc => 'The list of layers contained in the image',
 
430
          array => { name => 'num_layers',
 
431
                     desc => 'The number of layers contained in the image' } }
 
432
    );
 
433
 
 
434
    %invoke = (
 
435
        code => <<'CODE'
 
436
{
 
437
  GList *list = GIMP_LIST (image->layers)->list;
 
438
 
 
439
  num_layers = g_list_length (list);
 
440
 
 
441
  if (num_layers)
 
442
    {
 
443
      gint i;
 
444
 
 
445
      layer_ids = g_new (gint32, num_layers);
 
446
 
 
447
      for (i = 0; i < num_layers; i++, list = g_list_next (list))
 
448
        layer_ids[i] = gimp_item_get_ID (GIMP_ITEM (list->data));
 
449
    }
 
450
}
 
451
CODE
 
452
    );
506
453
}
507
454
 
508
455
sub image_get_channels {
509
 
    &image_list_proc('channel');
 
456
    $blurb = 'Returns the list of channels contained in the specified image.';
510
457
 
511
 
    $help .= <<'HELP';
 
458
    $help = <<HELP;
 
459
This procedure returns the list of channels contained in the specified image.
512
460
This does not include the selection mask, or layer masks. The order is from
513
461
topmost to bottommost.
514
462
HELP
 
463
 
 
464
    &std_pdb_misc;
 
465
 
 
466
    @inargs = (
 
467
        { name => 'image', type => 'image',
 
468
          desc => 'The image' }
 
469
    );
 
470
 
 
471
    @outargs = (
 
472
        { name => 'channel_ids', type => 'int32array',
 
473
          desc => 'The list of channels contained in the image',
 
474
          array => { name => 'num_channels',
 
475
                     desc => 'The number of channels contained in the image' } }
 
476
    );
 
477
 
 
478
    %invoke = (
 
479
        code => <<'CODE'
 
480
{
 
481
  GList *list = GIMP_LIST (image->channels)->list;
 
482
 
 
483
  num_channels = g_list_length (list);
 
484
 
 
485
  if (num_channels)
 
486
    {
 
487
      gint i;
 
488
 
 
489
      channel_ids = g_new (gint32, num_channels);
 
490
 
 
491
      for (i = 0; i < num_channels; i++, list = g_list_next (list))
 
492
        channel_ids[i] = gimp_item_get_ID (GIMP_ITEM (list->data));
 
493
    }
 
494
}
 
495
CODE
 
496
    );
 
497
}
 
498
 
 
499
sub image_get_vectors {
 
500
    $blurb = 'Returns the list of vectors contained in the specified image.';
 
501
 
 
502
    $help = <<HELP;
 
503
This procedure returns the list of vectors contained in the specified image.
 
504
HELP
 
505
 
 
506
    &simon_pdb_misc('2005', '2.4');
 
507
 
 
508
    @inargs = (
 
509
        { name => 'image', type => 'image',
 
510
          desc => 'The image' }
 
511
    );
 
512
 
 
513
    @outargs = (
 
514
        { name => 'vector_ids', type => 'int32array',
 
515
          desc => 'The list of vectors contained in the image',
 
516
          array => { name => 'num_vectors',
 
517
                     desc => 'The number of vectors contained in the image' } }
 
518
    );
 
519
 
 
520
    %invoke = (
 
521
        code => <<'CODE'
 
522
{
 
523
  GList *list = GIMP_LIST (image->vectors)->list;
 
524
 
 
525
  num_vectors = g_list_length (list);
 
526
 
 
527
  if (num_vectors)
 
528
    {
 
529
      gint i;
 
530
 
 
531
      vector_ids = g_new (gint32, num_vectors);
 
532
 
 
533
      for (i = 0; i < num_vectors; i++, list = g_list_next (list))
 
534
        vector_ids[i] = gimp_item_get_ID (GIMP_ITEM (list->data));
 
535
    }
 
536
}
 
537
CODE
 
538
    );
515
539
}
516
540
 
517
541
sub image_unset_active_channel {
525
549
 
526
550
    &std_pdb_misc;
527
551
 
528
 
    @inargs = ( &std_image_arg );
 
552
    @inargs = (
 
553
        { name => 'image', type => 'image',
 
554
          desc => 'The image' }
 
555
    );
529
556
 
530
 
    %invoke = ( code => 'gimp_image_unset_active_channel (gimage);' );
 
557
    %invoke = (
 
558
        code => <<'CODE'
 
559
{
 
560
  gimp_image_unset_active_channel (image);
 
561
}
 
562
CODE
 
563
    );
531
564
}
532
565
 
533
566
sub image_pick_color {
542
575
specified drawable, then an error is returned. If the drawable has an
543
576
alpha channel, the algorithm examines the alpha value of the drawable
544
577
at the coordinates. If the alpha value is completely transparent (0),
545
 
then an error is returned. If the sample_merged parameter is non-zero,
 
578
then an error is returned. If the sample_merged parameter is TRUE,
546
579
the data of the composite image will be used instead of that for the
547
580
specified drawable. This is equivalent to sampling for colors after
548
581
merging all visible layers. In the case of a merged sampling, the
549
 
supplied drawable is ignored except for finding the image it belongs
550
 
to.
 
582
supplied drawable is ignored.
551
583
HELP
552
584
 
553
585
    &std_pdb_misc;
554
586
 
555
587
    @inargs = (
556
 
        &std_image_arg,
557
 
        { name => 'drawable', type => 'drawable',
 
588
        { name => 'image', type => 'image',
 
589
          desc => 'The image' },
 
590
        { name => 'drawable', type => 'drawable', none_ok => 1,
558
591
          desc => 'The drawable to pick from' },
559
592
        { name => 'x', type => 'float',
560
593
          desc => 'x coordinate of upper-left corner of rectangle' },
565
598
        { name => 'sample_average', type => 'boolean',
566
599
          desc => 'Average the color of all the pixels in a specified
567
600
                   radius' },
568
 
        { name => 'average_radius', type => '0 < float',
569
 
          desc => 'The radius of pixels to average',
570
 
          cond => [ 'sample_average' ] }
 
601
        { name => 'average_radius', type => '0 < float', no_success => 1,
 
602
          desc => 'The radius of pixels to average' }
571
603
    );
572
 
    $inargs[1]->{no_success} = 1;
573
604
 
574
605
    @outargs = (
575
 
        { name => 'color', type => 'color', void_ret => 1,
576
 
          desc => 'The return color', init => 1 }
 
606
        { name => 'color', type => 'color', has_alpha => 1, void_ret => 1,
 
607
          desc => 'The return color' }
577
608
    );
578
609
 
579
610
    %invoke = (
580
 
        headers => [ qw("core/gimpimage-pick-color.h" "core/gimpprojection.h") ],
 
611
        headers => [ qw("core/gimpimage-pick-color.h" "core/gimppickable.h") ],
581
612
        code => <<'CODE'
582
613
{
583
614
  if (!sample_merged)
584
 
    if (!drawable || (gimp_item_get_image (GIMP_ITEM (drawable)) != gimage))
 
615
    if (!drawable || (gimp_item_get_image (GIMP_ITEM (drawable)) != image))
585
616
      success = FALSE;
586
617
 
 
618
  if (success && sample_average)
 
619
    {
 
620
      if (average_radius <= 0.0)
 
621
        success = FALSE;
 
622
    }
 
623
 
587
624
  if (success)
588
625
    {
589
626
      if (sample_merged)
590
 
        {
591
 
          gimp_projection_finish_draw (gimage->projection);
592
 
          gimp_projection_flush_now (gimage->projection);
593
 
        }
 
627
        gimp_pickable_flush (GIMP_PICKABLE (image->projection));
 
628
      else
 
629
        gimp_pickable_flush (GIMP_PICKABLE (drawable));
594
630
 
595
 
      success = gimp_image_pick_color (gimage,
 
631
      success = gimp_image_pick_color (image,
596
632
                                       drawable,
597
633
                                       (gint) x, (gint) y,
598
 
                                       sample_merged,
 
634
                                       sample_merged,
599
635
                                       sample_average,
600
636
                                       average_radius,
601
637
                                       NULL,
619
655
 
620
656
    &std_pdb_misc;
621
657
 
622
 
    @inargs = ( &std_image_arg );
623
 
    foreach (qw(x y)) {
624
 
        push @inargs, { name => $_, type => 'int32',
625
 
                        desc => "The $_ coordinate for the pick" }
626
 
    }
 
658
    @inargs = (
 
659
        { name => 'image', type => 'image',
 
660
          desc => 'The image' },
 
661
        { name => 'x', type => 'int32',
 
662
          desc => 'The x coordinate for the pick' },
 
663
        { name => 'y', type => 'int32',
 
664
          desc => 'The y coordinate for the pick' }
 
665
    );
627
666
 
628
667
    @outargs = (
629
 
        { name => 'layer', type => 'layer', init => 1,
 
668
        { name => 'layer', type => 'layer',
630
669
          desc => 'The layer found at the specified coordinates' }
631
670
    );
632
671
 
633
672
    %invoke = (
634
 
        code => 'layer = gimp_image_pick_correlate_layer (gimage, x, y);'
 
673
        code => <<'CODE'
 
674
{
 
675
  layer = gimp_image_pick_correlate_layer (image, x, y);
 
676
}
 
677
CODE
 
678
    );
 
679
}
 
680
 
 
681
sub image_get_layer_position {
 
682
    $blurb = 'Returns the position of the layer in the layer stack.';
 
683
 
 
684
    $help = <<'HELP';
 
685
This procedure determines the positioin of the specified layer in the images
 
686
layer stack. If the layer doesn't exist in the image, an error is returned.
 
687
HELP
 
688
 
 
689
    &simon_pdb_misc('2006', '2.4');
 
690
 
 
691
    @inargs = (
 
692
        { name => 'image', type => 'image',
 
693
          desc => 'The image' },
 
694
        { name => 'layer', type => 'layer',
 
695
          desc => 'The layer' }
 
696
    );
 
697
 
 
698
    @outargs = (
 
699
        { name => 'position', type => 'int32',
 
700
          desc => "The position of the layer in the layer stack" }
 
701
    );
 
702
 
 
703
 
 
704
    %invoke = (
 
705
        code => <<'CODE'
 
706
{
 
707
  position = gimp_container_get_child_index (GIMP_CONTAINER (image->layers),
 
708
                                             GIMP_OBJECT (layer));
 
709
  if (position < 0)
 
710
    success = FALSE;
 
711
}
 
712
CODE
635
713
    );
636
714
}
637
715
 
638
716
sub image_raise_layer {
639
 
    &type_move('layer', 'raise', 'above');
 
717
    $blurb = "Raise the specified layer in the image's layer stack";
 
718
 
 
719
    $help = <<'HELP';
 
720
This procedure raises the specified layer one step in the existing layer stack.
 
721
It will not move the layer if there is no layer above it.
 
722
HELP
 
723
 
640
724
    &std_pdb_misc;
 
725
 
 
726
    @inargs = (
 
727
        { name => 'image', type => 'image',
 
728
          desc => 'The image' },
 
729
        { name => 'layer', type => 'layer',
 
730
          desc => 'The layer to raise' }
 
731
    );
 
732
 
 
733
    %invoke = (
 
734
        code => <<'CODE'
 
735
{
 
736
  success = gimp_image_raise_layer (image, layer);
 
737
}
 
738
CODE
 
739
    );
641
740
}
642
741
 
643
742
sub image_lower_layer {
644
 
    &type_move('layer', 'lower', 'below');
 
743
    $blurb = "Lower the specified layer in the image's layer stack";
 
744
 
 
745
    $help = <<'HELP';
 
746
This procedure lowers the specified layer one step in the existing layer stack.
 
747
It will not move the layer if there is no layer below it.
 
748
HELP
 
749
 
645
750
    &std_pdb_misc;
 
751
 
 
752
    @inargs = (
 
753
        { name => 'image', type => 'image',
 
754
          desc => 'The image' },
 
755
        { name => 'layer', type => 'layer',
 
756
          desc => 'The layer to lower' }
 
757
    );
 
758
 
 
759
    %invoke = (
 
760
        code => <<'CODE'
 
761
{
 
762
  success = gimp_image_lower_layer (image, layer);
 
763
}
 
764
CODE
 
765
    );
646
766
}
647
767
 
648
768
sub image_raise_layer_to_top {
649
 
    &type_move('layer', 'raise_to_top', 'above');
650
 
    $copyright = "Wolfgang Hofer";
651
 
    $author = $copyright . ", Sven Neumann";
652
 
    $date = 1998;
 
769
    $blurb = <<'BLURB';
 
770
Raise the specified layer in the image's layer stack to top of stack
 
771
BLURB
 
772
 
 
773
    $help = <<'HELP';
 
774
This procedure raises the specified layer to top of the existing layer stack.
 
775
It will not move the layer if there is no layer above it.
 
776
HELP
 
777
 
 
778
    &wolfgang_pdb_misc('1998');
 
779
    $author .= ", Sven Neumann";
 
780
 
 
781
    @inargs = (
 
782
        { name => 'image', type => 'image',
 
783
          desc => 'The image' },
 
784
        { name => 'layer', type => 'layer',
 
785
          desc => 'The layer to raise to top' }
 
786
    );
 
787
 
 
788
    %invoke = (
 
789
        code => <<'CODE'
 
790
{
 
791
  success = gimp_image_raise_layer_to_top (image, layer);
 
792
}
 
793
CODE
 
794
    );
653
795
}
654
796
 
655
797
sub image_lower_layer_to_bottom {
656
 
    &type_move('layer', 'lower_to_bottom', 'below');
657
 
    $copyright = "Wolfgang Hofer";
658
 
    $author = $copyright . ", Sven Neumann";
659
 
    $date = 1998;
 
798
    $blurb = <<'BLURB';
 
799
Lower the specified layer in the image's layer stack to bottom of stack
 
800
BLURB
 
801
 
 
802
    $help = <<'HELP';
 
803
This procedure lowers the specified layer to bottom of the existing layer stack.
 
804
It will not move the layer if there is no layer below it.
 
805
HELP
 
806
 
 
807
    &wolfgang_pdb_misc('1998');
 
808
    $author .= ", Sven Neumann";
 
809
 
 
810
    @inargs = (
 
811
        { name => 'image', type => 'image',
 
812
          desc => 'The image' },
 
813
        { name => 'layer', type => 'layer',
 
814
          desc => 'The layer to lower to bottom' }
 
815
    );
 
816
 
 
817
    %invoke = (
 
818
        code => <<'CODE'
 
819
{
 
820
  success = gimp_image_lower_layer_to_bottom (image, layer);
 
821
}
 
822
CODE
 
823
    );
660
824
}
661
825
 
662
826
sub image_merge_visible_layers {
674
838
    &std_pdb_misc;
675
839
 
676
840
    @inargs = (
677
 
        &std_image_arg,
 
841
        { name => 'image', type => 'image',
 
842
          desc => 'The image' },
678
843
        { name => 'merge_type',
679
844
          type => 'enum GimpMergeType (no GIMP_FLATTEN_IMAGE)',
680
 
          desc => 'The type of merge: { %%desc%% }' }
 
845
          desc => 'The type of merge' }
681
846
    );
682
847
 
683
848
    @outargs = (
684
 
        { name => 'layer', type => 'layer', init => 1,
 
849
        { name => 'layer', type => 'layer',
685
850
          desc => 'The resulting layer' }
686
851
    );
687
852
 
689
854
        headers => [ qw("core/gimpimage-merge.h") ],
690
855
        code => <<'CODE'
691
856
{
692
 
  layer = gimp_image_merge_visible_layers (gimage, context, merge_type);
693
 
  success = layer != NULL;
 
857
  layer = gimp_image_merge_visible_layers (image, context, merge_type, FALSE);
 
858
 
 
859
  if (! layer)
 
860
    success = FALSE;
694
861
}
695
862
CODE
696
863
    );
708
875
layer.
709
876
HELP
710
877
 
711
 
    $author = $copyright = 'Larry Ewing';
712
 
    $date = '1998';
 
878
    &larry_pdb_misc('1998');
713
879
 
714
880
    @inargs = (
715
 
        &std_image_arg,
 
881
        { name => 'image', type => 'image',
 
882
          desc => 'The image' },
716
883
        { name => 'merge_layer', type => 'layer',
717
884
          desc => 'The layer to merge down from' },
718
885
        { name => 'merge_type',
719
886
          type => 'enum GimpMergeType (no GIMP_FLATTEN_IMAGE)',
720
 
          desc => 'The type of merge: { %%desc%% }' }
 
887
          desc => 'The type of merge' }
721
888
    );
722
889
 
723
890
    @outargs = (
724
 
        { name => 'layer', type => 'layer', init => 1,
 
891
        { name => 'layer', type => 'layer',
725
892
          desc => 'The resulting layer' }
726
893
    );
727
894
 
729
896
        headers => [ qw("core/gimpimage-merge.h") ],
730
897
        code => <<'CODE'
731
898
{
732
 
  layer = gimp_image_merge_down (gimage, merge_layer, context, merge_type);
733
 
  success = layer != NULL;
 
899
  layer = gimp_image_merge_down (image, merge_layer, context, merge_type);
 
900
 
 
901
  if (! layer)
 
902
    success = FALSE;
734
903
}
735
904
CODE
736
905
    );
749
918
 
750
919
    &std_pdb_misc;
751
920
 
752
 
    @inargs = ( &std_image_arg );
 
921
    @inargs = (
 
922
        { name => 'image', type => 'image',
 
923
          desc => 'The image' }
 
924
   );
753
925
 
754
926
    @outargs = (
755
 
        { name => 'layer', type => 'layer', init => 1,
 
927
        { name => 'layer', type => 'layer',
756
928
          desc => 'The resulting layer' }
757
929
    );
758
930
 
759
931
    %invoke = (
760
932
        headers => [ qw("core/gimpimage-merge.h") ],
761
 
        code => 'success = (layer = gimp_image_flatten (gimage, context)) != NULL;'
 
933
        code => <<'CODE'
 
934
{
 
935
  layer = gimp_image_flatten (image, context);
 
936
 
 
937
  if (! layer)
 
938
    success = FALSE;
 
939
}
 
940
CODE
762
941
    );
763
942
}
764
943
 
766
945
    $blurb = 'Add the specified layer to the image.';
767
946
 
768
947
    $help = <<'HELP';
769
 
This procedure adds the specified layer to the gimage at the given position. If
770
 
the position is specified as -1, then the layer is inserted at the top of the
771
 
layer stack. If the layer to be added has no alpha channel, it must be added at
772
 
position 0. The layer type must be compatible with the image base type.
 
948
This procedure adds the specified layer to the image at the given position.
 
949
If the position is specified as -1, then the layer is inserted above the
 
950
active layer. The layer type must be compatible with the image base type.
773
951
HELP
774
952
 
775
953
    &std_pdb_misc;
776
954
 
777
955
    @inargs = (
778
 
        &std_image_arg,
779
 
        &layer_arg,
 
956
        { name => 'image', type => 'image',
 
957
          desc => 'The image' },
 
958
        { name => 'layer', type => 'layer',
 
959
          desc => 'The layer' },
780
960
        { name => 'position', type => 'int32',
781
961
          desc => 'The layer position' }
782
962
    );
783
963
 
784
964
    $invoke{code} = <<'CODE';
785
965
{
786
 
  if (! gimp_item_is_floating (GIMP_ITEM (layer)) ||
 
966
  if (! g_object_is_floating (layer) ||
787
967
      GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (layer))) !=
788
 
      gimp_image_base_type (gimage))
 
968
      gimp_image_base_type (image))
789
969
    {
790
970
      success = FALSE;
791
971
    }
792
972
  else
793
973
    {
794
 
      success = gimp_image_add_layer (gimage, layer, MAX (position, -1));
 
974
      success = gimp_image_add_layer (image, layer, MAX (position, -1));
795
975
    }
796
976
}
797
977
CODE
810
990
    &std_pdb_misc;
811
991
 
812
992
    @inargs = (
813
 
        &std_image_arg,
814
 
        &layer_arg
 
993
        { name => 'image', type => 'image',
 
994
          desc => 'The image' },
 
995
        { name => 'layer', type => 'layer',
 
996
          desc => 'The layer' }
815
997
    );
816
998
 
817
 
    %invoke = ( code => 'gimp_image_remove_layer (gimage, layer);' );
 
999
    %invoke = (
 
1000
        code => <<'CODE'
 
1001
{
 
1002
  gimp_image_remove_layer (image, layer);
 
1003
}
 
1004
CODE
 
1005
    );
818
1006
}
819
1007
 
820
1008
sub image_add_layer_mask {
821
 
    &std_pdb_deprecated ('gimp_layer_add_mask');
 
1009
    &std_pdb_deprecated ('gimp-layer-add-mask');
822
1010
 
823
1011
    @inargs = (
824
 
        &std_image_arg,
825
 
        &layer_arg,
 
1012
        { name => 'image', type => 'image',
 
1013
          desc => 'The image' },
 
1014
        { name => 'layer', type => 'layer',
 
1015
          desc => 'The layer to receive the mask' },
826
1016
        { name => 'mask', type => 'layer_mask',
827
1017
          desc => 'The mask to add to the layer' }
828
1018
    );
829
 
    $inargs[1]->{desc} .= ' to receive the mask';
830
1019
 
831
1020
    %invoke = (
832
1021
        code => <<'CODE'
833
1022
{
834
 
  success = gimp_layer_add_mask (layer, mask, TRUE) != NULL;
 
1023
  if (! gimp_layer_add_mask (layer, mask, TRUE))
 
1024
    success = FALSE;
835
1025
}
836
1026
CODE
837
1027
    );
838
1028
}
839
1029
 
840
1030
sub image_remove_layer_mask {
841
 
    &std_pdb_deprecated ('gimp_layer_remove_mask');
 
1031
    &std_pdb_deprecated ('gimp-layer-remove-mask');
842
1032
 
843
1033
    @inargs = (
844
 
        &std_image_arg,
845
 
        &layer_arg,
 
1034
        { name => 'image', type => 'image',
 
1035
          desc => 'The image' },
 
1036
        { name => 'layer', type => 'layer',
 
1037
          desc => 'The layer from which to remove mask' },
846
1038
        { name => 'mode', type => 'enum GimpMaskApplyMode',
847
 
          desc => 'Removal mode: { %%desc%% }' }
848
 
    );
849
 
    $inargs[1]->{desc} .= ' from which to remove mask';
850
 
 
851
 
    %invoke = ( code => 'gimp_layer_apply_mask (layer, mode, TRUE);' );
 
1039
          desc => 'Removal mode' }
 
1040
    );
 
1041
 
 
1042
    %invoke = (
 
1043
        code => <<'CODE'
 
1044
{
 
1045
  gimp_layer_apply_mask (layer, mode, TRUE);
 
1046
}
 
1047
CODE
 
1048
    );
 
1049
}
 
1050
 
 
1051
sub image_get_channel_position {
 
1052
    $blurb = 'Returns the position of the channel in the channel stack.';
 
1053
 
 
1054
    $help = <<'HELP';
 
1055
This procedure determines the positioin of the specified channel in the images
 
1056
channel stack. If the channel doesn't exist in the image, an error is returned.
 
1057
HELP
 
1058
 
 
1059
    &simon_pdb_misc('2006', '2.4');
 
1060
 
 
1061
    @inargs = (
 
1062
        { name => 'image', type => 'image',
 
1063
          desc => 'The image' },
 
1064
        { name => 'channel', type => 'channel',
 
1065
          desc => 'The channel' }
 
1066
    );
 
1067
 
 
1068
    @outargs = (
 
1069
        { name => 'position', type => 'int32',
 
1070
          desc => "The position of the channel in the channel stack" }
 
1071
    );
 
1072
 
 
1073
 
 
1074
    %invoke = (
 
1075
        code => <<'CODE'
 
1076
{
 
1077
  position = gimp_container_get_child_index (GIMP_CONTAINER (image->channels),
 
1078
                                             GIMP_OBJECT (channel));
 
1079
  if (position < 0)
 
1080
    success = FALSE;
 
1081
}
 
1082
CODE
 
1083
    );
852
1084
}
853
1085
 
854
1086
sub image_raise_channel {
855
 
    &type_move('channel', 'raise', 'above');
 
1087
    $blurb = "Raise the specified channel in the image's channel stack";
 
1088
 
 
1089
    $help = <<'HELP';
 
1090
This procedure raises the specified channel one step in the existing
 
1091
channel stack. It will not move the channel if there is no channel
 
1092
above it.
 
1093
HELP
 
1094
 
856
1095
    &std_pdb_misc;
 
1096
 
 
1097
    @inargs = (
 
1098
        { name => 'image', type => 'image',
 
1099
          desc => 'The image' },
 
1100
        { name => 'channel', type => 'channel',
 
1101
          desc => 'The channel to raise' }
 
1102
    );
 
1103
 
 
1104
    %invoke = (
 
1105
        code => <<'CODE'
 
1106
{
 
1107
  success = gimp_image_raise_channel (image, channel);
 
1108
}
 
1109
CODE
 
1110
    );
857
1111
}
858
1112
 
859
1113
sub image_lower_channel {
860
 
    &type_move('layer', 'lower', 'below');
 
1114
    $blurb = "Lower the specified channel in the image's channel stack";
 
1115
 
 
1116
    $help = <<'HELP';
 
1117
This procedure lowers the specified channel one step in the existing
 
1118
channel stack. It will not move the channel if there is no channel
 
1119
below it.
 
1120
HELP
 
1121
 
861
1122
    &std_pdb_misc;
 
1123
 
 
1124
    @inargs = (
 
1125
        { name => 'image', type => 'image',
 
1126
          desc => 'The image' },
 
1127
        { name => 'channel', type => 'channel',
 
1128
          desc => 'The channel to lower' }
 
1129
    );
 
1130
 
 
1131
    %invoke = (
 
1132
        code => <<'CODE'
 
1133
{
 
1134
  success = gimp_image_lower_channel (image, channel);
 
1135
}
 
1136
CODE
 
1137
    );
862
1138
}
863
1139
 
864
1140
sub image_add_channel {
873
1149
    &std_pdb_misc;
874
1150
 
875
1151
    @inargs = (
876
 
        &std_image_arg,
877
 
        &channel_arg,
 
1152
        { name => 'image', type => 'image',
 
1153
          desc => 'The image' },
 
1154
        { name => 'channel', type => 'channel',
 
1155
          desc => 'The channel' },
878
1156
        { name => 'position', type => 'int32',
879
1157
          desc => 'The channel position' }
880
1158
    );
882
1160
    %invoke = (
883
1161
        code => <<'CODE'
884
1162
{
885
 
  success = gimp_item_is_floating (GIMP_ITEM (channel));
886
 
 
887
 
  if (success)
888
 
    success = gimp_image_add_channel (gimage, channel, MAX (position, -1));
 
1163
  if (g_object_is_floating (channel))
 
1164
    success = gimp_image_add_channel (image, channel, MAX (position, -1));
 
1165
  else
 
1166
    success = FALSE;
889
1167
}
890
1168
CODE
891
1169
    );
902
1180
    &std_pdb_misc;
903
1181
 
904
1182
    @inargs = (
905
 
        &std_image_arg,
906
 
        &channel_arg
907
 
    );
908
 
 
909
 
    %invoke = ( code => 'gimp_image_remove_channel (gimage, channel);' );
 
1183
        { name => 'image', type => 'image',
 
1184
          desc => 'The image' },
 
1185
        { name => 'channel', type => 'channel',
 
1186
          desc => 'The channel' }
 
1187
    );
 
1188
 
 
1189
    %invoke = (
 
1190
        code => <<'CODE'
 
1191
{
 
1192
  gimp_image_remove_channel (image, channel);
 
1193
}
 
1194
CODE
 
1195
    );
 
1196
}
 
1197
 
 
1198
sub image_add_vectors {
 
1199
    $blurb = 'Add the specified vectors object to the image.';
 
1200
 
 
1201
    $help = <<'HELP';
 
1202
This procedure adds the specified vectors object to the image at the given
 
1203
position. If the position is specified as -1, then the vectors object is
 
1204
inserted at the top of the vectors stack.
 
1205
HELP
 
1206
 
 
1207
    &std_pdb_misc;
 
1208
 
 
1209
    @inargs = (
 
1210
        { name => 'image', type => 'image',
 
1211
          desc => 'The image' },
 
1212
        { name => 'vectors', type => 'vectors',
 
1213
          desc => 'The vectors object' },
 
1214
        { name => 'position', type => 'int32',
 
1215
          desc => 'The vectors objects position' }
 
1216
    );
 
1217
 
 
1218
    $invoke{code} = <<'CODE';
 
1219
{
 
1220
  if (g_object_is_floating (vectors))
 
1221
    success = gimp_image_add_vectors (image, vectors, MAX (position, -1));
 
1222
  else
 
1223
    success = FALSE;
 
1224
}
 
1225
CODE
 
1226
}
 
1227
 
 
1228
sub image_remove_vectors {
 
1229
    $blurb = 'Remove the specified path from the image.';
 
1230
 
 
1231
    $help = <<'HELP';
 
1232
This procedure removes the specified path from the image. If the path
 
1233
doesn't exist, an error is returned.
 
1234
HELP
 
1235
 
 
1236
    &simon_pdb_misc('2005', '2.4');
 
1237
 
 
1238
    @inargs = (
 
1239
        { name => 'image', type => 'image',
 
1240
          desc => 'The image' },
 
1241
        { name => 'vectors', type => 'vectors',
 
1242
          desc => 'The vectors object' }
 
1243
    );
 
1244
 
 
1245
    %invoke = (
 
1246
        code => <<'CODE'
 
1247
{
 
1248
  gimp_image_remove_vectors (image, vectors);
 
1249
}
 
1250
CODE
 
1251
    );
 
1252
}
 
1253
 
 
1254
sub image_get_vectors_position {
 
1255
    $blurb = 'Returns the position of the vectors object in the vectors objects stack.';
 
1256
 
 
1257
    $help = <<'HELP';
 
1258
This procedure determines the positioin of the specified vectors object in the
 
1259
images vectors object stack. If the vectors object doesn't exist in the image,
 
1260
an error is returned.
 
1261
HELP
 
1262
 
 
1263
    &simon_pdb_misc('2006', '2.4');
 
1264
 
 
1265
    @inargs = (
 
1266
        { name => 'image', type => 'image',
 
1267
          desc => 'The image' },
 
1268
        { name => 'vectors', type => 'vectors',
 
1269
          desc => 'The vectors object' }
 
1270
    );
 
1271
 
 
1272
    @outargs = (
 
1273
        { name => 'position', type => 'int32',
 
1274
          desc => "The position of the vectors object in the vectors stack" }
 
1275
    );
 
1276
 
 
1277
 
 
1278
    %invoke = (
 
1279
        code => <<'CODE'
 
1280
{
 
1281
  position = gimp_container_get_child_index (GIMP_CONTAINER (image->vectors),
 
1282
                                             GIMP_OBJECT (vectors));
 
1283
  if (position < 0)
 
1284
    success = FALSE;
 
1285
}
 
1286
CODE
 
1287
    );
 
1288
}
 
1289
 
 
1290
sub image_raise_vectors {
 
1291
    $blurb = "Raise the specified vectors in the image's vectors stack";
 
1292
 
 
1293
    $help = <<'HELP';
 
1294
This procedure raises the specified vectors one step in the existing
 
1295
vectors stack. It will not move the vectors if there is no vectors
 
1296
above it.
 
1297
HELP
 
1298
 
 
1299
    &simon_pdb_misc('2005', '2.4');
 
1300
 
 
1301
    @inargs = (
 
1302
        { name => 'image', type => 'image',
 
1303
          desc => 'The image' },
 
1304
        { name => 'vectors', type => 'vectors',
 
1305
          desc => 'The vectors object to raise' }
 
1306
    );
 
1307
 
 
1308
    %invoke = (
 
1309
        code => <<'CODE'
 
1310
{
 
1311
  success = gimp_image_raise_vectors (image, vectors);
 
1312
}
 
1313
CODE
 
1314
    );
 
1315
}
 
1316
 
 
1317
sub image_lower_vectors {
 
1318
    $blurb = "Lower the specified vectors in the image's vectors stack";
 
1319
 
 
1320
    $help = <<'HELP';
 
1321
This procedure lowers the specified vectors one step in the existing
 
1322
vectors stack. It will not move the vectors if there is no vectors
 
1323
below it.
 
1324
HELP
 
1325
 
 
1326
    &simon_pdb_misc('2005', '2.4');
 
1327
 
 
1328
    @inargs = (
 
1329
        { name => 'image', type => 'image',
 
1330
          desc => 'The image' },
 
1331
        { name => 'vectors', type => 'vectors',
 
1332
          desc => 'The vectors object to lower' }
 
1333
    );
 
1334
 
 
1335
    %invoke = (
 
1336
        code => <<'CODE'
 
1337
{
 
1338
  success = gimp_image_lower_vectors (image, vectors);
 
1339
}
 
1340
CODE
 
1341
    );
 
1342
}
 
1343
 
 
1344
sub image_raise_vectors_to_top {
 
1345
    $blurb = <<'BLURB';
 
1346
Raise the specified vectors in the image's vectors stack to top of stack
 
1347
BLURB
 
1348
 
 
1349
    $help = <<'HELP';
 
1350
This procedure raises the specified vectors to top of the existing
 
1351
vectors stack. It will not move the vectors if there is no vectors
 
1352
above it.
 
1353
HELP
 
1354
 
 
1355
    &simon_pdb_misc('2005', '2.4');
 
1356
 
 
1357
    @inargs = (
 
1358
        { name => 'image', type => 'image',
 
1359
          desc => 'The image' },
 
1360
        { name => 'vectors', type => 'vectors',
 
1361
          desc => 'The vectors object to raise to top' }
 
1362
    );
 
1363
 
 
1364
    %invoke = (
 
1365
        code => <<'CODE'
 
1366
{
 
1367
  success = gimp_image_raise_vectors_to_top (image, vectors);
 
1368
}
 
1369
CODE
 
1370
    );
 
1371
}
 
1372
 
 
1373
sub image_lower_vectors_to_bottom {
 
1374
    $blurb = <<'BLURB';
 
1375
Lower the specified vectors in the image's vectors stack to bottom of stack
 
1376
BLURB
 
1377
 
 
1378
    $help = <<'HELP';
 
1379
This procedure lowers the specified vectors to bottom of the existing
 
1380
vectors stack. It will not move the vectors if there is no vectors
 
1381
below it.
 
1382
HELP
 
1383
 
 
1384
    &simon_pdb_misc('2005', '2.4');
 
1385
 
 
1386
    @inargs = (
 
1387
        { name => 'image', type => 'image',
 
1388
          desc => 'The image' },
 
1389
        { name => 'vectors', type => 'vectors',
 
1390
          desc => 'The vectors object to lower to bottom' }
 
1391
    );
 
1392
 
 
1393
    %invoke = (
 
1394
        code => <<'CODE'
 
1395
{
 
1396
  success = gimp_image_lower_vectors_to_bottom (image, vectors);
 
1397
}
 
1398
CODE
 
1399
    );
910
1400
}
911
1401
 
912
1402
sub image_get_active_drawable {
922
1412
 
923
1413
    &std_pdb_misc;
924
1414
 
925
 
    @inargs = ( &std_image_arg );
 
1415
    @inargs = (
 
1416
        { name => 'image', type => 'image',
 
1417
          desc => 'The image' }
 
1418
    );
926
1419
 
927
1420
    @outargs = (
928
 
        { name => 'drawable', type => 'drawable', init => 1,
 
1421
        { name => 'drawable', type => 'drawable',
929
1422
          desc => 'The active drawable' }
930
1423
    );
931
1424
 
932
1425
    %invoke = (
933
1426
        code => <<'CODE'
934
 
success = (drawable = gimp_image_active_drawable (gimage)) != NULL;
 
1427
{
 
1428
  drawable = gimp_image_active_drawable (image);
 
1429
}
935
1430
CODE
936
1431
    );
937
1432
}
946
1441
 
947
1442
    &std_pdb_misc;
948
1443
 
949
 
    @inargs = ( &std_image_arg );
 
1444
    @inargs = (
 
1445
        { name => 'image', type => 'image',
 
1446
          desc => 'The image' }
 
1447
    );
950
1448
 
951
1449
    @outargs = (
952
 
        { name => 'base_type', type => 'enum GimpImageBaseType', init => 1,
953
 
          desc => "The image's base type: { %%desc%% }" }
 
1450
        { name => 'base_type', type => 'enum GimpImageBaseType',
 
1451
          desc => "The image's base type" }
954
1452
    );
955
1453
 
956
 
    %invoke = ( code => 'base_type = gimp_image_base_type (gimage);' );
 
1454
    %invoke = (
 
1455
        code => <<'CODE'
 
1456
{
 
1457
  base_type = gimp_image_base_type (image);
 
1458
}
 
1459
CODE
 
1460
    );
957
1461
}
958
1462
 
959
1463
sub image_get_colormap {
962
1466
    $help = <<'HELP';
963
1467
This procedure returns an actual pointer to the image's colormap, as well as
964
1468
the number of bytes contained in the colormap. The actual number of colors in
965
 
the transmitted colormap will be "num_bytes" / 3. If the image is not of base
966
 
type GIMP_INDEXED, this pointer will be NULL.
 
1469
the transmitted colormap will be 'num-bytes' / 3. If the image is not in
 
1470
Indexed color mode, no colormap is returned.
967
1471
HELP
968
1472
 
969
1473
    &std_pdb_misc;
970
1474
 
971
 
    @inargs = ( &std_image_arg );
 
1475
    @inargs = (
 
1476
        { name => 'image', type => 'image',
 
1477
          desc => 'The image' }
 
1478
    );
972
1479
 
973
1480
    @outargs = (
974
 
        { name => 'colormap', type => 'int8array', init => 1, wrap => 1,
 
1481
        { name => 'colormap', type => 'int8array', wrap => 1,
975
1482
          desc => "The image's colormap",
976
 
          array => { name => 'num_bytes', init => 1,
977
 
                     desc => 'Number of bytes in the colormap array:
978
 
                              %%desc%%' } }
 
1483
          array => { name => 'num_bytes',
 
1484
                     desc => 'Number of bytes in the colormap array' } }
979
1485
    );
980
1486
 
981
1487
    %invoke = (
982
1488
        headers => [ qw("core/gimpimage-colormap.h") ],
983
1489
        code => <<'CODE'
984
1490
{
985
 
  num_bytes = 3 * gimp_image_get_colormap_size (gimage);
986
 
  colormap = g_memdup (gimp_image_get_colormap (gimage), num_bytes);
 
1491
  num_bytes = 3 * gimp_image_get_colormap_size (image);
 
1492
  colormap = g_memdup (gimp_image_get_colormap (image), num_bytes);
987
1493
}
988
1494
CODE
989
1495
    );
994
1500
 
995
1501
    $help = <<'HELP';
996
1502
This procedure sets the entries in the specified image's colormap. The number
997
 
of entries is specified by the "num_bytes" parameter and corresponds to the
998
 
number of INT8 triples that must be contained in the "colormap" array. The actual
999
 
number of colors in the transmitted colormap is "num_bytes" / 3.
 
1503
of entries is specified by the 'num-bytes' parameter and corresponds to the
 
1504
number of INT8 triples that must be contained in the 'colormap' array. The
 
1505
actual number of colors in the transmitted colormap is 'num-bytes' / 3.
1000
1506
HELP
1001
1507
 
1002
1508
    &std_pdb_misc;
1003
1509
 
1004
1510
    @inargs = (
1005
 
        &std_image_arg,
 
1511
        { name => 'image', type => 'image',
 
1512
          desc => 'The image' },
1006
1513
        { name => 'colormap', type => 'int8array', wrap => 1,
1007
 
          desc => "The new colormap values",
 
1514
          desc => 'The new colormap values',
1008
1515
          array => { name => 'num_bytes', type => '0 <= int32 <= 768',
1009
 
                     desc => 'Number of bytes in the colormap array:
1010
 
                              %%desc%%' } }
 
1516
                     desc => 'Number of bytes in the colormap array' } }
1011
1517
    );
1012
1518
 
1013
1519
    %invoke = (
1014
1520
        headers => [ qw("core/gimpimage-colormap.h") ],
1015
 
        code => 'gimp_image_set_colormap (gimage, colormap, num_bytes / 3, TRUE);' );
 
1521
        code => <<'CODE'
 
1522
{
 
1523
  gimp_image_set_colormap (image, colormap, num_bytes / 3, TRUE);
 
1524
}
 
1525
CODE
 
1526
    );
1016
1527
}
1017
1528
 
1018
1529
sub image_clean_all {
1019
1530
    $blurb = 'Set the image dirty count to 0.';
1020
1531
 
1021
1532
    $help = <<'HELP';
1022
 
This procedure sets the specified image's dirty count to 0, allowing operations
1023
 
to occur without having a 'dirtied' image. This is especially useful for
1024
 
creating and loading images which should not initially be considered dirty, even
1025
 
though layers must be created, filled, and installed in the image.
 
1533
This procedure sets the specified image's dirty count to 0, allowing
 
1534
operations to occur without having a 'dirtied' image. This is
 
1535
especially useful for creating and loading images which should not
 
1536
initially be considered dirty, even though layers must be created,
 
1537
filled, and installed in the image. Note that save plug-ins must NOT
 
1538
call this function themselves after saving the image.
1026
1539
HELP
1027
1540
 
1028
1541
    &std_pdb_misc;
1029
1542
 
1030
 
    @inargs = ( &std_image_arg );
 
1543
    @inargs = (
 
1544
        { name => 'image', type => 'image',
 
1545
          desc => 'The image' }
 
1546
    );
1031
1547
 
1032
 
    %invoke = ( code => 'gimp_image_clean_all (gimage);' );
 
1548
    %invoke = (
 
1549
        code => <<'CODE'
 
1550
{
 
1551
  gimp_image_clean_all (image);
 
1552
}
 
1553
CODE
 
1554
    );
1033
1555
}
1034
1556
 
1035
1557
sub image_is_dirty {
1036
1558
    $blurb = 'Checks if the image has unsaved changes.';
1037
1559
 
1038
1560
    $help = <<'HELP';
1039
 
This procedure checks the specified image's dirty count to see if it needs
1040
 
to be saved.
 
1561
This procedure checks the specified image's dirty count to see if it
 
1562
needs to be saved. Note that saving the image does not automatically
 
1563
set the dirty count to 0, you need to call gimp_image_clean_all() after
 
1564
calling a save procedure to make the image clean.
1041
1565
HELP
1042
1566
 
1043
1567
    &std_pdb_misc;
1044
1568
 
1045
 
    @inargs = ( &std_image_arg );
 
1569
    @inargs = (
 
1570
        { name => 'image', type => 'image',
 
1571
          desc => 'The image' }
 
1572
    );
1046
1573
 
1047
1574
    @outargs = (
1048
 
        { name => 'dirty', type => 'boolean', init => 1,
1049
 
          desc => 'True if the image has unsaved changes.' }
 
1575
        { name => 'dirty', type => 'boolean',
 
1576
          desc => 'TRUE if the image has unsaved changes.' }
1050
1577
    );
1051
1578
 
1052
 
    %invoke = ( code => 'dirty = (gimage->dirty != 0);' );
 
1579
    %invoke = (
 
1580
        code => <<'CODE'
 
1581
{
 
1582
  dirty = (image->dirty != 0);
 
1583
}
 
1584
CODE
 
1585
    );
1053
1586
}
1054
1587
 
1055
1588
sub image_get_floating_sel {
1062
1595
 
1063
1596
    &std_pdb_misc;
1064
1597
 
1065
 
    @inargs = ( &std_image_arg );
 
1598
    @inargs = (
 
1599
        { name => 'image', type => 'image',
 
1600
          desc => 'The image' }
 
1601
    );
1066
1602
 
1067
1603
    @outargs = (
1068
 
        { name => 'floating_sel', type => 'layer', init => 1,
1069
 
          desc => "The image's floating selection",
1070
 
          return_fail => -1 }
 
1604
        { name => 'floating_sel', type => 'layer',
 
1605
          desc => "The image's floating selection" }
1071
1606
    );
1072
1607
 
1073
 
    %invoke = ( code => 'floating_sel = gimp_image_floating_sel (gimage);' );
 
1608
    %invoke = (
 
1609
        code => <<'CODE'
 
1610
{
 
1611
  floating_sel = gimp_image_floating_sel (image);
 
1612
}
 
1613
CODE
 
1614
    );
1074
1615
}
1075
1616
 
1076
1617
sub image_floating_sel_attached_to {
1081
1622
to, if it exists. If it doesn't exist, -1 is returned as the drawable ID.
1082
1623
HELP
1083
1624
 
1084
 
    $author = $copyright = 'Wolfgang Hofer';
1085
 
    $date = '1998';
 
1625
    &wolfgang_pdb_misc('1998');
1086
1626
 
1087
 
    @inargs = ( &std_image_arg );
 
1627
    @inargs = (
 
1628
        { name => 'image', type => 'image',
 
1629
          desc => 'The image' }
 
1630
    );
1088
1631
 
1089
1632
    @outargs = (
1090
 
        { name => 'drawable', type => 'drawable', init => 1,
1091
 
          desc => 'The drawable the floating selection is attached to',
1092
 
          return_fail => -1 }
 
1633
        { name => 'drawable', type => 'drawable',
 
1634
          desc => 'The drawable the floating selection is attached to' }
1093
1635
    );
1094
1636
 
1095
1637
    %invoke = (
1096
 
        vars => [ 'GimpLayer *floating_sel' ],
1097
1638
        code => <<'CODE'
1098
1639
{
1099
 
  floating_sel = gimp_image_floating_sel (gimage);
 
1640
  GimpLayer *floating_sel = gimp_image_floating_sel (image);
1100
1641
 
1101
1642
  if (floating_sel)
1102
1643
    drawable = GIMP_DRAWABLE (GIMP_LAYER (floating_sel)->fs.drawable);
1107
1648
    );
1108
1649
}
1109
1650
 
1110
 
foreach (qw(width height)) {
1111
 
    eval <<SUB;
1112
 
sub image_$_ {
1113
 
    \$blurb = 'Return the $_ of the image';
1114
 
 
1115
 
    \$help = <<'HELP';
1116
 
This procedure returns the image's $_. This value is independent of any of
1117
 
the layers in this image. This is the "canvas" $_.
1118
 
HELP
1119
 
 
1120
 
    \&std_pdb_misc;
1121
 
 
1122
 
    \@inargs = ( \&std_image_arg );
1123
 
 
1124
 
    \@outargs = (
1125
 
        { name => '$_', type => 'int32',
1126
 
          desc => "The image's $_",
1127
 
          alias => 'gimage->$_', no_declare => 1 }
1128
 
    );
1129
 
}
1130
 
SUB
1131
 
}
1132
 
 
1133
 
&image_accessors('active_layer', 'layer', 'active layer', 1,
1134
 
                 [ <<'CODE1', <<'CODE2' ]);
1135
 
    $invoke{code} = "active_layer = $outargs[0]->{alias};";
1136
 
    delete @{$outargs[0]}{qw(alias no_declare)};
1137
 
    $outargs[0]->{return_fail} = -1;
1138
 
    $outargs[0]->{init} = 1;
 
1651
sub image_width {
 
1652
    $blurb = 'Return the width of the image';
 
1653
 
 
1654
    $help = <<'HELP';
 
1655
This procedure returns the image's width. This value is independent of any of
 
1656
the layers in this image. This is the "canvas" width.
 
1657
HELP
 
1658
 
 
1659
    &std_pdb_misc;
 
1660
 
 
1661
    @inargs = (
 
1662
        { name => 'image', type => 'image',
 
1663
          desc => 'The image' }
 
1664
    );
 
1665
 
 
1666
    @outargs = (
 
1667
        { name => 'width', type => 'int32',
 
1668
          desc => "The image's width" }
 
1669
    );
 
1670
 
 
1671
    %invoke = (
 
1672
        code => <<'CODE'
 
1673
{
 
1674
  width = gimp_image_get_width (image);
 
1675
}
 
1676
CODE
 
1677
    );
 
1678
}
 
1679
 
 
1680
sub image_height {
 
1681
    $blurb = 'Return the height of the image';
 
1682
 
 
1683
    $help = <<'HELP';
 
1684
This procedure returns the image's height. This value is independent of any of
 
1685
the layers in this image. This is the "canvas" height.
 
1686
HELP
 
1687
 
 
1688
    &std_pdb_misc;
 
1689
 
 
1690
    @inargs = (
 
1691
        { name => 'image', type => 'image',
 
1692
          desc => 'The image' }
 
1693
    );
 
1694
 
 
1695
    @outargs = (
 
1696
        { name => 'height', type => 'int32',
 
1697
          desc => "The image's height" }
 
1698
    );
 
1699
 
 
1700
    %invoke = (
 
1701
        code => <<'CODE'
 
1702
{
 
1703
  height = gimp_image_get_height (image);
 
1704
}
 
1705
CODE
 
1706
    );
 
1707
}
 
1708
 
 
1709
sub image_get_active_layer {
 
1710
    $blurb = "Returns the specified image's active layer.";
1139
1711
 
1140
1712
    $help = <<'HELP';
1141
1713
If there is an active layer, its ID will be returned, otherwise, -1.  If a
1142
1714
channel is currently active, then no layer will be. If a layer mask is active,
1143
1715
then this will return the associated layer.
1144
1716
HELP
1145
 
CODE1
1146
 
    $invoke{code} =~ s/;//g;
1147
 
    $invoke{code} = "success = ($invoke{code} == active_layer);";
 
1717
 
 
1718
    &std_pdb_misc;
 
1719
 
 
1720
    @inargs = (
 
1721
        { name => 'image', type => 'image',
 
1722
          desc => 'The image' }
 
1723
    );
 
1724
 
 
1725
    @outargs = (
 
1726
        { name => 'active_layer', type => 'layer',
 
1727
          desc => 'The active layer' }
 
1728
    );
 
1729
 
 
1730
    %invoke = (
 
1731
        code => <<'CODE'
 
1732
{
 
1733
  active_layer = gimp_image_get_active_layer (image);
 
1734
}
 
1735
CODE
 
1736
    );
 
1737
}
 
1738
 
 
1739
sub image_set_active_layer {
 
1740
    $blurb = "Sets the specified image's active layer.";
1148
1741
 
1149
1742
    $help = <<'HELP';
1150
1743
If the layer exists, it is set as the active layer in the image. Any
1152
1745
previously existing floating selection, in which case this procedure
1153
1746
will return an execution error.
1154
1747
HELP
1155
 
CODE2
1156
 
 
1157
 
&image_accessors('active_channel', 'channel', 'active channel', 1,
1158
 
                 [ <<'CODE1', <<'CODE2' ]);
1159
 
    $invoke{code} = "active_channel = $outargs[0]->{alias};";
1160
 
    delete @{$outargs[0]}{qw(alias no_declare)};
1161
 
    $outargs[0]->{return_fail} = -1;
1162
 
    $outargs[0]->{init} = 1;
 
1748
 
 
1749
    &std_pdb_misc;
 
1750
 
 
1751
    @inargs = (
 
1752
        { name => 'image', type => 'image',
 
1753
          desc => 'The image' },
 
1754
        { name => 'active_layer', type => 'layer',
 
1755
          desc => 'The new image active layer' }
 
1756
    );
 
1757
 
 
1758
    %invoke = (
 
1759
        code => <<'CODE'
 
1760
{
 
1761
  if (gimp_image_set_active_layer (image, active_layer) != active_layer)
 
1762
    success = FALSE;
 
1763
}
 
1764
CODE
 
1765
    );
 
1766
}
 
1767
 
 
1768
sub image_get_active_channel {
 
1769
    $blurb = "Returns the specified image's active channel.";
1163
1770
 
1164
1771
    $help = <<'HELP';
1165
1772
If there is an active channel, this will return the channel ID, otherwise, -1.
1166
1773
HELP
1167
 
CODE1
1168
 
    $invoke{code} =~ s/;//g;
1169
 
    $invoke{code} = "success = ($invoke{code} == active_channel);";
 
1774
 
 
1775
    &std_pdb_misc;
 
1776
 
 
1777
    @inargs = (
 
1778
        { name => 'image', type => 'image',
 
1779
          desc => 'The image' }
 
1780
    );
 
1781
 
 
1782
    @outargs = (
 
1783
        { name => 'active_channel', type => 'channel',
 
1784
          desc => 'The active channel' }
 
1785
    );
 
1786
 
 
1787
    %invoke = (
 
1788
        code => <<'CODE'
 
1789
{
 
1790
  active_channel = gimp_image_get_active_channel (image);
 
1791
}
 
1792
CODE
 
1793
    );
 
1794
}
 
1795
 
 
1796
sub image_set_active_channel {
 
1797
    $blurb = "Sets the specified image's active channel.";
1170
1798
 
1171
1799
    $help = <<'HELP';
1172
1800
If the channel exists, it is set as the active channel in the
1174
1802
exception is a previously existing floating selection, in which case
1175
1803
this procedure will return an execution error.
1176
1804
HELP
1177
 
CODE2
1178
 
 
1179
 
&image_accessors('selection', 'selection', 'selection', 1,
1180
 
                 [ <<'CODE', undef ]);
1181
 
    $invoke{code} = "success = (selection = gimp_image_get_mask (gimage)) != NULL;";
1182
 
    delete @{$outargs[0]}{qw(alias no_declare)};
1183
 
    $outargs[0]->{desc} .= ' channel';
1184
 
    $outargs[0]->{init} = 1;
 
1805
 
 
1806
    &std_pdb_misc;
 
1807
 
 
1808
    @inargs = (
 
1809
        { name => 'image', type => 'image',
 
1810
          desc => 'The image' },
 
1811
        { name => 'active_channel', type => 'channel',
 
1812
          desc => 'The new image active channel' }
 
1813
    );
 
1814
 
 
1815
    %invoke = (
 
1816
        code => <<'CODE'
 
1817
{
 
1818
  if (gimp_image_set_active_channel (image, active_channel) != active_channel)
 
1819
    success = FALSE;
 
1820
}
 
1821
CODE
 
1822
    );
 
1823
}
 
1824
 
 
1825
sub image_get_active_vectors {
 
1826
    $blurb = "Returns the specified image's active vectors.";
 
1827
 
 
1828
    $help = <<'HELP';
 
1829
If there is an active path, its ID will be returned, otherwise, -1.
 
1830
HELP
 
1831
 
 
1832
    &std_pdb_misc;
 
1833
 
 
1834
    @inargs = (
 
1835
        { name => 'image', type => 'image',
 
1836
          desc => 'The image' }
 
1837
    );
 
1838
 
 
1839
    @outargs = (
 
1840
        { name => 'active_vectors', type => 'vectors',
 
1841
          desc => 'The active vectors' }
 
1842
    );
 
1843
 
 
1844
    %invoke = (
 
1845
        code => <<'CODE'
 
1846
{
 
1847
  active_vectors = gimp_image_get_active_vectors (image);
 
1848
}
 
1849
CODE
 
1850
    );
 
1851
}
 
1852
 
 
1853
sub image_set_active_vectors {
 
1854
    $blurb = "Sets the specified image's active vectors.";
 
1855
 
 
1856
    $help = <<'HELP';
 
1857
If the path exists, it is set as the active path in the image.
 
1858
HELP
 
1859
 
 
1860
    &std_pdb_misc;
 
1861
 
 
1862
    @inargs = (
 
1863
        { name => 'image', type => 'image',
 
1864
          desc => 'The image' },
 
1865
        { name => 'active_vectors', type => 'vectors',
 
1866
          desc => 'The new image active vectors' }
 
1867
    );
 
1868
 
 
1869
    %invoke = (
 
1870
        code => <<'CODE'
 
1871
{
 
1872
  if (gimp_image_set_active_vectors (image, active_vectors) != active_vectors)
 
1873
    success = FALSE;
 
1874
}
 
1875
CODE
 
1876
    );
 
1877
}
 
1878
 
 
1879
sub image_get_selection {
 
1880
    $blurb = "Returns the specified image's selection.";
1185
1881
 
1186
1882
    $help = <<'HELP';
1187
1883
This will always return a valid ID for a selection -- which is represented as a
1188
1884
channel internally.
1189
1885
HELP
1190
 
CODE
1191
 
$#procs--;
1192
 
 
1193
 
my $comp_arg = <<'CODE';
1194
 
    splice @inargs, 1, 0, ({ name => 'component',
1195
 
                             type => 'enum GimpChannelType',
1196
 
                             desc => 'The image component: { %%desc%% }' });
1197
 
 
1198
 
    $invoke{code} = <<'SUCCESS';
1199
 
{
1200
 
  if (component == GIMP_GRAY_CHANNEL)
1201
 
    success = gimp_image_base_type (gimage) == GIMP_GRAY;
1202
 
  else if (component == GIMP_INDEXED_CHANNEL)
1203
 
    success = gimp_image_base_type (gimage) == GIMP_INDEXED;
1204
 
  else
1205
 
    success = gimp_image_base_type (gimage) == GIMP_RGB;
1206
 
}
1207
 
SUCCESS
1208
 
CODE
1209
 
 
1210
 
my $comp_help = <<'CODE';
1211
 
        $help =~ s/(component)/$1 (i.e. Red, Green, Blue intensity channels
1212
 
                               in an RGB image)/;
1213
 
        $help =~ s/\. $/ /;
1214
 
        $help .= <<HELP;
1215
 
or in%%type%% -- whether or not it can be %%action%%. If the specified component
1216
 
is not valid for the image type, an error is returned.
1217
 
HELP
1218
 
CODE
1219
 
 
1220
 
my %comp_action = (
1221
 
    active => 'modified',
1222
 
    visible => 'seen'
1223
 
);
1224
 
 
1225
 
foreach (sort keys %comp_action) {
1226
 
    my $help = $comp_help;
1227
 
 
1228
 
    $help =~ s/%%type%%/$_/e;
1229
 
    $help =~ s/%%action%%/$comp_action{$_}/e;
1230
 
 
1231
 
    &image_accessors("component_$_", 'boolean', "image component is $_", 1,
1232
 
                     [ <<CODE1, <<CODE2 ]);
1233
 
        $comp_arg;
1234
 
        \$outargs[0]->{name} = '$_';
1235
 
        \$outargs[0]->{desc} = 'Component is $_ (%%desc%%)';
1236
 
 
1237
 
        chop \$outargs[0]->{alias};
1238
 
        \$outargs[0]->{alias} .= ', component)';
1239
 
        $help;
1240
 
CODE1
1241
 
        my \$code = <<CODE;
1242
 
 
1243
 
  if (success)
1244
 
    \$invoke{code}
1245
 
CODE
1246
 
        $comp_arg;
1247
 
        \$invoke{code} =~ s/}/"\$code}"/e;
1248
 
        \$invoke{code} =~ s/ component_$_/ component, $_/;
1249
 
        \$inargs[2]->{name} = '$_';
1250
 
        \$inargs[2]->{desc} = 'Component is $_ (%%desc%%)';
1251
 
        $help;
1252
 
CODE2
1253
 
}
1254
 
 
1255
 
&image_accessors('filename', 'string', 'filename', 1,
1256
 
                 [ <<'CODE1', <<'CODE2' ]);
1257
 
    $help =~ s/\. $//;
1258
 
    $help .= <<'HELP';
1259
 
 in the filesystem encoding. The image has a filename only if it was loaded
1260
 
or has since been saved. Otherwise, this function returns %NULL.
1261
 
HELP
1262
 
 
1263
 
    $outargs[0]->{alias} =~ s/g_strdup \((.*)\)/$1/;
1264
 
CODE1
1265
 
    $help .= " The filename should be in the filesystem encoding.";
1266
 
 
1267
 
    $inargs[1]->{no_validate} = 1;
1268
 
 
1269
 
    $invoke{code} = <<CODE3;
 
1886
 
 
1887
    &std_pdb_misc;
 
1888
 
 
1889
    @inargs = (
 
1890
        { name => 'image', type => 'image',
 
1891
          desc => 'The image' }
 
1892
    );
 
1893
 
 
1894
    @outargs = (
 
1895
        { name => 'selection', type => 'selection',
 
1896
          desc => 'The selection channel' }
 
1897
    );
 
1898
 
 
1899
    %invoke = (
 
1900
        code => <<'CODE'
 
1901
{
 
1902
  selection = GIMP_SELECTION (gimp_image_get_mask (image));
 
1903
 
 
1904
  if (! selection)
 
1905
    success = FALSE;
 
1906
}
 
1907
CODE
 
1908
    );
 
1909
}
 
1910
 
 
1911
sub image_get_component_active {
 
1912
    $blurb = "Returns if the specified image's image component is active.";
 
1913
 
 
1914
    $help = <<'HELP';
 
1915
This procedure returns if the specified image's image component
 
1916
(i.e. Red, Green, Blue intensity channels in an RGB image) is active
 
1917
or inactive -- whether or not it can be modified. If the specified
 
1918
component is not valid for the image type, an error is returned.
 
1919
HELP
 
1920
 
 
1921
    &std_pdb_misc;
 
1922
 
 
1923
    @inargs = (
 
1924
        { name => 'image', type => 'image',
 
1925
          desc => 'The image' },
 
1926
        { name => 'component', type => 'enum GimpChannelType',
 
1927
          desc => 'The image component' }
 
1928
    );
 
1929
 
 
1930
    @outargs = (
 
1931
        { name => 'active', type => 'boolean',
 
1932
          desc => 'Component is active' }
 
1933
    );
 
1934
 
 
1935
    %invoke = (
 
1936
        code => <<'CODE'
 
1937
{
 
1938
  if (component == GIMP_GRAY_CHANNEL)
 
1939
    success = gimp_image_base_type (image) == GIMP_GRAY;
 
1940
  else if (component == GIMP_INDEXED_CHANNEL)
 
1941
    success = gimp_image_base_type (image) == GIMP_INDEXED;
 
1942
  else
 
1943
    success = gimp_image_base_type (image) == GIMP_RGB;
 
1944
 
 
1945
  if (success)
 
1946
    active = gimp_image_get_component_active (image, component);
 
1947
}
 
1948
CODE
 
1949
    );
 
1950
}
 
1951
 
 
1952
sub image_set_component_active {
 
1953
    $blurb = "Sets if the specified image's image component is active.";
 
1954
 
 
1955
    $help = <<'HELP';
 
1956
This procedure sets if the specified image's image component
 
1957
(i.e. Red, Green, Blue intensity channels in an RGB image) is active
 
1958
or inactive -- whether or not it can be modified. If the specified
 
1959
component is not valid for the image type, an error is returned.
 
1960
HELP
 
1961
 
 
1962
    &std_pdb_misc;
 
1963
 
 
1964
    @inargs = (
 
1965
        { name => 'image', type => 'image',
 
1966
          desc => 'The image' },
 
1967
        { name => 'component', type => 'enum GimpChannelType',
 
1968
          desc => 'The image component' },
 
1969
        { name => 'active', type => 'boolean',
 
1970
          desc => 'Component is active' }
 
1971
    );
 
1972
 
 
1973
    %invoke = (
 
1974
        code => <<'CODE'
 
1975
{
 
1976
  if (component == GIMP_GRAY_CHANNEL)
 
1977
    success = gimp_image_base_type (image) == GIMP_GRAY;
 
1978
  else if (component == GIMP_INDEXED_CHANNEL)
 
1979
    success = gimp_image_base_type (image) == GIMP_INDEXED;
 
1980
  else
 
1981
    success = gimp_image_base_type (image) == GIMP_RGB;
 
1982
 
 
1983
  if (success)
 
1984
    gimp_image_set_component_active (image, component, active);
 
1985
}
 
1986
CODE
 
1987
    );
 
1988
}
 
1989
 
 
1990
sub image_get_component_visible {
 
1991
    $blurb = "Returns if the specified image's image component is visible.";
 
1992
 
 
1993
    $help = <<'HELP';
 
1994
This procedure returns if the specified image's image component
 
1995
(i.e. Red, Green, Blue intensity channels in an RGB image) is visible
 
1996
or invisible -- whether or not it can be seen. If the specified
 
1997
component is not valid for the image type, an error is returned.
 
1998
HELP
 
1999
 
 
2000
    &std_pdb_misc;
 
2001
 
 
2002
    @inargs = (
 
2003
        { name => 'image', type => 'image',
 
2004
          desc => 'The image' },
 
2005
        { name => 'component', type => 'enum GimpChannelType',
 
2006
          desc => 'The image component' }
 
2007
    );
 
2008
 
 
2009
    @outargs = (
 
2010
        { name => 'visible', type => 'boolean',
 
2011
          desc => 'Component is visible' }
 
2012
    );
 
2013
 
 
2014
    %invoke = (
 
2015
        code => <<'CODE'
 
2016
{
 
2017
  if (component == GIMP_GRAY_CHANNEL)
 
2018
    success = gimp_image_base_type (image) == GIMP_GRAY;
 
2019
  else if (component == GIMP_INDEXED_CHANNEL)
 
2020
    success = gimp_image_base_type (image) == GIMP_INDEXED;
 
2021
  else
 
2022
    success = gimp_image_base_type (image) == GIMP_RGB;
 
2023
 
 
2024
  if (success)
 
2025
    visible = gimp_image_get_component_visible (image, component);
 
2026
}
 
2027
CODE
 
2028
    );
 
2029
}
 
2030
 
 
2031
sub image_set_component_visible {
 
2032
    $blurb = "Sets if the specified image's image component is visible.";
 
2033
 
 
2034
    $help = <<'HELP';
 
2035
This procedure sets if the specified image's image component
 
2036
(i.e. Red, Green, Blue intensity channels in an RGB image) is visible
 
2037
or invisible -- whether or not it can be seen. If the specified
 
2038
component is not valid for the image type, an error is returned.
 
2039
HELP
 
2040
 
 
2041
    &std_pdb_misc;
 
2042
 
 
2043
    @inargs = (
 
2044
        { name => 'image', type => 'image',
 
2045
          desc => 'The image' },
 
2046
        { name => 'component', type => 'enum GimpChannelType',
 
2047
          desc => 'The image component' },
 
2048
        { name => 'visible', type => 'boolean',
 
2049
          desc => 'Component is visible' }
 
2050
    );
 
2051
 
 
2052
    %invoke = (
 
2053
        code => <<'CODE'
 
2054
{
 
2055
  if (component == GIMP_GRAY_CHANNEL)
 
2056
    success = gimp_image_base_type (image) == GIMP_GRAY;
 
2057
  else if (component == GIMP_INDEXED_CHANNEL)
 
2058
    success = gimp_image_base_type (image) == GIMP_INDEXED;
 
2059
  else
 
2060
    success = gimp_image_base_type (image) == GIMP_RGB;
 
2061
 
 
2062
  if (success)
 
2063
    gimp_image_set_component_visible (image, component, visible);
 
2064
}
 
2065
CODE
 
2066
    );
 
2067
}
 
2068
 
 
2069
sub image_get_filename {
 
2070
    $blurb = "Returns the specified image's filename.";
 
2071
 
 
2072
    $help = <<'HELP';
 
2073
This procedure returns the specified image's filename in the
 
2074
filesystem encoding. The image has a filename only if it was loaded or
 
2075
has since been saved. Otherwise, this function returns %NULL.
 
2076
HELP
 
2077
 
 
2078
    &std_pdb_misc;
 
2079
 
 
2080
    @inargs = (
 
2081
        { name => 'image', type => 'image',
 
2082
          desc => 'The image' }
 
2083
    );
 
2084
 
 
2085
    @outargs = (
 
2086
        { name => 'filename', type => 'string',
 
2087
          desc => 'The filename' }
 
2088
    );
 
2089
 
 
2090
    %invoke = (
 
2091
        code => <<'CODE'
 
2092
{
 
2093
  filename = gimp_image_get_filename (image);
 
2094
}
 
2095
CODE
 
2096
    );
 
2097
}
 
2098
 
 
2099
sub image_set_filename {
 
2100
    $blurb = "Sets the specified image's filename.";
 
2101
 
 
2102
    $help = <<'HELP';
 
2103
This procedure sets the specified image's filename. The filename
 
2104
should be in the filesystem encoding.
 
2105
HELP
 
2106
 
 
2107
    &std_pdb_misc;
 
2108
 
 
2109
    @inargs = (
 
2110
        { name => 'image', type => 'image',
 
2111
          desc => 'The image' },
 
2112
        { name => 'filename', type => 'string',
 
2113
          desc => 'The new image filename', no_validate => 1 }
 
2114
    );
 
2115
 
 
2116
    %invoke = (
 
2117
        code => <<'CODE'
1270
2118
{
1271
2119
  /*  verify that the filename can be converted to UTF-8 and back  */
1272
2120
  gchar *utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
1286
2134
    success = FALSE;
1287
2135
 
1288
2136
  if (success)
1289
 
    $invoke{code}
1290
 
}
1291
 
CODE3
1292
 
CODE2
1293
 
 
1294
 
&image_accessors('name', 'string', 'name', 1,
1295
 
                 [ <<'CODE1', undef ]);
1296
 
    delete @{$outargs[0]}{qw(alias no_declare)};
1297
 
    $outargs[0]->{init} = 1;
 
2137
    gimp_image_set_filename (image, filename);
 
2138
}
 
2139
CODE
 
2140
    );
 
2141
}
 
2142
 
 
2143
sub image_get_name {
 
2144
    $blurb = "Returns the specified image's name.";
 
2145
    $help  = "This procedure returns the specified image's name.";
 
2146
 
 
2147
    &std_pdb_misc;
 
2148
 
 
2149
    @inargs = (
 
2150
        { name => 'image', type => 'image',
 
2151
          desc => 'The image' }
 
2152
    );
 
2153
 
 
2154
    @outargs = (
 
2155
        { name => 'name', type => 'string',
 
2156
          desc => 'The name' }
 
2157
    );
1298
2158
 
1299
2159
    %invoke = (
1300
 
        vars => [ 'gchar *filename' ],
1301
 
        code => <<'CODE2'
 
2160
        code => <<'CODE'
1302
2161
{
1303
 
  filename = gimp_image_get_filename (gimage);
 
2162
  gchar *filename = gimp_image_get_filename (image);
1304
2163
 
1305
2164
  if (filename)
1306
 
    {
1307
 
      gchar *basename = g_path_get_basename (filename);
1308
 
      name = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);
1309
 
      g_free (basename);
1310
 
 
1311
 
      if (! name)
1312
 
        name = g_strdup (_("(invalid UTF-8 string)"));
1313
 
    }
 
2165
    name = g_filename_display_basename (filename);
1314
2166
  else
1315
 
    {
1316
 
      name = g_strdup (_("Untitled"));
1317
 
    }
 
2167
    name = g_strdup (_("Untitled"));
1318
2168
}
1319
 
CODE2
 
2169
CODE
1320
2170
    );
1321
 
CODE1
1322
 
$#procs--;
1323
 
 
1324
 
&image_accessors('resolution', 'float', 'resolution', 0,
1325
 
                 [ <<'CODE1', <<'CODE2' ]);
1326
 
    $help =~ s/\. $/ /;
1327
 
    $help .= <<'HELP';
1328
 
in dots per inch. This value is independent of any of the layers in this image.
 
2171
}
 
2172
 
 
2173
sub image_get_resolution {
 
2174
    $blurb = "Returns the specified image's resolution.";
 
2175
 
 
2176
    $help = <<'HELP';
 
2177
This procedure returns the specified image's resolution in dots per inch. 
 
2178
This value is independent of any of the layers in this image.
1329
2179
HELP
1330
2180
 
1331
 
    $author = $copyright = 'Austin Donnelly';
1332
 
    $date = '1998';
1333
 
 
1334
 
    push @outargs, { %{$outargs[0]} };
1335
 
    $outargs[0]->{void_ret} = 1;
1336
 
 
1337
 
    my $count = 0;
1338
 
    foreach $coord (qw(x y)) {
1339
 
        foreach (qw(name alias)) {
1340
 
            $outargs[$count]->{$_} =~ s/res/"${coord}res"/e
1341
 
        }
1342
 
        $outargs[$count++]->{desc} .= "in the $coord-axis, in dots per inch";
1343
 
    }
1344
 
CODE1
1345
 
    $help =~ s/\. $/ /;
1346
 
    $help .= <<'HELP';
1347
 
in dots per inch. This value is independent of any of the layers in this image.
 
2181
    &austin_pdb_misc('1998');
 
2182
 
 
2183
    @inargs = (
 
2184
        { name => 'image', type => 'image',
 
2185
          desc => 'The image' }
 
2186
    );
 
2187
 
 
2188
    @outargs = (
 
2189
        { name => 'xresolution', type => 'float', void_ret => 1,
 
2190
          desc => 'The resolution in the x-axis, in dots per inch' },
 
2191
        { name => 'yresolution', type => 'float',
 
2192
          desc => 'The resolution in the y-axis, in dots per inch' }
 
2193
    );
 
2194
 
 
2195
    %invoke = (
 
2196
        code => <<'CODE'
 
2197
{
 
2198
  gimp_image_get_resolution (image, &xresolution, &yresolution);
 
2199
}
 
2200
CODE
 
2201
    );
 
2202
}
 
2203
 
 
2204
sub image_set_resolution {
 
2205
    $blurb = "Sets the specified image's resolution.";
 
2206
 
 
2207
    $help = <<'HELP';
 
2208
This procedure sets the specified image's resolution in dots per inch. 
 
2209
This value is independent of any of the layers in this image.
1348
2210
No scaling or resizing is performed.
1349
2211
HELP
1350
2212
 
1351
 
    $author = $copyright = 'Austin Donnelly';
1352
 
    $date = '1998';
1353
 
 
1354
 
    push @inargs, { %{$inargs[1]} };
1355
 
 
1356
 
    my $count = 1; undef %invoke;
1357
 
    foreach $coord (qw(x y)) {
1358
 
        my $arg = $inargs[$count];
1359
 
        $arg->{name} =~ s/res/"${coord}res"/e;
1360
 
        $arg->{desc} .= "in the $coord-axis, in dots per inch";
1361
 
        $count++;
1362
 
    }
1363
 
 
1364
 
    $invoke{code} = <<'CODE';
 
2213
    &austin_pdb_misc('1998');
 
2214
 
 
2215
    @inargs = (
 
2216
        { name => 'image', type => 'image',
 
2217
          desc => 'The image' },
 
2218
        { name => 'xresolution', type => 'float',
 
2219
          desc => 'The new image resolution in the x-axis, in dots per inch' },
 
2220
        { name => 'yresolution', type => 'float',
 
2221
          desc => 'The new image resolution in the y-axis, in dots per inch' }
 
2222
    );
 
2223
 
 
2224
    %invoke = (
 
2225
        code => <<'CODE'
1365
2226
{
1366
2227
  if (! FINITE (xresolution) ||
1367
2228
      xresolution < GIMP_MIN_RESOLUTION || xresolution > GIMP_MAX_RESOLUTION ||
1368
2229
      ! FINITE (yresolution) ||
1369
2230
      yresolution < GIMP_MIN_RESOLUTION || yresolution > GIMP_MAX_RESOLUTION)
1370
2231
    {
1371
 
      g_message (_("Image resolution is out of bounds, "
1372
 
                   "using the default resolution instead."));
 
2232
      gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING,
 
2233
                    _("Image resolution is out of bounds, "
 
2234
                      "using the default resolution instead."));
1373
2235
      success = FALSE;
1374
2236
    }
1375
2237
  else
1376
2238
    {
1377
 
      gimp_image_set_resolution (gimage, xresolution, yresolution);
 
2239
      gimp_image_set_resolution (image, xresolution, yresolution);
1378
2240
    }
1379
2241
}
1380
2242
CODE
1381
 
CODE2
1382
 
 
1383
 
 
1384
 
my $unit_help = <<'HELP';
1385
 
This value is independent of any of the layers in this image. See the
1386
 
gimp_unit_* procedure definitions for the valid range of unit IDs and a
 
2243
    );
 
2244
}
 
2245
 
 
2246
sub image_get_unit {
 
2247
    $blurb = "Returns the specified image's unit.";
 
2248
 
 
2249
    $help = <<'HELP';
 
2250
This procedure returns the specified image's unit. This value is
 
2251
independent of any of the layers in this image. See the gimp_unit_*()
 
2252
procedure definitions for the valid range of unit IDs and a
1387
2253
description of the unit system.
1388
2254
HELP
1389
2255
 
1390
 
my $unit_misc = <<'CODE';
1391
 
    $author = $copyright = 'Michael Natterer';
1392
 
    $date = '1998';
1393
 
CODE
1394
 
 
1395
 
&image_accessors('unit', 'unit (min GIMP_UNIT_INCH)', 'unit', 1,
1396
 
                 [ <<CODE1, <<CODE2 ]);
1397
 
    \$help .= '$unit_help';
1398
 
    $unit_misc
1399
 
CODE1
1400
 
    \$help .= 'No scaling or resizing is performed. $unit_help';
1401
 
    $unit_misc
1402
 
CODE2
1403
 
 
1404
 
 
1405
 
my $tattoo_state_misc = <<'CODE';
1406
 
    $author = $copyright = 'Andy Thomas';
1407
 
    $date = '2000';
1408
 
CODE
1409
 
&image_accessors('tattoo_state', 'int32', 'tattoo_state', 1,
1410
 
                 [ <<CODE1, <<CODE2 ]);
1411
 
    \$blurb = 'Returns the tattoo state associated with the image.';
1412
 
    \$help = <<'HELP';
 
2256
    &mitch_pdb_misc('1998');
 
2257
 
 
2258
    @inargs = (
 
2259
        { name => 'image', type => 'image',
 
2260
          desc => 'The image' }
 
2261
    );
 
2262
 
 
2263
    @outargs = (
 
2264
        { name => 'unit', type => 'unit',
 
2265
          desc => 'The unit' }
 
2266
    );
 
2267
 
 
2268
    %invoke = (
 
2269
        code => <<'CODE'
 
2270
{
 
2271
  unit = gimp_image_get_unit (image);
 
2272
}
 
2273
CODE
 
2274
    );
 
2275
}
 
2276
 
 
2277
sub image_set_unit {
 
2278
    $blurb = "Sets the specified image's unit.";
 
2279
 
 
2280
    $help = <<'HELP';
 
2281
This procedure sets the specified image's unit. No scaling or resizing
 
2282
is performed. This value is independent of any of the layers in this
 
2283
image. See the gimp_unit_*() procedure definitions for the valid range
 
2284
of unit IDs and a description of the unit system.
 
2285
HELP
 
2286
 
 
2287
    &mitch_pdb_misc('1998');
 
2288
 
 
2289
    @inargs = (
 
2290
        { name => 'image', type => 'image',
 
2291
          desc => 'The image' },
 
2292
        { name => 'unit', type => 'unit (min GIMP_UNIT_INCH)',
 
2293
          desc => 'The new image unit' }
 
2294
    );
 
2295
 
 
2296
    %invoke = (
 
2297
        code => <<'CODE'
 
2298
{
 
2299
  gimp_image_set_unit (image, unit);
 
2300
}
 
2301
CODE
 
2302
    );
 
2303
}
 
2304
 
 
2305
sub image_get_tattoo_state {
 
2306
    $blurb = 'Returns the tattoo state associated with the image.';
 
2307
 
 
2308
    $help = <<'HELP';
1413
2309
This procedure returns the tattoo state of the image. Use only by
1414
2310
save/load plugins that wish to preserve an images tattoo state. Using this
1415
2311
function at other times will produce unexpected results.
1416
2312
HELP
1417
 
    $tattoo_state_misc
1418
 
CODE1
1419
 
    \$blurb = 'Set the tattoo state associated with the image.';
1420
 
    \$help = <<'HELP';
 
2313
 
 
2314
    &andy_pdb_misc('2000');
 
2315
 
 
2316
    @inargs = (
 
2317
        { name => 'image', type => 'image',
 
2318
          desc => 'The image' }
 
2319
    );
 
2320
 
 
2321
    @outargs = (
 
2322
        { name => 'tattoo_state', type => 'tattoo',
 
2323
          desc => 'The tattoo state' }
 
2324
    );
 
2325
 
 
2326
    %invoke = (
 
2327
        code => <<'CODE'
 
2328
{
 
2329
  tattoo_state = gimp_image_get_tattoo_state (image);
 
2330
}
 
2331
CODE
 
2332
    );
 
2333
}
 
2334
 
 
2335
sub image_set_tattoo_state {
 
2336
    $blurb = 'Set the tattoo state associated with the image.';
 
2337
 
 
2338
    $help = <<'HELP';
1421
2339
This procedure sets the tattoo state of the image. Use only by
1422
2340
save/load plugins that wish to preserve an images tattoo state. Using
1423
2341
this function at other times will produce unexpected results. A full
1430
2348
procedure that should be called. If effectively does a status check on
1431
2349
the tattoo values that have been set to make sure that all is OK.
1432
2350
HELP
1433
 
    $tattoo_state_misc
1434
 
CODE2
1435
 
 
1436
 
 
1437
 
foreach (qw(layer channel)) {
1438
 
    push @procs, "image_get_${_}_by_tattoo";
1439
 
    eval <<SUB;
1440
 
sub image_get_${_}_by_tattoo {
1441
 
    \$blurb = 'Find a $_ with a given tattoo in an image.';
1442
 
 
1443
 
    \$help = <<'HELP';
1444
 
This procedure returns the $_ with the given tattoo in the specified image.
1445
 
HELP
1446
 
 
1447
 
    \$author = \$copyright = 'Jay Cox';
1448
 
    \$date = '1998';
1449
 
 
1450
 
    \@inargs = (
1451
 
        \&std_image_arg,
1452
 
        { name => 'tattoo', type => 'tattoo',
1453
 
          desc => 'The tattoo of the $_ to find' }
1454
 
    );
1455
 
 
1456
 
    \@outargs = (
1457
 
        { name => '$_', type => '$_', init => 1,
1458
 
          desc => 'The $_ with the specified tattoo' }
1459
 
    );
1460
 
 
1461
 
    \%invoke = (
1462
 
        code => <<'CODE'
1463
 
{
1464
 
  $_ = gimp_image_get_${_}_by_tattoo (gimage, tattoo);
1465
 
  success = $_ != NULL;
1466
 
}
1467
 
CODE
1468
 
    );
1469
 
}
1470
 
SUB
1471
 
}
1472
 
 
1473
 
sub preview_dim_args () {
1474
 
    my @args;
1475
 
    foreach (qw(width height bpp)) {
1476
 
        push @args, { name => $_,
1477
 
                      type => 'int32',
1478
 
                      desc => "The previews $_",
1479
 
                      init => 1 };
1480
 
    }
1481
 
    @args;
 
2351
 
 
2352
    &andy_pdb_misc('2000');
 
2353
 
 
2354
    @inargs = (
 
2355
        { name => 'image', type => 'image',
 
2356
          desc => 'The image' },
 
2357
        { name => 'tattoo_state', type => 'tattoo',
 
2358
          desc => 'The new image tattoo state' }
 
2359
    );
 
2360
 
 
2361
    %invoke = (
 
2362
        code => <<'CODE'
 
2363
{
 
2364
  gimp_image_set_tattoo_state (image, tattoo_state);
 
2365
}
 
2366
CODE
 
2367
    );
 
2368
}
 
2369
 
 
2370
sub image_get_layer_by_tattoo {
 
2371
    $blurb = 'Find a layer with a given tattoo in an image.';
 
2372
 
 
2373
    $help = <<'HELP';
 
2374
This procedure returns the layer with the given tattoo in the specified image.
 
2375
HELP
 
2376
 
 
2377
    &jay_pdb_misc('1998');
 
2378
 
 
2379
    @inargs = (
 
2380
        { name => 'image', type => 'image',
 
2381
          desc => 'The image' },
 
2382
        { name => 'tattoo', type => 'tattoo',
 
2383
          desc => 'The tattoo of the layer to find' }
 
2384
    );
 
2385
 
 
2386
    @outargs = (
 
2387
        { name => 'layer', type => 'layer',
 
2388
          desc => 'The layer with the specified tattoo' }
 
2389
    );
 
2390
 
 
2391
    %invoke = (
 
2392
        code => <<'CODE'
 
2393
{
 
2394
  layer = gimp_image_get_layer_by_tattoo (image, tattoo);
 
2395
}
 
2396
CODE
 
2397
    );
 
2398
}
 
2399
 
 
2400
sub image_get_channel_by_tattoo {
 
2401
    $blurb = 'Find a channel with a given tattoo in an image.';
 
2402
 
 
2403
    $help = <<'HELP';
 
2404
This procedure returns the channel with the given tattoo in the specified image.
 
2405
HELP
 
2406
 
 
2407
    &jay_pdb_misc('1998');
 
2408
 
 
2409
    @inargs = (
 
2410
        { name => 'image', type => 'image',
 
2411
          desc => 'The image' },
 
2412
        { name => 'tattoo', type => 'tattoo',
 
2413
          desc => 'The tattoo of the channel to find' }
 
2414
    );
 
2415
 
 
2416
    @outargs = (
 
2417
        { name => 'channel', type => 'channel',
 
2418
          desc => 'The channel with the specified tattoo' }
 
2419
    );
 
2420
 
 
2421
    %invoke = (
 
2422
        code => <<'CODE'
 
2423
{
 
2424
  channel = gimp_image_get_channel_by_tattoo (image, tattoo);
 
2425
}
 
2426
CODE
 
2427
    );
 
2428
}
 
2429
 
 
2430
sub image_get_vectors_by_tattoo {
 
2431
    $blurb = 'Find a vectors with a given tattoo in an image.';
 
2432
 
 
2433
    $help = <<'HELP';
 
2434
This procedure returns the vectors with the given tattoo in the specified image.
 
2435
HELP
 
2436
 
 
2437
    &jay_pdb_misc('1998');
 
2438
 
 
2439
    @inargs = (
 
2440
        { name => 'image', type => 'image',
 
2441
          desc => 'The image' },
 
2442
        { name => 'tattoo', type => 'tattoo',
 
2443
          desc => 'The tattoo of the vectors to find' }
 
2444
    );
 
2445
 
 
2446
    @outargs = (
 
2447
        { name => 'vectors', type => 'vectors',
 
2448
          desc => 'The vectors with the specified tattoo' }
 
2449
    );
 
2450
 
 
2451
    %invoke = (
 
2452
        code => <<'CODE'
 
2453
{
 
2454
  vectors = gimp_image_get_vectors_by_tattoo (image, tattoo);
 
2455
}
 
2456
CODE
 
2457
    );
1482
2458
}
1483
2459
 
1484
2460
sub image_thumbnail {
1491
2467
number of bits per pixel in the image.
1492
2468
HELP
1493
2469
 
1494
 
    $author = $copyright = 'Andy Thomas';
1495
 
    $date = '1999';
 
2470
    &andy_pdb_misc('1999');
1496
2471
 
1497
2472
    @inargs = (
1498
 
        &std_image_arg,
1499
 
        { name => 'width', type => '0 < int32 <= 1024',
1500
 
          desc => 'The thumbnail width', alias => 'req_width' },
1501
 
        { name => 'height', type => '0 < int32 <= 1024',
1502
 
          desc => 'The thumbnail height', alias => 'req_height' }
 
2473
        { name => 'image', type => 'image',
 
2474
          desc => 'The image' },
 
2475
        { name => 'width', type => '1 <= int32 <= 1024',
 
2476
          desc => 'The requested thumbnail width' },
 
2477
        { name => 'height', type => '1 <= int32 <= 1024',
 
2478
          desc => 'The requested thumbnail height' }
1503
2479
    );
1504
2480
 
1505
2481
    @outargs = (
1506
 
        &preview_dim_args,
 
2482
        { name => 'actual_width', type => 'int32', void_ret => 1,
 
2483
          desc => 'The previews width' },
 
2484
        { name => 'actual_height', type => 'int32',
 
2485
          desc => 'The previews height' },
 
2486
        { name => 'bpp', type => 'int32',
 
2487
          desc => 'The previews bpp' },
1507
2488
        { name => 'thumbnail_data', type => 'int8array', wrap => 1,
1508
 
          desc => 'The thumbnail data', init => 1,
 
2489
          desc => 'The thumbnail data',
1509
2490
          array => { name => 'thumbnail_data_count',
1510
 
                     desc => 'The number of bytes in thumbnail data',
1511
 
                     alias => 'num_bytes', init => 1 } }
 
2491
                     desc => 'The number of bytes in thumbnail data' } }
1512
2492
    );
1513
 
    $outargs[0]->{void_ret} = 1;
1514
2493
 
1515
2494
    %invoke = (
1516
2495
        code => <<'CODE'
1521
2500
  g_assert (GIMP_VIEWABLE_MAX_PREVIEW_SIZE >= 1024);
1522
2501
 
1523
2502
  /* Adjust the width/height ratio */
1524
 
  dwidth  = gimp_image_get_width  (gimage);
1525
 
  dheight = gimp_image_get_height (gimage);
 
2503
  dwidth  = gimp_image_get_width  (image);
 
2504
  dheight = gimp_image_get_height (image);
1526
2505
 
1527
2506
  if (dwidth > dheight)
1528
 
    req_height = MAX (1, (req_width * dheight) / dwidth);
 
2507
    height = MAX (1, (width * dheight) / dwidth);
1529
2508
  else
1530
 
    req_width  = MAX (1, (req_height * dwidth) / dheight);
 
2509
    width  = MAX (1, (height * dwidth) / dheight);
1531
2510
 
1532
 
  if (gimage->gimp->config->layer_previews)
1533
 
    buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (gimage),
1534
 
                                         req_width, req_height);
 
2511
  if (image->gimp->config->layer_previews)
 
2512
    buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (image), context,
 
2513
                                         width, height);
1535
2514
  else
1536
 
    buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (gimage),
1537
 
                                           req_width, req_height,
1538
 
                                           gimp_image_has_alpha (gimage) ?
 
2515
    buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (image),
 
2516
                                           width, height,
 
2517
                                           gimp_image_has_alpha (image) ?
1539
2518
                                           4 : 3);
1540
2519
 
1541
2520
  if (buf)
1542
2521
    {
1543
 
      num_bytes      = buf->height * buf->width * buf->bytes;
1544
 
      thumbnail_data = g_memdup (temp_buf_data (buf), num_bytes);
1545
 
      width          = buf->width;
1546
 
      height         = buf->height;
1547
 
      bpp            = buf->bytes;
 
2522
      actual_width         = buf->width;
 
2523
      actual_height        = buf->height;
 
2524
      bpp                  = buf->bytes;
 
2525
      thumbnail_data_count = actual_width * actual_height * bpp;
 
2526
      thumbnail_data       = g_memdup (temp_buf_data (buf),
 
2527
                                       thumbnail_data_count);
1548
2528
 
1549
2529
      temp_buf_free (buf);
1550
2530
    }
1551
2531
  else
1552
 
    {
1553
 
      success = FALSE;
1554
 
    }
 
2532
    success = FALSE;
1555
2533
}
1556
2534
CODE
1557
2535
    );
1558
2536
}
1559
2537
 
1560
2538
 
1561
 
@headers = qw("core/gimp.h" "core/gimplist.h" "core/gimpunit.h"
1562
 
              "base/temp-buf.h" "libgimpmath/gimpmath.h"
1563
 
              "libgimpbase/gimpbase.h" "gimp-intl.h");
1564
 
 
1565
2539
$extra{app}->{code} = <<'CODE';
1566
2540
#if defined (HAVE_FINITE)
1567
2541
#define FINITE(x) finite(x)
1574
2548
#endif
1575
2549
CODE
1576
2550
 
1577
 
unshift @procs, qw(image_list image_new image_duplicate image_delete
1578
 
                   image_base_type
1579
 
                   image_width image_height
1580
 
                   image_free_shadow
1581
 
                   image_resize image_resize_to_layers image_scale
1582
 
                   image_crop image_flip image_rotate
1583
 
                   image_get_layers image_get_channels
1584
 
                   image_get_active_drawable
1585
 
                   image_unset_active_channel
1586
 
                   image_get_floating_sel image_floating_sel_attached_to
1587
 
                   image_pick_color image_pick_correlate_layer
1588
 
                   image_add_layer image_remove_layer
1589
 
                   image_raise_layer image_lower_layer
1590
 
                   image_raise_layer_to_top image_lower_layer_to_bottom
1591
 
                   image_add_channel image_remove_channel
1592
 
                   image_raise_channel image_lower_channel
1593
 
                   image_flatten image_merge_visible_layers image_merge_down
1594
 
                   image_add_layer_mask image_remove_layer_mask
1595
 
                   image_get_colormap image_set_colormap
1596
 
                   image_clean_all image_is_dirty
1597
 
                   image_thumbnail);
1598
 
%exports = (app => [@procs], lib => [@procs[0..34,37..61]]);
 
2551
@headers = qw("libgimpmath/gimpmath.h"
 
2552
              "libgimpbase/gimpbase.h"
 
2553
              "base/temp-buf.h"
 
2554
              "core/gimp.h"
 
2555
              "core/gimplist.h"
 
2556
              "core/gimpunit.h"
 
2557
              "gimp-intl.h");
 
2558
 
 
2559
@procs = qw(image_is_valid
 
2560
            image_list
 
2561
            image_new image_duplicate image_delete
 
2562
            image_base_type
 
2563
            image_width image_height
 
2564
            image_free_shadow
 
2565
            image_resize image_resize_to_layers image_scale
 
2566
            image_crop image_flip image_rotate
 
2567
            image_get_layers image_get_channels
 
2568
            image_get_vectors
 
2569
            image_get_active_drawable
 
2570
            image_unset_active_channel
 
2571
            image_get_floating_sel image_floating_sel_attached_to
 
2572
            image_pick_color image_pick_correlate_layer
 
2573
            image_add_layer image_remove_layer
 
2574
            image_get_layer_position
 
2575
            image_raise_layer image_lower_layer
 
2576
            image_raise_layer_to_top image_lower_layer_to_bottom
 
2577
            image_add_channel image_remove_channel
 
2578
            image_get_channel_position
 
2579
            image_raise_channel image_lower_channel
 
2580
            image_add_vectors image_remove_vectors
 
2581
            image_get_vectors_position
 
2582
            image_raise_vectors image_lower_vectors
 
2583
            image_raise_vectors_to_top image_lower_vectors_to_bottom
 
2584
            image_flatten image_merge_visible_layers image_merge_down
 
2585
            image_add_layer_mask image_remove_layer_mask
 
2586
            image_get_colormap image_set_colormap
 
2587
            image_clean_all image_is_dirty
 
2588
            image_thumbnail
 
2589
            image_get_active_layer image_set_active_layer
 
2590
            image_get_active_channel image_set_active_channel
 
2591
            image_get_active_vectors image_set_active_vectors
 
2592
            image_get_selection
 
2593
            image_get_component_active image_set_component_active
 
2594
            image_get_component_visible image_set_component_visible
 
2595
            image_get_filename image_set_filename
 
2596
            image_get_name
 
2597
            image_get_resolution image_set_resolution
 
2598
            image_get_unit image_set_unit
 
2599
            image_get_tattoo_state image_set_tattoo_state
 
2600
            image_get_layer_by_tattoo
 
2601
            image_get_channel_by_tattoo
 
2602
            image_get_vectors_by_tattoo);
 
2603
 
 
2604
%exports = (app => [@procs], lib => [@procs[0..45,48..74]]);
1599
2605
 
1600
2606
$desc = 'Image';
1601
2607