18
18
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
26
sub operation_arg () {{
28
type => 'enum GimpChannelOps',
29
desc => 'The selection operation: { %%desc%% }'
32
sub channel_get_prop_proc {
33
my ($prop, $type, $desc, $undo, $core_type, $core_var) = @_;
35
$core_type = 'channel' unless $core_type;
36
$core_var = 'channel' unless $core_var;
38
$blurb = "Get the $desc of the specified channel.";
40
$help = "This procedure returns the specified channel's $desc. ";
44
@inargs = ( &channel_arg );
47
{ name => $prop, type => $type,
48
desc => "The channel $desc", no_declare => 1 }
51
my $alias = "gimp_${core_type}_get_$prop ($core_var)";
52
$alias = "g_strdup ($alias)" if $type eq 'string';
53
$outargs[0]->{alias} .= "$alias";
55
if ($type eq 'color') {
56
delete @{$outargs[0]}{qw(alias no_declare)};
57
$invoke{code} = 'gimp_channel_get_color (channel, &color);';
61
sub channel_set_prop_proc {
62
my ($prop, $type, $desc, $undo, $core_type, $core_var) = @_;
64
$core_type = 'channel' unless $core_type;
65
$core_var = 'channel' unless $core_var;
67
$blurb = "Set the $desc of the specified channel.";
69
$help = "This procedure sets the specified channel's $desc. ";
75
{ name => $prop, type => $type,
76
desc => "The new channel $desc" }
79
if ($type =~ /float/) {
80
$inargs[1]->{desc} .= ' (%%desc%%)';
83
$invoke{code} = $undo ? "gimp_${core_type}_set_$prop ($core_var, $prop, TRUE);"
84
: "gimp_${core_type}_set_$prop ($core_var, $prop);";
86
if ($type eq 'color') {
87
$invoke{code} = <<'CODE'
89
GimpRGB rgb_color = color;
91
rgb_color.a = channel->color.a;
92
gimp_channel_set_color (channel, &rgb_color, TRUE);
98
sub channel_accessors {
99
my ($prop, $type, $desc, $undo, $extra, $core_type, $core_var) = @_;
101
$core_type = 'channel' unless $core_type;
102
$core_var = 'channel' unless $core_var;
104
my (@extra, %extra); my $once = 0;
106
ref($extra) ? (@extra = @$extra) : (@extra = ($extra, $extra));
107
%extra = map { $once++ ? 'set' : 'get', $_ ? $_ : "" } @extra;
109
foreach (sort keys %extra) {
110
my $proc = "channel_${_}_$prop";
115
sub @{[ scalar caller ]}::$proc {
116
\&channel_${_}_prop_proc('$prop', '$type', '$desc', $undo,
117
'$core_type', '$core_var');
125
21
$blurb = 'Create a new channel.';
140
{ name => 'width', type => '0 < int32',
141
desc => 'The channel width: (%%desc%%)' },
142
{ name => 'height', type => '0 < int32',
143
desc => 'The channel height: (%%desc%%)' },
35
{ name => 'image', type => 'image',
36
desc => 'The image to which to add the channel' },
37
{ name => 'width', type => '1 <= int32',
38
desc => 'The channel width' },
39
{ name => 'height', type => '1 <= int32',
40
desc => 'The channel height' },
144
41
{ name => 'name', type => 'string',
145
42
desc => 'The channel name' },
146
43
{ name => 'opacity', type => '0 <= float <= 100',
147
desc => 'The channel opacity: (%%desc%%)' },
44
desc => 'The channel opacity' },
148
45
{ name => 'color', type => 'color',
149
46
desc => 'The channel compositing color'
152
$inargs[0]->{desc} .= ' to which to add the channel';
155
51
{ name => 'channel', type => 'channel', wrap => 1,
156
desc => 'The newly created channel', init => 1 }
52
desc => 'The newly created channel' }
210
@inargs = ( &channel_arg, &channel_arg, &operation_arg );
212
foreach my $i (0,1) {
213
foreach my $unused (qw(name desc)) {
214
$inargs[$i]{$unused} .= $i + 1;
219
push @inargs, { name => "off$_", type => 'int32',
220
desc => "$_ offset between upper left corner of
221
channels: (second - first)" }
113
{ name => 'channel1', type => 'channel',
114
desc => 'The channel1' },
115
{ name => 'channel2', type => 'channel',
116
desc => 'The channel2' },
117
{ name => 'operation', type => 'enum GimpChannelOps',
118
desc => 'The selection operation' },
119
{ name => 'offx', type => 'int32',
120
desc => 'x offset between upper left corner of
121
channels: (second - first)' },
122
{ name => 'offy', type => 'int32',
123
desc => 'y offset between upper left corner of
124
channels: (second - first)' }
225
headers => [ qw("core/gimpchannel-combine.h") ],
128
headers => [ qw("core/gimpchannel-combine.h" "gimp-intl.h") ],
131
gimp_channel_push_undo (channel1, _("Combine Masks"));
228
132
gimp_channel_combine_mask (channel1, channel2, operation, offx, offy);
234
&channel_accessors('show_masked', 'boolean', 'composite method', 0,
237
If it is non-zero, then the channel is composited with the image so that masked
238
regions are shown. Otherwise, selected regions are shown.
242
&channel_accessors('opacity', '0 <= float <= 100', 'opacity', 1,
243
[ '$outargs[0]->{alias} =
244
"gimp_channel_get_opacity (channel) * 100.0"',
246
s%opacity, %opacity / 100.0, %' ]);
248
&channel_accessors('color', 'color', 'compositing color', 0,
249
[ '$outargs[0]->{void_ret} = 1', '' ]);
251
unshift @procs, qw(channel_new channel_copy channel_combine_masks);
138
sub channel_new_from_component {
139
$blurb = 'Create a new channel from a color component';
142
This procedure creates a new channel from a color component.
145
&shlomi_pdb_misc('2005', '2.4');
148
{ name => 'image', type => 'image',
149
desc => 'The image to which to add the channel' },
150
{ name => 'component', type => 'enum GimpChannelType',
151
desc => 'The image component' },
152
{ name => 'name', type => 'string',
153
desc => 'The channel name' },
157
{ name => 'channel', type => 'channel',
158
desc => 'The newly created channel' }
164
if (gimp_image_get_component_index (image, component) != -1)
165
channel = gimp_channel_new_from_component (image,
166
component, name, NULL);
169
gimp_item_set_visible (GIMP_ITEM (channel), FALSE, FALSE);
177
sub channel_get_show_masked {
178
$blurb = "Get the composite method of the specified channel.";
181
This procedure returns the specified channel's composite method. If
182
it is TRUE, then the channel is composited with the image so that
183
masked regions are shown. Otherwise, selected regions are shown.
189
{ name => 'channel', type => 'channel',
190
desc => 'The channel' }
194
{ name => 'show_masked', type => 'boolean',
195
desc => 'The channel composite method' }
201
show_masked = gimp_channel_get_show_masked (channel);
207
sub channel_set_show_masked {
208
$blurb = "Set the composite method of the specified channel.";
211
This procedure sets the specified channel's composite method. If
212
it is TRUE, then the channel is composited with the image so that
213
masked regions are shown. Otherwise, selected regions are shown.
219
{ name => 'channel', type => 'channel',
220
desc => 'The channel' },
221
{ name => 'show_masked', type => 'boolean',
222
desc => 'The new channel composite method' }
228
gimp_channel_set_show_masked (channel, show_masked);
234
sub channel_get_opacity {
235
$blurb = "Get the opacity of the specified channel.";
238
This procedure returns the specified channel's opacity.
244
{ name => 'channel', type => 'channel',
245
desc => 'The channel' }
249
{ name => 'opacity', type => '0 <= float <= 100',
250
desc => 'The channel opacity' }
256
opacity = gimp_channel_get_opacity (channel) * 100;
262
sub channel_set_opacity {
263
$blurb = "Set the opacity of the specified channel.";
266
This procedure sets the specified channel's opacity.
272
{ name => 'channel', type => 'channel',
273
desc => 'The channel' },
274
{ name => 'opacity', type => '0 <= float <= 100',
275
desc => 'The new channel opacity' }
281
gimp_channel_set_opacity (channel, opacity / 100.0, TRUE);
287
sub channel_get_color {
288
$blurb = "Get the compositing color of the specified channel.";
291
This procedure returns the specified channel's compositing color.
297
{ name => 'channel', type => 'channel',
298
desc => 'The channel' }
302
{ name => 'color', type => 'color', void_ret => 1,
303
desc => 'The channel compositing color' }
309
gimp_channel_get_color (channel, &color);
310
gimp_rgb_set_alpha (&color, 1.0);
316
sub channel_set_color {
317
$blurb = "Set the compositing color of the specified channel.";
320
This procedure sets the specified channel's compositing color.
326
{ name => 'channel', type => 'channel',
327
desc => 'The channel' },
328
{ name => 'color', type => 'color',
329
desc => 'The new channel compositing color' }
335
GimpRGB rgb_color = color;
337
rgb_color.a = channel->color.a;
338
gimp_channel_set_color (channel, &rgb_color, TRUE);
345
@procs = qw(channel_new channel_new_from_component channel_copy
346
channel_combine_masks
347
channel_get_show_masked channel_set_show_masked
348
channel_get_opacity channel_set_opacity
349
channel_get_color channel_set_color);
252
351
%exports = (app => [@procs], lib => [@procs]);
254
353
$desc = 'Channel';