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

« back to all changes in this revision

Viewing changes to tools/pdbgen/pdb/convert.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 simple_inargs {
21
 
    @inargs = (
22
 
        &std_image_arg
23
 
    );
24
 
}
25
 
 
26
 
sub simple_invoke {
27
 
    my $type = shift;
28
 
    %invoke = (
29
 
        code => <<CODE
30
 
{
31
 
  if (gimp_image_base_type (gimage) != $type)
32
 
    gimp_image_convert (gimage, $type, 0, 0, FALSE, FALSE, 0, NULL, NULL);
33
 
  else
34
 
    success = FALSE;
35
 
}
36
 
CODE
37
 
    );
38
 
}
39
 
 
40
20
sub image_convert_rgb {
41
21
    $blurb = 'Convert specified image to RGB color';
42
22
 
43
23
    $help = <<'HELP';
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.
47
27
HELP
48
28
 
49
29
    &std_pdb_misc;
50
 
    &simple_inargs;
51
 
    &simple_invoke('GIMP_RGB');
 
30
 
 
31
    @inargs = (
 
32
        { name => 'image', type => 'image',
 
33
          desc => 'The image' }
 
34
    );
 
35
 
 
36
    %invoke = (
 
37
        code => <<'CODE'
 
38
{
 
39
  if (gimp_image_base_type (image) != GIMP_RGB)
 
40
    gimp_image_convert (image, GIMP_RGB, 0, 0, FALSE, FALSE, 0, NULL, NULL);
 
41
  else
 
42
    success = FALSE;
 
43
}
 
44
CODE
 
45
    );
52
46
}
53
47
 
54
48
sub image_convert_grayscale {
55
49
    $blurb = 'Convert specified image to grayscale (256 intensity levels)';
56
50
 
57
51
    $help = <<'HELP';
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 
60
 
GIMP_INDEXED.
 
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.
61
55
HELP
62
56
 
63
57
    &std_pdb_misc;
64
 
    &simple_inargs;
65
 
    &simple_invoke('GIMP_GRAY');
 
58
 
 
59
    @inargs = (
 
60
        { name => 'image', type => 'image',
 
61
          desc => 'The image' }
 
62
    );
 
63
 
 
64
    %invoke = (
 
65
        code => <<'CODE'
 
66
{
 
67
  if (gimp_image_base_type (image) != GIMP_GRAY)
 
68
    gimp_image_convert (image, GIMP_GRAY, 0, 0, FALSE, FALSE, 0, NULL, NULL);
 
69
  else
 
70
    success = FALSE;
 
71
}
 
72
CODE
 
73
    );
66
74
}
67
75
 
68
76
sub image_convert_indexed {
70
78
 
71
79
    $help = <<'HELP';
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'
 
92
dithering).
85
93
HELP
86
94
 
87
95
    &std_pdb_misc;
88
96
 
89
97
    @inargs = (
90
 
        &std_image_arg,
 
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)' }
107
115
    );
108
116
 
109
117
    %invoke = (
110
118
        code => <<'CODE'
111
119
{
112
 
  GimpPalette *palette = NULL;
 
120
  GimpPalette *pal = NULL;
113
121
 
114
 
  if (gimp_image_base_type (gimage) != GIMP_INDEXED)
 
122
  if (gimp_image_base_type (image) != GIMP_INDEXED)
115
123
    {
116
124
      switch (palette_type)
117
125
        {
121
129
          break;
122
130
 
123
131
        case GIMP_CUSTOM_PALETTE:
124
 
          if (! gimp->palette_factory->container->num_children)
125
 
            gimp_data_factory_data_init (gimp->palette_factory, FALSE);
126
 
 
127
 
          palette = (GimpPalette *)
 
132
          pal = (GimpPalette *)
128
133
            gimp_container_get_child_by_name (gimp->palette_factory->container,
129
 
                                              palette_name);
130
 
 
131
 
          if (palette == NULL)
 
134
                                              palette);
 
135
          if (pal == NULL)
132
136
            success = FALSE;
133
 
 
134
137
          break;
135
138
 
136
139
        default:
138
141
        }
139
142
    }
140
143
  else
141
 
    {
142
 
      success = FALSE;
143
 
    }
 
144
    success = FALSE;
144
145
 
145
146
  if (success)
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,
148
149
                        NULL);
149
150
}
150
151
CODE
151
152
    );
152
153
}
153
154
 
154
 
@headers = qw("core/gimp.h" "core/gimpcontainer.h" "core/gimpimage.h"
155
 
              "core/gimpimage-convert.h" "core/gimpdatafactory.h"
156
 
              "core/gimppalette.h");
157
 
 
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';
 
157
 
 
158
    $help = <<'HELP';
 
159
This procedure sets the dither matrix used when converting images to INDEXED mode with 
 
160
positional dithering. 
 
161
HELP
 
162
 
 
163
    &david_pdb_misc('2006', '2.4');
 
164
 
 
165
    @inargs = (
 
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'" }
 
174
          },
 
175
    );
 
176
 
 
177
    %invoke = (
 
178
        code => <<'CODE'
 
179
{
 
180
    gimp_image_convert_set_dither_matrix (width, height, (guchar *) matrix);
 
181
}
 
182
CODE
 
183
    );
 
184
}
 
185
 
 
186
@headers = qw("core/gimp.h" "core/gimpcontainer.h" "core/gimpdatafactory.h"
 
187
              "core/gimpimage.h" "core/gimpimage-convert.h"
 
188
              "core/gimppalette.h");
 
189
 
 
190
@procs = qw(image_convert_rgb
 
191
            image_convert_grayscale
 
192
            image_convert_indexed
 
193
            image_convert_set_dither_matrix);
 
194
 
159
195
%exports = (app => [@procs], lib => [@procs]);
160
196
 
161
197
$desc = 'Convert';