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

« back to all changes in this revision

Viewing changes to plug-ins/common/rotate.c

  • 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
 *  Rotate plug-in v1.0
57
57
 
58
58
 
59
59
/* Defines */
 
60
#define PLUG_IN_PROC        "plug-in-rotate"
60
61
#define PLUG_IN_VERSION     "v1.0 (2000/06/18)"
61
62
#define PLUG_IN_IMAGE_TYPES "RGB*, INDEXED*, GRAY*"
62
63
#define PLUG_IN_AUTHOR      "Sven Neumann <sven@gimp.org>, Adam D. Moss <adam@gimp.org>"
100
101
                                     gint          height);
101
102
 
102
103
/* Global Variables */
103
 
GimpPlugInInfo PLUG_IN_INFO =
 
104
const GimpPlugInInfo PLUG_IN_INFO =
104
105
{
105
106
  NULL,  /* init_proc  */
106
107
  NULL,  /* quit_proc  */
119
120
static void
120
121
query (void)
121
122
{
122
 
  static GimpParamDef args[] =
 
123
  static const GimpParamDef args[] =
123
124
  {
124
 
    { GIMP_PDB_INT32,    "run_mode",   "Interactive, non-interactive"},
125
 
    { GIMP_PDB_IMAGE,    "image",      "Input image" },
126
 
    { GIMP_PDB_DRAWABLE, "drawable",   "Input drawable" },
 
125
    { GIMP_PDB_INT32,    "run-mode",   "Interactive, non-interactive" },
 
126
    { GIMP_PDB_IMAGE,    "image",      "Input image"                  },
 
127
    { GIMP_PDB_DRAWABLE, "drawable",   "Input drawable"               },
127
128
    { GIMP_PDB_INT32,    "angle",      "Angle { 90 (1), 180 (2), 270 (3) } degrees" },
128
129
    { GIMP_PDB_INT32,    "everything", "Rotate the whole image? { TRUE, FALSE }" }
129
130
  };
130
131
 
131
 
  gimp_install_procedure ("plug_in_rotate",
 
132
  gimp_install_procedure (PLUG_IN_PROC,
132
133
                          "Rotates a layer or the whole image by 90, 180 or 270 degrees",
133
134
                          "This plug-in does rotate the active layer or the "
134
135
                          "whole image clockwise by multiples of 90 degrees. "
151
152
     gint             *nreturn_vals,
152
153
     GimpParam       **return_vals)
153
154
{
154
 
  /* Get the runmode from the in-parameters */
155
 
  GimpRunMode run_mode = param[0].data.d_int32;
156
 
 
157
 
  /* status variable, use it to check for errors in invocation usualy only
158
 
     during non-interactive calling */
159
 
  GimpPDBStatusType status = GIMP_PDB_SUCCESS;
160
 
 
161
 
  /*always return at least the status to the caller. */
162
 
  static GimpParam values[1];
163
 
 
164
 
  /* initialize the return of the status */
165
 
  values[0].type = GIMP_PDB_STATUS;
166
 
  values[0].data.d_status = status;
 
155
  GimpRunMode       run_mode = param[0].data.d_int32;
 
156
  GimpPDBStatusType status   = GIMP_PDB_SUCCESS;
 
157
  static GimpParam  values[1];
 
158
 
167
159
  *nreturn_vals = 1;
168
 
  *return_vals = values;
 
160
  *return_vals  = values;
 
161
 
 
162
  values[0].type          = GIMP_PDB_STATUS;
 
163
  values[0].data.d_status = status;
169
164
 
170
165
  INIT_I18N ();
171
166
 
172
 
  /* get image and drawable */
173
 
  image_ID = param[1].data.d_int32;
 
167
  image_ID        = param[1].data.d_int32;
174
168
  active_drawable = gimp_drawable_get (param[2].data.d_drawable);
175
169
 
176
 
  /* Check the procedure name we were called with, to decide
177
 
     what needs to be done. */
178
 
  if (strcmp (name, "plug_in_rotate") == 0)
 
170
  if (strcmp (name, PLUG_IN_PROC) == 0)
179
171
    {
180
172
      switch (run_mode)
181
173
        {
188
180
              rotvals.angle = rotvals.angle % 4;
189
181
              rotvals.everything = (gint) param[4].data.d_int32;
190
182
              /* Store variable states for next run */
191
 
              gimp_set_data ("plug_in_rotate", &rotvals, sizeof (RotateValues));
 
183
              gimp_set_data (PLUG_IN_PROC, &rotvals, sizeof (RotateValues));
192
184
            }
193
185
          else
194
186
            status = GIMP_PDB_CALLING_ERROR;
195
187
          break;
196
188
        case GIMP_RUN_WITH_LAST_VALS:
197
189
          /* Possibly retrieve data from a previous run */
198
 
          gimp_get_data ("plug_in_rotate", &rotvals);
 
190
          gimp_get_data (PLUG_IN_PROC, &rotvals);
199
191
          rotvals.angle = rotvals.angle % 4;
200
192
          break;
201
193
        default:
271
263
  gint          bytes;
272
264
  gint          row, col;
273
265
  gint          offsetx, offsety;
274
 
  gboolean      was_preserve_transparency = FALSE;
 
266
  gboolean      was_lock_alpha = FALSE;
275
267
  guchar       *buffer;
276
268
  guchar       *src_row, *dest_row;
277
269
 
284
276
  height = drawable->height;
285
277
  bytes = drawable->bpp;
286
278
 
287
 
  if (gimp_layer_get_preserve_trans (drawable->drawable_id))
 
279
  if (gimp_layer_get_lock_alpha (drawable->drawable_id))
288
280
    {
289
 
      was_preserve_transparency = TRUE;
290
 
      gimp_layer_set_preserve_trans (drawable->drawable_id, FALSE);
 
281
      was_lock_alpha = TRUE;
 
282
      gimp_layer_set_lock_alpha (drawable->drawable_id, FALSE);
291
283
    }
292
284
 
293
285
  if (rotvals.angle == 2)  /* we're rotating by 180� */
390
382
                          width, height);
391
383
  gimp_layer_set_offsets (drawable->drawable_id, offsetx, offsety);
392
384
 
393
 
  if (was_preserve_transparency)
394
 
    gimp_layer_set_preserve_trans (drawable->drawable_id, TRUE);
 
385
  if (was_lock_alpha)
 
386
    gimp_layer_set_lock_alpha (drawable->drawable_id, TRUE);
395
387
 
396
388
  return;
397
389
}
442
434
        }
443
435
    }
444
436
 
445
 
  gimp_progress_init (_("Rotating..."));
 
437
  gimp_progress_init (_("Rotating"));
446
438
 
447
439
  gimp_image_undo_group_start (image_ID);
448
440