gimp/plug-ins/common/vpropagate.c

1110 lines
32 KiB
C
Raw Normal View History

1997-11-25 06:05:25 +08:00
/* vpropagate.c -- This is a plug-in for the GIMP (1.0's API)
* Author: Shuji Narazaki <narazaki@InetQ.or.jp>
* Time-stamp: <2000-01-09 15:50:46 yasuhiro>
* Version: 0.89a
1997-11-25 06:05:25 +08:00
*
* Copyright (C) 1996-1997 Shuji Narazaki <narazaki@InetQ.or.jp>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1997-11-25 06:05:25 +08:00
*/
/* memo
the initial value of each pixel is the value of the pixel itself.
To determine whether it is an isolated local peak point, use:
(self == min && (! modified_flag)) ; modified_flag holds history of update
In other word, pixel itself is not a neighbor of it.
*/
#include "config.h"
1997-11-25 06:05:25 +08:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
1997-11-25 06:05:25 +08:00
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "libgimp/stdplugins-intl.h"
1997-11-25 06:05:25 +08:00
#define PLUG_IN_NAME "plug_in_vpropagate"
#define SHORT_NAME "vpropagate"
#define VP_RGB (1 << 0)
#define VP_GRAY (1 << 1)
#define VP_WITH_ALPHA (1 << 2)
#define VP_WO_ALPHA (1 << 3)
1997-11-25 06:05:25 +08:00
#define num_direction 4
#define Right2Left 0
#define Bottom2Top 1
#define Left2Right 2
#define Top2Bottom 3
static void query (void);
static void run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static GimpPDBStatusType value_propagate (gint drawable_id);
static void value_propagate_body (gint drawable_id);
static int vpropagate_dialog (GimpImageBaseType image_type);
static void prepare_row (GimpPixelRgn *pixel_rgn,
guchar *data,
gint x,
gint y,
gint w);
static void vpropagate_ok_callback (GtkWidget *widget,
gpointer data);
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
static GtkWidget * gtk_table_add_toggle (GtkWidget *table,
gchar *name,
gint x1,
gint x2,
gint y,
GtkSignalFunc update,
gint *value);
static int value_difference_check (guchar *, guchar *, int);
static void set_value (GimpImageBaseType, int, guchar *, guchar *, guchar *, void *);
static void initialize_white (GimpImageBaseType, int, guchar *, guchar *, void **);
static void propagate_white (GimpImageBaseType, int, guchar *, guchar *, guchar *, void *);
static void initialize_black (GimpImageBaseType, int, guchar *, guchar *, void **);
static void propagate_black (GimpImageBaseType, int, guchar *, guchar *, guchar *, void *);
static void initialize_middle (GimpImageBaseType, int, guchar *, guchar *, void **);
static void propagate_middle (GimpImageBaseType, int, guchar *, guchar *, guchar *, void *);
static void set_middle_to_peak (GimpImageBaseType, int, guchar *, guchar *, guchar *, void *);
static void set_foreground_to_peak (GimpImageBaseType, int, guchar *, guchar *, guchar *, void *);
static void initialize_foreground (GimpImageBaseType, int, guchar *, guchar *, void **);
static void initialize_background (GimpImageBaseType, int, guchar *, guchar *, void **);
static void propagate_a_color (GimpImageBaseType, int, guchar *, guchar *, guchar *, void *);
static void propagate_opaque (GimpImageBaseType, int, guchar *, guchar *, guchar *, void *);
static void propagate_transparent (GimpImageBaseType, int, guchar *, guchar *, guchar *, void *);
GimpPlugInInfo PLUG_IN_INFO =
1997-11-25 06:05:25 +08:00
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
1997-11-25 06:05:25 +08:00
};
#define UPDATE_STEP 20
#define SCALE_WIDTH 100
#define PROPAGATING_VALUE 1<<0
#define PROPAGATING_ALPHA 1<<1
1997-11-25 06:05:25 +08:00
/* parameters */
typedef struct
{
gint propagate_mode;
gint propagating_channel;
gdouble propagating_rate;
gint direction_mask;
gint lower_limit;
gint upper_limit;
/* gint channel_mask[3]; */
/* gint peak_includes_equals; */
/* gint overwrite; */
} VPValueType;
static VPValueType vpvals =
{
0,
3, /* PROPAGATING_VALUE + PROPAGATING_ALPHA */
1.0, /* [0.0:1.0] */
15, /* propagate to all 4 directions */
0,
255
};
/* dialog vairables */
static gint propagate_alpha;
static gint propagate_value;
static gint direction_mask_vec[4];
static gint channel_mask[] = { 1, 1, 1 };
static gint peak_max = 1;
static gint peak_min = 1;
static gint peak_includes_equals = 1;
static guchar fore[3];
1997-11-25 06:05:25 +08:00
typedef struct
{
gint applicable_image_type;
gchar *name;
void (*initializer) ();
void (*updater) ();
void (*finalizer) ();
1997-11-25 06:05:25 +08:00
} ModeParam;
#define num_mode 8
static ModeParam modes[num_mode] =
{
{ VP_RGB | VP_GRAY | VP_WITH_ALPHA | VP_WO_ALPHA,
N_("More White (Larger Value)"),
initialize_white, propagate_white, set_value },
{ VP_RGB | VP_GRAY | VP_WITH_ALPHA | VP_WO_ALPHA,
N_("More Black (Smaller Value)"),
initialize_black, propagate_black, set_value },
{ VP_RGB | VP_GRAY | VP_WITH_ALPHA | VP_WO_ALPHA,
N_("Middle Value to Peaks"),
initialize_middle, propagate_middle, set_middle_to_peak },
{ VP_RGB | VP_GRAY | VP_WITH_ALPHA | VP_WO_ALPHA,
N_("Foreground to Peaks"),
initialize_middle, propagate_middle, set_foreground_to_peak },
{ VP_RGB | VP_WITH_ALPHA | VP_WO_ALPHA,
N_("Only Foreground"),
initialize_foreground, propagate_a_color, set_value },
{ VP_RGB | VP_WITH_ALPHA | VP_WO_ALPHA,
N_("Only Background"),
initialize_background, propagate_a_color, set_value },
{ VP_RGB | VP_GRAY | VP_WITH_ALPHA,
N_("More Opaque"),
NULL, propagate_opaque, set_value },
{ VP_RGB | VP_GRAY | VP_WITH_ALPHA,
N_("More Transparent"),
NULL, propagate_transparent, set_value },
1997-11-25 06:05:25 +08:00
};
typedef struct
{
gint run;
} VPInterface;
static VPInterface vpropagate_interface = { FALSE };
static gint drawable_id;
1997-11-25 06:05:25 +08:00
MAIN ()
1997-11-25 06:05:25 +08:00
static void
query (void)
1997-11-25 06:05:25 +08:00
{
static GimpParamDef args[] =
1997-11-25 06:05:25 +08:00
{
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
{ GIMP_PDB_IMAGE, "image", "Input image (not used)" },
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
{ GIMP_PDB_INT32, "propagate-mode", "propagate 0:white, 1:black, 2:middle value 3:foreground to peak, 4:foreground, 5:background, 6:opaque, 7:transparent" },
{ GIMP_PDB_INT32, "propagating-channel", "channels which values are propagated" },
{ GIMP_PDB_FLOAT, "propagating-rate", "0.0 <= propagatating_rate <= 1.0" },
{ GIMP_PDB_INT32, "direction-mask", "0 <= direction-mask <= 15" },
{ GIMP_PDB_INT32, "lower-limit", "0 <= lower-limit <= 255" },
{ GIMP_PDB_INT32, "upper-limit", "0 <= upper-limit <= 255" }
1997-11-25 06:05:25 +08:00
};
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
static gint nargs = sizeof (args) / sizeof (args[0]);
1997-11-25 06:05:25 +08:00
gimp_install_procedure (PLUG_IN_NAME,
"Propagate values of the layer",
"Propagate values of the layer",
1997-11-25 06:05:25 +08:00
"Shuji Narazaki (narazaki@InetQ.or.jp)",
"Shuji Narazaki",
"1996-1997",
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
N_("<Image>/Filters/Distorts/Value Propagate..."),
"RGB*,GRAY*",
GIMP_PLUGIN,
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
nargs, 0,
args, NULL);
1997-11-25 06:05:25 +08:00
}
static void
run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
1997-11-25 06:05:25 +08:00
{
static GimpParam values[1];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
GimpRunModeType run_mode;
1997-11-25 06:05:25 +08:00
run_mode = param[0].data.d_int32;
drawable_id = param[2].data.d_int32;
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
1997-11-25 06:05:25 +08:00
values[0].data.d_status = status;
switch (run_mode)
1997-11-25 06:05:25 +08:00
{
case GIMP_RUN_INTERACTIVE:
INIT_I18N_UI();
1997-11-25 06:05:25 +08:00
gimp_get_data (PLUG_IN_NAME, &vpvals);
/* building the values of dialog variables from vpvals. */
propagate_alpha =
(vpvals.propagating_channel & PROPAGATING_ALPHA) ? TRUE : FALSE;
propagate_value =
(vpvals.propagating_channel & PROPAGATING_VALUE) ? TRUE : FALSE;
1997-11-25 06:05:25 +08:00
{
int i;
for (i = 0; i < 4; i++)
direction_mask_vec[i] = (vpvals.direction_mask & (1 << i))
? TRUE : FALSE;
}
if (! vpropagate_dialog (gimp_drawable_type(drawable_id)))
return;
break;
case GIMP_RUN_NONINTERACTIVE:
INIT_I18N();
1997-11-25 06:05:25 +08:00
vpvals.propagate_mode = param[3].data.d_int32;
vpvals.propagating_channel = param[4].data.d_int32;
vpvals.propagating_rate = param[5].data.d_float;
vpvals.direction_mask = param[6].data.d_int32;
vpvals.lower_limit = param[7].data.d_int32;
vpvals.upper_limit = param[8].data.d_int32;
break;
case GIMP_RUN_WITH_LAST_VALS:
INIT_I18N();
1997-11-25 06:05:25 +08:00
gimp_get_data (PLUG_IN_NAME, &vpvals);
break;
}
status = value_propagate (drawable_id);
if (run_mode != GIMP_RUN_NONINTERACTIVE)
1997-11-25 06:05:25 +08:00
gimp_displays_flush();
if (run_mode == GIMP_RUN_INTERACTIVE && status == GIMP_PDB_SUCCESS)
1997-11-25 06:05:25 +08:00
gimp_set_data (PLUG_IN_NAME, &vpvals, sizeof (VPValueType));
values[0].type = GIMP_PDB_STATUS;
1997-11-25 06:05:25 +08:00
values[0].data.d_status = status;
}
/* registered function entry */
static GimpPDBStatusType
value_propagate (gint drawable_id)
1997-11-25 06:05:25 +08:00
{
/* check the validness of parameters */
if (!(vpvals.propagating_channel & (PROPAGATING_VALUE | PROPAGATING_ALPHA)))
{
/* gimp_message ("No channel selected."); */
return GIMP_PDB_EXECUTION_ERROR;
1997-11-25 06:05:25 +08:00
}
if (vpvals.direction_mask == 0)
{
/* gimp_message ("No direction selected."); */
return GIMP_PDB_EXECUTION_ERROR;
1997-11-25 06:05:25 +08:00
}
if ((vpvals.lower_limit < 0) || (255 < vpvals.lower_limit) ||
1997-11-25 06:05:25 +08:00
(vpvals.upper_limit < 0) || (255 < vpvals.lower_limit) ||
(vpvals.upper_limit < vpvals.lower_limit))
1997-11-25 06:05:25 +08:00
{
/* gimp_message ("Limit values are not valid."); */
return GIMP_PDB_EXECUTION_ERROR;
1997-11-25 06:05:25 +08:00
}
value_propagate_body (drawable_id);
return GIMP_PDB_SUCCESS;
1997-11-25 06:05:25 +08:00
}
static void
value_propagate_body (gint drawable_id)
1997-11-25 06:05:25 +08:00
{
GimpDrawable *drawable;
GimpImageBaseType dtype;
ModeParam operation;
GimpPixelRgn srcRgn, destRgn;
guchar *here, *best, *dest;
guchar *dest_row, *prev_row, *cur_row, *next_row, *pr, *cr, *nr, *swap;
gint width, height, bytes, index;
gint begx, begy, endx, endy, x, y, dx;
gint left_index, right_index, up_index, down_index;
void *tmp;
GimpRGB foreground;
1997-11-25 06:05:25 +08:00
/* calculate neighbors' indexes */
left_index = (vpvals.direction_mask & (1 << Left2Right)) ? -1 : 0;
right_index = (vpvals.direction_mask & (1 << Right2Left)) ? 1 : 0;
up_index = (vpvals.direction_mask & (1 << Top2Bottom)) ? -1 : 0;
down_index = (vpvals.direction_mask & (1 << Bottom2Top)) ? 1 : 0;
operation = modes[vpvals.propagate_mode];
tmp = NULL;
drawable = gimp_drawable_get (drawable_id);
dtype = gimp_drawable_type (drawable_id);
/* Here I use the algorithm of blur.c . */
gimp_drawable_mask_bounds (drawable->drawable_id, &begx, &begy, &endx, &endy);
1997-11-25 06:05:25 +08:00
width = drawable->width;
height = drawable->height;
bytes = drawable->bpp;
prev_row = g_new (guchar, (endx - begx + 2) * bytes);
cur_row = g_new (guchar, (endx - begx + 2) * bytes);
next_row = g_new (guchar, (endx - begx + 2) * bytes);
dest_row = g_new (guchar, (endx - begx) * bytes);
1997-11-25 06:05:25 +08:00
gimp_pixel_rgn_init (&srcRgn, drawable, 0, 0, width, height, FALSE, FALSE);
gimp_pixel_rgn_init (&destRgn, drawable, 0, 0, width, height, TRUE, TRUE);
pr = prev_row + bytes;
cr = cur_row + bytes;
nr = next_row + bytes;
prepare_row (&srcRgn, pr, begx, (0 < begy) ? begy : begy - 1, endx-begx);
prepare_row (&srcRgn, cr, begx, begy, endx-begx);
best = g_new (guchar, bytes);
1997-11-25 06:05:25 +08:00
gimp_progress_init (_("Value propagating..."));
tools/pdbgen/lib.pl tools/pdbgen/pdb.pl tools/pdbgen/pdb/channel.pdb 2001-01-25 Sven Neumann <sven@gimp.org> * tools/pdbgen/lib.pl * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: changed these with the help of Yosh. PDB functions take GimpRGB as color type now. * app/plug_in.c * app/pdb/channel_cmds.c * app/pdb/internal_procs.c * app/pdb/palette_cmds.c * app/pdb/procedural_db.[ch] * app/pdb/tools_cmds.c * libgimp/gimp.[ch] * libgimp/gimpchannel.[ch] * libgimp/gimpchannel_pdb.[ch] * libgimp/gimppalette_pdb.[ch] * libgimp/gimpprotocol.[ch] * libgimp/gimptools_pdb.[ch]: incremented Gimp protocol version and changed color type from array of chars to GimpRGB. * libgimp/Makefile.am * libgimp/gimppalette.[ch]: removed these files again * app/libgimp_glue.[ch] * libgimpwidgets/gimpcolorbutton.c * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_preview.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/psd.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/tiff.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gap/gap_filter_iterators.c * plug-ins/gap/gap_mov_dialog.c * plug-ins/gdyntext/gdyntext.c * plug-ins/gfig/gfig.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu.c * plug-ins/xjt/xjt.c: changed accordingly. A few plug-ins need to be looked at more closely after this change. I tried to put FIXME comments into those.
2001-01-25 09:20:05 +08:00
gimp_palette_get_foreground (&foreground);
gimp_rgb_get_uchar (&foreground, fore+0, fore+1, fore+2);
1997-11-25 06:05:25 +08:00
/* start real job */
for (y = begy ; y < endy ; y++)
1997-11-25 06:05:25 +08:00
{
prepare_row (&srcRgn, nr, begx, ((y+1) < endy) ? y+1 : endy, endx-begx);
for (index = 0; index < (endx - begx) * bytes; index++)
dest_row[index] = cr[index];
for (x = 0 ; x < endx - begx; x++)
1997-11-25 06:05:25 +08:00
{
dest = dest_row + (x * bytes);
here = cr + (x * bytes);
/* *** copy source value to best value holder *** */
1998-03-21 10:17:49 +08:00
memcpy ((void *)best, (void *)here, bytes);
if (operation.initializer)
1997-11-25 06:05:25 +08:00
(* operation.initializer)(dtype, bytes, best, here, &tmp);
/* *** gather neighbors' values: loop-unfolded version *** */
if (up_index == -1)
for (dx = left_index ; dx <= right_index ; dx++)
(* operation.updater)(dtype, bytes, here, pr+((x+dx)*bytes), best, tmp);
for (dx = left_index ; dx <= right_index ; dx++)
if (dx != 0)
1997-11-25 06:05:25 +08:00
(* operation.updater)(dtype, bytes, here, cr+((x+dx)*bytes), best, tmp);
if (down_index == 1)
for (dx = left_index ; dx <= right_index ; dx++)
(* operation.updater)(dtype, bytes, here, nr+((x+dx)*bytes), best, tmp);
/* *** store it to dest_row*** */
(* operation.finalizer)(dtype, bytes, best, here, dest, tmp);
}
/* now store destline to destRgn */
gimp_pixel_rgn_set_row (&destRgn, dest_row, begx, y, endx - begx);
/* shift the row pointers */
swap = pr;
pr = cr;
cr = nr;
nr = swap;
/* update each UPDATE_STEP (optimizer must generate cheap code) */
if ((y % 5) == 0) /*(y % (int) ((endy - begy) / UPDATE_STEP)) == 0 */
gimp_progress_update ((double)y / (double)(endy - begy));
}
/* update the region */
gimp_progress_update(1.0);
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
gimp_drawable_update (drawable->drawable_id, begx, begy, endx-begx, endy-begy);
1997-11-25 06:05:25 +08:00
}
static void
prepare_row (GimpPixelRgn *pixel_rgn,
1997-11-25 06:05:25 +08:00
guchar *data,
gint x,
gint y,
gint w)
1997-11-25 06:05:25 +08:00
{
gint b;
1997-11-25 06:05:25 +08:00
if (y == 0)
gimp_pixel_rgn_get_row (pixel_rgn, data, x, (y + 1), w);
else if (y == pixel_rgn->h)
gimp_pixel_rgn_get_row (pixel_rgn, data, x, (y - 1), w);
else
gimp_pixel_rgn_get_row (pixel_rgn, data, x, y, w);
/* Fill in edge pixels */
for (b = 0; b < pixel_rgn->bpp; b++)
{
data[-(gint)pixel_rgn->bpp + b] = data[b];
1997-11-25 06:05:25 +08:00
data[w * pixel_rgn->bpp + b] = data[(w - 1) * pixel_rgn->bpp + b];
}
}
static void
set_value (GimpImageBaseType dtype,
gint bytes,
guchar *best,
guchar *here,
guchar *dest,
void *tmp)
1997-11-25 06:05:25 +08:00
{
gint value_chs = 0;
gint alpha = 0;
gint ch;
1997-11-25 06:05:25 +08:00
switch (dtype)
1997-11-25 06:05:25 +08:00
{
case GIMP_RGB_IMAGE:
1997-11-25 06:05:25 +08:00
value_chs = 3;
break;
case GIMP_RGBA_IMAGE:
1997-11-25 06:05:25 +08:00
value_chs = 3;
alpha = 3;
break;
case GIMP_GRAY_IMAGE:
1997-11-25 06:05:25 +08:00
value_chs = 1;
break;
case GIMP_GRAYA_IMAGE:
1997-11-25 06:05:25 +08:00
value_chs = 1;
alpha = 1;
break;
default:
break;
}
for (ch = 0; ch < value_chs; ch++)
{
if (vpvals.propagating_channel & PROPAGATING_VALUE) /* value channel */
*dest++ = (guchar)(vpvals.propagating_rate * best[ch]
1997-11-25 06:05:25 +08:00
+ (1.0 - vpvals.propagating_rate) * here[ch]);
else
*dest++ = here[ch];
}
if (alpha)
1997-11-25 06:05:25 +08:00
{
if (vpvals.propagating_channel & PROPAGATING_ALPHA) /* alpha channel */
*dest++ = (guchar)(vpvals.propagating_rate * best[alpha]
1997-11-25 06:05:25 +08:00
+ (1.0 - vpvals.propagating_rate) * here[alpha]);
else
*dest++ = here[alpha];
}
}
static int
value_difference_check (guchar *pos1,
guchar *pos2,
gint ch)
1997-11-25 06:05:25 +08:00
{
gint index;
1997-11-25 06:05:25 +08:00
int diff;
for (index = 0 ; index < ch; index++)
if (channel_mask[index] != 0)
1997-11-25 06:05:25 +08:00
{
diff = abs(pos1[index] - pos2[index]);
if (! ((vpvals.lower_limit <= diff) && (diff <= vpvals.upper_limit)))
1997-11-25 06:05:25 +08:00
return 0;
}
return 1;
}
/* mothods for each mode */
static void
initialize_white (GimpImageBaseType dtype,
gint bytes,
guchar *best,
guchar *here,
void **tmp)
1997-11-25 06:05:25 +08:00
{
if (*tmp == NULL)
*tmp = (void *) g_new (gfloat, 1);
1997-11-25 06:05:25 +08:00
*(float *)*tmp = sqrt (channel_mask[0] * here[0] * here[0]
+ channel_mask[1] * here[1] * here[1]
+ channel_mask[2] * here[2] * here[2]);
}
static void
propagate_white (GimpImageBaseType dtype,
gint bytes,
guchar *orig,
guchar *here,
guchar *best,
void *tmp)
1997-11-25 06:05:25 +08:00
{
float v_here;
switch (dtype)
1997-11-25 06:05:25 +08:00
{
case GIMP_RGB_IMAGE:
case GIMP_RGBA_IMAGE:
1997-11-25 06:05:25 +08:00
v_here = sqrt (channel_mask[0] * here[0] * here[0]
+ channel_mask[1] * here[1] * here[1]
+ channel_mask[2] * here[2] * here[2]);
if (*(float *)tmp < v_here && value_difference_check(orig, here, 3))
1997-11-25 06:05:25 +08:00
{
*(float *)tmp = v_here;
memcpy(best, here, 3 * sizeof(guchar)); /* alpha channel holds old value */
1997-11-25 06:05:25 +08:00
}
break;
case GIMP_GRAYA_IMAGE:
case GIMP_GRAY_IMAGE:
if (*best < *here && value_difference_check(orig, here, 1))
1997-11-25 06:05:25 +08:00
*best = *here;
break;
default:
break;
}
}
static void
initialize_black (GimpImageBaseType dtype,
gint channels,
guchar *best,
guchar *here,
void **tmp)
1997-11-25 06:05:25 +08:00
{
if (*tmp == NULL)
*tmp = (void *) g_new (gfloat, 1);
1997-11-25 06:05:25 +08:00
*(float *)*tmp = sqrt (channel_mask[0] * here[0] * here[0]
+ channel_mask[1] * here[1] * here[1]
+ channel_mask[2] * here[2] * here[2]);
}
static void
propagate_black (GimpImageBaseType image_type,
gint channels,
guchar *orig,
guchar *here,
guchar *best,
void *tmp)
1997-11-25 06:05:25 +08:00
{
float v_here;
switch (image_type)
1997-11-25 06:05:25 +08:00
{
case GIMP_RGB_IMAGE:
case GIMP_RGBA_IMAGE:
1997-11-25 06:05:25 +08:00
v_here = sqrt (channel_mask[0] * here[0] * here[0]
+ channel_mask[1] * here[1] * here[1]
+ channel_mask[2] * here[2] * here[2]);
if (v_here < *(float *)tmp && value_difference_check(orig, here, 3))
1997-11-25 06:05:25 +08:00
{
*(float *)tmp = v_here;
memcpy (best, here, 3 * sizeof(guchar)); /* alpha channel holds old value */
1997-11-25 06:05:25 +08:00
}
break;
case GIMP_GRAYA_IMAGE:
case GIMP_GRAY_IMAGE:
if (*here < *best && value_difference_check(orig, here, 1))
1997-11-25 06:05:25 +08:00
*best = *here;
break;
default:
break;
}
}
typedef struct
{
gshort min_modified;
gshort max_modified;
glong original_value;
glong minv;
guchar min[3];
glong maxv;
guchar max[3];
1997-11-25 06:05:25 +08:00
} MiddlePacket;
static void
initialize_middle (GimpImageBaseType image_type,
gint channels,
guchar *best,
guchar *here,
void **tmp)
1997-11-25 06:05:25 +08:00
{
int index;
MiddlePacket *data;
if (*tmp == NULL)
*tmp = (void *) g_new (MiddlePacket, 1);
1997-11-25 06:05:25 +08:00
data = (MiddlePacket *)*tmp;
for (index = 0; index < channels; index++)
data->min[index] = data->max[index] = here[index];
switch (image_type)
1997-11-25 06:05:25 +08:00
{
case GIMP_RGB_IMAGE:
case GIMP_RGBA_IMAGE:
1997-11-25 06:05:25 +08:00
data->original_value = sqrt (channel_mask[0] * here[0] * here[0]
+ channel_mask[1] * here[1] * here[1]
+ channel_mask[2] * here[2] * here[2]);
break;
case GIMP_GRAYA_IMAGE:
case GIMP_GRAY_IMAGE:
1997-11-25 06:05:25 +08:00
data->original_value = *here;
break;
default:
break;
}
data->minv = data->maxv = data->original_value;
data->min_modified = data->max_modified = 0;
}
static void
propagate_middle (GimpImageBaseType image_type,
gint channels,
guchar *orig,
guchar *here,
guchar *best,
void *tmp)
1997-11-25 06:05:25 +08:00
{
float v_here;
MiddlePacket *data;
data = (MiddlePacket *)tmp;
switch (image_type)
1997-11-25 06:05:25 +08:00
{
case GIMP_RGB_IMAGE:
case GIMP_RGBA_IMAGE:
1997-11-25 06:05:25 +08:00
v_here = sqrt (channel_mask[0] * here[0] * here[0]
+ channel_mask[1] * here[1] * here[1]
+ channel_mask[2] * here[2] * here[2]);
if ((v_here <= data->minv) && value_difference_check(orig, here, 3))
1997-11-25 06:05:25 +08:00
{
data->minv = v_here;
memcpy (data->min, here, 3*sizeof(guchar));
1997-11-25 06:05:25 +08:00
data->min_modified = 1;
}
if (data->maxv <= v_here && value_difference_check(orig, here, 3))
1997-11-25 06:05:25 +08:00
{
data->maxv = v_here;
memcpy (data->max, here, 3*sizeof(guchar));
1997-11-25 06:05:25 +08:00
data->max_modified = 1;
}
break;
case GIMP_GRAYA_IMAGE:
case GIMP_GRAY_IMAGE:
if ((*here <= data->min[0]) && value_difference_check(orig, here, 1))
1997-11-25 06:05:25 +08:00
{
data->min[0] = *here;
data->min_modified = 1;
}
if ((data->max[0] <= *here) && value_difference_check(orig, here, 1))
1997-11-25 06:05:25 +08:00
{
data->max[0] = *here;
data->max_modified = 1;
}
break;
default:
break;
}
}
static void
set_middle_to_peak (GimpImageBaseType image_type,
gint channels,
guchar *here,
guchar *best,
guchar *dest,
void *tmp)
1997-11-25 06:05:25 +08:00
{
gint value_chs = 0;
gint alpha = 0;
gint ch;
1997-11-25 06:05:25 +08:00
MiddlePacket *data;
data = (MiddlePacket *)tmp;
if (! ((peak_min & (data->minv == data->original_value))
|| (peak_max & (data->maxv == data->original_value))))
1997-11-25 06:05:25 +08:00
return;
if ((! peak_includes_equals)
&& ((peak_min & (! data->min_modified))
|| (peak_max & (! data->max_modified))))
return;
switch (image_type)
1997-11-25 06:05:25 +08:00
{
case GIMP_RGB_IMAGE:
1997-11-25 06:05:25 +08:00
value_chs = 3;
break;
case GIMP_RGBA_IMAGE:
1997-11-25 06:05:25 +08:00
value_chs = 3;
alpha = 3;
break;
case GIMP_GRAY_IMAGE:
1997-11-25 06:05:25 +08:00
value_chs = 1;
break;
case GIMP_GRAYA_IMAGE:
1997-11-25 06:05:25 +08:00
value_chs = 1;
alpha = 1;
break;
default:
break;
}
for (ch = 0; ch < value_chs; ch++)
{
if (vpvals.propagating_channel & PROPAGATING_VALUE) /* value channel */
*dest++ = (guchar)(vpvals.propagating_rate * 0.5 * (data->min[ch] + data->max[ch])
1997-11-25 06:05:25 +08:00
+ (1.0 - vpvals.propagating_rate) * here[ch]);
else
*dest++ = here[ch];
}
if (alpha)
1997-11-25 06:05:25 +08:00
{
if (vpvals.propagating_channel & PROPAGATING_ALPHA) /* alpha channel */
*dest++ = (guchar)(vpvals.propagating_rate * best[alpha]
1997-11-25 06:05:25 +08:00
+ (1.0 - vpvals.propagating_rate) * here[alpha]);
else
*dest++ = here[alpha];
}
}
static void
set_foreground_to_peak (GimpImageBaseType image_type,
gint channels,
guchar *here,
guchar *best,
guchar *dest,
void *tmp)
1997-11-25 06:05:25 +08:00
{
gint value_chs = 0;
gint alpha = 0;
gint ch;
1997-11-25 06:05:25 +08:00
MiddlePacket *data;
data = (MiddlePacket *)tmp;
if (! ((peak_min & (data->minv == data->original_value))
|| (peak_max & (data->maxv == data->original_value))))
1997-11-25 06:05:25 +08:00
return;
if (peak_includes_equals
&& ((peak_min & (! data->min_modified))
|| (peak_max & (! data->max_modified))))
return;
switch (image_type)
1997-11-25 06:05:25 +08:00
{
case GIMP_RGB_IMAGE:
1997-11-25 06:05:25 +08:00
value_chs = 3;
break;
case GIMP_RGBA_IMAGE:
1997-11-25 06:05:25 +08:00
value_chs = 3;
alpha = 3;
break;
case GIMP_GRAY_IMAGE:
1997-11-25 06:05:25 +08:00
value_chs = 1;
break;
case GIMP_GRAYA_IMAGE:
1997-11-25 06:05:25 +08:00
value_chs = 1;
alpha = 1;
break;
default:
break;
}
for (ch = 0; ch < value_chs; ch++)
{
if (vpvals.propagating_channel & PROPAGATING_VALUE) /* value channel */
*dest++ = (guchar)(vpvals.propagating_rate*fore[ch]
1997-11-25 06:05:25 +08:00
+ (1.0 - vpvals.propagating_rate)*here[ch]);
else
*dest++ = here[ch];
}
}
static void
initialize_foreground (GimpImageBaseType image_type,
gint channels,
guchar *here,
guchar *best,
void **tmp)
1997-11-25 06:05:25 +08:00
{
GimpRGB foreground;
guchar *ch;
1997-11-25 06:05:25 +08:00
if (*tmp == NULL)
{
*tmp = (void *) g_new (guchar, 3);
ch = (guchar *)*tmp;
tools/pdbgen/lib.pl tools/pdbgen/pdb.pl tools/pdbgen/pdb/channel.pdb 2001-01-25 Sven Neumann <sven@gimp.org> * tools/pdbgen/lib.pl * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: changed these with the help of Yosh. PDB functions take GimpRGB as color type now. * app/plug_in.c * app/pdb/channel_cmds.c * app/pdb/internal_procs.c * app/pdb/palette_cmds.c * app/pdb/procedural_db.[ch] * app/pdb/tools_cmds.c * libgimp/gimp.[ch] * libgimp/gimpchannel.[ch] * libgimp/gimpchannel_pdb.[ch] * libgimp/gimppalette_pdb.[ch] * libgimp/gimpprotocol.[ch] * libgimp/gimptools_pdb.[ch]: incremented Gimp protocol version and changed color type from array of chars to GimpRGB. * libgimp/Makefile.am * libgimp/gimppalette.[ch]: removed these files again * app/libgimp_glue.[ch] * libgimpwidgets/gimpcolorbutton.c * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_preview.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/psd.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/tiff.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gap/gap_filter_iterators.c * plug-ins/gap/gap_mov_dialog.c * plug-ins/gdyntext/gdyntext.c * plug-ins/gfig/gfig.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu.c * plug-ins/xjt/xjt.c: changed accordingly. A few plug-ins need to be looked at more closely after this change. I tried to put FIXME comments into those.
2001-01-25 09:20:05 +08:00
gimp_palette_get_foreground (&foreground);
gimp_rgb_get_uchar (&foreground, &ch[0], &ch[1], &ch[2]);
1997-11-25 06:05:25 +08:00
}
}
static void
initialize_background (GimpImageBaseType image_type,
gint channels,
guchar *here,
guchar *best,
void **tmp)
1997-11-25 06:05:25 +08:00
{
GimpRGB background;
guchar *ch;
1997-11-25 06:05:25 +08:00
if (*tmp == NULL)
{
*tmp = (void *) g_new (guchar, 3);
ch = (guchar *)*tmp;
tools/pdbgen/lib.pl tools/pdbgen/pdb.pl tools/pdbgen/pdb/channel.pdb 2001-01-25 Sven Neumann <sven@gimp.org> * tools/pdbgen/lib.pl * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: changed these with the help of Yosh. PDB functions take GimpRGB as color type now. * app/plug_in.c * app/pdb/channel_cmds.c * app/pdb/internal_procs.c * app/pdb/palette_cmds.c * app/pdb/procedural_db.[ch] * app/pdb/tools_cmds.c * libgimp/gimp.[ch] * libgimp/gimpchannel.[ch] * libgimp/gimpchannel_pdb.[ch] * libgimp/gimppalette_pdb.[ch] * libgimp/gimpprotocol.[ch] * libgimp/gimptools_pdb.[ch]: incremented Gimp protocol version and changed color type from array of chars to GimpRGB. * libgimp/Makefile.am * libgimp/gimppalette.[ch]: removed these files again * app/libgimp_glue.[ch] * libgimpwidgets/gimpcolorbutton.c * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_preview.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/psd.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/tiff.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gap/gap_filter_iterators.c * plug-ins/gap/gap_mov_dialog.c * plug-ins/gdyntext/gdyntext.c * plug-ins/gfig/gfig.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu.c * plug-ins/xjt/xjt.c: changed accordingly. A few plug-ins need to be looked at more closely after this change. I tried to put FIXME comments into those.
2001-01-25 09:20:05 +08:00
gimp_palette_get_background (&background);
gimp_rgb_get_uchar (&background, &ch[0], &ch[1], &ch[2]);
1997-11-25 06:05:25 +08:00
}
}
static void
propagate_a_color (GimpImageBaseType image_type,
gint channels,
guchar *orig,
guchar *here,
guchar *best,
void *tmp)
1997-11-25 06:05:25 +08:00
{
guchar *fg = (guchar *)tmp;
1997-11-25 06:05:25 +08:00
switch (image_type)
1997-11-25 06:05:25 +08:00
{
case GIMP_RGB_IMAGE:
case GIMP_RGBA_IMAGE:
if (here[0] == fg[0] && here[1] == fg[1] && here[2] == fg[2] &&
value_difference_check(orig, here, 3))
{
memcpy (best, here, 3 * sizeof(guchar)); /* alpha channel holds old value */
1997-11-25 06:05:25 +08:00
}
break;
case GIMP_GRAYA_IMAGE:
case GIMP_GRAY_IMAGE:
1997-11-25 06:05:25 +08:00
break;
default:
break;
}
}
static void
propagate_opaque (GimpImageBaseType image_type,
gint channels,
guchar *orig,
guchar *here,
guchar *best,
void *tmp)
1997-11-25 06:05:25 +08:00
{
switch (image_type)
1997-11-25 06:05:25 +08:00
{
case GIMP_RGBA_IMAGE:
if (best[3] < here[3] && value_difference_check(orig, here, 3))
memcpy(best, here, channels * sizeof(guchar));
1997-11-25 06:05:25 +08:00
break;
case GIMP_GRAYA_IMAGE:
if (best[1] < here[1] && value_difference_check(orig, here, 1))
memcpy(best, here, channels * sizeof(guchar));
1997-11-25 06:05:25 +08:00
break;
default:
break;
}
}
static void
propagate_transparent (GimpImageBaseType image_type,
gint channels,
guchar *orig,
guchar *here,
guchar *best,
void *tmp)
1997-11-25 06:05:25 +08:00
{
switch (image_type)
1997-11-25 06:05:25 +08:00
{
case GIMP_RGBA_IMAGE:
if (here[3] < best[3] && value_difference_check(orig, here, 3))
memcpy(best, here, channels * sizeof(guchar));
1997-11-25 06:05:25 +08:00
break;
case GIMP_GRAYA_IMAGE:
if (here[1] < best[1] && value_difference_check(orig, here, 1))
memcpy(best, here, channels * sizeof(guchar));
1997-11-25 06:05:25 +08:00
break;
default:
break;
}
}
/* dialog stuff */
static int
vpropagate_dialog (GimpImageBaseType image_type)
1997-11-25 06:05:25 +08:00
{
GtkWidget *dlg;
GtkWidget *hbox;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *toggle_vbox;
GtkWidget *button;
1997-11-25 06:05:25 +08:00
GtkWidget *sep;
GtkObject *adj;
GSList *group = NULL;
gint index = 0;
1997-11-25 06:05:25 +08:00
gimp_ui_init ("vpropagate", FALSE);
dlg = gimp_dialog_new (_("Value Propagate"), "vpropagate",
gimp_standard_help_func, "filters/vpropagate.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
2001-08-04 03:52:08 +08:00
GTK_STOCK_OK, vpropagate_ok_callback,
NULL, NULL, NULL, TRUE, FALSE,
2001-08-04 03:52:08 +08:00
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
NULL);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
GTK_SIGNAL_FUNC (gtk_main_quit),
NULL);
hbox = gtk_hbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
1997-11-25 06:05:25 +08:00
/* Propagate Mode */
frame = gtk_frame_new (_("Propagate Mode"));
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
1997-11-25 06:05:25 +08:00
toggle_vbox = gtk_vbox_new (FALSE, 1);
gtk_container_set_border_width (GTK_CONTAINER (toggle_vbox), 2);
gtk_container_add (GTK_CONTAINER (frame), toggle_vbox);
1997-11-25 06:05:25 +08:00
for (index = 0; index < num_mode; index++)
{
button = gtk_radio_button_new_with_label (group,
gettext (modes[index].name));
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
gtk_box_pack_start (GTK_BOX (toggle_vbox), button, FALSE, FALSE, 0);
gtk_object_set_user_data (GTK_OBJECT (button), (gpointer) index);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
GTK_SIGNAL_FUNC (gimp_radio_button_update),
&vpvals.propagate_mode);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
index == vpvals.propagate_mode);
gtk_widget_show (button);
}
gtk_widget_show (toggle_vbox);
gtk_widget_show (frame);
1997-11-25 06:05:25 +08:00
/* Parameter settings */
frame = gtk_frame_new (_("Parameter Settings"));
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
table = gtk_table_new (10, 3, FALSE); /* 4 raw, 2 columns(name and value) */
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
added -DGTK_DISABLE_COMPAT_H to CPPFLAGS. 2000-08-28 Michael Natterer <mitch@gimp.org> * configure.in: added -DGTK_DISABLE_COMPAT_H to CPPFLAGS. * app/app_procs.c * app/gdisplay.c * app/layers_dialog.c * app/menus.c * app/tips_dialog.c * libgimp/gimpcolorbutton.c * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/bmp/bmpwrite.c * plug-ins/common/AlienMap.c * plug-ins/common/AlienMap2.c * plug-ins/common/CML_explorer.c * plug-ins/common/animationplay.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/deinterlace.c * plug-ins/common/gee.c * plug-ins/common/glasstile.c * plug-ins/common/iwarp.c * plug-ins/common/mail.c * plug-ins/common/pat.c * plug-ins/common/pixelize.c * plug-ins/common/plugindetails.c * plug-ins/common/png.c * plug-ins/common/sample_colorize.c * plug-ins/common/sel_gauss.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/tga.c * plug-ins/common/tileit.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/waves.c * plug-ins/common/wmf.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/gap/gap_arr_dialog.c * plug-ins/gap/gap_dbbrowser_utils.c * plug-ins/gap/gap_mov_dialog.c * plug-ins/gap/gap_navigator_dialog.c * plug-ins/gap/gap_resi_dialog.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/gfig/gfig.c * plug-ins/gimpressionist/brush.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/gimp_main_window.c * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/xjt/xjt.c: removed COMPAT_CRUFT.
2000-08-28 08:42:32 +08:00
gtk_container_set_border_width (GTK_CONTAINER (table), 4);
1997-11-25 06:05:25 +08:00
gtk_container_add (GTK_CONTAINER (frame), table);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("Lower Threshold:"), SCALE_WIDTH, 0,
vpvals.lower_limit, 0, 255, 1, 8, 0,
TRUE, 0, 0,
NULL, NULL);
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
GTK_SIGNAL_FUNC (gimp_int_adjustment_update),
&vpvals.lower_limit);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("Upper Threshold:"), SCALE_WIDTH, 0,
vpvals.upper_limit, 0, 255, 1, 8, 0,
TRUE, 0, 0,
NULL, NULL);
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
GTK_SIGNAL_FUNC (gimp_int_adjustment_update),
&vpvals.upper_limit);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
_("Propagating Rate:"), SCALE_WIDTH, 0,
vpvals.propagating_rate, 0, 1, 0.01, 0.1, 2,
TRUE, 0, 0,
NULL, NULL);
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
GTK_SIGNAL_FUNC (gimp_double_adjustment_update),
&vpvals.propagating_rate);
1997-11-25 06:05:25 +08:00
sep = gtk_hseparator_new ();
gtk_table_attach (GTK_TABLE (table), sep, 0, 3, 3, 4, GTK_FILL, 0, 0, 0);
1997-11-25 06:05:25 +08:00
gtk_widget_show (sep);
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
gtk_table_add_toggle (table, _("To Left"), 0, 1, 5,
GTK_SIGNAL_FUNC (gimp_toggle_button_update),
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
&direction_mask_vec[Right2Left]);
gtk_table_add_toggle (table, _("To Right"), 2, 3, 5,
GTK_SIGNAL_FUNC (gimp_toggle_button_update),
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
&direction_mask_vec[Left2Right]);
gtk_table_add_toggle (table, _("To Top"), 1, 2, 4,
GTK_SIGNAL_FUNC (gimp_toggle_button_update),
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
&direction_mask_vec[Bottom2Top]);
gtk_table_add_toggle (table, _("To Bottom"), 1, 2, 6,
GTK_SIGNAL_FUNC (gimp_toggle_button_update),
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
&direction_mask_vec[Top2Bottom]);
if ((image_type == GIMP_RGBA_IMAGE) | (image_type == GIMP_GRAYA_IMAGE))
1997-11-25 06:05:25 +08:00
{
sep = gtk_hseparator_new ();
gtk_table_attach (GTK_TABLE (table), sep, 0, 3, 7, 8, GTK_FILL, 0, 0, 0);
1997-11-25 06:05:25 +08:00
gtk_widget_show (sep);
{
GtkWidget *toggle;
toggle =
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
gtk_table_add_toggle (table, _("Propagating Alpha Channel"),
0, 3, 8,
(GtkSignalFunc) gimp_toggle_button_update,
&propagate_alpha);
1997-11-25 06:05:25 +08:00
if (gimp_layer_get_preserve_transparency (drawable_id))
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), 0);
1997-11-25 06:05:25 +08:00
gtk_widget_set_sensitive (toggle, FALSE);
}
}
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
gtk_table_add_toggle (table, _("Propagating Value Channel"), 0, 3, 9,
(GtkSignalFunc) gimp_toggle_button_update,
&propagate_value);
1997-11-25 06:05:25 +08:00
}
gtk_widget_show (table);
gtk_widget_show (frame);
gtk_widget_show (hbox);
gtk_widget_show (dlg);
gtk_main ();
gdk_flush ();
return vpropagate_interface.run;
}
static void
vpropagate_ok_callback (GtkWidget *widget,
gpointer data)
{
gint i, result;
1997-11-25 06:05:25 +08:00
for (i = result = 0; i < 4; i++)
result |= (direction_mask_vec[i] ? 1 : 0) << i;
vpvals.direction_mask = result;
1997-11-25 06:05:25 +08:00
vpvals.propagating_channel = ((propagate_alpha ? PROPAGATING_ALPHA : 0) |
(propagate_value ? PROPAGATING_VALUE : 0));
1997-11-25 06:05:25 +08:00
vpropagate_interface.run = TRUE;
1997-11-25 06:05:25 +08:00
gtk_widget_destroy (GTK_WIDGET (data));
1997-11-25 06:05:25 +08:00
}
static GtkWidget *
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
gtk_table_add_toggle (GtkWidget *table,
gchar *name,
gint x1,
gint x2,
gint y,
GtkSignalFunc update,
gint *value)
1997-11-25 06:05:25 +08:00
{
GtkWidget *toggle;
toggle = gtk_check_button_new_with_label(name);
gtk_table_attach (GTK_TABLE (table), toggle, x1, x2, y, y+1,
GTK_FILL|GTK_EXPAND, 0, 0, 0);
gtk_signal_connect (GTK_OBJECT (toggle), "toggled",
(GtkSignalFunc) update,
value);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), *value);
1997-11-25 06:05:25 +08:00
gtk_widget_show (toggle);
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
1997-11-25 06:05:25 +08:00
return toggle;
}