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>"
122
static GimpParamDef args[] =
123
static const GimpParamDef args[] =
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 }" }
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)
154
/* Get the runmode from the in-parameters */
155
GimpRunMode run_mode = param[0].data.d_int32;
157
/* status variable, use it to check for errors in invocation usualy only
158
during non-interactive calling */
159
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
161
/*always return at least the status to the caller. */
162
static GimpParam values[1];
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];
167
159
*nreturn_vals = 1;
168
*return_vals = values;
160
*return_vals = values;
162
values[0].type = GIMP_PDB_STATUS;
163
values[0].data.d_status = status;
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);
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)
180
172
switch (run_mode)
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));
194
186
status = GIMP_PDB_CALLING_ERROR;
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;
284
276
height = drawable->height;
285
277
bytes = drawable->bpp;
287
if (gimp_layer_get_preserve_trans (drawable->drawable_id))
279
if (gimp_layer_get_lock_alpha (drawable->drawable_id))
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);
293
285
if (rotvals.angle == 2) /* we're rotating by 180� */
391
383
gimp_layer_set_offsets (drawable->drawable_id, offsetx, offsety);
393
if (was_preserve_transparency)
394
gimp_layer_set_preserve_trans (drawable->drawable_id, TRUE);
386
gimp_layer_set_lock_alpha (drawable->drawable_id, TRUE);