~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): Sebastien Bacher
  • Date: 2008-10-06 13:30:41 UTC
  • mto: This revision was merged to the branch mainline in revision 35.
  • Revision ID: james.westby@ubuntu.com-20081006133041-3panbkcanaymfsmp
Tags: upstream-2.6.0
ImportĀ upstreamĀ versionĀ 2.6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    %invoke = (
37
37
        code => <<'CODE'
38
38
{
39
 
  if (gimp_image_base_type (image) != GIMP_RGB)
40
 
    gimp_image_convert (image, GIMP_RGB, 0, 0, FALSE, FALSE, 0, NULL, NULL);
 
39
  if (gimp_pdb_image_is_not_base_type (image, GIMP_RGB, error))
 
40
    {
 
41
      success = gimp_image_convert (image, GIMP_RGB,
 
42
                                    0, 0, FALSE, FALSE, 0, NULL,
 
43
                                    NULL, error);
 
44
    }
41
45
  else
42
 
    success = FALSE;
 
46
    {
 
47
      success = FALSE;
 
48
    }
43
49
}
44
50
CODE
45
51
    );
64
70
    %invoke = (
65
71
        code => <<'CODE'
66
72
{
67
 
  if (gimp_image_base_type (image) != GIMP_GRAY)
68
 
    gimp_image_convert (image, GIMP_GRAY, 0, 0, FALSE, FALSE, 0, NULL, NULL);
 
73
  if (gimp_pdb_image_is_not_base_type (image, GIMP_GRAY, error))
 
74
    {
 
75
      success = gimp_image_convert (image, GIMP_GRAY,
 
76
                                    0, 0, FALSE, FALSE, 0, NULL,
 
77
                                    NULL, error);
 
78
    }
69
79
  else
70
 
    success = FALSE;
 
80
    {
 
81
      success = FALSE;
 
82
    }
71
83
}
72
84
CODE
73
85
    );
119
131
{
120
132
  GimpPalette *pal = NULL;
121
133
 
122
 
  if (gimp_image_base_type (image) != GIMP_INDEXED)
 
134
  if (gimp_pdb_image_is_not_base_type (image, GIMP_INDEXED, error))
123
135
    {
124
136
      switch (palette_type)
125
137
        {
129
141
          break;
130
142
 
131
143
        case GIMP_CUSTOM_PALETTE:
132
 
          pal = (GimpPalette *)
133
 
            gimp_container_get_child_by_name (gimp->palette_factory->container,
134
 
                                              palette);
135
 
          if (pal == NULL || pal->n_colors > 256)
136
 
            success = FALSE;
137
 
          break;
 
144
          pal = gimp_pdb_get_palette (gimp, palette, FALSE, error);
 
145
          if (! pal)
 
146
            {
 
147
              success = FALSE;
 
148
            }
 
149
          else if (pal->n_colors > MAXNUMCOLORS)
 
150
            {
 
151
              g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_INVALID_ARGUMENT,
 
152
                           _("Cannot convert to a palette "
 
153
                             "with more than 256 colors."));
 
154
              success = FALSE;
 
155
            }
 
156
          break;
138
157
 
139
158
        default:
140
159
          break;
141
160
        }
142
161
    }
143
162
  else
144
 
    success = FALSE;
 
163
    {
 
164
      success = FALSE;
 
165
    }
145
166
 
146
167
  if (success)
147
 
    gimp_image_convert (image, GIMP_INDEXED, num_cols, dither_type,
148
 
                        alpha_dither, remove_unused, palette_type, pal,
149
 
                        NULL);
 
168
    success = gimp_image_convert (image, GIMP_INDEXED,
 
169
                                  num_cols, dither_type,
 
170
                                  alpha_dither, remove_unused,
 
171
                                  palette_type, pal,
 
172
                                  NULL, error);
150
173
}
151
174
CODE
152
175
    );
177
200
    %invoke = (
178
201
        code => <<'CODE'
179
202
{
180
 
  gimp_image_convert_set_dither_matrix (width, height, (guchar *) matrix);
 
203
  gimp_image_convert_set_dither_matrix (matrix, width, height);
181
204
}
182
205
CODE
183
206
    );
184
207
}
185
208
 
186
 
@headers = qw("core/gimp.h" "core/gimpcontainer.h" "core/gimpdatafactory.h"
187
 
              "core/gimpimage.h" "core/gimpimage-convert.h"
188
 
              "core/gimppalette.h");
 
209
@headers = qw("core/gimpimage.h"
 
210
              "core/gimpimage-convert.h"
 
211
              "core/gimppalette.h"
 
212
              "gimppdberror.h"
 
213
              "gimppdb-utils.h"
 
214
              "gimp-intl.h");
189
215
 
190
216
@procs = qw(image_convert_rgb
191
217
            image_convert_grayscale