18
18
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
31
if (gimp_image_base_type (gimage) != $type)
32
gimp_image_convert (gimage, $type, 0, 0, FALSE, FALSE, 0, NULL, NULL);
40
20
sub image_convert_rgb {
41
21
$blurb = 'Convert specified image to RGB color';
44
This procedure converts the specified image to RGB color. This process requires
45
an image of type GIMP_GRAY or GIMP_INDEXED. No image content is lost in this
46
process aside from the colormap for an indexed image.
24
This procedure converts the specified image to RGB color. This process
25
requires an image in RGB or Indexed color mode. No image content is lost
26
in this process aside from the colormap for an indexed image.
51
&simple_invoke('GIMP_RGB');
32
{ name => 'image', type => 'image',
39
if (gimp_image_base_type (image) != GIMP_RGB)
40
gimp_image_convert (image, GIMP_RGB, 0, 0, FALSE, FALSE, 0, NULL, NULL);
54
48
sub image_convert_grayscale {
55
49
$blurb = 'Convert specified image to grayscale (256 intensity levels)';
58
This procedure converts the specified image to grayscale with 8 bits per pixel
59
(256 intensity levels). This process requires an image of type GIMP_RGB or
52
This procedure converts the specified image to grayscale with 8 bits
53
per pixel (256 intensity levels). This process requires an image in RGB
54
or Indexed color mode.
65
&simple_invoke('GIMP_GRAY');
60
{ name => 'image', type => 'image',
67
if (gimp_image_base_type (image) != GIMP_GRAY)
68
gimp_image_convert (image, GIMP_GRAY, 0, 0, FALSE, FALSE, 0, NULL, NULL);
68
76
sub image_convert_indexed {
72
80
This procedure converts the specified image to 'indexed' color. This
73
process requires an image of type GIMP_GRAY or GIMP_RGB. The
74
'palette_type' specifies what kind of palette to use, A type of '0'
75
means to use an optimal palette of 'num_cols' generated from the
76
colors in the image. A type of '1' means to re-use the previous
77
palette (not currently implemented). A type of '2' means to use the
78
so-called WWW-optimized palette. Type '3' means to use only black and
79
white colors. A type of '4' means to use a palette from the gimp
80
palettes directories. The 'dither type' specifies what kind of
81
dithering to use. '0' means no dithering, '1' means standard
82
Floyd-Steinberg error diffusion, '2' means Floyd-Steinberg error
83
diffusion with reduced bleeding, '3' means dithering based on pixel
84
location ('Fixed' dithering).
81
process requires an image in RGB or Grayscale mode. The 'palette_type'
82
specifies what kind of palette to use, A type of '0' means to use an
83
optimal palette of 'num_cols' generated from the colors in the
84
image. A type of '1' means to re-use the previous palette (not
85
currently implemented). A type of '2' means to use the so-called
86
WWW-optimized palette. Type '3' means to use only black and white
87
colors. A type of '4' means to use a palette from the gimp palettes
88
directories. The 'dither type' specifies what kind of dithering to
89
use. '0' means no dithering, '1' means standard Floyd-Steinberg error
90
diffusion, '2' means Floyd-Steinberg error diffusion with reduced
91
bleeding, '3' means dithering based on pixel location ('Fixed'
98
{ name => 'image', type => 'image',
99
desc => 'The image' },
91
100
{ name => 'dither_type', type => 'enum GimpConvertDitherType',
92
desc => 'The dither type to use: { %%desc%% }' },
101
desc => 'The dither type to use' },
93
102
{ name => 'palette_type', type => 'enum GimpConvertPaletteType',
94
desc => 'The type of palette to use: { %%desc%% }' },
103
desc => 'The type of palette to use' },
95
104
{ name => 'num_cols', type => 'int32',
96
105
desc => 'The number of colors to quantize to, ignored unless
97
106
(palette_type == GIMP_MAKE_PALETTE)' },
98
107
{ name => 'alpha_dither', type => 'boolean',
99
108
desc => 'Dither transparency to fake partial opacity' },
100
109
{ name => 'remove_unused', type => 'boolean',
101
desc => 'Remove unused or duplicate colour entries from final
110
desc => 'Remove unused or duplicate color entries from final
102
111
palette, ignored if (palette_type == GIMP_MAKE_PALETTE)' },
103
112
{ name => 'palette', type => 'string',
104
113
desc => 'The name of the custom palette to use, ignored unless
105
(palette_type == GIMP_CUSTOM_PALETTE)',
106
alias => 'palette_name' }
114
(palette_type == GIMP_CUSTOM_PALETTE)' }
112
GimpPalette *palette = NULL;
120
GimpPalette *pal = NULL;
114
if (gimp_image_base_type (gimage) != GIMP_INDEXED)
122
if (gimp_image_base_type (image) != GIMP_INDEXED)
116
124
switch (palette_type)
146
gimp_image_convert (gimage, GIMP_INDEXED, num_cols, dither_type,
147
alpha_dither, remove_unused, palette_type, palette,
147
gimp_image_convert (image, GIMP_INDEXED, num_cols, dither_type,
148
alpha_dither, remove_unused, palette_type, pal,
154
@headers = qw("core/gimp.h" "core/gimpcontainer.h" "core/gimpimage.h"
155
"core/gimpimage-convert.h" "core/gimpdatafactory.h"
156
"core/gimppalette.h");
158
@procs = qw(image_convert_rgb image_convert_grayscale image_convert_indexed);
155
sub image_convert_set_dither_matrix {
156
$blurb = 'Set dither matrix for conversion to indexed';
159
This procedure sets the dither matrix used when converting images to INDEXED mode with
160
positional dithering.
163
&david_pdb_misc('2006', '2.4');
166
{ name => 'width', type => 'int32',
167
desc => 'Width of the matrix (0 to reset to default matrix)' },
168
{ name => 'height', type => 'int32',
169
desc => 'Height of the matrix (0 to reset to default matrix)' },
170
{ name => 'matrix', type => 'int8array',
171
desc => 'The matrix -- all values must be >= 1',
172
array => { name => 'matrix_length', type => '1 <= int32 <= 1024',
173
desc => "The length of 'matrix'" }
180
gimp_image_convert_set_dither_matrix (width, height, (guchar *) matrix);
186
@headers = qw("core/gimp.h" "core/gimpcontainer.h" "core/gimpdatafactory.h"
187
"core/gimpimage.h" "core/gimpimage-convert.h"
188
"core/gimppalette.h");
190
@procs = qw(image_convert_rgb
191
image_convert_grayscale
192
image_convert_indexed
193
image_convert_set_dither_matrix);
159
195
%exports = (app => [@procs], lib => [@procs]);
161
197
$desc = 'Convert';