Pass the values which are treated as 0% and 100% to the constructor and

2000-02-03  Michael Natterer  <mitch@gimp.org>

	* libgimp/gimpwidgets.[ch] gimp_coordinates_new():
	Pass the values which are treated as 0% and 100% to the
	constructor and allow the chainbutton to constrain either the
	pixel values or the aspect ratio.

	* plug-ins/common/bumpmap.c
	* plug-ins/common/sparkle.c: removed unused variables.

	* plug-ins/common/gauss_iir.c
	* plug-ins/common/gauss_rle.c
	* plug-ins/common/spread.c: updated the gimp_coordinates_new()
	calls.

	* plug-ins/common/tile.c: use gimp_coordinates instead of
	spinbuttons.
This commit is contained in:
Michael Natterer 2000-02-02 17:59:44 +00:00 committed by Michael Natterer
parent c33289b6ae
commit 9508a095d1
11 changed files with 533 additions and 457 deletions

View File

@ -1,3 +1,21 @@
2000-02-03 Michael Natterer <mitch@gimp.org>
* libgimp/gimpwidgets.[ch] gimp_coordinates_new():
Pass the values which are treated as 0% and 100% to the
constructor and allow the chainbutton to constrain either the
pixel values or the aspect ratio.
* plug-ins/common/bumpmap.c
* plug-ins/common/sparkle.c: removed unused variables.
* plug-ins/common/gauss_iir.c
* plug-ins/common/gauss_rle.c
* plug-ins/common/spread.c: updated the gimp_coordinates_new()
calls.
* plug-ins/common/tile.c: use gimp_coordinates instead of
spinbuttons.
Wed Feb 2 19:01:26 PST 2000 Manish Singh <yosh@gimp.org>
* tools/pdbgen/pdb/fileops.pdb: correct g_message warning call

View File

@ -530,12 +530,15 @@ gimp_random_seed_new (gint *seed,
typedef struct
{
GimpChainButton *chainbutton;
gboolean chain_constrains_ratio;
gdouble orig_x;
gdouble orig_y;
gdouble last_x;
gdouble last_y;
} GimpCoordinatesData;
static void
gimp_coordinates_callback (GtkWidget *widget,
gimp_coordinates_callback (GtkWidget *widget,
gpointer data)
{
GimpCoordinatesData *gcd;
@ -551,16 +554,39 @@ gimp_coordinates_callback (GtkWidget *widget,
{
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "value_changed");
if (new_x != gcd->last_x)
{
gcd->last_y = new_y = gcd->last_x = new_x;
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1, new_x);
}
else if (new_y != gcd->last_y)
{
gcd->last_x = new_x = gcd->last_y = new_y;
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0, new_y);
}
if (gcd->chain_constrains_ratio)
{
if ((gcd->orig_x != 0) && (gcd->orig_y != 0))
{
if (new_x != gcd->last_x)
{
gcd->last_x = new_x;
gcd->last_y = new_y = (new_x * gcd->orig_y) / gcd->orig_x;
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1,
new_y);
}
else if (new_y != gcd->last_y)
{
gcd->last_y = new_y;
gcd->last_x = new_x = (new_y * gcd->orig_x) / gcd->orig_y;
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0,
new_x);
}
}
}
else
{
if (new_x != gcd->last_x)
{
gcd->last_y = new_y = gcd->last_x = new_x;
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1, new_x);
}
else if (new_y != gcd->last_y)
{
gcd->last_x = new_x = gcd->last_y = new_y;
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0, new_y);
}
}
}
else
{
@ -579,23 +605,32 @@ gimp_coordinates_new (GUnit unit,
gint spinbutton_usize,
GimpSizeEntryUP update_policy,
gboolean chainbutton_active,
gboolean chain_constrains_ratio,
/* return value: */
GtkWidget **chainbutton,
gchar *xlabel,
gdouble x,
gdouble xres,
gint lower_boundary_x,
gint upper_boundary_x,
gdouble lower_boundary_x,
gdouble upper_boundary_x,
gdouble xsize_0, /* % */
gdouble xsize_100, /* % */
gchar *ylabel,
gdouble y,
gdouble yres,
gint lower_boundary_y,
gint upper_boundary_y)
gdouble lower_boundary_y,
gdouble upper_boundary_y,
gdouble ysize_0, /* % */
gdouble ysize_100 /* % */)
{
GimpCoordinatesData *gcd;
GtkObject *adjustment;
GtkWidget *spinbutton;
GtkWidget *sizeentry;
GtkWidget *chainbutton;
GtkWidget *chainb;
spinbutton = gimp_spin_button_new (&adjustment, 1, 0, 1, 1, 10, 1, 1, 2);
sizeentry = gimp_size_entry_new (1, unit, unit_format,
@ -605,6 +640,7 @@ gimp_coordinates_new (GUnit unit,
spinbutton_usize,
update_policy);
gtk_table_set_col_spacing (GTK_TABLE (sizeentry), 0, 4);
gtk_table_set_col_spacing (GTK_TABLE (sizeentry), 2, 4);
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (sizeentry),
GTK_SPIN_BUTTON (spinbutton), NULL);
gtk_table_attach_defaults (GTK_TABLE (sizeentry), spinbutton, 1, 2, 0, 1);
@ -619,23 +655,37 @@ gimp_coordinates_new (GUnit unit,
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 1,
lower_boundary_y, upper_boundary_y);
if (menu_show_percent)
{
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 0,
xsize_0, xsize_100);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 1,
ysize_0, ysize_100);
}
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0, x);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 1, y);
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry), xlabel, 0, 0, 1.0);
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry), ylabel, 1, 0, 1.0);
chainbutton = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
if (x == y)
gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chainbutton), TRUE);
gtk_table_attach (GTK_TABLE (sizeentry), chainbutton, 2, 3, 0, 2,
chainb = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
if (chainbutton_active)
gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chainb), TRUE);
gtk_table_attach (GTK_TABLE (sizeentry), chainb, 2, 3, 0, 2,
GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (chainbutton);
gtk_widget_show (chainb);
if (chainbutton)
*chainbutton = chainb;
gcd = g_new (GimpCoordinatesData, 1);
gcd->chainbutton = GIMP_CHAIN_BUTTON (chainbutton);
gcd->last_x = x;
gcd->last_y = y;
gcd->chainbutton = GIMP_CHAIN_BUTTON (chainb);
gcd->chain_constrains_ratio = chain_constrains_ratio;
gcd->orig_x = x;
gcd->orig_y = y;
gcd->last_x = x;
gcd->last_y = y;
gtk_signal_connect_object (GTK_OBJECT (sizeentry), "destroy",
GTK_SIGNAL_FUNC (g_free),

View File

@ -127,17 +127,26 @@ GtkWidget * gimp_coordinates_new (GUnit unit,
gint spinbutton_usize,
GimpSizeEntryUP update_policy,
gboolean chainbutton_active,
gboolean chain_constrains_ratio,
/* return value: */
GtkWidget **chainbutton,
gchar *xlabel,
gdouble x,
gdouble xres,
gint lower_boundary_x,
gint upper_boundary_x,
gdouble lower_boundary_x,
gdouble upper_boundary_x,
gdouble xsize_0, /* % */
gdouble xsize_100, /* % */
gchar *ylabel,
gdouble y,
gdouble yres,
gint lower_boundary_y,
gint upper_boundary_y);
gdouble lower_boundary_y,
gdouble upper_boundary_y,
gdouble ysize_0, /* % */
gdouble ysize_100 /* % */);
/*
* Standard Callbacks

View File

@ -530,12 +530,15 @@ gimp_random_seed_new (gint *seed,
typedef struct
{
GimpChainButton *chainbutton;
gboolean chain_constrains_ratio;
gdouble orig_x;
gdouble orig_y;
gdouble last_x;
gdouble last_y;
} GimpCoordinatesData;
static void
gimp_coordinates_callback (GtkWidget *widget,
gimp_coordinates_callback (GtkWidget *widget,
gpointer data)
{
GimpCoordinatesData *gcd;
@ -551,16 +554,39 @@ gimp_coordinates_callback (GtkWidget *widget,
{
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "value_changed");
if (new_x != gcd->last_x)
{
gcd->last_y = new_y = gcd->last_x = new_x;
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1, new_x);
}
else if (new_y != gcd->last_y)
{
gcd->last_x = new_x = gcd->last_y = new_y;
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0, new_y);
}
if (gcd->chain_constrains_ratio)
{
if ((gcd->orig_x != 0) && (gcd->orig_y != 0))
{
if (new_x != gcd->last_x)
{
gcd->last_x = new_x;
gcd->last_y = new_y = (new_x * gcd->orig_y) / gcd->orig_x;
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1,
new_y);
}
else if (new_y != gcd->last_y)
{
gcd->last_y = new_y;
gcd->last_x = new_x = (new_y * gcd->orig_x) / gcd->orig_y;
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0,
new_x);
}
}
}
else
{
if (new_x != gcd->last_x)
{
gcd->last_y = new_y = gcd->last_x = new_x;
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1, new_x);
}
else if (new_y != gcd->last_y)
{
gcd->last_x = new_x = gcd->last_y = new_y;
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0, new_y);
}
}
}
else
{
@ -579,23 +605,32 @@ gimp_coordinates_new (GUnit unit,
gint spinbutton_usize,
GimpSizeEntryUP update_policy,
gboolean chainbutton_active,
gboolean chain_constrains_ratio,
/* return value: */
GtkWidget **chainbutton,
gchar *xlabel,
gdouble x,
gdouble xres,
gint lower_boundary_x,
gint upper_boundary_x,
gdouble lower_boundary_x,
gdouble upper_boundary_x,
gdouble xsize_0, /* % */
gdouble xsize_100, /* % */
gchar *ylabel,
gdouble y,
gdouble yres,
gint lower_boundary_y,
gint upper_boundary_y)
gdouble lower_boundary_y,
gdouble upper_boundary_y,
gdouble ysize_0, /* % */
gdouble ysize_100 /* % */)
{
GimpCoordinatesData *gcd;
GtkObject *adjustment;
GtkWidget *spinbutton;
GtkWidget *sizeentry;
GtkWidget *chainbutton;
GtkWidget *chainb;
spinbutton = gimp_spin_button_new (&adjustment, 1, 0, 1, 1, 10, 1, 1, 2);
sizeentry = gimp_size_entry_new (1, unit, unit_format,
@ -605,6 +640,7 @@ gimp_coordinates_new (GUnit unit,
spinbutton_usize,
update_policy);
gtk_table_set_col_spacing (GTK_TABLE (sizeentry), 0, 4);
gtk_table_set_col_spacing (GTK_TABLE (sizeentry), 2, 4);
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (sizeentry),
GTK_SPIN_BUTTON (spinbutton), NULL);
gtk_table_attach_defaults (GTK_TABLE (sizeentry), spinbutton, 1, 2, 0, 1);
@ -619,23 +655,37 @@ gimp_coordinates_new (GUnit unit,
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 1,
lower_boundary_y, upper_boundary_y);
if (menu_show_percent)
{
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 0,
xsize_0, xsize_100);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 1,
ysize_0, ysize_100);
}
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0, x);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 1, y);
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry), xlabel, 0, 0, 1.0);
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry), ylabel, 1, 0, 1.0);
chainbutton = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
if (x == y)
gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chainbutton), TRUE);
gtk_table_attach (GTK_TABLE (sizeentry), chainbutton, 2, 3, 0, 2,
chainb = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
if (chainbutton_active)
gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chainb), TRUE);
gtk_table_attach (GTK_TABLE (sizeentry), chainb, 2, 3, 0, 2,
GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (chainbutton);
gtk_widget_show (chainb);
if (chainbutton)
*chainbutton = chainb;
gcd = g_new (GimpCoordinatesData, 1);
gcd->chainbutton = GIMP_CHAIN_BUTTON (chainbutton);
gcd->last_x = x;
gcd->last_y = y;
gcd->chainbutton = GIMP_CHAIN_BUTTON (chainb);
gcd->chain_constrains_ratio = chain_constrains_ratio;
gcd->orig_x = x;
gcd->orig_y = y;
gcd->last_x = x;
gcd->last_y = y;
gtk_signal_connect_object (GTK_OBJECT (sizeentry), "destroy",
GTK_SIGNAL_FUNC (g_free),

View File

@ -127,17 +127,26 @@ GtkWidget * gimp_coordinates_new (GUnit unit,
gint spinbutton_usize,
GimpSizeEntryUP update_policy,
gboolean chainbutton_active,
gboolean chain_constrains_ratio,
/* return value: */
GtkWidget **chainbutton,
gchar *xlabel,
gdouble x,
gdouble xres,
gint lower_boundary_x,
gint upper_boundary_x,
gdouble lower_boundary_x,
gdouble upper_boundary_x,
gdouble xsize_0, /* % */
gdouble xsize_100, /* % */
gchar *ylabel,
gdouble y,
gdouble yres,
gint lower_boundary_y,
gint upper_boundary_y);
gdouble lower_boundary_y,
gdouble upper_boundary_y,
gdouble ysize_0, /* % */
gdouble ysize_100 /* % */);
/*
* Standard Callbacks

View File

@ -197,17 +197,20 @@ static void bumpmap (void);
static void bumpmap_init_params (bumpmap_params_t *params);
static void bumpmap_row (guchar *src_row,
guchar *dest_row,
int width,
int bpp,
int has_alpha,
gint width,
gint bpp,
gint has_alpha,
guchar *bm_row1,
guchar *bm_row2,
guchar *bm_row3,
int bm_width,
int bm_xofs,
gint bm_width,
gint bm_xofs,
bumpmap_params_t *params);
static void bumpmap_convert_row (guchar *row, int width, int bpp,
int has_alpha, guchar *lut);
static void bumpmap_convert_row (guchar *row,
gint width,
gint bpp,
gint has_alpha,
guchar *lut);
static gint bumpmap_dialog (void);
static void dialog_init_preview (void);
@ -217,9 +220,10 @@ static gint dialog_preview_events (GtkWidget *widget, GdkEvent *event);
static void dialog_scroll_src (void);
static void dialog_scroll_bumpmap (void);
static void dialog_get_rows (GPixelRgn *pr, guchar **rows,
int x, int y, int width, int height);
static void dialog_fill_src_rows (int start, int how_many, int yofs);
static void dialog_fill_bumpmap_rows (int start, int how_many, int yofs);
gint x, gint y,
gint width, gint height);
static void dialog_fill_src_rows (gint start, gint how_many, gint yofs);
static void dialog_fill_bumpmap_rows (gint start, gint how_many, gint yofs);
static void dialog_compensate_callback (GtkWidget *widget, gpointer data);
static void dialog_invert_callback (GtkWidget *widget, gpointer data);
@ -237,10 +241,10 @@ static void dialog_ok_callback (GtkWidget *widget, gpointer data);
GPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run /* run_proc */
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run /* run_proc */
};
static bumpmap_vals_t bmvals =
@ -285,11 +289,11 @@ static bumpmap_interface_t bmint =
FALSE /* run */
};
GDrawable *drawable = NULL;
static GDrawable *drawable = NULL;
gint sel_x1, sel_y1, sel_x2, sel_y2;
gint sel_width, sel_height;
gint img_bpp, img_has_alpha;
static gint sel_x1, sel_y1, sel_x2, sel_y2;
static gint sel_width, sel_height;
static gint img_bpp, img_has_alpha;
/***** Functions *****/
@ -316,29 +320,27 @@ query (void)
{ PARAM_INT32, "invert", "Invert bumpmap" },
{ PARAM_INT32, "type", "Type of map (LINEAR (0), SPHERICAL (1), SINUOSIDAL (2))" }
};
static GParamDef *return_vals = NULL;
static int nargs = sizeof(args) / sizeof(args[0]);
static int nreturn_vals = 0;
static gint nargs = sizeof (args) / sizeof (args[0]);
INIT_I18N();
gimp_install_procedure (PLUG_IN_NAME,
_("Create an embossing effect using an image as a bump map"),
_("This plug-in uses the algorithm described by John Schlag, "
"\"Fast Embossing Effects on Raster Image Data\" in Graphics GEMS IV "
"(ISBN 0-12-336155-9). It takes a grayscale image to be applied as "
"a bump map to another image and produces a nice embossing effect."),
"Create an embossing effect using an image as a "
"bump map",
"This plug-in uses the algorithm described by John "
"Schlag, \"Fast Embossing Effects on Raster Image "
"Data\" in Graphics GEMS IV (ISBN 0-12-336155-9). "
"It takes a grayscale image to be applied as a bump "
"map to another image and produces a nice embossing "
"effect.",
"Federico Mena Quintero & Jens Lautenbacher",
"Federico Mena Quintero & Jens Lautenbacher",
PLUG_IN_VERSION,
N_("<Image>/Filters/Map/Bump Map..."),
"RGB*, GRAY*",
PROC_PLUG_IN,
nargs,
nreturn_vals,
args,
return_vals);
nargs, 0,
args, NULL);
}
static void
@ -390,9 +392,10 @@ run (gchar *name,
case RUN_NONINTERACTIVE:
/* Make sure all the arguments are present */
if (nparams != 14)
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS)
{
status = STATUS_CALLING_ERROR;
}
else
{
bmvals.bumpmap_id = param[3].data.d_drawable;
bmvals.azimuth = param[4].data.d_float;
@ -407,7 +410,6 @@ run (gchar *name,
bmvals.invert = param[12].data.d_int32;
bmvals.type = param[13].data.d_int32;
}
break;
case RUN_WITH_LAST_VALS:
@ -457,12 +459,12 @@ bumpmap (void)
bumpmap_params_t params;
GDrawable *bm_drawable;
GPixelRgn src_rgn, dest_rgn, bm_rgn;
int bm_width, bm_height, bm_bpp, bm_has_alpha;
int yofs1, yofs2, yofs3;
gint bm_width, bm_height, bm_bpp, bm_has_alpha;
gint yofs1, yofs2, yofs3;
guchar *bm_row1, *bm_row2, *bm_row3, *bm_tmprow;
guchar *src_row, *dest_row;
int y;
int progress;
gint y;
gint progress;
#if 0
g_print ("bumpmap: waiting... (pid %d)\n", getpid ());
@ -566,11 +568,11 @@ bumpmap (void)
static void
bumpmap_init_params (bumpmap_params_t *params)
{
double azimuth;
double elevation;
int lz, nz;
int i;
double n;
gdouble azimuth;
gdouble elevation;
gint lz, nz;
gint i;
gdouble n;
/* Convert to radians */
azimuth = G_PI * bmvals.azimuth / 180.0;
@ -621,24 +623,24 @@ bumpmap_init_params (bumpmap_params_t *params)
static void
bumpmap_row (guchar *src_row,
guchar *dest_row,
int width,
int bpp,
int has_alpha,
gint width,
gint bpp,
gint has_alpha,
guchar *bm_row1,
guchar *bm_row2,
guchar *bm_row3,
int bm_width,
int bm_xofs,
gint bm_width,
gint bm_xofs,
bumpmap_params_t *params)
{
guchar *src, *dest;
int xofs1, xofs2, xofs3;
int shade;
int ndotl;
int nx, ny;
int x, k;
int pbpp;
int result;
gint xofs1, xofs2, xofs3;
gint shade;
gint ndotl;
gint nx, ny;
gint x, k;
gint pbpp;
gint result;
if (has_alpha)
pbpp = bpp - 1;
@ -714,9 +716,9 @@ bumpmap_row (guchar *src_row,
static void
bumpmap_convert_row (guchar *row,
int width,
int bpp,
int has_alpha,
gint width,
gint bpp,
gint has_alpha,
guchar *lut)
{
guchar *p;
@ -763,7 +765,6 @@ bumpmap_dialog (void)
GtkWidget *pframe;
GtkWidget *table;
GtkWidget *right_vbox;
GtkWidget *label;
GtkWidget *option_menu;
GtkWidget *menu;
GtkWidget *button;
@ -783,9 +784,9 @@ bumpmap_dialog (void)
argv[0] = g_strdup ("bumpmap");
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc());
gdk_set_use_xshm (gimp_use_xshm());
gtk_rc_parse (gimp_gtkrc ());
gdk_set_use_xshm (gimp_use_xshm ());
gtk_preview_set_gamma (gimp_gamma ());
gtk_preview_set_install_cmap (gimp_install_cmap ());
color_cube = gimp_color_cube ();
@ -883,18 +884,17 @@ bumpmap_dialog (void)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button),
bmvals.compensate ? TRUE : FALSE);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
(GtkSignalFunc) dialog_compensate_callback,
GTK_SIGNAL_FUNC (dialog_compensate_callback),
NULL);
gtk_widget_show (button);
/* Invert bumpmap */
button = gtk_check_button_new_with_label (_("Invert Bumpmap"));
gtk_box_pack_start (GTK_BOX (right_vbox), button, FALSE, FALSE, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button),
bmvals.invert ? TRUE : FALSE);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
(GtkSignalFunc) dialog_invert_callback,
GTK_SIGNAL_FUNC (dialog_invert_callback),
NULL);
gtk_widget_show (button);
@ -1007,7 +1007,7 @@ bumpmap_dialog (void)
static void
dialog_init_preview (void)
{
int x;
gint x;
/* Create checkerboard rows */
@ -1140,8 +1140,8 @@ dialog_preview_events (GtkWidget *widget,
static void
dialog_new_bumpmap (void)
{
int i;
int yofs;
gint i;
gint yofs;
/* Get drawable */
@ -1194,11 +1194,11 @@ dialog_update_preview (void)
static guchar dest_row[PREVIEW_SIZE * 4];
static guchar preview_row[PREVIEW_SIZE * 3];
guchar *check_row;
guchar check;
int xofs;
int x, y;
guchar *sp, *p;
guchar *check_row;
guchar check;
gint xofs;
gint x, y;
guchar *sp, *p;
bumpmap_init_params (&bmint.params);
@ -1253,8 +1253,8 @@ dialog_update_preview (void)
static void
dialog_scroll_src (void)
{
int yofs;
int y, ofs;
gint yofs;
gint y, ofs;
guchar *tmp;
yofs = bmint.preview_yofs;
@ -1301,8 +1301,8 @@ dialog_scroll_src (void)
static void
dialog_scroll_bumpmap (void)
{
int yofs;
int y, ofs;
gint yofs;
gint y, ofs;
guchar *tmp;
yofs = bmvals.yofs + bmint.preview_yofs - 1; /* Minus 1 for conv. matrix */
@ -1357,10 +1357,10 @@ dialog_scroll_bumpmap (void)
static void
dialog_get_rows (GPixelRgn *pr,
guchar **rows,
int x,
int y,
int width,
int height)
gint x,
gint y,
gint width,
gint height)
{
/* This is shamelessly ripped off from gimp_pixel_rgn_get_rect().
* Its function is exactly the same, but it can fetch an image
@ -1370,14 +1370,14 @@ dialog_get_rows (GPixelRgn *pr,
GTile *tile;
guchar *src, *dest;
int xstart, ystart;
int xend, yend;
int xboundary;
int yboundary;
int xstep, ystep;
int b, bpp;
int tx, ty;
int tile_width, tile_height;
gint xstart, ystart;
gint xend, yend;
gint xboundary;
gint yboundary;
gint xstep, ystep;
gint b, bpp;
gint tx, ty;
gint tile_width, tile_height;
tile_width = gimp_tile_width();
tile_height = gimp_tile_height();
@ -1427,11 +1427,11 @@ dialog_get_rows (GPixelRgn *pr,
}
static void
dialog_fill_src_rows (int start,
int how_many,
int yofs)
dialog_fill_src_rows (gint start,
gint how_many,
gint yofs)
{
int x, y;
gint x, y;
guchar *sp, *p;
dialog_get_rows (&bmint.src_rgn,
@ -1472,13 +1472,13 @@ dialog_fill_src_rows (int start,
}
static void
dialog_fill_bumpmap_rows (int start,
int how_many,
int yofs)
dialog_fill_bumpmap_rows (gint start,
gint how_many,
gint yofs)
{
int buf_row_ofs;
int remaining;
int this_pass;
gint buf_row_ofs;
gint remaining;
gint this_pass;
buf_row_ofs = start;
remaining = how_many;

View File

@ -43,7 +43,8 @@ typedef struct
typedef struct
{
gint run;
GtkWidget *size;
gint run;
} BlurInterface;
@ -138,9 +139,6 @@ query (void)
{ PARAM_FLOAT, "vertical", "Vertical radius of gaussian blur (in pixels)" }
};
static gint nargs2 = sizeof (args2) / sizeof (args2[0]);
static GParamDef *return_vals = NULL;
static gint nreturn_vals = 0;
INIT_I18N();
@ -153,8 +151,8 @@ query (void)
NULL,
"RGB*, GRAY*",
PROC_PLUG_IN,
nargs, nreturn_vals,
args, return_vals);
nargs, 0,
args, NULL);
gimp_install_procedure ("plug_in_gauss_iir2",
"Applies a gaussian blur to the specified drawable.",
@ -165,8 +163,8 @@ query (void)
N_("<Image>/Filters/Blur/Gaussian Blur (IIR)..."),
"RGB*, GRAY*",
PROC_PLUG_IN,
nargs2, nreturn_vals,
args2, return_vals);
nargs2, 0,
args2, NULL);
}
static void
@ -465,11 +463,16 @@ gauss_iir2_dialog (gint32 image_ID,
size = gimp_coordinates_new (unit, "%a", TRUE, FALSE, 75,
GIMP_SIZE_ENTRY_UPDATE_SIZE,
_("Horizontal:"), b2vals.horizontal,
xres, 0, MAX (drawable->width, drawable->height),
b2vals.horizontal == b2vals.vertical,
FALSE, NULL,
_("Vertical:"), b2vals.horizontal,
yres, 0, MAX (drawable->width, drawable->height));
_("Horizontal:"), b2vals.horizontal, xres,
0, MAX (drawable->width, drawable->height),
0, 0,
_("Vertical:"), b2vals.vertical, yres,
0, MAX (drawable->width, drawable->height),
0, 0);
gtk_container_set_border_width (GTK_CONTAINER (size), 4);
gtk_container_add (GTK_CONTAINER (frame), size);
@ -477,7 +480,7 @@ gauss_iir2_dialog (gint32 image_ID,
gtk_widget_show (frame);
gtk_widget_show (dlg);
gtk_object_set_data (GTK_OBJECT (dlg), "size", size);
bint.size = size;
gtk_main ();
gdk_flush ();
@ -485,10 +488,26 @@ gauss_iir2_dialog (gint32 image_ID,
return bint.run;
}
static void
gauss_ok_callback (GtkWidget *widget,
gpointer data)
{
b2vals.horizontal =
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (bint.size), 0);
b2vals.vertical =
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (bint.size), 1);
bint.run = TRUE;
gtk_widget_destroy (GTK_WIDGET (data));
}
/* Convert from separated to premultiplied alpha, on a single scan line. */
static void
multiply_alpha (guchar *buf, gint width, gint bytes)
multiply_alpha (guchar *buf,
gint width,
gint bytes)
{
gint i, j;
gdouble alpha;
@ -504,7 +523,9 @@ multiply_alpha (guchar *buf, gint width, gint bytes)
/* Convert from premultiplied to separated alpha, on a single scan
line. */
static void
separate_alpha (guchar *buf, gint width, gint bytes)
separate_alpha (guchar *buf,
gint width,
gint bytes)
{
gint i, j;
guchar alpha;
@ -528,8 +549,8 @@ separate_alpha (guchar *buf, gint width, gint bytes)
static void
gauss_iir (GDrawable *drawable,
gdouble horz,
gdouble vert)
gdouble horz,
gdouble vert)
{
GPixelRgn src_rgn, dest_rgn;
gint width, height;
@ -875,23 +896,3 @@ find_constants (gdouble n_p[],
}
}
}
/* Gauss interface functions */
static void
gauss_ok_callback (GtkWidget *widget,
gpointer data)
{
GtkWidget *size;
bint.run = TRUE;
size = gtk_object_get_data (GTK_OBJECT (data), "size");
if (size)
{
b2vals.horizontal = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size), 0);
b2vals.vertical = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size), 1);
}
gtk_widget_destroy (GTK_WIDGET (data));
}

View File

@ -31,8 +31,8 @@
typedef struct
{
gdouble radius;
gint horizontal;
gint vertical;
gint horizontal;
gint vertical;
} BlurValues;
typedef struct
@ -43,7 +43,8 @@ typedef struct
typedef struct
{
gint run;
GtkWidget *size;
gint run;
} BlurInterface;
@ -456,14 +457,19 @@ gauss_rle2_dialog (gint32 image_ID,
gimp_image_get_resolution (image_ID, &xres, &yres);
unit = gimp_image_get_unit (image_ID);
size = gimp_coordinates_new (unit, "%a", TRUE, FALSE, 75,
size = gimp_coordinates_new (unit, "%a", TRUE, FALSE, 75,
GIMP_SIZE_ENTRY_UPDATE_SIZE,
_("Horizontal:"), b2vals.horizontal,
xres, 0, MAX (drawable->width, drawable->height),
b2vals.horizontal == b2vals.vertical,
FALSE, NULL,
_("Vertical:"), b2vals.vertical,
yres, 0, MAX (drawable->width, drawable->height));
_("Horizontal:"), b2vals.horizontal, xres,
0, MAX (drawable->width, drawable->height),
0, 0,
_("Vertical:"), b2vals.vertical, yres,
0, MAX (drawable->width, drawable->height),
0, 0);
gtk_container_set_border_width (GTK_CONTAINER (size), 4);
gtk_container_add (GTK_CONTAINER (frame), size);
@ -471,7 +477,7 @@ gauss_rle2_dialog (gint32 image_ID,
gtk_widget_show (frame);
gtk_widget_show (dlg);
gtk_object_set_data (GTK_OBJECT (dlg), "size", size);
bint.size = size;
gtk_main ();
gdk_flush ();
@ -479,6 +485,19 @@ gauss_rle2_dialog (gint32 image_ID,
return bint.run;
}
static void
gauss_ok_callback (GtkWidget *widget,
gpointer data)
{
b2vals.horizontal =
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (bint.size), 0);
b2vals.vertical =
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (bint.size), 1);
bint.run = TRUE;
gtk_widget_destroy (GTK_WIDGET (data));
}
/* Convert from separated to premultiplied alpha, on a single scan line. */
static void
@ -814,23 +833,3 @@ run_length_encode (guchar *src,
*dest++ = last;
}
}
/* Gauss interface functions */
static void
gauss_ok_callback (GtkWidget *widget,
gpointer data)
{
GtkWidget *size;
bint.run = TRUE;
size = gtk_object_get_data (GTK_OBJECT (data), "size");
if (size)
{
b2vals.horizontal = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size), 0);
b2vals.vertical = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size), 1);
}
gtk_widget_destroy (GTK_WIDGET (data));
}

View File

@ -1,3 +1,4 @@
/* Sparkle --- image filter plug-in for The Gimp image manipulation program
* Copyright (C) 1996 by John Beale; ported to Gimp by Michael J. Hammel;
* It has been optimized a little, bugfixed and modified by Martin Weber
@ -73,11 +74,11 @@ typedef struct
*/
static void query (void);
static void run (char *name,
int nparams,
GParam *param,
int *nreturn_vals,
GParam **return_vals);
static void run (gchar *name,
gint nparams,
GParam *param,
gint *nreturn_vals,
GParam **return_vals);
static gint sparkle_dialog (void);
static void sparkle_ok_callback (GtkWidget *widget,
@ -122,27 +123,27 @@ static GTile* rpnt (GDrawable * drawable,
GPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
};
static SparkleVals svals =
{
0.001, /* luminosity threshold */
0.5, /* flare intensity */
20.0, /* spike length */
4.0, /* spike points */
15.0, /* spike angle */
1.0, /* spike density */
0.0, /* opacity */
0.0, /* random hue */
0.0, /* random saturation */
FALSE, /* preserve_luminosity */
FALSE, /* invers */
FALSE, /* border */
NATURAL /* colortype */
0.001, /* luminosity threshold */
0.5, /* flare intensity */
20.0, /* spike length */
4.0, /* spike points */
15.0, /* spike angle */
1.0, /* spike density */
0.0, /* opacity */
0.0, /* random hue */
0.0, /* random saturation */
FALSE, /* preserve_luminosity */
FALSE, /* invers */
FALSE, /* border */
NATURAL /* colortype */
};
static SparkleInterface sint =
@ -177,30 +178,28 @@ query (void)
{ PARAM_INT32, "border", "Add border (TRUE/FALSE)" },
{ PARAM_INT32, "colortype", "Color of sparkles: { NATURAL (0), FOREGROUND (1), BACKGROUND (2) }" }
};
static GParamDef *return_vals = NULL;
static int nargs = sizeof (args) / sizeof (args[0]);
static int nreturn_vals = 0;
static gint nargs = sizeof (args) / sizeof (args[0]);
INIT_I18N();
gimp_install_procedure ("plug_in_sparkle",
"Simulates pixel bloom and diffraction effects",
"Simulates pixel bloom and diffraction effects",
"No help yet",
"John Beale, & (ported to GIMP v0.54) Michael J. Hammel & ted to GIMP v1.0) Spencer Kimball",
"John Beale, & (ported to GIMP v0.54) Michael J. Hammel & ted to GIMP v1.0) Spencer Kimball",
"John Beale",
"Version 1.26, December 1998",
N_("<Image>/Filters/Light Effects/Sparkle..."),
"RGB*, GRAY*",
PROC_PLUG_IN,
nargs, nreturn_vals,
args, return_vals);
nargs, 0,
args, NULL);
}
static void
run (char *name,
int nparams,
run (gchar *name,
gint nparams,
GParam *param,
int *nreturn_vals,
gint *nreturn_vals,
GParam **return_vals)
{
static GParam values[1];
@ -233,8 +232,10 @@ run (char *name,
INIT_I18N();
/* Make sure all the arguments are there! */
if (nparams != 16)
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS)
{
status = STATUS_CALLING_ERROR;
}
else
{
svals.lum_threshold = param[3].data.d_float;
svals.flare_inten = param[4].data.d_float;
@ -249,38 +250,29 @@ run (char *name,
svals.invers = (param[13].data.d_int32) ? TRUE : FALSE;
svals.border = (param[14].data.d_int32) ? TRUE : FALSE;
svals.colortype = param[15].data.d_int32;
}
if (status == STATUS_SUCCESS &&
(svals.lum_threshold < 0.0 || svals.lum_threshold > 1.0))
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS &&
(svals.flare_inten < 0.0 || svals.flare_inten > 1.0))
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS &&
(svals.spike_len < 0))
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS &&
(svals.spike_pts < 0))
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS &&
(svals.spike_angle < -1 || svals.spike_angle > 360))
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS &&
(svals.density < 0.0 || svals.density > 1.0))
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS &&
(svals.opacity < 0.0 || svals.opacity > 1.0))
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS &&
(svals.random_hue < 0.0 || svals.random_hue > 1.0))
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS &&
(svals.random_saturation < 0.0 || svals.random_saturation > 1.0))
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS &&
(svals.colortype < NATURAL || svals.colortype > BACKGROUND))
status = STATUS_CALLING_ERROR;
if (svals.lum_threshold < 0.0 || svals.lum_threshold > 1.0)
status = STATUS_CALLING_ERROR;
else if (svals.flare_inten < 0.0 || svals.flare_inten > 1.0)
status = STATUS_CALLING_ERROR;
else if (svals.spike_len < 0)
status = STATUS_CALLING_ERROR;
else if (svals.spike_pts < 0)
status = STATUS_CALLING_ERROR;
else if (svals.spike_angle < -1 || svals.spike_angle > 360)
status = STATUS_CALLING_ERROR;
else if (svals.density < 0.0 || svals.density > 1.0)
status = STATUS_CALLING_ERROR;
else if (svals.opacity < 0.0 || svals.opacity > 1.0)
status = STATUS_CALLING_ERROR;
else if (svals.random_hue < 0.0 || svals.random_hue > 1.0)
status = STATUS_CALLING_ERROR;
else if (svals.random_saturation < 0.0 ||
svals.random_saturation > 1.0)
status = STATUS_CALLING_ERROR;
else if (svals.colortype < NATURAL || svals.colortype > BACKGROUND)
status = STATUS_CALLING_ERROR;
}
break;
case RUN_WITH_LAST_VALS:
@ -299,7 +291,7 @@ run (char *name,
/* Make sure that the drawable is gray or RGB color */
if (gimp_drawable_is_rgb (drawable->id) || gimp_drawable_is_gray (drawable->id))
{
gimp_progress_init ( _("Sparkling..."));
gimp_progress_init (_("Sparkling..."));
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width () + 1));
if (svals.border == FALSE)
@ -345,7 +337,6 @@ sparkle_dialog (void)
GtkWidget *sep;
GtkWidget *r1, *r2, *r3;
GtkObject *scale_data;
GSList *group = NULL;
gchar **argv;
gint argc;
@ -609,15 +600,18 @@ compute_lum_threshold (GDrawable *drawable,
/* zero out the luminosity values array */
memset(values,0,sizeof(gint)*256);
memset (values, 0, sizeof (gint) * 256);
gimp_drawable_mask_bounds (drawable->id, &x1, &y1, &x2, &y2);
gray = gimp_drawable_is_gray (drawable->id);
has_alpha = gimp_drawable_has_alpha (drawable->id);
gimp_pixel_rgn_init (&src_rgn, drawable, x1, y1, (x2 - x1), (y2 - y1), FALSE, FALSE);
gimp_pixel_rgn_init (&src_rgn, drawable,
x1, y1, (x2 - x1), (y2 - y1), FALSE, FALSE);
for (pr = gimp_pixel_rgns_register (1, &src_rgn); pr != NULL; pr = gimp_pixel_rgns_process (pr))
for (pr = gimp_pixel_rgns_register (1, &src_rgn);
pr != NULL;
pr = gimp_pixel_rgns_process (pr))
{
data = src_rgn.data;
size = src_rgn.w * src_rgn.h;
@ -672,10 +666,14 @@ sparkle (GDrawable *drawable,
cur_progress = 0;
max_progress = num_sparkles;
gimp_pixel_rgn_init (&src_rgn, drawable, x1, y1, (x2 - x1), (y2 - y1), FALSE, FALSE);
gimp_pixel_rgn_init (&dest_rgn, drawable, x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE);
gimp_pixel_rgn_init (&src_rgn, drawable,
x1, y1, (x2 - x1), (y2 - y1), FALSE, FALSE);
gimp_pixel_rgn_init (&dest_rgn, drawable,
x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE);
for (pr = gimp_pixel_rgns_register (2, &src_rgn, &dest_rgn); pr != NULL; pr = gimp_pixel_rgns_process (pr))
for (pr = gimp_pixel_rgns_register (2, &src_rgn, &dest_rgn);
pr != NULL;
pr = gimp_pixel_rgns_process (pr))
{
src = src_rgn.data;
dest = dest_rgn.data;
@ -704,10 +702,14 @@ sparkle (GDrawable *drawable,
}
/* add effects to new image based on intensity of old pixels */
gimp_pixel_rgn_init (&src_rgn, drawable, x1, y1, (x2 - x1), (y2 - y1), FALSE, FALSE);
gimp_pixel_rgn_init (&dest_rgn, drawable, x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE);
gimp_pixel_rgn_init (&src_rgn, drawable,
x1, y1, (x2 - x1), (y2 - y1), FALSE, FALSE);
gimp_pixel_rgn_init (&dest_rgn, drawable,
x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE);
for (pr = gimp_pixel_rgns_register (2, &src_rgn, &dest_rgn); pr != NULL; pr = gimp_pixel_rgns_process (pr))
for (pr = gimp_pixel_rgns_register (2, &src_rgn, &dest_rgn);
pr != NULL;
pr = gimp_pixel_rgns_process (pr))
{
src = src_rgn.data;
@ -727,7 +729,8 @@ sparkle (GDrawable *drawable,
lum = compute_luminosity (src, gray, has_alpha);
if (lum >= threshold)
{
nfrac = fabs ((gdouble) (lum + 1 - threshold) / (gdouble) (256 - threshold));
nfrac = fabs ((gdouble) (lum + 1 - threshold) /
(gdouble) (256 - threshold));
length = (gdouble) svals.spike_len * (gdouble) pow (nfrac, 0.8);
inten = svals.flare_inten * nfrac /* pow (nfrac, 1.0) */;
@ -755,7 +758,8 @@ sparkle (GDrawable *drawable,
}
cur_progress ++;
if ((cur_progress % 5) == 0)
gimp_progress_update ((double) cur_progress / (double) max_progress);
gimp_progress_update ((double) cur_progress /
(double) max_progress);
}
src += src_rgn.bpp;
}

View File

@ -47,7 +47,8 @@ typedef struct
typedef struct
{
gint run;
GtkWidget *size;
gint run;
} SpreadInterface;
@ -399,15 +400,20 @@ spread_dialog (gint32 image_ID)
size = gimp_coordinates_new (unit, "%a", TRUE, FALSE, 75,
GIMP_SIZE_ENTRY_UPDATE_SIZE,
_("Horizontal:"), spvals.spread_amount_x,
xres, 0, 200,
spvals.spread_amount_x == spvals.spread_amount_y,
FALSE, NULL,
_("Vertical:"), spvals.spread_amount_y,
yres, 0, 200);
_("Horizontal:"), spvals.spread_amount_x, xres,
0, 200,
0, 0,
_("Vertical:"), spvals.spread_amount_y, yres,
0, 200,
0, 0);
gtk_container_set_border_width (GTK_CONTAINER (size), 4);
gtk_container_add (GTK_CONTAINER (frame), size);
gtk_object_set_data (GTK_OBJECT (dlg), "size", size);
pint.size = size;
gtk_widget_show (size);
gtk_widget_show (frame);
@ -420,6 +426,20 @@ spread_dialog (gint32 image_ID)
return pint.run;
}
static void
spread_ok_callback (GtkWidget *widget,
gpointer data)
{
spvals.spread_amount_x =
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (pint.size), 0);
spvals.spread_amount_y =
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (pint.size), 1);
pint.run = TRUE;
gtk_widget_destroy (GTK_WIDGET (data));
}
static GTile *
spread_pixel (GDrawable * drawable,
GTile * tile,
@ -459,23 +479,3 @@ spread_pixel (GDrawable * drawable,
return tile;
}
/* Spread interface functions */
static void
spread_ok_callback (GtkWidget *widget,
gpointer data)
{
GtkWidget *size;
pint.run = TRUE;
size = gtk_object_get_data (GTK_OBJECT (data), "size");
if (size)
{
spvals.spread_amount_x = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size), 0);
spvals.spread_amount_y = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (size), 1);
}
gtk_widget_destroy (GTK_WIDGET (data));
}

View File

@ -42,10 +42,8 @@ typedef struct
typedef struct
{
GtkObject *width_adj;
GtkObject *height_adj;
gint orig_width;
gint orig_height;
GtkWidget *sizeentry;
GtkWidget *chainbutton;
gint run;
} TileInterface;
@ -62,16 +60,11 @@ static gint32 tile (gint32 image_id,
gint32 drawable_id,
gint32 *layer_id);
static gint tile_dialog (gint width,
gint height);
static gint tile_dialog (gint32 image_ID,
gint32 drawable_ID);
static void tile_ok_callback (GtkWidget *widget,
gpointer data);
static void tile_chain_button_update (GtkWidget *widget,
gpointer data);
static void tile_adjustment_update (GtkAdjustment *adjustment,
gpointer data);
GPlugInInfo PLUG_IN_INFO =
{
@ -91,11 +84,8 @@ static TileVals tvals =
static TileInterface tint =
{
NULL, /* width_adj */
NULL, /* height_adj */
0, /* orig_width */
0, /* orig_height */
FALSE /* run */
NULL, /* sizeentry */
FALSE /* run */
};
MAIN ()
@ -158,7 +148,7 @@ run (gchar *name,
values[1].type = PARAM_IMAGE;
values[2].type = PARAM_LAYER;
width = gimp_drawable_width (param[2].data.d_drawable);
width = gimp_drawable_width (param[2].data.d_drawable);
height = gimp_drawable_height (param[2].data.d_drawable);
switch (run_mode)
@ -169,7 +159,8 @@ run (gchar *name,
gimp_get_data ("plug_in_tile", &tvals);
/* First acquire information with a dialog */
if (! tile_dialog (width, height))
if (! tile_dialog (param[1].data.d_image,
param[2].data.d_drawable))
return;
break;
@ -177,15 +168,18 @@ run (gchar *name,
INIT_I18N();
/* Make sure all the arguments are there! */
if (nparams != 6)
status = STATUS_CALLING_ERROR;
if (status == STATUS_SUCCESS)
{
tvals.new_width = param[3].data.d_int32;
tvals.new_height = param[4].data.d_int32;
tvals.new_image = (param[5].data.d_int32) ? TRUE : FALSE;
status = STATUS_CALLING_ERROR;
}
else
{
tvals.new_width = param[3].data.d_int32;
tvals.new_height = param[4].data.d_int32;
tvals.new_image = param[5].data.d_int32 ? TRUE : FALSE;
if (tvals.new_width < 0 || tvals.new_height < 0)
status = STATUS_CALLING_ERROR;
}
if (tvals.new_width < 0 || tvals.new_height < 0)
status = STATUS_CALLING_ERROR;
break;
case RUN_WITH_LAST_VALS:
@ -201,10 +195,12 @@ run (gchar *name,
/* Make sure that the drawable is gray or RGB color */
if (status == STATUS_SUCCESS)
{
gimp_progress_init ( _("Tiling..."));
gimp_progress_init (_("Tiling..."));
gimp_tile_cache_ntiles (2 * (width + 1) / gimp_tile_width ());
values[1].data.d_image = tile (param[1].data.d_image, param[2].data.d_drawable, &new_layer);
values[1].data.d_image = tile (param[1].data.d_image,
param[2].data.d_drawable,
&new_layer);
values[2].data.d_layer = new_layer;
/* Store data */
@ -244,7 +240,7 @@ tile (gint32 image_id,
image_type = RGB;
new_image_id = 0;
old_width = gimp_drawable_width (drawable_id);
old_width = gimp_drawable_width (drawable_id);
old_height = gimp_drawable_height (drawable_id);
if (tvals.new_image)
@ -338,7 +334,7 @@ tile (gint32 image_id,
/* copy the colormap, if necessary */
if (image_type == INDEXED && tvals.new_image)
{
int ncols;
gint ncols;
guchar *cmap;
cmap = gimp_image_get_cmap (image_id, &ncols);
@ -363,16 +359,20 @@ tile (gint32 image_id,
}
static gint
tile_dialog (gint width, gint height)
tile_dialog (gint32 image_ID,
gint32 drawable_ID)
{
GtkWidget *dlg;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *spinbutton;
GtkWidget *chain;
GtkWidget *sizeentry;
GtkWidget *toggle;
gchar **argv;
gint argc;
gint width;
gint height;
gdouble xres;
gdouble yres;
GUnit unit;
gchar **argv;
gint argc;
argc = 1;
argv = g_new (gchar *, 1);
@ -381,12 +381,15 @@ tile_dialog (gint width, gint height)
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
tint.orig_width = width;
tint.orig_height = height;
width = gimp_drawable_width (drawable_ID);
height = gimp_drawable_height (drawable_ID);
unit = gimp_image_get_unit (image_ID);
gimp_image_get_resolution (image_ID, &xres, &yres);
tvals.new_width = width;
tvals.new_height = height;
dlg = gimp_dialog_new ( _("Tile"), "tile",
dlg = gimp_dialog_new (_("Tile"), "tile",
gimp_plugin_help_func, "filters/tile.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
@ -407,42 +410,29 @@ tile_dialog (gint width, gint height)
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
gtk_container_set_border_width (GTK_CONTAINER (frame), 6);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
table = gtk_table_new (3, 3, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (table), 4);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
sizeentry = gimp_coordinates_new (unit, "%a", TRUE, TRUE, 75,
GIMP_SIZE_ENTRY_UPDATE_SIZE,
spinbutton = gimp_spin_button_new (&tint.width_adj, width,
1, width, 1, 10, 0, 1, 0);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Width:"), 1.0, 0.5,
spinbutton, 1, FALSE);
gtk_signal_connect (GTK_OBJECT (tint.width_adj), "value_changed",
GTK_SIGNAL_FUNC (tile_adjustment_update),
&tvals.new_width);
tvals.constrain, TRUE, &tint.chainbutton,
spinbutton = gimp_spin_button_new (&tint.height_adj, height,
1, height, 1, 10, 0, 1, 0);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Height:"), 1.0, 0.5,
spinbutton, 1, FALSE);
gtk_signal_connect (GTK_OBJECT (tint.height_adj), "value_changed",
GTK_SIGNAL_FUNC (tile_adjustment_update),
&tvals.new_height);
_("Width:"), width, xres,
1, GIMP_MAX_IMAGE_SIZE,
0, width,
chain = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain), tvals.constrain);
gtk_table_attach (GTK_TABLE (table), chain, 2, 3, 0, 2,
GTK_SHRINK, GTK_FILL | GTK_EXPAND, 0, 0);
gtk_signal_connect (GTK_OBJECT (GIMP_CHAIN_BUTTON (chain)->button), "clicked",
GTK_SIGNAL_FUNC (tile_chain_button_update),
chain);
gtk_widget_show (chain);
_("Height:"), height, yres,
1, GIMP_MAX_IMAGE_SIZE,
0, height);
gtk_container_set_border_width (GTK_CONTAINER (sizeentry), 4);
gtk_container_add (GTK_CONTAINER (frame), sizeentry);
gtk_table_set_row_spacing (GTK_TABLE (sizeentry), 1, 4);
gtk_widget_show (sizeentry);
toggle = gtk_check_button_new_with_label (_("New Image"));
gtk_table_attach (GTK_TABLE (table), toggle, 0, 3, 2, 3,
tint.sizeentry = sizeentry;
toggle = gtk_check_button_new_with_label (_("Create New Image"));
gtk_table_attach (GTK_TABLE (sizeentry), toggle, 0, 4, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
gtk_signal_connect (GTK_OBJECT (toggle), "toggled",
GTK_SIGNAL_FUNC (gimp_toggle_button_update),
@ -450,8 +440,6 @@ tile_dialog (gint width, gint height)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), tvals.new_image);
gtk_widget_show (toggle);
gtk_widget_show (table);
gtk_widget_show (frame);
gtk_widget_show (dlg);
gtk_main ();
@ -460,71 +448,19 @@ tile_dialog (gint width, gint height)
return tint.run;
}
/* Tile interface functions */
static void
tile_ok_callback (GtkWidget *widget,
gpointer data)
{
tvals.new_width =
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (tint.sizeentry), 0);
tvals.new_height =
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (tint.sizeentry), 1);
tvals.constrain =
gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (tint.chainbutton));
tint.run = TRUE;
gtk_widget_destroy (GTK_WIDGET (data));
}
static void
tile_chain_button_update (GtkWidget *widget,
gpointer data)
{
tvals.constrain = gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (data));
}
static void
tile_adjustment_update (GtkAdjustment *adjustment,
gpointer data)
{
gint val;
val = (gint) adjustment->value;
if (tvals.constrain)
{
if ((tint.orig_width != 0) && (tint.orig_height != 0))
{
if ((GtkObject *) adjustment == tint.width_adj &&
tvals.new_width != val)
{
tvals.new_width = val;
tvals.new_height = (int) ((tvals.new_width * tint.orig_height) /
tint.orig_width);
gtk_signal_handler_block_by_data (GTK_OBJECT (tint.height_adj),
&tvals.new_height);
gtk_adjustment_set_value (GTK_ADJUSTMENT (tint.height_adj),
tvals.new_height);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (tint.height_adj),
&tvals.new_height);
}
else if ((GtkObject *) adjustment == tint.height_adj &&
tvals.new_height != val)
{
tvals.new_height = val;
tvals.new_width = (int) ((tvals.new_height * tint.orig_width) /
tint.orig_height);
gtk_signal_handler_block_by_data (GTK_OBJECT (tint.width_adj),
&tvals.new_width);
gtk_adjustment_set_value (GTK_ADJUSTMENT (tint.width_adj),
tvals.new_width);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (tint.width_adj),
&tvals.new_width);
}
}
}
else
{
*((int *) data) = val;
}
}