Fixes for non-interactive operation of plugins including

holes, exchange, grid, deinterlace

-adrian
This commit is contained in:
Adrian Likins
1998-01-30 00:31:16 +00:00
parent 7e4a76203a
commit 7a31553002
8 changed files with 664 additions and 567 deletions

View File

@ -1,3 +1,10 @@
Thu Jan 29 19:25:52 EST 1998 Adrian Likins <adrian@gimp.org>
* fixed the non-iteractive modes for plugins:
exchange, holes, grid, deinterlace
(mainly expecting wrong number of arguments or just ingome
non-interactive mood entirely)
Thu Jan 29 01:05:10 PST 1998 Manish Singh <yosh@gimp.org>
* updated refract and warp plugins

View File

@ -108,10 +108,11 @@ run (char *name,
break;
case RUN_NONINTERACTIVE:
if (nparams != 1)
if (nparams != 4)
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS)
DeinterlaceValue = param[3].data.d_int32;
break;
case RUN_WITH_LAST_VALS:

View File

@ -150,8 +150,20 @@ void run(char *name, int nparams, GParam *param, int *nreturn_vals, GParam **ret
gimp_palette_get_foreground(&xargs.fromred, &xargs.fromgreen, &xargs.fromblue);
break;
case RUN_NONINTERACTIVE:
if(nparams != 10)
status = STATUS_EXECUTION_ERROR;
return;
if (status == STATUS_SUCCESS)
{
xargs.fromred = param[3].data.d_int8;
xargs.fromgreen = param[4].data.d_int8;
xargs.fromblue = param[5].data.d_int8;
xargs.tored = param[6].data.d_int8;
xargs.togreen = param[7].data.d_int8;
xargs.toblue = param[8].data.d_int8;
xargs.threshold = param[9].data.d_int32;
}
break;
default:
break;
}

View File

@ -39,10 +39,12 @@ gint bytes;
gint sx1, sy1, sx2, sy2;
int run_flag = 0;
typedef struct {
typedef struct
{
gint width, height;
gint x_offset, y_offset;
} config;
}
config;
config my_config =
{
@ -76,13 +78,14 @@ static void query()
"Tim Newsome",
"1997",
"<Image>/Filters/Render/Grid",
"RGB, GRAY",
"RGB*, GRAY*",
PROC_PLUG_IN,
nargs, nreturn_vals,
args, return_vals);
}
static void run(char *name, int n_params, GParam * param, int *nreturn_vals,
static void
run (char *name, int n_params, GParam * param, int *nreturn_vals,
GParam ** return_vals)
{
static GParam values[1];
@ -95,40 +98,51 @@ static void run(char *name, int n_params, GParam * param, int *nreturn_vals,
run_mode = param[0].data.d_int32;
if (run_mode == RUN_NONINTERACTIVE) {
if (n_params != 7) {
if (run_mode == RUN_NONINTERACTIVE)
{
if (n_params != 7)
{
status = STATUS_CALLING_ERROR;
} else {
my_config.width = param[4].data.d_int32;
my_config.height = param[5].data.d_int32;
my_config.x_offset = param[6].data.d_int32;
my_config.y_offset = param[7].data.d_int32;
}
} else {
if( status == STATUS_SUCCESS)
{
my_config.width = param[3].data.d_int32;
my_config.height = param[4].data.d_int32;
my_config.x_offset = param[5].data.d_int32;
my_config.y_offset = param[6].data.d_int32;
}
}
else
{
/* Possibly retrieve data */
gimp_get_data ("plug_in_grid", &my_config);
if (run_mode == RUN_INTERACTIVE) {
if (run_mode == RUN_INTERACTIVE)
{
/* Oh boy. We get to do a dialog box, because we can't really expect the
* user to set us up with the right values using gdb.
*/
if (!dialog()) {
if (!dialog ())
{
/* The dialog was closed, or something similarly evil happened. */
status = STATUS_EXECUTION_ERROR;
}
}
}
if (my_config.width <= 0 || my_config.height <= 0) {
if (my_config.width <= 0 || my_config.height <= 0)
{
status = STATUS_EXECUTION_ERROR;
}
if (status == STATUS_SUCCESS) {
if (status == STATUS_SUCCESS)
{
/* Get the specified drawable */
drawable = gimp_drawable_get (param[2].data.d_drawable);
/* Make sure that the drawable is gray or RGB color */
if (gimp_drawable_color(drawable->id) || gimp_drawable_gray(drawable->id)) {
if (gimp_drawable_color (drawable->id) || gimp_drawable_gray (drawable->id))
{
gimp_progress_init ("Drawing Grid...");
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width () + 1));
@ -140,7 +154,9 @@ static void run(char *name, int n_params, GParam * param, int *nreturn_vals,
if (run_mode == RUN_INTERACTIVE)
gimp_set_data ("plug_in_grid", &my_config, sizeof (my_config));
} else {
}
else
{
status = STATUS_EXECUTION_ERROR;
}
gimp_drawable_detach (drawable);
@ -150,13 +166,15 @@ static void run(char *name, int n_params, GParam * param, int *nreturn_vals,
values[0].data.d_status = status;
}
static void doit(GDrawable * drawable)
static void
doit (GDrawable * drawable)
{
GPixelRgn srcPR, destPR;
gint width, height;
int w, h, b;
guchar *copybuf;
guchar color[4] = {0, 0, 0, 0};
guchar color[4] =
{0, 0, 0, 0};
/* Get the input area. This is the bounding box of the selection in
* the image (or the entire image if there is no selection). Only
@ -173,7 +191,8 @@ static void doit(GDrawable * drawable)
height = drawable->height;
bytes = drawable->bpp;
if (gimp_drawable_has_alpha(drawable->id)) {
if (gimp_drawable_has_alpha (drawable->id))
{
color[bytes - 1] = 0xff;
}
@ -183,18 +202,27 @@ static void doit(GDrawable * drawable)
/* First off, copy the old one to the new one. */
copybuf = malloc (width * bytes);
for (h = sy1; h < sy2; h++) {
for (h = sy1; h < sy2; h++)
{
gimp_pixel_rgn_get_row (&srcPR, copybuf, sx1, h, width);
if ((h - my_config.y_offset) % my_config.height == 0) {
for (w = sx1; w < sx2; w++) {
for (b = 0; b < bytes; b++) {
if ((h - my_config.y_offset) % my_config.height == 0)
{
for (w = sx1; w < sx2; w++)
{
for (b = 0; b < bytes; b++)
{
copybuf[w * bytes + b] = color[b];
}
}
} else {
for (w = sx1; w < sx2; w++) {
if ((w - my_config.x_offset) % my_config.width == 0) {
for (b = 0; b < bytes; b++) {
}
else
{
for (w = sx1; w < sx2; w++)
{
if ((w - my_config.x_offset) % my_config.width == 0)
{
for (b = 0; b < bytes; b++)
{
copybuf[w * bytes + b] = color[b];
}
}
@ -215,18 +243,21 @@ static void doit(GDrawable * drawable)
* GUI stuff
*/
static void close_callback(GtkWidget * widget, gpointer data)
static void
close_callback (GtkWidget * widget, gpointer data)
{
gtk_main_quit ();
}
static void ok_callback(GtkWidget * widget, gpointer data)
static void
ok_callback (GtkWidget * widget, gpointer data)
{
run_flag = 1;
gtk_widget_destroy (GTK_WIDGET (data));
}
static void entry_callback(GtkWidget * widget, gpointer data)
static void
entry_callback (GtkWidget * widget, gpointer data)
{
if (data == &my_config.width)
my_config.width = atof (gtk_entry_get_text (GTK_ENTRY (widget)));
@ -238,7 +269,8 @@ static void entry_callback(GtkWidget * widget, gpointer data)
my_config.y_offset = atoi (gtk_entry_get_text (GTK_ENTRY (widget)));
}
static gint dialog()
static gint
dialog ()
{
GtkWidget *dlg;
GtkWidget *button;

View File

@ -108,10 +108,11 @@ run (char *name,
break;
case RUN_NONINTERACTIVE:
if (nparams != 1)
if (nparams != 4)
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS)
DeinterlaceValue = param[3].data.d_int32;
break;
case RUN_WITH_LAST_VALS:

View File

@ -150,8 +150,20 @@ void run(char *name, int nparams, GParam *param, int *nreturn_vals, GParam **ret
gimp_palette_get_foreground(&xargs.fromred, &xargs.fromgreen, &xargs.fromblue);
break;
case RUN_NONINTERACTIVE:
if(nparams != 10)
status = STATUS_EXECUTION_ERROR;
return;
if (status == STATUS_SUCCESS)
{
xargs.fromred = param[3].data.d_int8;
xargs.fromgreen = param[4].data.d_int8;
xargs.fromblue = param[5].data.d_int8;
xargs.tored = param[6].data.d_int8;
xargs.togreen = param[7].data.d_int8;
xargs.toblue = param[8].data.d_int8;
xargs.threshold = param[9].data.d_int32;
}
break;
default:
break;
}

View File

@ -39,10 +39,12 @@ gint bytes;
gint sx1, sy1, sx2, sy2;
int run_flag = 0;
typedef struct {
typedef struct
{
gint width, height;
gint x_offset, y_offset;
} config;
}
config;
config my_config =
{
@ -76,13 +78,14 @@ static void query()
"Tim Newsome",
"1997",
"<Image>/Filters/Render/Grid",
"RGB, GRAY",
"RGB*, GRAY*",
PROC_PLUG_IN,
nargs, nreturn_vals,
args, return_vals);
}
static void run(char *name, int n_params, GParam * param, int *nreturn_vals,
static void
run (char *name, int n_params, GParam * param, int *nreturn_vals,
GParam ** return_vals)
{
static GParam values[1];
@ -95,40 +98,51 @@ static void run(char *name, int n_params, GParam * param, int *nreturn_vals,
run_mode = param[0].data.d_int32;
if (run_mode == RUN_NONINTERACTIVE) {
if (n_params != 7) {
if (run_mode == RUN_NONINTERACTIVE)
{
if (n_params != 7)
{
status = STATUS_CALLING_ERROR;
} else {
my_config.width = param[4].data.d_int32;
my_config.height = param[5].data.d_int32;
my_config.x_offset = param[6].data.d_int32;
my_config.y_offset = param[7].data.d_int32;
}
} else {
if( status == STATUS_SUCCESS)
{
my_config.width = param[3].data.d_int32;
my_config.height = param[4].data.d_int32;
my_config.x_offset = param[5].data.d_int32;
my_config.y_offset = param[6].data.d_int32;
}
}
else
{
/* Possibly retrieve data */
gimp_get_data ("plug_in_grid", &my_config);
if (run_mode == RUN_INTERACTIVE) {
if (run_mode == RUN_INTERACTIVE)
{
/* Oh boy. We get to do a dialog box, because we can't really expect the
* user to set us up with the right values using gdb.
*/
if (!dialog()) {
if (!dialog ())
{
/* The dialog was closed, or something similarly evil happened. */
status = STATUS_EXECUTION_ERROR;
}
}
}
if (my_config.width <= 0 || my_config.height <= 0) {
if (my_config.width <= 0 || my_config.height <= 0)
{
status = STATUS_EXECUTION_ERROR;
}
if (status == STATUS_SUCCESS) {
if (status == STATUS_SUCCESS)
{
/* Get the specified drawable */
drawable = gimp_drawable_get (param[2].data.d_drawable);
/* Make sure that the drawable is gray or RGB color */
if (gimp_drawable_color(drawable->id) || gimp_drawable_gray(drawable->id)) {
if (gimp_drawable_color (drawable->id) || gimp_drawable_gray (drawable->id))
{
gimp_progress_init ("Drawing Grid...");
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width () + 1));
@ -140,7 +154,9 @@ static void run(char *name, int n_params, GParam * param, int *nreturn_vals,
if (run_mode == RUN_INTERACTIVE)
gimp_set_data ("plug_in_grid", &my_config, sizeof (my_config));
} else {
}
else
{
status = STATUS_EXECUTION_ERROR;
}
gimp_drawable_detach (drawable);
@ -150,13 +166,15 @@ static void run(char *name, int n_params, GParam * param, int *nreturn_vals,
values[0].data.d_status = status;
}
static void doit(GDrawable * drawable)
static void
doit (GDrawable * drawable)
{
GPixelRgn srcPR, destPR;
gint width, height;
int w, h, b;
guchar *copybuf;
guchar color[4] = {0, 0, 0, 0};
guchar color[4] =
{0, 0, 0, 0};
/* Get the input area. This is the bounding box of the selection in
* the image (or the entire image if there is no selection). Only
@ -173,7 +191,8 @@ static void doit(GDrawable * drawable)
height = drawable->height;
bytes = drawable->bpp;
if (gimp_drawable_has_alpha(drawable->id)) {
if (gimp_drawable_has_alpha (drawable->id))
{
color[bytes - 1] = 0xff;
}
@ -183,18 +202,27 @@ static void doit(GDrawable * drawable)
/* First off, copy the old one to the new one. */
copybuf = malloc (width * bytes);
for (h = sy1; h < sy2; h++) {
for (h = sy1; h < sy2; h++)
{
gimp_pixel_rgn_get_row (&srcPR, copybuf, sx1, h, width);
if ((h - my_config.y_offset) % my_config.height == 0) {
for (w = sx1; w < sx2; w++) {
for (b = 0; b < bytes; b++) {
if ((h - my_config.y_offset) % my_config.height == 0)
{
for (w = sx1; w < sx2; w++)
{
for (b = 0; b < bytes; b++)
{
copybuf[w * bytes + b] = color[b];
}
}
} else {
for (w = sx1; w < sx2; w++) {
if ((w - my_config.x_offset) % my_config.width == 0) {
for (b = 0; b < bytes; b++) {
}
else
{
for (w = sx1; w < sx2; w++)
{
if ((w - my_config.x_offset) % my_config.width == 0)
{
for (b = 0; b < bytes; b++)
{
copybuf[w * bytes + b] = color[b];
}
}
@ -215,18 +243,21 @@ static void doit(GDrawable * drawable)
* GUI stuff
*/
static void close_callback(GtkWidget * widget, gpointer data)
static void
close_callback (GtkWidget * widget, gpointer data)
{
gtk_main_quit ();
}
static void ok_callback(GtkWidget * widget, gpointer data)
static void
ok_callback (GtkWidget * widget, gpointer data)
{
run_flag = 1;
gtk_widget_destroy (GTK_WIDGET (data));
}
static void entry_callback(GtkWidget * widget, gpointer data)
static void
entry_callback (GtkWidget * widget, gpointer data)
{
if (data == &my_config.width)
my_config.width = atof (gtk_entry_get_text (GTK_ENTRY (widget)));
@ -238,7 +269,8 @@ static void entry_callback(GtkWidget * widget, gpointer data)
my_config.y_offset = atoi (gtk_entry_get_text (GTK_ENTRY (widget)));
}
static gint dialog()
static gint
dialog ()
{
GtkWidget *dlg;
GtkWidget *button;

View File

@ -148,7 +148,7 @@ static void run(char *name, int n_params, GParam * param, int *nreturn_vals,
run_mode = param[0].data.d_int32;
if (run_mode == RUN_NONINTERACTIVE) {
if (n_params != 8) {
if (n_params != 7) {
status = STATUS_CALLING_ERROR;
} else {
params.density = param[3].data.d_float;