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

« back to all changes in this revision

Viewing changes to tools/pdbgen/pdb/transform_tools.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
 
# Transform Tools
21
 
 
22
 
# shortcuts
23
 
 
24
 
sub drawable_arg () {{
25
 
    name => 'drawable',
26
 
    type => 'drawable',
27
 
    desc => 'The affected drawable',
28
 
}}
29
 
 
30
 
sub drawable_out_arg {
31
 
    my $type = shift;
32
 
    my $arg = &drawable_arg;
33
 
    $arg->{desc} = "The $type drawable";
34
 
    $arg->{no_declare} = 1;
35
 
    $arg;
36
 
}
37
 
 
38
 
 
39
 
# The defs
40
 
 
41
20
sub flip {
42
 
    &std_pdb_deprecated ('gimp_drawable_transform_flip_simple');
 
21
    &std_pdb_deprecated ('gimp-drawable-transform-flip-simple');
43
22
 
44
23
    @inargs = (
45
 
        &drawable_arg,
46
 
        { name => 'flip_type', type => &std_orientation_enum,
47
 
          desc => 'Type of flip: %%desc%%' }
 
24
        { name => 'drawable', type => 'drawable',
 
25
          desc => 'The affected drawable' },
 
26
        { name => 'flip_type',
 
27
          type => 'enum GimpOrientationType (no GIMP_ORIENTATION_UNKNOWN)',
 
28
          desc => 'Type of flip' }
48
29
    );
49
30
 
50
 
    @outargs = ( &drawable_out_arg('flipped') );
 
31
    @outargs = (
 
32
        { name => 'drawable', type => 'drawable', no_declare => 1,
 
33
          desc => 'The flipped drawable' }
 
34
    );
51
35
 
52
36
    %invoke = (
53
37
        code => <<'CODE'
68
52
}
69
53
 
70
54
sub perspective {
71
 
    &std_pdb_deprecated ('gimp_drawable_transform_perspective_default');
 
55
    &std_pdb_deprecated ('gimp-drawable-transform-perspective-default');
72
56
 
73
57
    @inargs = (
74
 
        &drawable_arg,
 
58
        { name => 'drawable', type => 'drawable',
 
59
          desc => 'The affected drawable' },
75
60
        { name => 'interpolation', type => 'boolean',
76
 
          desc => 'Whether to use interpolation' }
77
 
    );
78
 
 
79
 
    my $pos = 0;
80
 
    foreach $where (qw(upper-left upper-right lower-left lower-right)) {
81
 
        foreach (qw(x y)) {
82
 
            push @inargs,
83
 
                 { name => "$_$pos", type => 'float',
84
 
                   desc => "The new $_ coordinate of $where corner of original
85
 
                            bounding box",
86
 
                   alias => "trans_info[\U$_\E$pos]", no_declare => 1 }
87
 
        }
88
 
        $pos++;
89
 
    }
90
 
 
91
 
    @outargs = ( &drawable_out_arg('newly mapped') );
 
61
          desc => 'Whether to use interpolation' },
 
62
        { name => 'x0', type => 'float',
 
63
          desc => 'The new x coordinate of upper-left corner of original
 
64
                   bounding box' },
 
65
        { name => 'y0', type => 'float',
 
66
          desc => 'The new y coordinate of upper-left corner of original
 
67
                   bounding box' },
 
68
        { name => 'x1', type => 'float',
 
69
          desc => 'The new x coordinate of upper-right corner of original
 
70
                   bounding box' },
 
71
        { name => 'y1', type => 'float',
 
72
          desc => 'The new y coordinate of upper-right corner of original
 
73
                   bounding box' },
 
74
        { name => 'x2', type => 'float',
 
75
          desc => 'The new x coordinate of lower-left corner of original
 
76
                   bounding box' },
 
77
        { name => 'y2', type => 'float',
 
78
          desc => 'The new y coordinate of lower-left corner of original
 
79
                   bounding box' },
 
80
        { name => 'x3', type => 'float',
 
81
          desc => 'The new x coordinate of lower-right corner of original
 
82
                   bounding box' },
 
83
        { name => 'y3', type => 'float',
 
84
          desc => 'The new y coordinate of lower-right corner of original
 
85
                   bounding box' }
 
86
    );
 
87
 
 
88
    @outargs = (
 
89
        { name => 'drawable', type => 'drawable', no_declare => 1,
 
90
          desc => 'The newly mapped drawable' }
 
91
    );
92
92
 
93
93
    %invoke = (
94
 
        vars => [ 'gdouble trans_info[8]' ],
95
94
        code => <<'CODE'
96
95
{
97
96
  gint x, y, width, height;
111
110
      y += off_y;
112
111
 
113
112
      /* Assemble the transformation matrix */
114
 
      gimp_transform_matrix_perspective (x, y, width, height,
115
 
                                         trans_info[X0], trans_info[Y0],
116
 
                                         trans_info[X1], trans_info[Y1],
117
 
                                         trans_info[X2], trans_info[Y2],
118
 
                                         trans_info[X3], trans_info[Y3],
119
 
                                         &matrix);
 
113
      gimp_matrix3_identity (&matrix);
 
114
      gimp_transform_matrix_perspective (&matrix,
 
115
                                         x, y, width, height,
 
116
                                         x0, y0, x1, y1,
 
117
                                         x2, y2, x3, y3);
120
118
 
121
119
      if (interpolation)
122
120
        interpolation_type = gimp->config->interpolation_type;
123
121
 
124
122
      if (progress)
125
 
        gimp_progress_start (progress, _("Perspective..."), FALSE);
 
123
        gimp_progress_start (progress, _("Perspective"), FALSE);
126
124
 
127
125
      /* Perspective the selection */
128
126
      success = gimp_drawable_transform_affine (drawable, context,
140
138
}
141
139
 
142
140
sub rotate {
143
 
    &std_pdb_deprecated ('gimp_drawable_transform_rotate_default');
 
141
    &std_pdb_deprecated ('gimp-drawable-transform-rotate-default');
144
142
 
145
143
    @inargs = (
146
 
        &drawable_arg,
 
144
        { name => 'drawable', type => 'drawable',
 
145
          desc => 'The affected drawable' },
147
146
        { name => 'interpolation', type => 'boolean',
148
147
          desc => 'Whether to use interpolation' },
149
148
        { name => 'angle', type => 'float',
150
149
          desc => 'The angle of rotation (radians)' }
151
150
    );
152
151
 
153
 
    @outargs = ( &drawable_out_arg('rotated') );
 
152
    @outargs = (
 
153
        { name => 'drawable', type => 'drawable', no_declare => 1,
 
154
          desc => 'The rotated drawable' }
 
155
    );
154
156
 
155
157
    %invoke = (
156
158
        code => <<'CODE'
172
174
      y += off_y;
173
175
 
174
176
      /* Assemble the transformation matrix */
175
 
      gimp_transform_matrix_rotate (x, y, width, height,
176
 
                                    angle, &matrix);
 
177
      gimp_matrix3_identity (&matrix);
 
178
      gimp_transform_matrix_rotate_rect (&matrix,
 
179
                                         x, y, width, height,
 
180
                                         angle);
177
181
 
178
182
      if (interpolation)
179
183
        interpolation_type = gimp->config->interpolation_type;
180
184
 
181
185
      if (progress)
182
 
        gimp_progress_start (progress, _("Rotating..."), FALSE);
 
186
        gimp_progress_start (progress, _("Rotating"), FALSE);
183
187
 
184
188
      /* Rotate the selection */
185
189
      success = gimp_drawable_transform_affine (drawable, context,
197
201
}
198
202
 
199
203
sub scale {
200
 
    &std_pdb_deprecated ('gimp_drawable_transform_scale_default');
 
204
    &std_pdb_deprecated ('gimp-drawable-transform-scale-default');
201
205
 
202
206
    @inargs = (
203
 
        &drawable_arg,
 
207
        { name => 'drawable', type => 'drawable',
 
208
          desc => 'The affected drawable' },
204
209
        { name => 'interpolation', type => 'boolean',
205
 
          desc => 'Whether to use interpolation' }
206
 
    );
207
 
 
208
 
    my $pos = 0;
209
 
    foreach $where (qw(upper-left lower-right)) {
210
 
        foreach (qw(x y)) {
211
 
            push @inargs,
212
 
                 { name => "$_$pos", type => 'float',
213
 
                   desc => "The new $_ coordinate of $where corner of newly
214
 
                            scaled region",
215
 
                   alias => "trans_info[\U$_\E$pos]", no_declare => 1 }
216
 
        }
217
 
        $pos++;
218
 
    }
219
 
 
220
 
    @outargs = ( &drawable_out_arg('scaled') );
 
210
          desc => 'Whether to use interpolation' },
 
211
        { name => 'x0', type => 'float',
 
212
          desc => 'The new x coordinate of the upper-left corner of the
 
213
                    scaled region' },
 
214
        { name => 'y0', type => 'float',
 
215
          desc => 'The new y coordinate of the upper-left corner of the
 
216
                    scaled region' },
 
217
        { name => 'x1', type => 'float',
 
218
          desc => 'The new x coordinate of the lower-right corner of the
 
219
                    scaled region' },
 
220
        { name => 'y1', type => 'float',
 
221
          desc => 'The new y coordinate of the lower-right corner of the
 
222
                    scaled region' }
 
223
    );
 
224
 
 
225
    @outargs = (
 
226
        { name => 'drawable', type => 'drawable', no_declare => 1,
 
227
          desc => 'The scaled drawable' }
 
228
    );
221
229
 
222
230
    %invoke = (
223
 
        vars => [ 'gdouble trans_info[4]' ],
224
231
        code => <<'CODE'
225
232
{
226
233
  gint x, y, width, height;
227
234
 
228
235
  success = (gimp_item_is_attached (GIMP_ITEM (drawable)) &&
229
 
             trans_info[X0] < trans_info[X1] &&
230
 
             trans_info[Y0] < trans_info[Y1]);
 
236
             x0 < x1 && y0 < y1);
231
237
 
232
238
  if (success &&
233
239
      gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
242
248
      y += off_y;
243
249
 
244
250
      /* Assemble the transformation matrix */
245
 
      gimp_transform_matrix_scale (x, y, width, height,
246
 
                                   trans_info[X0],
247
 
                                   trans_info[Y0],
248
 
                                   trans_info[X1] - trans_info[X0],
249
 
                                   trans_info[Y1] - trans_info[Y0],
250
 
                                   &matrix);
 
251
      gimp_matrix3_identity (&matrix);
 
252
      gimp_transform_matrix_scale (&matrix,
 
253
                                   x, y, width, height,
 
254
                                   x0, y0, x1 - x0, y1 - y0);
251
255
 
252
256
      if (interpolation)
253
257
        interpolation_type = gimp->config->interpolation_type;
254
258
 
255
259
      if (progress)
256
 
        gimp_progress_start (progress, _("Scaling..."), FALSE);
 
260
        gimp_progress_start (progress, _("Scaling"), FALSE);
257
261
 
258
262
      /* Scale the selection */
259
263
      success = gimp_drawable_transform_affine (drawable, context,
271
275
}
272
276
 
273
277
sub shear {
274
 
    &std_pdb_deprecated ('gimp_drawable_transform_shear_default');
 
278
    &std_pdb_deprecated ('gimp-drawable-transform-shear-default');
275
279
 
276
280
    @inargs = (
277
 
        &drawable_arg,
 
281
        { name => 'drawable', type => 'drawable',
 
282
          desc => 'The affected drawable' },
278
283
        { name => 'interpolation', type => 'boolean',
279
284
          desc => 'Whether to use interpolation' },
280
 
        { name => 'shear_type', type => &std_orientation_enum,
281
 
          desc => 'Type of shear: %%desc%%' },
 
285
        { name => 'shear_type',
 
286
          type => 'enum GimpOrientationType (no GIMP_ORIENTATION_UNKNOWN)',
 
287
          desc => 'Type of shear' },
282
288
        { name => 'magnitude', type => 'float',
283
289
          desc => 'The magnitude of the shear' }
284
290
    );
285
291
 
286
 
    @outargs = ( &drawable_out_arg('sheared') );
 
292
    @outargs = (
 
293
        { name => 'drawable', type => 'drawable', no_declare => 1,
 
294
          desc => 'The sheared drawable' }
 
295
    );
287
296
 
288
297
    %invoke = (
289
298
        code => <<'CODE'
305
314
      y += off_y;
306
315
 
307
316
      /* Assemble the transformation matrix */
308
 
      gimp_transform_matrix_shear (x, y, width, height,
309
 
                                   shear_type, magnitude,
310
 
                                   &matrix);
 
317
      gimp_matrix3_identity (&matrix);
 
318
      gimp_transform_matrix_shear (&matrix,
 
319
                                   x, y, width, height,
 
320
                                   shear_type, magnitude);
311
321
 
312
322
      if (interpolation)
313
323
        interpolation_type = gimp->config->interpolation_type;
314
324
 
315
325
      if (progress)
316
 
        gimp_progress_start (progress, _("Shearing..."), FALSE);
 
326
        gimp_progress_start (progress, _("Shearing"), FALSE);
317
327
 
318
328
      /* Shear the selection */
319
329
      success = gimp_drawable_transform_affine (drawable, context,
331
341
}
332
342
 
333
343
sub transform_2d {
334
 
    &std_pdb_deprecated ('gimp_drawable_transform_2d_default');
 
344
    &std_pdb_deprecated ('gimp-drawable-transform-2d-default');
335
345
 
336
346
    @inargs = (
337
 
        &drawable_arg,
 
347
        { name => 'drawable', type => 'drawable',
 
348
          desc => 'The affected drawable' },
338
349
        { name => 'interpolation', type => 'boolean',
339
350
          desc => 'Whether to use interpolation' },
340
351
        { name => 'source_x', type => 'float',
353
364
          desc => 'Y coordinate of where the centre goes' }
354
365
    );
355
366
 
356
 
    @outargs = ( &drawable_out_arg('transformed') );
 
367
    @outargs = (
 
368
        { name => 'drawable', type => 'drawable', no_declare => 1,
 
369
          desc => 'The transformed drawable' }
 
370
    );
357
371
 
358
372
    %invoke = (
359
373
        code => <<'CODE'
379
393
        interpolation_type = gimp->config->interpolation_type;
380
394
 
381
395
      if (progress)
382
 
        gimp_progress_start (progress, _("2D Transform..."), FALSE);
 
396
        gimp_progress_start (progress, _("2D Transform"), FALSE);
383
397
 
384
398
      /* Transform the selection */
385
399
      success = gimp_drawable_transform_affine (drawable, context,
395
409
    );
396
410
}
397
411
 
 
412
 
398
413
@headers = qw("libgimpmath/gimpmath.h" "config/gimpcoreconfig.h"
399
414
              "core/gimp.h" "core/gimp-transform-utils.h" "core/gimpimage.h"
400
415
              "core/gimpdrawable.h" "core/gimpdrawable-transform.h"