91
91
GimpParamDef args[] =
93
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
94
{ GIMP_PDB_IMAGE, "image", "Input image (used for indexed images)" },
95
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
93
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
94
{ GIMP_PDB_IMAGE, "image", "Input image (used for indexed images)" },
95
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
98
gimp_install_procedure ("plug_in_rotate_colormap",
99
"Colormap rotation as in xv",
98
gimp_install_procedure (PLUG_IN_PROC,
99
N_("Replace a range of colors with another"),
100
100
"Exchanges two color ranges. "
101
101
"Based on code from Pavel Grinfeld (pavel@ml.com). "
102
102
"This version written by Sven Anders (anderss@fmi.uni-passau.de).",
103
103
"Sven Anders (anderss@fmi.uni-passau.de) and Pavel Grinfeld (pavel@ml.com)",
104
104
"Sven Anders (anderss@fmi.uni-passau.de)",
105
105
"04th April 1999",
106
N_("Colormap _Rotation..."),
106
N_("_Rotate Colors..."),
109
109
G_N_ELEMENTS (args), 0,
112
gimp_plugin_menu_register ("plug_in_rotate_colormap",
113
"<Image>/Filters/Colors/Map");
117
/* Rotate colormap of a single row */
112
gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Colors/Map");
116
run (const gchar *name,
118
const GimpParam *param,
120
GimpParam **return_vals)
123
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
126
*return_vals = values;
130
values[0].type = GIMP_PDB_STATUS;
131
values[0].data.d_status = status;
133
Current.drawable = gimp_drawable_get (param[2].data.d_drawable);
134
Current.mask = gimp_drawable_get (gimp_image_get_selection (param[1].data.d_image));
136
if (gimp_drawable_is_rgb (Current.drawable->drawable_id))
140
gimp_progress_init (_("Rotating the colors"));
142
gimp_tile_cache_ntiles (2 * (Current.drawable->width /
143
gimp_tile_width () + 1));
144
rcm (Current.drawable);
145
gimp_displays_flush ();
149
status = GIMP_PDB_CANCEL;
154
status = GIMP_PDB_EXECUTION_ERROR;
157
values[0].data.d_status = status;
159
if (status == GIMP_PDB_SUCCESS)
160
gimp_drawable_detach (Current.drawable);
164
/* Rotate colors of a single row */
120
167
rcm_row (const guchar *src_row,
121
168
guchar *dest_row,
126
gint col, bytenum, skip;
130
177
for (col = 0; col < row_width; col++)
179
gboolean skip = FALSE;
134
181
rgb[0] = src_row[col * bytes + 0];
135
182
rgb[1] = src_row[col * bytes + 1];
230
277
g_free (src_row);
231
278
g_free (dest_row);
238
run (const gchar *name,
240
const GimpParam *param,
242
GimpParam **return_vals)
245
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
248
*return_vals = values;
252
values[0].type = GIMP_PDB_STATUS;
253
values[0].data.d_status = status;
255
Current.drawable = gimp_drawable_get (param[2].data.d_drawable);
256
Current.mask = gimp_drawable_get (gimp_image_get_selection (param[1].data.d_image));
258
/* works not on INDEXED images */
260
if (gimp_drawable_is_indexed (Current.drawable->drawable_id) ||
261
gimp_drawable_is_gray (Current.drawable->drawable_id) )
263
status = GIMP_PDB_EXECUTION_ERROR;
267
/* call dialog and rotate the colormap */
268
if (gimp_drawable_is_rgb (Current.drawable->drawable_id) && rcm_dialog ())
270
gimp_progress_init (_("Rotating the colormap..."));
272
gimp_tile_cache_ntiles (2 * (Current.drawable->width /
273
gimp_tile_width () + 1));
274
rcm (Current.drawable);
275
gimp_displays_flush ();
278
status = GIMP_PDB_EXECUTION_ERROR;
281
values[0].data.d_status = status;
283
if (status == GIMP_PDB_SUCCESS)
284
gimp_drawable_detach (Current.drawable);