Commit ddc557c2 authored by Manish Singh's avatar Manish Singh
Browse files

Updated blur, randomize, and exchange plugins (not sure if they should go

into stable, they break PDB interfaces)

-Yosh
parent 5a6bc8de
Thu Jul 2 11:03:12 PDT 1998 Manish Singh <yosh@gimp.org>
* updated blur, randomize, and exchange plugins (not sure if
they should go into stable, they break PDB interfaces)
Thu Jul 2 01:45:24 EEST 1998 Lauri Alanko <nether@gimp.org>
* app/Makefile.am:
......
......@@ -2,7 +2,7 @@
* This is a plugin for the GIMP v 0.99.8 or later. Documentation is
* available at http://www.rru.com/~meo/gimp/ .
*
* Copyright (C) 1997 Miles O'Neal <meo@rru.com> http://www.rru.com/~meo/
* Copyright (C) 1997-98 Miles O'Neal <meo@rru.com> http://www.rru.com/~meo/
* Blur code Copyright (C) 1995 Spencer Kimball and Peter Mattis
* GUI based on GTK code from:
* alienmap (Copyright (C) 1996, 1997 Daniel Cotting)
......@@ -30,10 +30,10 @@
/****************************************************************************
* Blur:
*
* blur version 2.0 (6 Feb 1998, MEO)
* blur version 2.0 (1 May 1998, MEO)
* history
* 2.0 - 6 Feb 1998 MEO
* based on randomize 1.5
* 2.0 - 1 May 1998 MEO
* based on randomize 1.7
*
* Please send any patches or suggestions to the author: meo@rru.com .
*
......@@ -87,16 +87,16 @@
typedef struct {
gdouble blur_pct; /* likelihood of randomization (as %age) */
gdouble blur_rcount; /* repeat count */
gint seed_type; /* seed init. type - current time or user value */
gint blur_seed; /* seed value for rand() function */
gdouble blur_rcount; /* repeat count */
} BlurVals;
static BlurVals pivals = {
50.0,
1.0,
SEED_TIME,
0,
1.0,
};
typedef struct {
......@@ -176,6 +176,8 @@ query()
{ PARAM_DRAWABLE, "drawable", "Input drawable" },
{ PARAM_FLOAT, "blur_pct", "Randomization percentage (1 - 100)" },
{ PARAM_FLOAT, "blur_rcount", "Repeat count(1 - 100)" },
{ PARAM_INT32, "seed_type", "Seed type (10 = current time, 11 = seed value)" },
{ PARAM_INT32, "blur_seed", "Seed value (used only if seed type is 11)" },
};
static int nargs = sizeof(args) / sizeof (args[0]);
......@@ -183,7 +185,7 @@ query()
static int nreturn_vals = 0;
const char *blurb = "Apply a 3x3 blurring convolution kernel to the specified drawable.";
const char *help = "This function randomly blurs the specified drawable, using a 3x3 blur. The type and percentage are user selectable. Blurring is not supported for indexed images.";
const char *help = "This plug-in randomly blurs the specified drawable, using a 3x3 blur. You control the percentage of the pixels that are blurred and the number of times blurring is applied. Indexed images are not supported.";
const char *author = "Miles O'Neal <meo@rru.com> http://www.rru.com/~meo/";
const char *copyrights = "Miles O'Neal, Spencer Kimball, Peter Mattis, Torsten Martinsen, Brian Degenhardt, Federico Mena Quintero, Stephen Norris, Daniel Cotting";
const char *copyright_date = "1995-1998";
......@@ -266,18 +268,24 @@ run(char *name, int nparams, GParam *param, int *nreturn_vals,
*/
case RUN_NONINTERACTIVE:
if ((strcmp(name, "plug_in_blur_randomize") == 0) &&
(nparams == 5)) {
(nparams == 7)) {
pivals.blur_pct = (gdouble)param[3].data.d_float;
pivals.blur_pct = (gdouble)MIN(100.0, pivals.blur_pct);
pivals.blur_pct = (gdouble)MAX(1.0, pivals.blur_pct);
pivals.blur_rcount = (gdouble)param[4].data.d_float;
pivals.blur_rcount = (gdouble)MIN(100.0,pivals.blur_rcount);
pivals.blur_rcount = (gdouble)MAX(1.0, pivals.blur_rcount);
pivals.seed_type = (gint) param[5].data.d_int32;
pivals.seed_type = (gint) MIN(SEED_USER, param[5].data.d_int32);
pivals.seed_type = (gint) MAX(SEED_TIME, param[5].data.d_int32);
pivals.blur_seed = (gint) param[6].data.d_int32;
status = STATUS_SUCCESS;
} else if ((strcmp(name, PLUG_IN_NAME) == 0) &&
(nparams == 3)) {
pivals.blur_pct = (gdouble) 100.0;
pivals.blur_rcount = (gdouble) 1.0;
pivals.seed_type = SEED_TIME;
pivals.blur_seed = 0;
status = STATUS_SUCCESS;
} else {
status = STATUS_CALLING_ERROR;
......@@ -570,7 +578,6 @@ blur_dialog()
gtk_init(&argc, &argv);
gtk_rc_parse(gimp_gtkrc());
/*
* Open a new dialog, label it and set up its
* destroy callback.
......
......@@ -2,7 +2,7 @@
* This is a plugin for the GIMP v 0.99.8 or later. Documentation is
* available at http://www.rru.com/~meo/gimp/ .
*
* Copyright (C) 1997 Miles O'Neal <meo@rru.com> http://www.rru.com/~meo/
* Copyright (C) 1997-98 Miles O'Neal <meo@rru.com> http://www.rru.com/~meo/
* Blur code Copyright (C) 1995 Spencer Kimball and Peter Mattis
* GUI based on GTK code from:
* alienmap (Copyright (C) 1996, 1997 Daniel Cotting)
......@@ -30,10 +30,10 @@
/****************************************************************************
* Blur:
*
* blur version 2.0 (6 Feb 1998, MEO)
* blur version 2.0 (1 May 1998, MEO)
* history
* 2.0 - 6 Feb 1998 MEO
* based on randomize 1.5
* 2.0 - 1 May 1998 MEO
* based on randomize 1.7
*
* Please send any patches or suggestions to the author: meo@rru.com .
*
......@@ -87,16 +87,16 @@
typedef struct {
gdouble blur_pct; /* likelihood of randomization (as %age) */
gdouble blur_rcount; /* repeat count */
gint seed_type; /* seed init. type - current time or user value */
gint blur_seed; /* seed value for rand() function */
gdouble blur_rcount; /* repeat count */
} BlurVals;
static BlurVals pivals = {
50.0,
1.0,
SEED_TIME,
0,
1.0,
};
typedef struct {
......@@ -176,6 +176,8 @@ query()
{ PARAM_DRAWABLE, "drawable", "Input drawable" },
{ PARAM_FLOAT, "blur_pct", "Randomization percentage (1 - 100)" },
{ PARAM_FLOAT, "blur_rcount", "Repeat count(1 - 100)" },
{ PARAM_INT32, "seed_type", "Seed type (10 = current time, 11 = seed value)" },
{ PARAM_INT32, "blur_seed", "Seed value (used only if seed type is 11)" },
};
static int nargs = sizeof(args) / sizeof (args[0]);
......@@ -183,7 +185,7 @@ query()
static int nreturn_vals = 0;
const char *blurb = "Apply a 3x3 blurring convolution kernel to the specified drawable.";
const char *help = "This function randomly blurs the specified drawable, using a 3x3 blur. The type and percentage are user selectable. Blurring is not supported for indexed images.";
const char *help = "This plug-in randomly blurs the specified drawable, using a 3x3 blur. You control the percentage of the pixels that are blurred and the number of times blurring is applied. Indexed images are not supported.";
const char *author = "Miles O'Neal <meo@rru.com> http://www.rru.com/~meo/";
const char *copyrights = "Miles O'Neal, Spencer Kimball, Peter Mattis, Torsten Martinsen, Brian Degenhardt, Federico Mena Quintero, Stephen Norris, Daniel Cotting";
const char *copyright_date = "1995-1998";
......@@ -266,18 +268,24 @@ run(char *name, int nparams, GParam *param, int *nreturn_vals,
*/
case RUN_NONINTERACTIVE:
if ((strcmp(name, "plug_in_blur_randomize") == 0) &&
(nparams == 5)) {
(nparams == 7)) {
pivals.blur_pct = (gdouble)param[3].data.d_float;
pivals.blur_pct = (gdouble)MIN(100.0, pivals.blur_pct);
pivals.blur_pct = (gdouble)MAX(1.0, pivals.blur_pct);
pivals.blur_rcount = (gdouble)param[4].data.d_float;
pivals.blur_rcount = (gdouble)MIN(100.0,pivals.blur_rcount);
pivals.blur_rcount = (gdouble)MAX(1.0, pivals.blur_rcount);
pivals.seed_type = (gint) param[5].data.d_int32;
pivals.seed_type = (gint) MIN(SEED_USER, param[5].data.d_int32);
pivals.seed_type = (gint) MAX(SEED_TIME, param[5].data.d_int32);
pivals.blur_seed = (gint) param[6].data.d_int32;
status = STATUS_SUCCESS;
} else if ((strcmp(name, PLUG_IN_NAME) == 0) &&
(nparams == 3)) {
pivals.blur_pct = (gdouble) 100.0;
pivals.blur_rcount = (gdouble) 1.0;
pivals.seed_type = SEED_TIME;
pivals.blur_seed = 0;
status = STATUS_SUCCESS;
} else {
status = STATUS_CALLING_ERROR;
......@@ -570,7 +578,6 @@ blur_dialog()
gtk_init(&argc, &argv);
gtk_rc_parse(gimp_gtkrc());
/*
* Open a new dialog, label it and set up its
* destroy callback.
......
......@@ -26,10 +26,7 @@
* Author: robert@experimental.net
*
* TODO:
* - preview (working on it already :)
* - threshold for each channel (not hard to implement, but really
* needs a preview window)
*
* - locken van scales met elkaar
*/
#include <stdio.h>
......@@ -40,11 +37,14 @@
/* big scales */
#define SCALE_WIDTH 225
/* preview width/height */
#define PREVIEW_SIZE 128
/* datastructure to store parameters in */
typedef struct
{
guchar fromred, fromgreen, fromblue, tored, togreen, toblue;
guchar threshold;
guchar red_threshold, green_threshold, blue_threshold;
gint32 image;
gint32 drawable;
} myParams;
......@@ -53,15 +53,24 @@ typedef struct
static void query();
static void run(char *, int, GParam *, int *, GParam **);
static int doDialog();
static void exchange(GDrawable *);
static void exchange();
static void real_exchange(gint, gint, gint, gint, int);
static void doLabelAndScale(char *, GtkWidget *, guchar *);
static void update_preview();
static void ok_callback(GtkWidget *, gpointer);
static void lock_callback(GtkWidget *, gpointer);
static void scale_callback(GtkAdjustment *, gpointer);
/* some global variables */
GDrawable *drw;
myParams xargs = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int running = 0;
GPixelRgn origregion;
GtkWidget *preview;
gint sel_x1, sel_y1, sel_x2, sel_y2;
gint prev_width, prev_height, sel_width, sel_height;
gint lock_thres = 0;
/* lets declare what we want to do */
GPlugInInfo PLUG_IN_INFO =
......@@ -90,14 +99,16 @@ void query()
{ PARAM_INT8, "tored", "Red value (to)" },
{ PARAM_INT8, "togreen", "Green value (to)" },
{ PARAM_INT8, "toblue", "Blue value (to)" },
{ PARAM_INT8, "threshold", "Threshold" },
{ PARAM_INT8, "red_threshold", "Red threshold" },
{ PARAM_INT8, "green_threshold", "Green threshold" },
{ PARAM_INT8, "blue_threshold", "Blue threshold" },
};
static GParamDef *return_vals = NULL;
static int nargs = sizeof(args) / sizeof(args[0]);
static int nreturn_vals = 0;
gimp_install_procedure("plug_in_exchange",
"Color exchange",
"Color Exchange",
"Exchange one color with another, optionally setting a threshold to convert from one shade to another",
"robert@experimental.net",
"robert@experimental.net",
......@@ -115,7 +126,6 @@ void run(char *name, int nparams, GParam *param, int *nreturn_vals, GParam **ret
{
static GParam values[1];
GRunModeType runmode;
GDrawable *drawable;
gint32 imageID;
GStatusType status = STATUS_SUCCESS;
......@@ -128,19 +138,27 @@ void run(char *name, int nparams, GParam *param, int *nreturn_vals, GParam **ret
switch (runmode = param[0].data.d_int32)
{
case RUN_INTERACTIVE:
/* retrieve stored arguments (if any) */
gimp_get_data("plug_in_exchange", &xargs);
/* initialize using foreground color */
gimp_palette_get_foreground(&xargs.fromred, &xargs.fromgreen, &xargs.fromblue);
if (!xargs.image && !xargs.drawable)
xargs.threshold = 0;
xargs.red_threshold = xargs.green_threshold = xargs.blue_threshold = 0;
/* and initialize some other things */
xargs.image = param[1].data.d_image;
xargs.drawable = param[2].data.d_drawable;
drw = gimp_drawable_get(param[2].data.d_drawable);
gimp_drawable_mask_bounds(drw->id, &sel_x1, &sel_y1, &sel_x2, &sel_y2);
sel_width = sel_x2 - sel_x1;
sel_height = sel_y2 - sel_y1;
if (sel_width > PREVIEW_SIZE)
prev_width = PREVIEW_SIZE;
else
prev_width = sel_width;
if (sel_height > PREVIEW_SIZE)
prev_height = PREVIEW_SIZE;
else
prev_height = sel_height;
if (!doDialog())
return;
break;
......@@ -153,35 +171,32 @@ 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;
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;
if (nparams != 10)
status = STATUS_EXECUTION_ERROR;
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.red_threshold = param[9].data.d_int32;
xargs.green_threshold = param[10].data.d_int32;
xargs.blue_threshold = param[11].data.d_int32;
}
break;
default:
break;
}
/* Get the specified drawable */
drawable = gimp_drawable_get(param[2].data.d_drawable);
imageID = param[1].data.d_image;
if (status == STATUS_SUCCESS)
{
if (gimp_drawable_color(drawable->id))
if (gimp_drawable_color(drw->id))
{
gimp_progress_init("Color exchange...");
gimp_tile_cache_ntiles(2 * (drawable->width / gimp_tile_width() + 1));
exchange(drawable);
gimp_progress_init("Color Exchange...");
gimp_tile_cache_ntiles(2 * (drw->width / gimp_tile_width() + 1));
exchange();
/* store our settings */
gimp_set_data("plug_in_exchange", &xargs, sizeof(myParams));
/* and flush */
......@@ -191,106 +206,15 @@ void run(char *name, int nparams, GParam *param, int *nreturn_vals, GParam **ret
status = STATUS_EXECUTION_ERROR;
}
values[0].data.d_status = status;
gimp_drawable_detach(drawable);
gimp_drawable_detach(drw);
}
/* do the exchanging */
static
void exchange(GDrawable *drawable)
void exchange()
{
GPixelRgn srcPR, destPR;
guchar *src_row;
guchar *dest_row;
gint width, height;
gint x, y, bpp;
gint x1, y1, x2, y2;
/*
* 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
* operating on the input area is simply an optimization. It doesn't
* need to be done for correct operation. (It simply makes it go
* faster, since fewer pixels need to be operated on).
*/
gimp_drawable_mask_bounds(drawable->id, &x1, &y1, &x2, &y2);
/*
* Get the size of the input image. (This will/must be the same
* as the size of the output image.
*/
width = drawable->width;
height = drawable->height;
bpp = drawable->bpp;
/* allocate row buffers */
src_row = (guchar *) malloc((x2 - x1) * bpp);
dest_row = (guchar *) malloc((x2 - x1) * bpp);
/* initialize the pixel regions */
gimp_pixel_rgn_init(&srcPR, drawable, 0, 0, width, height, FALSE, FALSE);
gimp_pixel_rgn_init(&destPR, drawable, 0, 0, width, height, TRUE, TRUE);
for (y = y1; y < y2; y++)
{
gimp_pixel_rgn_get_row(&srcPR, src_row, x1, y, (x2 - x1));
for (x = x1; x < x2; x++)
{
guchar red, green, blue,
minred, mingreen, minblue,
maxred, maxgreen, maxblue;
int rest, wanted = 0,
redx = 0, greenx = 0, bluex = 0;
/* get boundary values */
minred = MAX((int) xargs.fromred - xargs.threshold, 0);
mingreen = MAX((int) xargs.fromgreen - xargs.threshold, 0);
minblue = MAX((int) xargs.fromblue - xargs.threshold, 0);
maxred = MIN((int) xargs.fromred + xargs.threshold, 255);
maxgreen = MIN((int) xargs.fromgreen + xargs.threshold, 255);
maxblue = MIN((int) xargs.fromblue + xargs.threshold, 255);
/* get current pixel values */
red = src_row[(x-x1) * bpp];
green = src_row[(x-x1) * bpp + 1];
blue = src_row[(x-x1) * bpp + 2];
/*
* check if we want this pixel (does it fall between
* our boundary?)
*/
if (red >= minred && red <= maxred &&
green >= mingreen && green <= maxgreen &&
blue >= minblue && blue <= maxblue)
{
redx = red - xargs.fromred;
greenx = green - xargs.fromgreen;
bluex = blue - xargs.fromblue;
wanted = 1;
}
/* exchange if needed */
dest_row[(x-x1) * bpp] = wanted ? MAX(MIN(xargs.tored + redx, 255), 0) : src_row[(x-x1) * bpp];
dest_row[(x-x1) * bpp + 1] = wanted ? MAX(MIN(xargs.togreen + greenx, 255), 0) : src_row[(x-x1) * bpp + 1];
dest_row[(x-x1) * bpp + 2] = wanted ? MAX(MIN(xargs.toblue + bluex, 255), 0) : src_row[(x-x1) * bpp + 2];
/* copy rest (most likely alpha-channel) */
for (rest = 3; rest < bpp; rest++)
dest_row[(x-x1) * bpp + rest] = src_row[(x-x1) * bpp + rest];
}
/* store the dest */
gimp_pixel_rgn_set_row(&destPR, dest_row, x1, y, (x2 - x1));
/* and tell the user what we're doing */
if ((y % 10) == 0)
gimp_progress_update((double) y / (double) (y2 - y1));
}
/* update the processed region */
gimp_drawable_flush(drawable);
gimp_drawable_merge_shadow(drawable->id, TRUE);
gimp_drawable_update(drawable->id, x1, y1, (x2 - x1), (y2 - y1));
/* and clean up */
free(src_row);
free(dest_row);
/* do the real exchange */
real_exchange(-1, -1, -1, -1, 0);
}
/* show our dialog */
......@@ -304,6 +228,8 @@ int doDialog()
GtkWidget *mainbox;
GtkWidget *tobox;
GtkWidget *frombox;
GtkWidget *prevbox;
guchar *color_cube;
gchar **argv;
gint argc;
int framenumber;
......@@ -313,7 +239,18 @@ int doDialog()
argv[0] = g_strdup("exchange");
gtk_init(&argc, &argv);
gtk_rc_parse(gimp_gtkrc());
gtk_rc_parse(gimp_gtkrc());
/* stuff for preview */
gtk_preview_set_gamma(gimp_gamma());
gtk_preview_set_install_cmap(gimp_install_cmap());
color_cube = gimp_color_cube();
gtk_preview_set_color_cube(color_cube[0], color_cube[1], color_cube[2], color_cube[3]);
gtk_widget_set_default_visual(gtk_preview_get_visual());
gtk_widget_set_default_colormap(gtk_preview_get_cmap());
/* load pixelregion */
gimp_pixel_rgn_init(&origregion, drw, 0, 0, PREVIEW_SIZE, PREVIEW_SIZE, FALSE, FALSE);
/* set up the dialog */
dialog = gtk_dialog_new();
......@@ -336,9 +273,9 @@ int doDialog()
button = gtk_button_new_with_label("Cancel");
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
gtk_signal_connect_object (GTK_OBJECT(button), "clicked",
(GtkSignalFunc) gtk_widget_destroy,
GTK_OBJECT(dialog));
gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
(GtkSignalFunc) gtk_widget_destroy,
GTK_OBJECT(dialog));
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),
button, TRUE, TRUE, 0);
gtk_widget_show(button);
......@@ -347,34 +284,66 @@ int doDialog()
mainbox = gtk_vbox_new(FALSE, 5);
gtk_container_border_width(GTK_CONTAINER(mainbox), 10);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), mainbox, TRUE, TRUE, 0);
prevbox = gtk_hbox_new(FALSE, 5);
gtk_container_border_width(GTK_CONTAINER(prevbox), 0);
gtk_box_pack_start(GTK_BOX(mainbox), prevbox, TRUE, TRUE, 0);
frombox = gtk_hbox_new(FALSE, 5);
gtk_container_border_width(GTK_CONTAINER(frombox), 10);
gtk_container_border_width(GTK_CONTAINER(frombox), 0);
gtk_box_pack_start(GTK_BOX(mainbox), frombox, TRUE, TRUE, 0);
tobox = gtk_hbox_new(FALSE, 5);
gtk_container_border_width(GTK_CONTAINER(tobox), 10);
gtk_container_border_width(GTK_CONTAINER(tobox), 0);
gtk_box_pack_start(GTK_BOX(mainbox), tobox, TRUE, TRUE, 0);
frame = gtk_frame_new("Preview");
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
gtk_container_border_width(GTK_CONTAINER(frame), 0);
gtk_box_pack_start(GTK_BOX(prevbox), frame, TRUE, TRUE, 0);
gtk_widget_show(frame);
preview = gtk_preview_new(GTK_PREVIEW_COLOR);
gtk_preview_size(GTK_PREVIEW(preview), prev_width, prev_height);
gtk_container_add(GTK_CONTAINER(frame), preview);
update_preview();
gtk_widget_show(preview);
/* and our scales */
for (framenumber = 0; framenumber < 2; framenumber++)
{
frame = gtk_frame_new(framenumber ? "To color" : "From color");
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
gtk_container_border_width(GTK_CONTAINER(frame), 10);
gtk_container_border_width(GTK_CONTAINER(frame), 0);
gtk_box_pack_start(framenumber ? GTK_BOX(tobox) : GTK_BOX(frombox),
frame, TRUE, TRUE, 0);
gtk_widget_show(frame);
table = gtk_table_new(8, 2, FALSE);
gtk_container_border_width(GTK_CONTAINER(table), 10);
gtk_container_border_width(GTK_CONTAINER(table), 0);
gtk_container_add(GTK_CONTAINER(frame), table);
doLabelAndScale("Red", table, framenumber ? &xargs.tored : &xargs.fromred);
if (! framenumber)
doLabelAndScale("Red threshold", table, &xargs.red_threshold);
doLabelAndScale("Green", table, framenumber ? &xargs.togreen : &xargs.fromgreen);
if (! framenumber)
doLabelAndScale("Green threshold", table, &xargs.green_threshold);
doLabelAndScale("Blue", table, framenumber ? &xargs.toblue : &xargs.fromblue);
if (!framenumber)
doLabelAndScale("Threshold", table, &xargs.threshold);
if (! framenumber)
doLabelAndScale("Blue threshold", table, &xargs.blue_threshold);
if (! framenumber)
{
GtkWidget *button;
button = gtk_check_button_new_with_label("Lock thresholds");
gtk_table_attach(GTK_TABLE(table), button, 1, 2, 6, 7, GTK_FILL, 0, 0, 0);
gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) lock_callback, dialog);
gtk_widget_show(button);
}
gtk_widget_show(table);
}
/* show everything */
gtk_widget_show(prevbox);
gtk_widget_show(tobox);
gtk_widget_show(frombox);
gtk_widget_show(mainbox);
......@@ -395,7 +364,7 @@ void doLabelAndScale(char *labelname, GtkWidget *table, guchar *dest)
idx++;
label = gtk_label_new(labelname);
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table), label, 0, 1, idx, idx + 1, GTK_FILL, 0, 5, 0);
gtk_table_attach(GTK_TABLE(table), label, 0, 1, idx, idx + 1, GTK_FILL, 0, 0, 0);
scale_data = gtk_adjustment_new(*dest, 0.0, 255.0, 0.0, 0.0, 0.0);
scale = gtk_hscale_new(GTK_ADJUSTMENT(scale_data));
gtk_widget_set_usize(scale, SCALE_WIDTH, 0);
......@@ -403,7 +372,7 @@ void doLabelAndScale(char *labelname, GtkWidget *table, guchar *dest)
gtk_scale_set_digits(GTK_SCALE(scale), 0);
gtk_table_attach(GTK_TABLE(table), scale, 1, 2, idx, idx + 1, GTK_FILL, 0, 0, 0);
gtk_scale_set_value_pos(GTK_SCALE(scale), GTK_POS_TOP);
gtk_range_set_update_policy(GTK_RANGE(scale), GTK_UPDATE_DELAYED);
gtk_range_set_update_policy(GTK_RANGE(scale), GTK_UPDATE_DISCONTINUOUS);
gtk_signal_connect(GTK_OBJECT(scale_data), "value_changed",
(GtkSignalFunc) scale_callback,
dest);
......@@ -418,10 +387,134 @@ void ok_callback(GtkWidget *widget, gpointer data)
gtk_widget_destroy(GTK_WIDGET(data));
}
static
void lock_callback(GtkWidget *widget, gpointer data)
{
lock_thres = 1 - lock_thres;
}
static
void scale_callback(GtkAdjustment *adj, gpointer data)
{
guchar *val = data;