small cosmetic changes, such as removing tabs.

This commit is contained in:
David Odin 2003-12-23 22:07:06 +00:00
parent 0632251cff
commit 39bf72558c
18 changed files with 2858 additions and 2847 deletions

View File

@ -1,3 +1,24 @@
2003-12-22 DindinX <david@dindinx.org>
* plug-ins/common/AlienMap.c:
* plug-ins/common/AlienMap2.c:
* plug-ins/common/CEL.c:
* plug-ins/common/aa.c:
* plug-ins/common/align_layers.c:
* plug-ins/common/animationplay.c:
* plug-ins/common/animoptimize.c:
* plug-ins/common/apply_lens.c:
* plug-ins/common/autocrop.c:
* plug-ins/common/blinds.c:
* plug-ins/common/blur.c:
* plug-ins/common/borderaverage.c:
* plug-ins/common/bumpmap.c:
* plug-ins/common/bz2.c:
* plug-ins/common/c_astretch.c:
* plug-ins/common/channel_mixer.c:
* plug-ins/common/nova.c: small cosmetic changes, such as removing
tabs.
2003-12-22 DindinX <david@dindinx.org>
* app/gui/user-install-dialog.c (user_install_dialog_run): added a

View File

@ -1346,10 +1346,10 @@ alienmap_logo_dialog (GtkWidget *parent)
GtkWidget *xframe, *xframe2;
GtkWidget *xvbox;
GtkWidget *xhbox;
gchar *text;
guchar *temp, *temp2;
guchar *datapointer;
gint y,x;
gchar *text;
guchar *temp, *temp2;
guchar *datapointer;
gint y, x;
if (logodlg)
{

View File

@ -849,7 +849,7 @@ typedef struct
gdouble greenangle;
gdouble bluefrequency;
gdouble blueangle;
gint colormodel;
gint colormodel;
gint redmode;
gint greenmode;
gint bluemode;
@ -864,25 +864,25 @@ typedef struct
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void alienmap2 (GimpDrawable *drawable);
static void transform (guchar*, guchar*, guchar*);
static void alienmap2 (GimpDrawable *drawable);
static void transform (guchar*, guchar*, guchar*);
static gint alienmap2_dialog (void);
static void dialog_update_preview (void);
static void dialog_scale_update (GtkAdjustment *adjustment,
gdouble *value);
gdouble *value);
static void dialog_response (GtkWidget *widget,
gint response_id,
gpointer data);
static void alienmap2_toggle_update (GtkWidget *widget,
gpointer data);
gpointer data);
static void alienmap2_radio_update (GtkWidget *widget,
gpointer data);
gpointer data);
static void alienmap2_logo_dialog (GtkWidget *parent);
/***** Variables *****/
@ -946,22 +946,22 @@ query (void)
static int nreturn_vals = 0;
gimp_install_procedure ("plug_in_alienmap2",
"AlienMap2 Color Transformation Plug-In",
"No help yet. Just try it and you'll see!",
"Martin Weber (martweb@gmx.net)",
"Martin Weber (martweb@gmx.net",
"24th April 1998",
N_("<Image>/Filters/Colors/Map/Alien Map _2..."),
"RGB*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), nreturn_vals,
args, return_vals);
"AlienMap2 Color Transformation Plug-In",
"No help yet. Just try it and you'll see!",
"Martin Weber (martweb@gmx.net)",
"Martin Weber (martweb@gmx.net",
"24th April 1998",
N_("<Image>/Filters/Colors/Map/Alien Map _2..."),
"RGB*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), nreturn_vals,
args, return_vals);
}
static void
transform (guchar *r,
guchar *g,
guchar *b)
guchar *g,
guchar *b)
{
if (wvals.colormodel == HSL_MODEL)
{
@ -972,15 +972,15 @@ transform (guchar *r,
gimp_rgb_to_hsl (&rgb, &hsl);
if (wvals.redmode)
hsl.h = 0.5 * (1.0 + sin (((2 * hsl.h - 1.0) * wvals.redfrequency +
hsl.h = 0.5 * (1.0 + sin (((2 * hsl.h - 1.0) * wvals.redfrequency +
wvals.redangle / 180.0) * G_PI));
if (wvals.greenmode)
hsl.s = 0.5 * (1.0 + sin (((2 * hsl.s - 1.0) * wvals.greenfrequency +
hsl.s = 0.5 * (1.0 + sin (((2 * hsl.s - 1.0) * wvals.greenfrequency +
wvals.greenangle / 180.0) * G_PI));
if (wvals.bluemode)
hsl.l = 0.5 * (1.0 + sin (((2 * hsl.l - 1.0) * wvals.bluefrequency +
hsl.l = 0.5 * (1.0 + sin (((2 * hsl.l - 1.0) * wvals.bluefrequency +
wvals.blueangle / 180.0) * G_PI));
gimp_hsl_to_rgb (&hsl, &rgb);
@ -989,12 +989,12 @@ transform (guchar *r,
else if (wvals.colormodel == RGB_MODEL)
{
if (wvals.redmode)
*r = ROUND (127.5 * (1.0 +
*r = ROUND (127.5 * (1.0 +
sin (((*r / 127.5 - 1.0) * wvals.redfrequency +
wvals.redangle / 180.0) * G_PI)));
if (wvals.greenmode)
*g = ROUND (127.5 * (1.0 +
*g = ROUND (127.5 * (1.0 +
sin (((*g / 127.5 - 1.0) * wvals.greenfrequency +
wvals.greenangle / 180.0) * G_PI)));
@ -1037,28 +1037,28 @@ run (const gchar *name,
/* Get information from the dialog */
if (!alienmap2_dialog())
return;
return;
break;
case GIMP_RUN_NONINTERACTIVE:
/* Make sure all the arguments are present */
if (nparams != 13)
status = GIMP_PDB_CALLING_ERROR;
status = GIMP_PDB_CALLING_ERROR;
if (status == GIMP_PDB_SUCCESS)
{
wvals.redfrequency = param[3].data.d_float;
wvals.redangle = param[4].data.d_float;
wvals.greenfrequency = param[5].data.d_float;
wvals.greenangle = param[6].data.d_float;
wvals.bluefrequency = param[7].data.d_float;
wvals.blueangle = param[8].data.d_float;
wvals.colormodel = param[9].data.d_int8;
wvals.redmode = param[10].data.d_int8 ? TRUE : FALSE;
wvals.greenmode = param[11].data.d_int8 ? TRUE : FALSE;
wvals.bluemode = param[12].data.d_int8 ? TRUE : FALSE;
}
{
wvals.redfrequency = param[3].data.d_float;
wvals.redangle = param[4].data.d_float;
wvals.greenfrequency = param[5].data.d_float;
wvals.greenangle = param[6].data.d_float;
wvals.bluefrequency = param[7].data.d_float;
wvals.blueangle = param[8].data.d_float;
wvals.colormodel = param[9].data.d_int8;
wvals.redmode = param[10].data.d_int8 ? TRUE : FALSE;
wvals.greenmode = param[11].data.d_int8 ? TRUE : FALSE;
wvals.bluemode = param[12].data.d_int8 ? TRUE : FALSE;
}
break;
@ -1078,22 +1078,22 @@ run (const gchar *name,
{
gimp_progress_init (_("AlienMap2: Transforming..."));
/* Set the tile cache size */
gimp_tile_cache_ntiles(2*(drawable->width / gimp_tile_width()+1));
/* Set the tile cache size */
gimp_tile_cache_ntiles(2*(drawable->width / gimp_tile_width()+1));
/* Run! */
/* Run! */
alienmap2 (drawable);
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush();
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush();
/* Store data */
if (run_mode == GIMP_RUN_INTERACTIVE)
gimp_set_data("plug_in_alienmap2", &wvals, sizeof(alienmap2_vals_t));
/* Store data */
if (run_mode == GIMP_RUN_INTERACTIVE)
gimp_set_data("plug_in_alienmap2", &wvals, sizeof(alienmap2_vals_t));
}
else
{
/* gimp_message("This filter only applies on RGB_MODEL-images"); */
/* gimp_message("This filter only applies on RGB_MODEL-images"); */
status = GIMP_PDB_EXECUTION_ERROR;
}
}
@ -1168,7 +1168,7 @@ alienmap2_dialog (void)
gtk_container_set_border_width (GTK_CONTAINER (top_table), 6);
gtk_table_set_row_spacings (GTK_TABLE (top_table), 4);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), top_table,
FALSE, FALSE, 0);
FALSE, FALSE, 0);
gtk_widget_show (top_table);
/* Preview */
@ -1187,65 +1187,65 @@ alienmap2_dialog (void)
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_attach (GTK_TABLE (top_table), table, 0, 2, 1, 2,
GTK_EXPAND | GTK_FILL, 0, 0, 0);
GTK_EXPAND | GTK_FILL, 0, 0, 0);
gtk_widget_show (table);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("R/H-_Frequency:"), SCALE_WIDTH, ENTRY_WIDTH,
wvals.redfrequency, 0, 5.0, 0.1, 1, 2,
TRUE, 0, 0,
_("Change frequency of the red/hue channel"),
NULL);
_("R/H-_Frequency:"), SCALE_WIDTH, ENTRY_WIDTH,
wvals.redfrequency, 0, 5.0, 0.1, 1, 2,
TRUE, 0, 0,
_("Change frequency of the red/hue channel"),
NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (dialog_scale_update),
&wvals.redfrequency);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("R/H-_Phaseshift:"), SCALE_WIDTH, ENTRY_WIDTH,
wvals.redangle, 0, 360.0, 1, 15, 2,
TRUE, 0, 0,
_("Change angle of the red/hue channel"),
NULL);
_("R/H-_Phaseshift:"), SCALE_WIDTH, ENTRY_WIDTH,
wvals.redangle, 0, 360.0, 1, 15, 2,
TRUE, 0, 0,
_("Change angle of the red/hue channel"),
NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (dialog_scale_update),
&wvals.redangle);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
_("G/S-Fr_equency:"), SCALE_WIDTH, ENTRY_WIDTH,
wvals.greenfrequency, 0, 5.0, 0.1, 1, 2,
TRUE, 0, 0,
_("Change frequency of the green/saturation "
"channel"), NULL);
_("G/S-Fr_equency:"), SCALE_WIDTH, ENTRY_WIDTH,
wvals.greenfrequency, 0, 5.0, 0.1, 1, 2,
TRUE, 0, 0,
_("Change frequency of the green/saturation "
"channel"), NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (dialog_scale_update),
&wvals.greenfrequency);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 3,
_("G/S-Ph_aseshift:"), SCALE_WIDTH, ENTRY_WIDTH,
wvals.redangle, 0, 360.0, 1, 15, 2,
TRUE, 0, 0,
_("Change angle of the green/saturation channel"),
NULL);
_("G/S-Ph_aseshift:"), SCALE_WIDTH, ENTRY_WIDTH,
wvals.redangle, 0, 360.0, 1, 15, 2,
TRUE, 0, 0,
_("Change angle of the green/saturation channel"),
NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (dialog_scale_update),
&wvals.greenangle);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 4,
_("B/L-Freq_uency:"), SCALE_WIDTH, ENTRY_WIDTH,
wvals.bluefrequency, 0, 5.0, 0.1, 1, 2,
TRUE, 0, 0,
_("Change frequency of the blue/luminance "
"channel"), NULL);
_("B/L-Freq_uency:"), SCALE_WIDTH, ENTRY_WIDTH,
wvals.bluefrequency, 0, 5.0, 0.1, 1, 2,
TRUE, 0, 0,
_("Change frequency of the blue/luminance "
"channel"), NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (dialog_scale_update),
&wvals.bluefrequency);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 5,
_("B/L-Pha_seshift:"), SCALE_WIDTH, ENTRY_WIDTH,
wvals.blueangle, 0, 360.0, 1, 15, 2,
TRUE, 0, 0,
_("Change angle of the blue/luminance channel"),
NULL);
_("B/L-Pha_seshift:"), SCALE_WIDTH, ENTRY_WIDTH,
wvals.blueangle, 0, 360.0, 1, 15, 2,
TRUE, 0, 0,
_("Change angle of the blue/luminance channel"),
NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (dialog_scale_update),
&wvals.blueangle);
@ -1253,15 +1253,15 @@ alienmap2_dialog (void)
/* Mode toggle box */
frame =
gimp_int_radio_group_new (TRUE, _("Mode"),
G_CALLBACK (alienmap2_radio_update),
&wvals.colormodel, wvals.colormodel,
G_CALLBACK (alienmap2_radio_update),
&wvals.colormodel, wvals.colormodel,
_("_RGB Color Model"), RGB_MODEL, NULL,
_("_HSL Color Model"), HSL_MODEL, NULL,
_("_RGB Color Model"), RGB_MODEL, NULL,
_("_HSL Color Model"), HSL_MODEL, NULL,
NULL);
NULL);
gtk_table_attach (GTK_TABLE (top_table), frame, 1, 2, 0, 1,
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
toggle_vbox = GTK_BIN (frame)->child;
@ -1275,7 +1275,7 @@ alienmap2_dialog (void)
gtk_widget_show (toggle);
gimp_help_set_help_data (toggle, _("Use function for red/hue component"),
NULL);
NULL);
g_signal_connect (toggle, "toggled",
G_CALLBACK (alienmap2_toggle_update),
@ -1287,8 +1287,8 @@ alienmap2_dialog (void)
gtk_widget_show (toggle);
gimp_help_set_help_data (toggle,
_("Use function for green/saturation component"),
NULL);
_("Use function for green/saturation component"),
NULL);
g_signal_connect (toggle, "toggled",
G_CALLBACK (alienmap2_toggle_update),
@ -1300,8 +1300,8 @@ alienmap2_dialog (void)
gtk_widget_show (toggle);
gimp_help_set_help_data (toggle,
_("Use function for blue/luminance component"),
NULL);
_("Use function for blue/luminance component"),
NULL);
g_signal_connect (toggle, "toggled",
G_CALLBACK (alienmap2_toggle_update),
@ -1326,7 +1326,7 @@ dialog_update_preview (void)
static void
dialog_scale_update (GtkAdjustment *adjustment,
gdouble *value)
gdouble *value)
{
gimp_double_adjustment_update (adjustment, value);
@ -1355,7 +1355,7 @@ dialog_response (GtkWidget *widget,
static void
alienmap2_toggle_update (GtkWidget *widget,
gpointer data)
gpointer data)
{
gimp_toggle_button_update (widget, data);
@ -1364,7 +1364,7 @@ alienmap2_toggle_update (GtkWidget *widget,
static void
alienmap2_radio_update (GtkWidget *widget,
gpointer data)
gpointer data)
{
gimp_radio_button_update (widget, data);
@ -1381,10 +1381,10 @@ alienmap2_logo_dialog (GtkWidget *parent)
GtkWidget *xframe, *xframe2;
GtkWidget *xvbox;
GtkWidget *xhbox;
gchar *text;
guchar *temp, *temp2;
guchar *datapointer;
gint y,x;
gchar *text;
guchar *temp, *temp2;
guchar *datapointer;
gint y, x;
if (logodlg)
{

View File

@ -6,7 +6,7 @@
*/
/* History:
* 0.1 Very limited functionality (modern 4bit only)
* 0.1 Very limited functionality (modern 4bit only)
* 0.2 Default palette (nice yellows) is automatically used
* 0.3 Support for the older (pre KISS/GS) cell format
* 0.4 First support for saving images
@ -41,24 +41,24 @@
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static gint load_palette (FILE *fp,
guchar palette[]);
guchar palette[]);
static gint32 load_image (const gchar *file,
const gchar *brief);
const gchar *brief);
static gint save_image (const gchar *file,
const gchar *brief,
gint32 image,
gint32 layer);
const gchar *brief,
gint32 image,
gint32 layer);
static void palette_dialog (const gchar *title);
/* Globals... */
GimpPlugInInfo PLUG_IN_INFO =
GimpPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
NULL, /* quit_proc */
@ -101,37 +101,37 @@ query (void)
};
gimp_install_procedure ("file_cel_load",
"Loads files in KISS CEL file format",
"This plug-in loads individual KISS cell files.",
"Nick Lamb",
"Nick Lamb <njl195@zepler.org.uk>",
"May 1998",
"<Load>/CEL",
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (load_args),
"Loads files in KISS CEL file format",
"This plug-in loads individual KISS cell files.",
"Nick Lamb",
"Nick Lamb <njl195@zepler.org.uk>",
"May 1998",
"<Load>/CEL",
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (load_args),
G_N_ELEMENTS (load_return_vals),
load_args, load_return_vals);
load_args, load_return_vals);
gimp_install_procedure ("file_cel_save",
"Saves files in KISS CEL file format",
"This plug-in saves individual KISS cell files.",
"Nick Lamb",
"Nick Lamb <njl195@zepler.org.uk>",
"May 1998",
"<Save>/CEL",
"INDEXEDA",
GIMP_PLUGIN,
G_N_ELEMENTS (save_args), 0,
save_args, NULL);
"Saves files in KISS CEL file format",
"This plug-in saves individual KISS cell files.",
"Nick Lamb",
"Nick Lamb <njl195@zepler.org.uk>",
"May 1998",
"<Save>/CEL",
"INDEXEDA",
GIMP_PLUGIN,
G_N_ELEMENTS (save_args), 0,
save_args, NULL);
gimp_register_magic_load_handler ("file_cel_load",
"cel",
"",
"0,string,KiSS\\040");
"cel",
"",
"0,string,KiSS\\040");
gimp_register_save_handler ("file_cel_save",
"cel",
"");
"cel",
"");
}
static void
@ -160,58 +160,58 @@ run (const gchar *name,
if (strcmp (name, "file_cel_load") == 0)
{
if (run_mode != GIMP_RUN_NONINTERACTIVE)
{
gimp_get_data ("file_cel_save:length", &data_length);
if (data_length > 0)
{
palette_file = (char *) g_malloc(data_length);
gimp_get_data ("file_cel_save:data", palette_file);
}
else
{
palette_file = g_strdup("*.kcf");
data_length = strlen(palette_file) + 1;
}
}
{
gimp_get_data ("file_cel_save:length", &data_length);
if (data_length > 0)
{
palette_file = g_malloc(data_length);
gimp_get_data ("file_cel_save:data", palette_file);
}
else
{
palette_file = g_strdup("*.kcf");
data_length = strlen(palette_file) + 1;
}
}
if (run_mode == GIMP_RUN_NONINTERACTIVE)
{
palette_file = param[3].data.d_string;
data_length = strlen(palette_file) + 1;
}
{
palette_file = param[3].data.d_string;
data_length = strlen(palette_file) + 1;
}
else if (run_mode == GIMP_RUN_INTERACTIVE)
{
/* Let user choose KCF palette (cancel ignores) */
palette_dialog (_("Load KISS Palette"));
gimp_set_data ("file_cel_save:length", &data_length, sizeof (size_t));
gimp_set_data ("file_cel_save:data", palette_file, data_length);
}
{
/* Let user choose KCF palette (cancel ignores) */
palette_dialog (_("Load KISS Palette"));
gimp_set_data ("file_cel_save:length", &data_length, sizeof (size_t));
gimp_set_data ("file_cel_save:data", palette_file, data_length);
}
image = load_image (param[1].data.d_string, param[2].data.d_string);
if (image != -1)
{
*nreturn_vals = 2;
values[1].type = GIMP_PDB_IMAGE;
values[1].data.d_image = image;
}
{
*nreturn_vals = 2;
values[1].type = GIMP_PDB_IMAGE;
values[1].data.d_image = image;
}
else
{
status = GIMP_PDB_EXECUTION_ERROR;
}
{
status = GIMP_PDB_EXECUTION_ERROR;
}
}
else if (strcmp (name, "file_cel_save") == 0)
{
if (! save_image (param[3].data.d_string, param[4].data.d_string,
param[1].data.d_int32, param[2].data.d_int32))
{
status = GIMP_PDB_EXECUTION_ERROR;
}
param[1].data.d_int32, param[2].data.d_int32))
{
status = GIMP_PDB_EXECUTION_ERROR;
}
else
{
gimp_set_data ("file_cel_save:length", &data_length, sizeof (size_t));
gimp_set_data ("file_cel_save:data", palette_file, data_length);
}
{
gimp_set_data ("file_cel_save:length", &data_length, sizeof (size_t));
gimp_set_data ("file_cel_save:data", palette_file, data_length);
}
}
else
{
@ -225,7 +225,7 @@ run (const gchar *name,
static gint32
load_image (const gchar *file,
const gchar *brief)
const gchar *brief)
{
FILE *fp; /* Read file pointer */
gchar *progress; /* Title for progress display */
@ -294,7 +294,7 @@ load_image (const gchar *file,
/* Create an indexed-alpha layer to hold the image... */
layer = gimp_layer_new (image, _("Background"), width, height,
GIMP_INDEXEDA_IMAGE, 100, GIMP_NORMAL_MODE);
GIMP_INDEXEDA_IMAGE, 100, GIMP_NORMAL_MODE);
gimp_image_add_layer (image, layer, 0);
gimp_layer_set_offsets (layer, offx, offy);
@ -303,7 +303,7 @@ load_image (const gchar *file,
drawable = gimp_drawable_get (layer);
gimp_pixel_rgn_init (&pixel_rgn, drawable, 0, 0, drawable->width,
drawable->height, TRUE, FALSE);
drawable->height, TRUE, FALSE);
/* Read the image in and give it to the GIMP a line at a time */
@ -313,55 +313,55 @@ load_image (const gchar *file,
for (i = 0; i < height && !feof(fp); ++i)
{
switch (colours)
{
case 16:
fread (buffer, (width+1)/2, 1, fp);
for (j = 0, k = 0; j < width*2; j+= 4, ++k)
{
if (buffer[k] / 16 == 0)
{
line[j]= 16;
line[j+1]= 0;
}
else
{
line[j]= (buffer[k] / 16) - 1;
line[j+1]= 255;
}
if (buffer[k] % 16 == 0)
{
line[j+2]= 16;
line[j+3]= 0;
}
else
{
line[j+2]= (buffer[k] % 16) - 1;
line[j+3]= 255;
}
}
break;
{
case 16:
fread (buffer, (width+1)/2, 1, fp);
for (j = 0, k = 0; j < width*2; j+= 4, ++k)
{
if (buffer[k] / 16 == 0)
{
line[j]= 16;
line[j+1]= 0;
}
else
{
line[j]= (buffer[k] / 16) - 1;
line[j+1]= 255;
}
if (buffer[k] % 16 == 0)
{
line[j+2]= 16;
line[j+3]= 0;
}
else
{
line[j+2]= (buffer[k] % 16) - 1;
line[j+3]= 255;
}
}
break;
case 256:
fread (buffer, width, 1, fp);
for (j = 0, k = 0; j < width*2; j+= 2, ++k)
{
if (buffer[k] == 0)
{
line[j]= 255;
line[j+1]= 0;
}
else
{
line[j]= buffer[k] - 1;
line[j+1]= 255;
}
}
break;
case 256:
fread (buffer, width, 1, fp);
for (j = 0, k = 0; j < width*2; j+= 2, ++k)
{
if (buffer[k] == 0)
{
line[j]= 255;
line[j+1]= 0;
}
else
{
line[j]= buffer[k] - 1;
line[j+1]= 255;
}
}
break;
default:
g_message (_("Unsupported number of colors (%d)"), colours);
return -1;
}
default:
g_message (_("Unsupported number of colors (%d)"), colours);
return -1;
}
gimp_pixel_rgn_set_rect (&pixel_rgn, line, 0, i, drawable->width, 1);
gimp_progress_update ((float) i / (float) height);
@ -394,9 +394,9 @@ load_image (const gchar *file,
else
{
for (i= 0; i < colours; ++i)
{
palette[i*3] = palette[i*3+1] = palette[i*3+2]= i * 256 / colours;
}
{
palette[i*3] = palette[i*3+1] = palette[i*3+2]= i * 256 / colours;
}
}
gimp_image_set_cmap (image, palette + 3, colours - 1);
@ -415,11 +415,11 @@ load_image (const gchar *file,
static gint
load_palette (FILE *fp,
guchar palette[])
guchar palette[])
{
guchar header[32]; /* File header */
guchar buffer[2];
int i, bpp, colours= 0;
guchar header[32]; /* File header */
guchar buffer[2];
int i, bpp, colours= 0;
fread (header, 4, 1, fp);
if (!strncmp(header, "KiSS", 4))
@ -428,31 +428,31 @@ load_palette (FILE *fp,
bpp = header[5];
colours = header[8] + header[9] * 256;
if (bpp == 12)
{
for (i= 0; i < colours; ++i)
{
fread (buffer, 1, 2, fp);
palette[i*3]= buffer[0] & 0xf0;
palette[i*3+1]= (buffer[1] & 0x0f) * 16;
palette[i*3+2]= (buffer[0] & 0x0f) * 16;
}
}
{
for (i= 0; i < colours; ++i)
{
fread (buffer, 1, 2, fp);
palette[i*3]= buffer[0] & 0xf0;
palette[i*3+1]= (buffer[1] & 0x0f) * 16;
palette[i*3+2]= (buffer[0] & 0x0f) * 16;
}
}
else
{
fread (palette, colours, 3, fp);
}
{
fread (palette, colours, 3, fp);
}
}
else
{
colours = 16; bpp = 12;
fseek (fp, 0, SEEK_SET);
for (i= 0; i < colours; ++i)
{
fread (buffer, 1, 2, fp);
palette[i*3] = buffer[0] & 0xf0;
palette[i*3+1] = (buffer[1] & 0x0f) * 16;
palette[i*3+2] = (buffer[0] & 0x0f) * 16;
}
{
fread (buffer, 1, 2, fp);
palette[i*3] = buffer[0] & 0xf0;
palette[i*3+1] = (buffer[1] & 0x0f) * 16;
palette[i*3+2] = (buffer[0] & 0x0f) * 16;
}
}
return colours;
@ -460,9 +460,9 @@ load_palette (FILE *fp,
static gint
save_image (const gchar *file,
const gchar *brief,
gint32 image,
gint32 layer)
const gchar *brief,
gint32 image,
gint32 layer)
{
FILE *fp; /* Write file pointer */
char *progress; /* Title for progress display */
@ -533,7 +533,7 @@ save_image (const gchar *file,
/* Arrange for memory etc. */
gimp_pixel_rgn_init (&pixel_rgn, drawable, 0, 0, drawable->width,
drawable->height, TRUE, FALSE);
drawable->height, TRUE, FALSE);
buffer = g_new (guchar, drawable->width);
line = g_new (guchar, (drawable->width+1) * 2);
@ -544,32 +544,32 @@ save_image (const gchar *file,
memset (buffer, 0, drawable->width);
if (colours > 16)
{
for (j = 0, k = 0; j < drawable->width*2; j+= 2, ++k)
{
if (line[j+1] > 127)
{
buffer[k]= line[j] + 1;
}
}
fwrite (buffer, drawable->width, 1, fp);
}
{
for (j = 0, k = 0; j < drawable->width*2; j+= 2, ++k)
{
if (line[j+1] > 127)
{
buffer[k]= line[j] + 1;
}
}
fwrite (buffer, drawable->width, 1, fp);
}
else
{
for (j = 0, k = 0; j < drawable->width*2; j+= 4, ++k)
{
buffer[k] = 0;
if (line[j+1] > 127)
{
buffer[k] += (line[j] + 1)<< 4;
}
if (line[j+3] > 127)
{
buffer[k] += (line[j+2] + 1);
}
}
fwrite (buffer, (drawable->width+1)/2, 1, fp);
}
{
for (j = 0, k = 0; j < drawable->width*2; j+= 4, ++k)
{
buffer[k] = 0;
if (line[j+1] > 127)
{
buffer[k] += (line[j] + 1)<< 4;
}
if (line[j+3] > 127)
{
buffer[k] += (line[j+2] + 1);
}
}
fwrite (buffer, (drawable->width+1)/2, 1, fp);
}
gimp_progress_update ((float) i / (float) drawable->height);
}
@ -594,7 +594,7 @@ palette_dialog (const gchar *title)
gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), palette_file);
gimp_help_connect (dialog, gimp_standard_help_func,
"filters/cel.html", NULL);
"filters/cel.html", NULL);
gtk_widget_show (dialog);

View File

@ -76,21 +76,21 @@ query (void)
};
gimp_install_procedure ("file_aa_save",
"Saves grayscale image in various text formats",
"This plug-in uses aalib to save grayscale image "
"Saves grayscale image in various text formats",
"This plug-in uses aalib to save grayscale image "
"as ascii art into a variety of text formats",
"Tim Newsome <nuisance@cmu.edu>",
"Tim Newsome <nuisance@cmu.edu>",
"1997",
"<Save>/AA",
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (save_args), 0,
save_args, NULL);
"Tim Newsome <nuisance@cmu.edu>",
"Tim Newsome <nuisance@cmu.edu>",
"1997",
"<Save>/AA",
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (save_args), 0,
save_args, NULL);
gimp_register_save_handler ("file_aa_save",
"ansi,txt,text",
"");
"ansi,txt,text",
"");
}
/**
@ -149,14 +149,14 @@ run (const gchar *name,
case GIMP_RUN_WITH_LAST_VALS:
gimp_ui_init ("aa", FALSE);
export = gimp_export_image (&image_ID, &drawable_ID, "AA",
(GIMP_EXPORT_CAN_HANDLE_RGB |
(GIMP_EXPORT_CAN_HANDLE_RGB |
GIMP_EXPORT_CAN_HANDLE_GRAY |
GIMP_EXPORT_CAN_HANDLE_ALPHA ));
GIMP_EXPORT_CAN_HANDLE_ALPHA ));
if (export == GIMP_EXPORT_CANCEL)
{
values[0].data.d_status = GIMP_PDB_CANCEL;
return;
}
{
values[0].data.d_status = GIMP_PDB_CANCEL;
return;
}
break;
default:
break;
@ -171,47 +171,47 @@ run (const gchar *name,
if (status == GIMP_PDB_SUCCESS)
{
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
gimp_get_data ("file_aa_save", &output_type);
output_type = type_dialog (output_type);
if (output_type < 0)
status = GIMP_PDB_CANCEL;
break;
{
case GIMP_RUN_INTERACTIVE:
gimp_get_data ("file_aa_save", &output_type);
output_type = type_dialog (output_type);
if (output_type < 0)
status = GIMP_PDB_CANCEL;
break;
case GIMP_RUN_NONINTERACTIVE:
/* Make sure all the arguments are there! */
if (nparams != 6)
{
status = GIMP_PDB_CALLING_ERROR;
}
else
{
output_type = get_type_from_string (param[5].data.d_string);
if (output_type < 0)
status = GIMP_PDB_CALLING_ERROR;
}
break;
case GIMP_RUN_NONINTERACTIVE:
/* Make sure all the arguments are there! */
if (nparams != 6)
{
status = GIMP_PDB_CALLING_ERROR;
}
else
{
output_type = get_type_from_string (param[5].data.d_string);
if (output_type < 0)
status = GIMP_PDB_CALLING_ERROR;
}
break;
case GIMP_RUN_WITH_LAST_VALS:
gimp_get_data ("file_aa_save", &output_type);
break;
case GIMP_RUN_WITH_LAST_VALS:
gimp_get_data ("file_aa_save", &output_type);
break;
default:
break;
}
default:
break;
}
}
if (status == GIMP_PDB_SUCCESS)
{
if (save_aa (drawable_ID, param[3].data.d_string, output_type))
{
gimp_set_data ("file_aa_save", &output_type, sizeof (output_type));
}
{
gimp_set_data ("file_aa_save", &output_type, sizeof (output_type));
}
else
{
status = GIMP_PDB_EXECUTION_ERROR;
}
{
status = GIMP_PDB_EXECUTION_ERROR;
}
}
if (export == GIMP_EXPORT_EXPORT)
@ -253,7 +253,7 @@ save_aa (gint32 drawable_ID,
static void
gimp2aa (gint32 drawable_ID,
aa_context *context)
aa_context *context)
{
GimpDrawable *drawable;
GimpPixelRgn pixel_rgn;
@ -321,7 +321,7 @@ gimp2aa (gint32 drawable_ID,
renderparams->dither = AA_FLOYD_S;
aa_render (context, renderparams, 0, 0,
aa_scrwidth (context), aa_scrheight (context));
aa_scrwidth (context), aa_scrheight (context));
}
/*
@ -340,12 +340,12 @@ type_dialog (gint selected)
/* Create the actual window. */
dlg = gimp_dialog_new (_("Save as Text"), "aa",
NULL, 0,
gimp_standard_help_func, "filters/aa.html",
gimp_standard_help_func, "filters/aa.html",
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
NULL);
/* file save type */
frame = gtk_frame_new (_("Data Formatting"));
@ -363,20 +363,20 @@ type_dialog (gint selected)
while (*p != NULL)
{
toggle = gtk_radio_button_new_with_label (group, (*p)->formatname);
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (toggle));
gtk_box_pack_start (GTK_BOX (toggle_vbox), toggle, FALSE, FALSE, 0);
gtk_widget_show (toggle);
toggle = gtk_radio_button_new_with_label (group, (*p)->formatname);
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (toggle));
gtk_box_pack_start (GTK_BOX (toggle_vbox), toggle, FALSE, FALSE, 0);
gtk_widget_show (toggle);
g_signal_connect (toggle, "toggled",
g_signal_connect (toggle, "toggled",
G_CALLBACK (type_dialog_toggle_update),
(gpointer) (*p)->formatname);
if (current == selected)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), TRUE);
if (current == selected)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), TRUE);
p++;
current++;
p++;
current++;
}
}
@ -399,7 +399,7 @@ type_dialog (gint selected)
static void
type_dialog_toggle_update (GtkWidget *widget,
gpointer data)
gpointer data)
{
selected_type = get_type_from_string ((const gchar *) data);
}

View File

@ -33,7 +33,7 @@
#include "libgimp/stdplugins-intl.h"
#define PLUG_IN_NAME "plug_in_align_layers"
#define PLUG_IN_NAME "plug_in_align_layers"
#define SHORT_NAME "align_layers"
#define SCALE_WIDTH 150
@ -69,17 +69,17 @@ enum
V_BASE_BOTTOM
};
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static GimpPDBStatusType align_layers (gint32 image_id);
static void align_layers_get_align_offsets (gint32 drawable_id,
gint *x,
gint *y);
gint *x,
gint *y);
static gint align_layers_dialog (void);
@ -95,13 +95,13 @@ GimpPlugInInfo PLUG_IN_INFO =
/* dialog variables */
typedef struct
{
gint h_style;
gint h_base;
gint v_style;
gint v_base;
gint ignore_bottom;
gint base_is_bottom_layer;
gint grid_size;
gint h_style;
gint h_base;
gint v_style;
gint v_base;
gboolean ignore_bottom;
gboolean base_is_bottom_layer;
gint grid_size;
} ValueType;
static ValueType VALS =
@ -131,16 +131,16 @@ query (void)
};
gimp_install_procedure (PLUG_IN_NAME,
"Align visible layers",
"Align visible layers",
"Shuji Narazaki <narazaki@InetQ.or.jp>",
"Shuji Narazaki",
"1997",
N_("<Image>/Layer/Align _Visible Layers..."),
"RGB*,GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
"Align visible layers",
"Align visible layers",
"Shuji Narazaki <narazaki@InetQ.or.jp>",
"Shuji Narazaki",
"1997",
N_("<Image>/Layer/Align _Visible Layers..."),
"RGB*,GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
}
static void
@ -171,13 +171,13 @@ run (const gchar *name,
case GIMP_RUN_INTERACTIVE:
gimp_image_get_layers (image_id, &layer_num);
if (layer_num < 2)
{
g_message (_("There are not enough layers to align."));
return;
}
{
g_message (_("There are not enough layers to align."));
return;
}
gimp_get_data (PLUG_IN_NAME, &VALS);
if (! align_layers_dialog ())
return;
return;
break;
case GIMP_RUN_NONINTERACTIVE:
@ -202,21 +202,21 @@ run (const gchar *name,
static GimpPDBStatusType
align_layers (gint32 image_id)
{
gint layer_num = 0;
gint visible_layer_num = 0;
gint layer_num = 0;
gint visible_layer_num = 0;
gint *layers = NULL;
gint index;
gint index;
gint vindex;
gint step_x = 0;
gint step_y = 0;
gint x = 0;
gint y = 0;
gint orig_x = 0;
gint orig_y = 0;
gint offset_x = 0;
gint offset_y = 0;
gint base_x = 0;
gint base_y = 0;
gint step_x = 0;
gint step_y = 0;
gint x = 0;
gint y = 0;
gint orig_x = 0;
gint orig_y = 0;
gint offset_x = 0;
gint offset_y = 0;
gint base_x = 0;
gint base_y = 0;
gint bg_index = 0;
layers = gimp_image_get_layers (image_id, &layer_num);
@ -225,63 +225,63 @@ align_layers (gint32 image_id)
for (index = 0; index < layer_num; index++)
{
if (gimp_drawable_get_visible (layers[index]))
visible_layer_num++;
visible_layer_num++;
}
if (VALS.ignore_bottom)
{
layer_num--;
if (gimp_drawable_get_visible (layers[bg_index]))
visible_layer_num--;
visible_layer_num--;
}
if (0 < visible_layer_num)
{
gint min_x = G_MAXINT;
gint min_y = G_MAXINT;
gint max_x = G_MININT;
gint max_y = G_MININT;
gint min_x = G_MAXINT;
gint min_y = G_MAXINT;
gint max_x = G_MININT;
gint max_y = G_MININT;
/* 0 is the top layer */
for (index = 0; index < layer_num; index++)
{
if (gimp_drawable_get_visible (layers[index]))
{
gimp_drawable_offsets (layers[index], &orig_x, &orig_y);
align_layers_get_align_offsets (layers[index], &offset_x,
&offset_y);
orig_x += offset_x;
orig_y += offset_y;
{
if (gimp_drawable_get_visible (layers[index]))
{
gimp_drawable_offsets (layers[index], &orig_x, &orig_y);
align_layers_get_align_offsets (layers[index], &offset_x,
&offset_y);
orig_x += offset_x;
orig_y += offset_y;
if ( orig_x < min_x ) min_x = orig_x;
if ( max_x < orig_x ) max_x = orig_x;
if ( orig_y < min_y ) min_y = orig_y;
if ( max_y < orig_y ) max_y = orig_y;
}
}
if ( orig_x < min_x ) min_x = orig_x;
if ( max_x < orig_x ) max_x = orig_x;
if ( orig_y < min_y ) min_y = orig_y;
if ( max_y < orig_y ) max_y = orig_y;
}
}
if (VALS.base_is_bottom_layer)
{
gimp_drawable_offsets (layers[bg_index], &orig_x, &orig_y);
align_layers_get_align_offsets (layers[bg_index], &offset_x,
&offset_y);
orig_x += offset_x;
orig_y += offset_y;
base_x = min_x = orig_x;
base_y = min_y = orig_y;
}
{
gimp_drawable_offsets (layers[bg_index], &orig_x, &orig_y);
align_layers_get_align_offsets (layers[bg_index], &offset_x,
&offset_y);
orig_x += offset_x;
orig_y += offset_y;
base_x = min_x = orig_x;
base_y = min_y = orig_y;
}
if (visible_layer_num > 1)
{
step_x = (max_x - min_x) / (visible_layer_num - 1);
step_y = (max_y - min_y) / (visible_layer_num - 1);
}
{
step_x = (max_x - min_x) / (visible_layer_num - 1);
step_y = (max_y - min_y) / (visible_layer_num - 1);
}
if ( (VALS.h_style == LEFT2RIGHT) || (VALS.h_style == RIGHT2LEFT))
base_x = min_x;
base_x = min_x;
if ( (VALS.v_style == TOP2BOTTOM) || (VALS.v_style == BOTTOM2TOP))
base_y = min_y;
base_y = min_y;
}
gimp_image_undo_group_start (image_id);
@ -289,53 +289,53 @@ align_layers (gint32 image_id)
for (vindex = -1, index = 0; index < layer_num; index++)
{
if (gimp_drawable_get_visible (layers[index]))
vindex++;
vindex++;
else
continue;
continue;
gimp_drawable_offsets (layers[index], &orig_x, &orig_y);
align_layers_get_align_offsets (layers[index], &offset_x, &offset_y);
switch (VALS.h_style)
{
case H_NONE:
x = orig_x;
break;
case H_COLLECT:
x = base_x - offset_x;
break;
case LEFT2RIGHT:
x = (base_x + vindex * step_x) - offset_x;
break;
case RIGHT2LEFT:
x = (base_x + (visible_layer_num - vindex - 1) * step_x) - offset_x;
break;
case SNAP2HGRID:
x = VALS.grid_size
* (int) ((orig_x + offset_x + VALS.grid_size /2) / VALS.grid_size)
- offset_x;
break;
}
{
case H_NONE:
x = orig_x;
break;
case H_COLLECT:
x = base_x - offset_x;
break;
case LEFT2RIGHT:
x = (base_x + vindex * step_x) - offset_x;
break;
case RIGHT2LEFT:
x = (base_x + (visible_layer_num - vindex - 1) * step_x) - offset_x;
break;
case SNAP2HGRID:
x = VALS.grid_size
* (int) ((orig_x + offset_x + VALS.grid_size /2) / VALS.grid_size)
- offset_x;
break;
}
switch (VALS.v_style)
{
case V_NONE:
y = orig_y;
break;
case V_COLLECT:
y = base_y - offset_y;
break;
case TOP2BOTTOM:
y = (base_y + vindex * step_y) - offset_y;
break;
case BOTTOM2TOP:
y = (base_y + (visible_layer_num - vindex - 1) * step_y) - offset_y;
break;
case SNAP2VGRID:
y = VALS.grid_size
* (int) ((orig_y + offset_y + VALS.grid_size / 2) / VALS.grid_size)
- offset_y;
break;
}
{
case V_NONE:
y = orig_y;
break;
case V_COLLECT:
y = base_y - offset_y;
break;
case TOP2BOTTOM:
y = (base_y + vindex * step_y) - offset_y;
break;
case BOTTOM2TOP:
y = (base_y + (visible_layer_num - vindex - 1) * step_y) - offset_y;
break;
case SNAP2VGRID:
y = VALS.grid_size
* (int) ((orig_y + offset_y + VALS.grid_size / 2) / VALS.grid_size)
- offset_y;
break;
}
gimp_layer_set_offsets (layers[index], x, y);
}
@ -345,11 +345,11 @@ align_layers (gint32 image_id)
}
static void
align_layers_get_align_offsets (gint32 drawable_id,
gint *x,
gint *y)
align_layers_get_align_offsets (gint32 drawable_id,
gint *x,
gint *y)
{
GimpDrawable *layer = gimp_drawable_get (drawable_id);
GimpDrawable *layer = gimp_drawable_get (drawable_id);
switch (VALS.h_base)
{
@ -399,12 +399,12 @@ align_layers_dialog (void)
dlg = gimp_dialog_new (_("Align Visible Layers"), SHORT_NAME,
NULL, 0,
gimp_standard_help_func, "filters/align_layers.html",
gimp_standard_help_func, "filters/align_layers.html",
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
NULL);
frame = gtk_frame_new (_("Parameter Settings"));
gtk_container_set_border_width (GTK_CONTAINER (frame), 6);
@ -420,59 +420,59 @@ align_layers_dialog (void)
optionmenu =
gimp_int_option_menu_new (FALSE, G_CALLBACK (gimp_menu_item_update),
&VALS.h_style, VALS.h_style,
&VALS.h_style, VALS.h_style,
_("None"), H_NONE, NULL,
_("Collect"), H_COLLECT, NULL,
_("Fill (left to right)"), LEFT2RIGHT, NULL,
_("Fill (right to left)"), RIGHT2LEFT, NULL,
_("Snap to Grid"), SNAP2HGRID, NULL,
_("None"), H_NONE, NULL,
_("Collect"), H_COLLECT, NULL,
_("Fill (left to right)"), LEFT2RIGHT, NULL,
_("Fill (right to left)"), RIGHT2LEFT, NULL,
_("Snap to Grid"), SNAP2HGRID, NULL,
NULL);
NULL);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("_Horizontal Style:"), 1.0, 0.5,
optionmenu, 1, FALSE);
_("_Horizontal Style:"), 1.0, 0.5,
optionmenu, 1, FALSE);
optionmenu =
gimp_int_option_menu_new (FALSE, G_CALLBACK (gimp_menu_item_update),
&VALS.h_base, VALS.h_base,
&VALS.h_base, VALS.h_base,
_("Left Edge"), H_BASE_LEFT, NULL,
_("Center"), H_BASE_CENTER, NULL,
_("Right Edge"), H_BASE_RIGHT, NULL,
_("Left Edge"), H_BASE_LEFT, NULL,
_("Center"), H_BASE_CENTER, NULL,
_("Right Edge"), H_BASE_RIGHT, NULL,
NULL);
NULL);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Ho_rizontal Base:"), 1.0, 0.5,
optionmenu, 1, FALSE);
_("Ho_rizontal Base:"), 1.0, 0.5,
optionmenu, 1, FALSE);
optionmenu =
gimp_int_option_menu_new (FALSE, G_CALLBACK (gimp_menu_item_update),
&VALS.v_style, VALS.v_style,
&VALS.v_style, VALS.v_style,
_("None"), V_NONE, NULL,
_("Collect"), V_COLLECT, NULL,
_("Fill (top to bottom)"), TOP2BOTTOM, NULL,
_("Fill (bottom to top)"), BOTTOM2TOP, NULL,
_("Snap to Grid"), SNAP2VGRID, NULL,
_("None"), V_NONE, NULL,
_("Collect"), V_COLLECT, NULL,
_("Fill (top to bottom)"), TOP2BOTTOM, NULL,
_("Fill (bottom to top)"), BOTTOM2TOP, NULL,
_("Snap to Grid"), SNAP2VGRID, NULL,
NULL);
NULL);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
_("_Vertical Style:"), 1.0, 0.5,
optionmenu, 1, FALSE);
_("_Vertical Style:"), 1.0, 0.5,
optionmenu, 1, FALSE);
optionmenu =
gimp_int_option_menu_new (FALSE, G_CALLBACK (gimp_menu_item_update),
&VALS.v_base, VALS.v_base,
&VALS.v_base, VALS.v_base,
_("Top Edge"), V_BASE_TOP, NULL,
_("Center"), V_BASE_CENTER, NULL,
_("Bottom Edge"), V_BASE_BOTTOM, NULL,
_("Top Edge"), V_BASE_TOP, NULL,
_("Center"), V_BASE_CENTER, NULL,
_("Bottom Edge"), V_BASE_BOTTOM, NULL,
NULL);
NULL);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
_("Ver_tical Base:"), 1.0, 0.5,
optionmenu, 1, FALSE);
_("Ver_tical Base:"), 1.0, 0.5,
optionmenu, 1, FALSE);
toggle = gtk_check_button_new_with_mnemonic
(_("_Ignore the Bottom Layer even if Visible"));
@ -487,7 +487,7 @@ align_layers_dialog (void)
toggle = gtk_check_button_new_with_mnemonic
(_("_Use the (Invisible) Bottom Layer as the Base"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
VALS.base_is_bottom_layer);
VALS.base_is_bottom_layer);
gtk_table_attach_defaults (GTK_TABLE (table), toggle, 0, 2, 5, 6);
gtk_widget_show (toggle);
@ -496,10 +496,10 @@ align_layers_dialog (void)
&VALS.base_is_bottom_layer);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 6,
_("_Grid Size:"), SCALE_WIDTH, 0,
VALS.grid_size, 0, 200, 1, 10, 0,
TRUE, 0, 0,
NULL, NULL);
_("_Grid Size:"), SCALE_WIDTH, 0,
VALS.grid_size, 0, 200, 1, 10, 0,
TRUE, 0, 0,
NULL, NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (gimp_int_adjustment_update),
&VALS.grid_size);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -63,10 +63,10 @@
*/
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void drawlens (GimpDrawable *drawable);
@ -114,16 +114,16 @@ query (void)
};
gimp_install_procedure ("plug_in_applylens",
"Apply a lens effect",
"This plug-in uses Snell's law to draw an ellipsoid lens over the image",
"Morten Eriksen",
"Morten Eriksen",
"1997",
N_("<Image>/Filters/Glass Effects/Apply _Lens..."),
"RGB*, GRAY*, INDEXED*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
"Apply a lens effect",
"This plug-in uses Snell's law to draw an ellipsoid lens over the image",
"Morten Eriksen",
"Morten Eriksen",
"1997",
N_("<Image>/Filters/Glass Effects/Apply _Lens..."),
"RGB*, GRAY*, INDEXED*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
}
static void
@ -155,23 +155,23 @@ run (const gchar *name,
case GIMP_RUN_INTERACTIVE:
gimp_get_data ("plug_in_applylens", &lvals);
if(!lens_dialog (drawable))
return;
return;
break;
case GIMP_RUN_NONINTERACTIVE:
if (nparams != 7)
status = GIMP_PDB_CALLING_ERROR;
status = GIMP_PDB_CALLING_ERROR;
if (status == GIMP_PDB_SUCCESS)
{
lvals.refraction = param[3].data.d_float;
lvals.keep_surr = param[4].data.d_int32;
lvals.use_bkgr = param[5].data.d_int32;
lvals.set_transparent = param[6].data.d_int32;
}
{
lvals.refraction = param[3].data.d_float;
lvals.keep_surr = param[4].data.d_int32;
lvals.use_bkgr = param[5].data.d_int32;
lvals.set_transparent = param[6].data.d_int32;
}
if (status == GIMP_PDB_SUCCESS && (lvals.refraction < 1.0))
status = GIMP_PDB_CALLING_ERROR;
status = GIMP_PDB_CALLING_ERROR;
break;
case GIMP_RUN_WITH_LAST_VALS:
@ -201,12 +201,12 @@ run (const gchar *name,
*/
static void
find_projected_pos (gfloat a2,
gfloat b2,
gfloat c2,
gfloat x,
gfloat y,
gfloat *projx,
gfloat *projy)
gfloat b2,
gfloat c2,
gfloat x,
gfloat y,
gfloat *projx,
gfloat *projy)
{
gfloat n[3];
gfloat nxangle, nyangle, theta1, theta2;
@ -250,7 +250,7 @@ drawlens (GimpDrawable *drawable)
gimp_palette_get_background (&background);
gimp_rgb_get_uchar (&background,
&bgr_red, &bgr_green, &bgr_blue);
&bgr_red, &bgr_green, &bgr_blue);
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
regionwidth = x2 - x1;
@ -280,65 +280,65 @@ drawlens (GimpDrawable *drawable)
dx = (gfloat) col - a + 0.5;
xsqr = dx * dx;
for (row = 0; row < regionheight; row++)
{
pixelpos = (col + row * regionwidth) * bytes;
dy = -((gfloat) row - b) - 0.5;
ysqr = dy * dy;
if (ysqr < (bsqr - (bsqr * xsqr) / asqr))
{
find_projected_pos (asqr, bsqr, csqr, dx, dy, &x, &y);
y = -y;
pos = ((gint) (y + b) * regionwidth + (gint) (x + a)) * bytes;
{
pixelpos = (col + row * regionwidth) * bytes;
dy = -((gfloat) row - b) - 0.5;
ysqr = dy * dy;
if (ysqr < (bsqr - (bsqr * xsqr) / asqr))
{
find_projected_pos (asqr, bsqr, csqr, dx, dy, &x, &y);
y = -y;
pos = ((gint) (y + b) * regionwidth + (gint) (x + a)) * bytes;
for (i = 0; i < bytes; i++)
{
dest[pixelpos + i] = src[pos + i];
}
}
else
{
if (lvals.keep_surr)
{
for (i = 0; i < bytes; i++)
{
dest[pixelpos + i] = src[pixelpos + i];
}
}
else
{
if (lvals.set_transparent)
alphaval = 0;
else
alphaval = 255;
for (i = 0; i < bytes; i++)
{
dest[pixelpos + i] = src[pos + i];
}
}
else
{
if (lvals.keep_surr)
{
for (i = 0; i < bytes; i++)
{
dest[pixelpos + i] = src[pixelpos + i];
}
}
else
{
if (lvals.set_transparent)
alphaval = 0;
else
alphaval = 255;
switch (drawtype)
{
case GIMP_INDEXEDA_IMAGE:
dest[pixelpos + 1] = alphaval;
case GIMP_INDEXED_IMAGE:
dest[pixelpos + 0] = 0;
break;
switch (drawtype)
{
case GIMP_INDEXEDA_IMAGE:
dest[pixelpos + 1] = alphaval;
case GIMP_INDEXED_IMAGE:
dest[pixelpos + 0] = 0;
break;
case GIMP_RGBA_IMAGE:
dest[pixelpos + 3] = alphaval;
case GIMP_RGB_IMAGE:
dest[pixelpos + 0] = bgr_red;
dest[pixelpos + 1] = bgr_green;
dest[pixelpos + 2] = bgr_blue;
break;
case GIMP_RGBA_IMAGE:
dest[pixelpos + 3] = alphaval;
case GIMP_RGB_IMAGE:
dest[pixelpos + 0] = bgr_red;
dest[pixelpos + 1] = bgr_green;
dest[pixelpos + 2] = bgr_blue;
break;
case GIMP_GRAYA_IMAGE:
dest[pixelpos + 1] = alphaval;
case GIMP_GRAY_IMAGE:
dest[pixelpos+0] = bgr_red;
break;
}
}
}
}
case GIMP_GRAYA_IMAGE:
dest[pixelpos + 1] = alphaval;
case GIMP_GRAY_IMAGE:
dest[pixelpos+0] = bgr_red;
break;
}
}
}
}
if (((gint) (regionwidth-col) % 5) == 0)
gimp_progress_update ((gdouble) col / (gdouble) regionwidth);
gimp_progress_update ((gdouble) col / (gdouble) regionwidth);
}
gimp_pixel_rgn_set_rect (&destPR, dest, x1, y1, regionwidth, regionheight);
@ -368,12 +368,12 @@ lens_dialog (GimpDrawable *drawable)
dlg = gimp_dialog_new (_("Lens Effect"), "apply_lens",
NULL, 0,
gimp_standard_help_func, "filters/apply_lens.html",
gimp_standard_help_func, "filters/apply_lens.html",
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
NULL);
frame = gtk_frame_new (_("Parameter Settings"));
gtk_container_set_border_width (GTK_CONTAINER (frame), 6);
@ -414,7 +414,7 @@ lens_dialog (GimpDrawable *drawable)
(GTK_RADIO_BUTTON (toggle), _("_Make Surroundings Transparent"));
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
lvals.set_transparent);
lvals.set_transparent);
gtk_widget_show (toggle);
g_signal_connect (toggle, "toggled",
@ -434,7 +434,7 @@ lens_dialog (GimpDrawable *drawable)
gtk_widget_show (label);
spinbutton = gimp_spin_button_new (&adj, lvals.refraction,
1.0, 100.0, 0.1, 1.0, 0, 1, 2);
1.0, 100.0, 0.1, 1.0, 0, 1, 2);
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);

View File

@ -24,31 +24,31 @@
/* Declare local functions. */
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static gint colors_equal (guchar *col1,
guchar *col2,
gint bytes);
guchar *col2,
gint bytes);
static gint guess_bgcolor (GimpPixelRgn *pr,
gint width,
gint height,
gint bytes,
guchar *color);
gint width,
gint height,
gint bytes,
guchar *color);
static void doit (GimpDrawable *drawable,
gint32 image_id,
gboolean show_progress);
gint32 image_id,
gboolean show_progress);
GimpPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
run, /* run_proc */
};
static gint bytes;
@ -67,16 +67,16 @@ query (void)
};
gimp_install_procedure ("plug_in_autocrop",
"Automagically crops a picture.",
"",
"Tim Newsome",
"Tim Newsome",
"1997",
N_("<Image>/Image/Transform/_Autocrop"),
"RGB*, GRAY*, INDEXED*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
"Automagically crops a picture.",
"",
"Tim Newsome",
"Tim Newsome",
"1997",
N_("<Image>/Image/Transform/_Autocrop"),
"RGB*, GRAY*, INDEXED*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
}
static void
@ -171,9 +171,9 @@ doit (GimpDrawable *drawable,
{
gimp_pixel_rgn_get_row (&srcPR, buffer, 0, y, width);
for (x = 0; x < width && !abort; x++)
{
abort = !colors_equal (color, buffer + x * bytes, bytes);
}
{
abort = !colors_equal (color, buffer + x * bytes, bytes);
}
}
if (y == height && !abort)
{
@ -194,9 +194,9 @@ doit (GimpDrawable *drawable,
{
gimp_pixel_rgn_get_row (&srcPR, buffer, 0, y, width);
for (x = 0; x < width && !abort; x++)
{
abort = !colors_equal (color, buffer + x * bytes, bytes);
}
{
abort = !colors_equal (color, buffer + x * bytes, bytes);
}
}
nh = y - ny + 2;
@ -209,9 +209,9 @@ doit (GimpDrawable *drawable,
{
gimp_pixel_rgn_get_col (&srcPR, buffer, x, ny, nh);
for (y = 0; y < nh && !abort; y++)
{
abort = !colors_equal (color, buffer + y * bytes, bytes);
}
{
abort = !colors_equal (color, buffer + y * bytes, bytes);
}
}
x--;
nx = x;
@ -226,9 +226,9 @@ doit (GimpDrawable *drawable,
{
gimp_pixel_rgn_get_col (&srcPR, buffer, x, ny, nh);
for (y = 0; y < nh && !abort; y++)
{
abort = !colors_equal (color, buffer + y * bytes, bytes);
}
{
abort = !colors_equal (color, buffer + y * bytes, bytes);
}
}
nw = x - nx + 2;
@ -245,10 +245,10 @@ doit (GimpDrawable *drawable,
static gint
guess_bgcolor (GimpPixelRgn *pr,
gint width,
gint height,
gint bytes,
guchar *color)
gint width,
gint height,
gint bytes,
guchar *color)
{
guchar tl[4], tr[4], bl[4], br[4];
@ -284,7 +284,7 @@ guess_bgcolor (GimpPixelRgn *pr,
return 3;
}
else if (colors_equal (tl, tr, bytes) || colors_equal (tl, bl, bytes) ||
colors_equal (tl, br, bytes))
colors_equal (tl, br, bytes))
{
memcpy (color, tl, bytes);
return 2;
@ -302,35 +302,35 @@ guess_bgcolor (GimpPixelRgn *pr,
else
{
while (bytes--)
{
color[bytes] = (tl[bytes] + tr[bytes] + bl[bytes] + br[bytes]) / 4;
}
{
color[bytes] = (tl[bytes] + tr[bytes] + bl[bytes] + br[bytes]) / 4;
}
return 0;
}
}
static gint
colors_equal (guchar *col1,
guchar *col2,
gint bytes)
guchar *col2,
gint bytes)
{
gint equal = 1;
gint b;
if ((bytes == 2 || bytes == 4) && /* HACK! */
if ((bytes == 2 || bytes == 4) && /* HACK! */
col1[bytes-1] == 0 &&
col2[bytes-1] == 0)
{
return 1; /* handle zero alpha */
return 1; /* handle zero alpha */
}
for (b = 0; b < bytes; b++)
{
if (col1[b] != col2[b])
{
equal = 0;
break;
}
{
equal = 0;
break;
}
}
return equal;

View File

@ -427,11 +427,11 @@ blindsapply (guchar *srow,
gint bpp,
guchar *bg)
{
guchar *src;
guchar *dst;
gint i,j,k;
gdouble ang;
gint available;
guchar *src;
guchar *dst;
gint i,j,k;
gdouble ang;
gint available;
/* Make the row 'shrink' around points along its length */
/* The bvals.numsegs determins how many segments to slip it in to */
@ -686,11 +686,11 @@ apply_blinds (void)
* this act as a transfomation matrix for the
* rows. Make row 0 invalid so we can find it again!
*/
int i;
gint *sr = g_new (gint, sel_height * 4);
gint *dr = g_new (gint, sel_height * 4);
int i;
gint *sr = g_new (gint, sel_height * 4);
gint *dr = g_new (gint, sel_height * 4);
guchar *dst = g_new (guchar, STEP * 4);
guchar dummybg[4];
guchar dummybg[4];
memset (dummybg, 0, 4);
memset (dr, 0, sel_height * 4); /* all dr rows are background rows */
@ -709,7 +709,7 @@ apply_blinds (void)
/* Fill in with background color ? */
for (i = 0 ; i < STEP ; i++)
{
int j;
int j;
guchar *bgdst;
bgdst = &dst[i * src_rgn.bpp];
@ -721,8 +721,8 @@ apply_blinds (void)
for (x = 0; x < sel_width; x += STEP)
{
int rr;
int step;
int rr;
int step;
guchar *p;
if((x + STEP) > sel_width)

View File

@ -116,10 +116,10 @@ static BlurVals pivals =
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
GimpPlugInInfo PLUG_IN_INFO =
{
@ -132,10 +132,10 @@ GimpPlugInInfo PLUG_IN_INFO =
static void blur (GimpDrawable *drawable);
static inline void blur_prepare_row (GimpPixelRgn *pixel_rgn,
guchar *data,
gint x,
gint y,
gint w);
guchar *data,
gint x,
gint y,
gint w);
static gint blur_dialog (void);
@ -179,28 +179,28 @@ query (void)
const gchar *copyright_date = "1995-1998";
gimp_install_procedure ("plug_in_blur_randomize",
(gchar *) blurb,
(gchar *) help,
(gchar *) author,
(gchar *) copyrights,
(gchar *) copyright_date,
N_("<Image>/Filters/Blur/_Blur..."),
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
(gchar *) blurb,
(gchar *) help,
(gchar *) author,
(gchar *) copyrights,
(gchar *) copyright_date,
N_("<Image>/Filters/Blur/_Blur..."),
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
gimp_install_procedure (PLUG_IN_NAME,
(gchar *) blurb,
(gchar *) help,
(gchar *) author,
(gchar *) copyrights,
(gchar *) copyright_date,
NULL,
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args_ni), 0,
args_ni, NULL);
(gchar *) blurb,
(gchar *) help,
(gchar *) author,
(gchar *) copyrights,
(gchar *) copyright_date,
NULL,
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args_ni), 0,
args_ni, NULL);
}
/*********************************
@ -244,90 +244,90 @@ run (const gchar *name,
gimp_drawable_is_gray (drawable->drawable_id))
{
switch (run_mode)
{
/*
* If we're running interactively, pop up the dialog box.
*/
case GIMP_RUN_INTERACTIVE:
gimp_get_data (PLUG_IN_NAME, &pivals);
if (!blur_dialog ()) /* return on Cancel */
return;
break;
{
/*
* If we're running interactively, pop up the dialog box.
*/
case GIMP_RUN_INTERACTIVE:
gimp_get_data (PLUG_IN_NAME, &pivals);
if (!blur_dialog ()) /* return on Cancel */
return;
break;
/*
* If we're not interactive (probably scripting), we
* get the parameters from the param[] array, since
* we don't use the dialog box. Make sure all
* parameters have legitimate values.
*/
case GIMP_RUN_NONINTERACTIVE:
if ((strcmp (name, "plug_in_blur_randomize") == 0) &&
(nparams == 7))
{
pivals.blur_pct = (gdouble) param[3].data.d_float;
pivals.blur_pct = (gdouble) MIN (100.0, pivals.blur_pct);
pivals.blur_pct = (gdouble) MAX (1.0, pivals.blur_pct);
pivals.blur_rcount = (gdouble) param[4].data.d_float;
pivals.blur_rcount = (gdouble) MIN (100.0,pivals.blur_rcount);
pivals.blur_rcount = (gdouble) MAX (1.0, pivals.blur_rcount);
pivals.blur_randomize = (gboolean) param[5].data.d_int32;
pivals.blur_seed = (gint) param[6].data.d_int32;
}
else if ((strcmp (name, PLUG_IN_NAME) == 0) &&
(nparams == 3))
{
pivals.blur_pct = (gdouble) 100.0;
pivals.blur_rcount = (gdouble) 1.0;
pivals.blur_randomize = FALSE;
pivals.blur_seed = g_random_int ();
}
else
{
status = GIMP_PDB_CALLING_ERROR;
}
break;
/*
* If we're not interactive (probably scripting), we
* get the parameters from the param[] array, since
* we don't use the dialog box. Make sure all
* parameters have legitimate values.
*/
case GIMP_RUN_NONINTERACTIVE:
if ((strcmp (name, "plug_in_blur_randomize") == 0) &&
(nparams == 7))
{
pivals.blur_pct = (gdouble) param[3].data.d_float;
pivals.blur_pct = (gdouble) MIN (100.0, pivals.blur_pct);
pivals.blur_pct = (gdouble) MAX (1.0, pivals.blur_pct);
pivals.blur_rcount = (gdouble) param[4].data.d_float;
pivals.blur_rcount = (gdouble) MIN (100.0,pivals.blur_rcount);
pivals.blur_rcount = (gdouble) MAX (1.0, pivals.blur_rcount);
pivals.blur_randomize = (gboolean) param[5].data.d_int32;
pivals.blur_seed = (gint) param[6].data.d_int32;
}
else if ((strcmp (name, PLUG_IN_NAME) == 0) &&
(nparams == 3))
{
pivals.blur_pct = (gdouble) 100.0;
pivals.blur_rcount = (gdouble) 1.0;
pivals.blur_randomize = FALSE;
pivals.blur_seed = g_random_int ();
}
else
{
status = GIMP_PDB_CALLING_ERROR;
}
break;
/*
* If we're running with the last set of values, get those values.
*/
case GIMP_RUN_WITH_LAST_VALS:
gimp_get_data (PLUG_IN_NAME, &pivals);
break;
/*
* If we're running with the last set of values, get those values.
*/
case GIMP_RUN_WITH_LAST_VALS:
gimp_get_data (PLUG_IN_NAME, &pivals);
break;
/*
* Hopefully we never get here!
*/
default:
break;
/*
* Hopefully we never get here!
*/
default:
break;
}
if (status == GIMP_PDB_SUCCESS)
{
/*
* JUST DO IT!
*/
gimp_progress_init (_("Blurring..."));
{
/*
* JUST DO IT!
*/
gimp_progress_init (_("Blurring..."));
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width ()
+ 1));
/*
* Initialize the rand() function seed
*/
/*
* Initialize the rand() function seed
*/
g_random_set_seed (pivals.blur_seed);
blur (drawable);
/*
* If we ran interactively (even repeating) update the display.
*/
if (run_mode != GIMP_RUN_NONINTERACTIVE)
{
gimp_displays_flush ();
blur (drawable);
/*
* If we ran interactively (even repeating) update the display.
*/
if (run_mode != GIMP_RUN_NONINTERACTIVE)
{
gimp_displays_flush ();
}
/*
* If we use the dialog popup, set the data for future use.
*/
if (run_mode == GIMP_RUN_INTERACTIVE)
{
gimp_set_data (PLUG_IN_NAME, &pivals, sizeof (BlurVals));
/*
* If we use the dialog popup, set the data for future use.
*/
if (run_mode == GIMP_RUN_INTERACTIVE)
{
gimp_set_data (PLUG_IN_NAME, &pivals, sizeof (BlurVals));
}
}
}
@ -359,10 +359,10 @@ run (const gchar *name,
static inline void
blur_prepare_row (GimpPixelRgn *pixel_rgn,
guchar *data,
gint x,
gint y,
gint w)
guchar *data,
gint x,
gint y,
gint w)
{
int b;
@ -455,97 +455,97 @@ blur (GimpDrawable *drawable)
* loop through the rows, applying the selected convolution
*/
for (row = y1; row < y2; row++)
{
/* prepare the next row */
blur_prepare_row (sp, nr, x1, row + 1, (x2 - x1));
{
/* prepare the next row */
blur_prepare_row (sp, nr, x1, row + 1, (x2 - x1));
d = dest;
ind = 0;
for (col = 0; col < (x2 - x1) * bytes; col++)
{
if (g_random_int_range (0, 100) <= (gint) pivals.blur_pct)
{
ind++;
if (ind == bytes || !has_alpha)
{
/*
* If no alpha channel,
* or if there is one and this is it...
*/
*d++ = ((gint) pr[col - bytes] + (gint) pr[col] +
(gint) pr[col + bytes] +
(gint) cr[col - bytes] + (gint) cr[col] +
(gint) cr[col + bytes] +
(gint) nr[col - bytes] + (gint) nr[col] +
(gint) nr[col + bytes]) / 9;
ind = 0;
d = dest;
ind = 0;
for (col = 0; col < (x2 - x1) * bytes; col++)
{
if (g_random_int_range (0, 100) <= (gint) pivals.blur_pct)
{
ind++;
if (ind == bytes || !has_alpha)
{
/*
* If no alpha channel,
* or if there is one and this is it...
*/
*d++ = ((gint) pr[col - bytes] + (gint) pr[col] +
(gint) pr[col + bytes] +
(gint) cr[col - bytes] + (gint) cr[col] +
(gint) cr[col + bytes] +
(gint) nr[col - bytes] + (gint) nr[col] +
(gint) nr[col + bytes]) / 9;
ind = 0;
}
else
{
/*
* otherwise we have an alpha channel,
* but this is a color channel
*/
*d++ = ((gint)
(((gdouble) (pr[col - bytes] * pr[col - ind])
+ (gdouble) (pr[col] * pr[col + bytes - ind])
+ (gdouble) (pr[col + bytes] * pr[col + 2*bytes - ind])
+ (gdouble) (cr[col - bytes] * cr[col - ind])
+ (gdouble) (cr[col] * cr[col + bytes - ind])
+ (gdouble) (cr[col + bytes] * cr[col + 2*bytes - ind])
+ (gdouble) (nr[col - bytes] * nr[col - ind])
+ (gdouble) (nr[col] * nr[col + bytes - ind])
+ (gdouble) (nr[col + bytes] * nr[col + 2*bytes - ind]))
else
{
/*
* otherwise we have an alpha channel,
* but this is a color channel
*/
*d++ = ((gint)
(((gdouble) (pr[col - bytes] * pr[col - ind])
+ (gdouble) (pr[col] * pr[col + bytes - ind])
+ (gdouble) (pr[col + bytes] * pr[col + 2*bytes - ind])
+ (gdouble) (cr[col - bytes] * cr[col - ind])
+ (gdouble) (cr[col] * cr[col + bytes - ind])
+ (gdouble) (cr[col + bytes] * cr[col + 2*bytes - ind])
+ (gdouble) (nr[col - bytes] * nr[col - ind])
+ (gdouble) (nr[col] * nr[col + bytes - ind])
+ (gdouble) (nr[col + bytes] * nr[col + 2*bytes - ind]))
/ ((gdouble) pr[col - ind]
+ (gdouble) pr[col + bytes - ind]
+ (gdouble) pr[col + 2*bytes - ind]
+ (gdouble) cr[col - ind]
+ (gdouble) cr[col + bytes - ind]
+ (gdouble) cr[col + 2*bytes - ind]
+ (gdouble) nr[col - ind]
+ (gdouble) nr[col + bytes - ind]
+ (gdouble) nr[col + 2*bytes - ind])));
+ (gdouble) pr[col + bytes - ind]
+ (gdouble) pr[col + 2*bytes - ind]
+ (gdouble) cr[col - ind]
+ (gdouble) cr[col + bytes - ind]
+ (gdouble) cr[col + 2*bytes - ind]
+ (gdouble) nr[col - ind]
+ (gdouble) nr[col + bytes - ind]
+ (gdouble) nr[col + 2*bytes - ind])));
}
/*
* Otherwise, this pixel was not selected for randomization,
* so use the current value.
*/
/*
* Otherwise, this pixel was not selected for randomization,
* so use the current value.
*/
}
else
{
*d++ = (gint) cr[col];
else
{
*d++ = (gint) cr[col];
}
}
/*
* Save the modified row, shuffle the row pointers, and every
* so often, update the progress meter.
*/
gimp_pixel_rgn_set_row (dp, dest, x1, row, (x2 - x1));
/*
* Save the modified row, shuffle the row pointers, and every
* so often, update the progress meter.
*/
gimp_pixel_rgn_set_row (dp, dest, x1, row, (x2 - x1));
tmp = pr;
pr = cr;
cr = nr;
nr = tmp;
tmp = pr;
pr = cr;
cr = nr;
nr = tmp;
if (PROG_UPDATE_TIME)
gimp_progress_update ((double) row / (double) (y2 - y1));
if (PROG_UPDATE_TIME)
gimp_progress_update ((double) row / (double) (y2 - y1));
}
/*
* if we have more cycles to perform, swap the src and dest Pixel Regions
*/
if (cnt < repeat_count)
{
if (tp != NULL)
{
tp = dp;
dp = sp;
sp = tp;
{
if (tp != NULL)
{
tp = dp;
dp = sp;
sp = tp;
}
else
{
tp = &srcPR;
sp = &destPR;
dp = &destPR2;
else
{
tp = &srcPR;
sp = &destPR;
dp = &destPR2;
}
}
}
@ -584,12 +584,12 @@ blur_dialog (void)
dlg = gimp_dialog_new (_("Blur"), "blur",
NULL, 0,
gimp_standard_help_func, "filters/blur.html",
gimp_standard_help_func, "filters/blur.html",
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
NULL);
/*
* Parameter settings
@ -611,19 +611,19 @@ blur_dialog (void)
/* Random Seed */
seed_hbox = gimp_random_seed_new (&pivals.blur_seed, &pivals.blur_randomize);
label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("_Random Seed:"), 1.0, 0.5,
seed_hbox, 1, TRUE);
_("_Random Seed:"), 1.0, 0.5,
seed_hbox, 1, TRUE);
gtk_label_set_mnemonic_widget (GTK_LABEL (label),
GIMP_RANDOM_SEED_SPINBUTTON (seed_hbox));
GIMP_RANDOM_SEED_SPINBUTTON (seed_hbox));
/*
* Randomization percentage label & scale (1 to 100)
*/
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("R_andomization %:"), SCALE_WIDTH, 0,
pivals.blur_pct, 1.0, 100.0, 1.0, 10.0, 0,
TRUE, 0, 0,
_("Percentage of pixels to be filtered"), NULL);
_("R_andomization %:"), SCALE_WIDTH, 0,
pivals.blur_pct, 1.0, 100.0, 1.0, 10.0, 0,
TRUE, 0, 0,
_("Percentage of pixels to be filtered"), NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (gimp_double_adjustment_update),
&pivals.blur_pct);
@ -632,10 +632,10 @@ blur_dialog (void)
* Repeat count label & scale (1 to 100)
*/
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
_("R_epeat:"), SCALE_WIDTH, 0,
pivals.blur_rcount, 1.0, 100.0, 1.0, 10.0, 0,
TRUE, 0, 0,
_("Number of times to apply filter"), NULL);
_("R_epeat:"), SCALE_WIDTH, 0,
pivals.blur_rcount, 1.0, 100.0, 1.0, 10.0, 0,
TRUE, 0, 0,
_("Number of times to apply filter"), NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (gimp_double_adjustment_update),
&pivals.blur_rcount);

View File

@ -33,20 +33,20 @@
*/
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void borderaverage (GimpDrawable *drawable,
GimpRGB *result);
GimpRGB *result);
static gint borderaverage_dialog (void);
static void add_new_color (gint bytes,
guchar *buffer,
gint *cube,
gint bucket_expo);
guchar *buffer,
gint *cube,
gint bucket_expo);
GimpPlugInInfo PLUG_IN_INFO =
@ -91,17 +91,17 @@ query (void)
};
gimp_install_procedure ("plug_in_borderaverage",
"Borderaverage",
"",
"Philipp Klaus",
"Internet Access AG",
"1998",
N_("<Image>/Filters/Colors/_Border Average..."),
"RGB*",
GIMP_PLUGIN,
G_N_ELEMENTS (args),
"Borderaverage",
"",
"Philipp Klaus",
"Internet Access AG",
"1998",
N_("<Image>/Filters/Colors/_Border Average..."),
"RGB*",
GIMP_PLUGIN,
G_N_ELEMENTS (args),
G_N_ELEMENTS (return_vals),
args, return_vals);
args, return_vals);
}
static void
@ -121,7 +121,7 @@ run (const gchar *name,
run_mode = param[0].data.d_int32;
/* Get the specified drawable */
/* Get the specified drawable */
drawable = gimp_drawable_get (param[2].data.d_drawable);
switch (run_mode)
@ -131,17 +131,17 @@ run (const gchar *name,
borderaverage_thickness = borderaverage_data.thickness;
borderaverage_bucket_exponent = borderaverage_data.bucket_exponent;
if (! borderaverage_dialog ())
status = GIMP_PDB_EXECUTION_ERROR;
status = GIMP_PDB_EXECUTION_ERROR;
break;
case GIMP_RUN_NONINTERACTIVE:
if (nparams != 5)
status = GIMP_PDB_CALLING_ERROR;
status = GIMP_PDB_CALLING_ERROR;
if (status == GIMP_PDB_SUCCESS)
{
borderaverage_thickness = param[3].data.d_int32;
borderaverage_bucket_exponent = param[4].data.d_int32;
}
{
borderaverage_thickness = param[3].data.d_int32;
borderaverage_bucket_exponent = param[4].data.d_int32;
}
break;
case GIMP_RUN_WITH_LAST_VALS:
@ -158,26 +158,26 @@ run (const gchar *name,
{
/* Make sure that the drawable is RGB color */
if (gimp_drawable_is_rgb (drawable->drawable_id))
{
gimp_progress_init ( _("Border Average..."));
borderaverage (drawable, &result_color);
{
gimp_progress_init ( _("Border Average..."));
borderaverage (drawable, &result_color);
if (run_mode != GIMP_RUN_NONINTERACTIVE)
{
gimp_palette_set_foreground (&result_color);
}
if (run_mode == GIMP_RUN_INTERACTIVE)
{
borderaverage_data.thickness = borderaverage_thickness;
borderaverage_data.bucket_exponent = borderaverage_bucket_exponent;
gimp_set_data ("plug_in_borderaverage",
&borderaverage_data, sizeof (borderaverage_data));
}
}
if (run_mode != GIMP_RUN_NONINTERACTIVE)
{
gimp_palette_set_foreground (&result_color);
}
if (run_mode == GIMP_RUN_INTERACTIVE)
{
borderaverage_data.thickness = borderaverage_thickness;
borderaverage_data.bucket_exponent = borderaverage_bucket_exponent;
gimp_set_data ("plug_in_borderaverage",
&borderaverage_data, sizeof (borderaverage_data));
}
}
else
{
status = GIMP_PDB_EXECUTION_ERROR;
}
{
status = GIMP_PDB_EXECUTION_ERROR;
}
}
*nreturn_vals = 3;
*return_vals = values;
@ -193,7 +193,7 @@ run (const gchar *name,
static void
borderaverage (GimpDrawable *drawable,
GimpRGB *result)
GimpRGB *result)
{
gint width;
gint height;
@ -218,12 +218,12 @@ borderaverage (GimpDrawable *drawable,
for (i = 0; i < bucket_num; i++)
{
for (j = 0; j < bucket_num; j++)
{
for (k = 0; k < bucket_num; k++)
{
cube[(i << (bucket_rexpo << 1)) + (j << bucket_rexpo) + k] = 0;
}
}
{
for (k = 0; k < bucket_num; k++)
{
cube[(i << (bucket_rexpo << 1)) + (j << bucket_rexpo) + k] = 0;
}
}
}
/* Get the input area. This is the bounding box of the selection in
@ -255,31 +255,31 @@ borderaverage (GimpDrawable *drawable,
gimp_pixel_rgn_get_row (&myPR, buffer, x1, row, (x2-x1));
if (row < y1 + borderaverage_thickness ||
row >= y2 - borderaverage_thickness)
{
/* add the whole row */
for (col = 0; col < ((x2 - x1) * bytes); col += bytes)
{
add_new_color (bytes, &buffer[col], cube, bucket_expo);
}
}
row >= y2 - borderaverage_thickness)
{
/* add the whole row */
for (col = 0; col < ((x2 - x1) * bytes); col += bytes)
{
add_new_color (bytes, &buffer[col], cube, bucket_expo);
}
}
else
{
/* add the left border */
for (col = 0; col < (borderaverage_thickness * bytes); col += bytes)
{
add_new_color (bytes, &buffer[col], cube, bucket_expo);
}
/* add the right border */
for (col = ((x2 - x1 - borderaverage_thickness) * bytes);
col < ((x2 - x1) * bytes); col += bytes)
{
add_new_color (bytes, &buffer[col], cube, bucket_expo);
}
}
{
/* add the left border */
for (col = 0; col < (borderaverage_thickness * bytes); col += bytes)
{
add_new_color (bytes, &buffer[col], cube, bucket_expo);
}
/* add the right border */
for (col = ((x2 - x1 - borderaverage_thickness) * bytes);
col < ((x2 - x1) * bytes); col += bytes)
{
add_new_color (bytes, &buffer[col], cube, bucket_expo);
}
}
if ((row % 5) == 0)
gimp_progress_update ((double) row / (double) (y2 - y1));
gimp_progress_update ((double) row / (double) (y2 - y1));
}
max = 0; r = 0; g = 0; b = 0;
@ -288,20 +288,20 @@ borderaverage (GimpDrawable *drawable,
for (i = 0; i < bucket_num; i++)
{
for (j = 0; j < bucket_num; j++)
{
for (k = 0; k < bucket_num; k++)
{
if (cube[(i << (bucket_rexpo << 1)) +
(j << bucket_rexpo) + k] > max)
{
max = cube[(i << (bucket_rexpo << 1)) +
(j << bucket_rexpo) + k];
r = (i<<bucket_expo) + (1<<(bucket_expo - 1));
g = (j<<bucket_expo) + (1<<(bucket_expo - 1));
b = (k<<bucket_expo) + (1<<(bucket_expo - 1));
}
}
}
{
for (k = 0; k < bucket_num; k++)
{
if (cube[(i << (bucket_rexpo << 1)) +
(j << bucket_rexpo) + k] > max)
{
max = cube[(i << (bucket_rexpo << 1)) +
(j << bucket_rexpo) + k];
r = (i<<bucket_expo) + (1<<(bucket_expo - 1));
g = (j<<bucket_expo) + (1<<(bucket_expo - 1));
b = (k<<bucket_expo) + (1<<(bucket_expo - 1));
}
}
}
}
/* return the color */
@ -313,12 +313,12 @@ borderaverage (GimpDrawable *drawable,
static void
add_new_color (gint bytes,
guchar *buffer,
gint *cube,
gint bucket_expo)
guchar *buffer,
gint *cube,
gint bucket_expo)
{
guchar r, g, b;
gint bucket_rexpo;
gint bucket_rexpo;
bucket_rexpo = 8 - bucket_expo;
r = buffer[0] >>bucket_expo;
@ -358,12 +358,12 @@ borderaverage_dialog (void)
dlg = gimp_dialog_new (_("Borderaverage"), "borderaverage",
NULL, 0,
gimp_standard_help_func, "filters/borderaverage.html",
gimp_standard_help_func, "filters/borderaverage.html",
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
NULL);
vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
@ -384,7 +384,7 @@ borderaverage_dialog (void)
gtk_widget_show (label);
spinbutton = gimp_spin_button_new (&adj, borderaverage_thickness,
0, 256, 1, 5, 0, 0, 0);
0, 256, 1, 5, 0, 0, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton);
@ -407,20 +407,20 @@ borderaverage_dialog (void)
gtk_widget_show (label);
menu = gimp_int_option_menu_new (FALSE, G_CALLBACK (gimp_menu_item_update),
&borderaverage_bucket_exponent,
borderaverage_bucket_exponent,
&borderaverage_bucket_exponent,
borderaverage_bucket_exponent,
_("1 (nonsense?)"), 0, NULL,
"2", 1, NULL,
"4", 2, NULL,
"8", 3, NULL,
"16", 4, NULL,
"32", 5, NULL,
"64", 6, NULL,
"128", 7, NULL,
_("256 (nonsense?)"), 8, NULL,
_("1 (nonsense?)"), 0, NULL,
"2", 1, NULL,
"4", 2, NULL,
"8", 3, NULL,
"16", 4, NULL,
"32", 5, NULL,
"64", 6, NULL,
"128", 7, NULL,
_("256 (nonsense?)"), 8, NULL,
NULL);
NULL);
gtk_box_pack_start (GTK_BOX (hbox), menu, FALSE, FALSE, 0);
gtk_widget_show (menu);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), menu);

File diff suppressed because it is too large Load Diff

View File

@ -55,18 +55,18 @@
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static gint32 load_image (const gchar *filename,
gint32 run_mode,
GimpPDBStatusType *status /* return value */);
gint32 run_mode,
GimpPDBStatusType *status /* return value */);
static GimpPDBStatusType save_image (const gchar *filename,
gint32 image_ID,
gint32 drawable_ID,
gint32 run_mode);
gint32 image_ID,
gint32 drawable_ID,
gint32 run_mode);
static gboolean valid_file (const gchar *filename);
static const gchar * find_extension (const gchar *filename);
@ -111,7 +111,7 @@ query (void)
"Daniel Risacher, Spencer Kimball and Peter Mattis",
"1995-1997",
"<Load>/bzip2",
NULL,
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (load_args),
G_N_ELEMENTS (load_return_vals),
@ -124,18 +124,18 @@ query (void)
"Daniel Risacher, Spencer Kimball and Peter Mattis",
"1995-1997",
"<Save>/bzip2",
"RGB*, GRAY*, INDEXED*",
"RGB*, GRAY*, INDEXED*",
GIMP_PLUGIN,
G_N_ELEMENTS (save_args), 0,
save_args, NULL);
gimp_register_magic_load_handler ("file_bz2_load",
"xcf.bz2,bz2,xcfbz2",
"",
"0,string,BZh");
"xcf.bz2,bz2,xcfbz2",
"",
"0,string,BZh");
gimp_register_save_handler ("file_bz2_save",
"xcf.bz2,bz2,xcfbz2",
"");
"xcf.bz2,bz2,xcfbz2",
"");
}
static void
@ -162,42 +162,42 @@ run (const gchar *name,
if (strcmp (name, "file_bz2_load") == 0)
{
image_ID = load_image (param[1].data.d_string,
param[0].data.d_int32,
&status);
param[0].data.d_int32,
&status);
if (image_ID != -1 &&
status == GIMP_PDB_SUCCESS)
{
*nreturn_vals = 2;
values[1].type = GIMP_PDB_IMAGE;
values[1].data.d_image = image_ID;
}
status == GIMP_PDB_SUCCESS)
{
*nreturn_vals = 2;
values[1].type = GIMP_PDB_IMAGE;
values[1].data.d_image = image_ID;
}
}
else if (strcmp (name, "file_bz2_save") == 0)
{
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
break;
case GIMP_RUN_NONINTERACTIVE:
/* Make sure all the arguments are there! */
if (nparams != 4)
status = GIMP_PDB_CALLING_ERROR;
break;
case GIMP_RUN_WITH_LAST_VALS:
break;
{
case GIMP_RUN_INTERACTIVE:
break;
case GIMP_RUN_NONINTERACTIVE:
/* Make sure all the arguments are there! */
if (nparams != 4)
status = GIMP_PDB_CALLING_ERROR;
break;
case GIMP_RUN_WITH_LAST_VALS:
break;
default:
break;
}
default:
break;
}
if (status == GIMP_PDB_SUCCESS)
{
status = save_image (param[3].data.d_string,
param[1].data.d_int32,
param[2].data.d_int32,
param[0].data.d_int32);
}
{
status = save_image (param[3].data.d_string,
param[1].data.d_int32,
param[2].data.d_int32,
param[0].data.d_int32);
}
}
else
{
@ -210,12 +210,12 @@ run (const gchar *name,
#ifdef __EMX__
static gint
spawn_bz (gchar *filename,
gchar *tmpname,
gchar *parms,
gint *pid)
gchar *tmpname,
gchar *parms,
gint *pid)
{
FILE *f;
gint tfd;
gint tfd;
if (!(f = fopen (filename,"wb")))
{
@ -249,9 +249,9 @@ spawn_bz (gchar *filename,
static GimpPDBStatusType
save_image (const gchar *filename,
gint32 image_ID,
gint32 drawable_ID,
gint32 run_mode)
gint32 image_ID,
gint32 drawable_ID,
gint32 run_mode)
{
FILE *f;
const gchar *ext;
@ -270,10 +270,10 @@ save_image (const gchar *filename,
tmpname = gimp_temp_name (ext + 1);
if (! (gimp_file_save (run_mode,
image_ID,
drawable_ID,
tmpname,
tmpname) && valid_file (tmpname)) )
image_ID,
drawable_ID,
tmpname,
tmpname) && valid_file (tmpname)) )
{
unlink (tmpname);
g_free (tmpname);
@ -291,15 +291,15 @@ save_image (const gchar *filename,
else if (pid == 0)
{
if (!(f = fopen (filename, "w")))
{
g_message ("fopen() failed: %s", g_strerror (errno));
g_free (tmpname);
_exit(127);
}
{
g_message ("fopen() failed: %s", g_strerror (errno));
g_free (tmpname);
_exit(127);
}
/* make stdout for this process be the output file */
if (-1 == dup2 (fileno (f), fileno (stdout)))
g_message ("dup2() failed: %s", g_strerror (errno));
g_message ("dup2() failed: %s", g_strerror (errno));
/* and bzip2 into it */
execlp ("bzip2", "bzip2", "-cf", tmpname, NULL);
@ -319,13 +319,13 @@ save_image (const gchar *filename,
wpid = waitpid (pid, &process_status, 0);
if ((wpid < 0)
|| !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{
g_message ("bzip2 exited abnormally on file '%s'", tmpname);
g_free (tmpname);
return GIMP_PDB_EXECUTION_ERROR;
}
|| !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{
g_message ("bzip2 exited abnormally on file '%s'", tmpname);
g_free (tmpname);
return GIMP_PDB_EXECUTION_ERROR;
}
}
unlink (tmpname);
@ -336,8 +336,8 @@ save_image (const gchar *filename,
static gint32
load_image (const gchar *filename,
gint32 run_mode,
GimpPDBStatusType *status /* return value */)
gint32 run_mode,
GimpPDBStatusType *status /* return value */)
{
gint32 image_ID;
const gchar *ext;
@ -369,15 +369,15 @@ load_image (const gchar *filename,
{
FILE *f;
if (!(f = fopen (tmpname,"w")))
{
g_message ("fopen() failed: %s", g_strerror (errno));
g_free (tmpname);
_exit (127);
}
{
g_message ("fopen() failed: %s", g_strerror (errno));
g_free (tmpname);
_exit (127);
}
/* make stdout for this child process be the temp file */
if (-1 == dup2 (fileno (f), fileno (stdout)))
g_message ("dup2() failed: %s", g_strerror (errno));
g_message ("dup2() failed: %s", g_strerror (errno));
/* and unzip into it */
execlp ("bzip2", "bzip2", "-cfd", filename, NULL);
@ -398,14 +398,14 @@ load_image (const gchar *filename,
wpid = waitpid (pid, &process_status, 0);
if ((wpid < 0)
|| !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{
g_message ("bzip2 exited abnormally on file '%s'", filename);
g_free (tmpname);
*status = GIMP_PDB_EXECUTION_ERROR;
return -1;
}
|| !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{
g_message ("bzip2 exited abnormally on file '%s'", filename);
g_free (tmpname);
*status = GIMP_PDB_EXECUTION_ERROR;
return -1;
}
}
/* now that we un-bzip2ed it, load the temp file */
@ -455,22 +455,22 @@ find_extension (const gchar* filename)
while (TRUE)
{
if (!ext || ext[1] == '\0' || strchr (ext, '/'))
{
return NULL;
}
{
return NULL;
}
if (0 == g_ascii_strcasecmp (ext, ".xcfbz2"))
{
return ".xcf"; /* we've found it */
}
{
return ".xcf"; /* we've found it */
}
if (0 != g_ascii_strcasecmp (ext, ".bz2"))
{
return ext;
}
{
return ext;
}
else
{
/* we found ".bz2" so strip it, loop back, and look again */
*ext = '\0';
ext = strrchr (filename_copy, '.');
}
{
/* we found ".bz2" so strip it, loop back, and look again */
*ext = '\0';
ext = strrchr (filename_copy, '.');
}
}
}

View File

@ -73,23 +73,23 @@ query (void)
};
gimp_install_procedure ("plug_in_c_astretch",
"Automatically stretch the contrast of the "
"specified drawable to cover all possible ranges.",
"This simple plug-in does an automatic contrast "
"stretch. For each channel in the image, it finds "
"the minimum and maximum values... it uses those "
"values to stretch the individual histograms to the "
"full contrast range. For some images it may do "
"just what you want; for others it may not work "
"that well.",
"Federico Mena Quintero",
"Federico Mena Quintero",
"1996",
N_("<Image>/Layer/Colors/Auto/_Stretch Contrast"),
"RGB*, GRAY*, INDEXED*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
"Automatically stretch the contrast of the "
"specified drawable to cover all possible ranges.",
"This simple plug-in does an automatic contrast "
"stretch. For each channel in the image, it finds "
"the minimum and maximum values... it uses those "
"values to stretch the individual histograms to the "
"full contrast range. For some images it may do "
"just what you want; for others it may not work "
"that well.",
"Federico Mena Quintero",
"Federico Mena Quintero",
"1996",
N_("<Image>/Layer/Colors/Auto/_Stretch Contrast"),
"RGB*, GRAY*, INDEXED*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
}
static void
@ -122,14 +122,14 @@ run (const gchar *name,
c_astretch (drawable);
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush ();
gimp_displays_flush ();
}
else if (gimp_drawable_is_indexed (drawable->drawable_id))
{
indexed_c_astretch (image_ID);
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush ();
gimp_displays_flush ();
}
else
{
@ -150,8 +150,8 @@ static void
indexed_c_astretch (gint32 image_ID)
{
guchar *cmap;
gint ncols,i;
gint rhi=0,ghi=0,bhi=0,rlo=255,glo=255,blo=255;
gint ncols, i;
gint rhi=0, ghi=0, bhi=0, rlo=255, glo=255, blo=255;
cmap = gimp_image_get_cmap (image_ID, &ncols);
@ -174,22 +174,22 @@ indexed_c_astretch (gint32 image_ID)
for (i=0;i<ncols;i++)
{
if (rhi!=rlo)
cmap[i*3 +0] = (255 * (cmap[i*3 +0] - rlo)) / (rhi-rlo);
cmap[i*3 +0] = (255 * (cmap[i*3 +0] - rlo)) / (rhi-rlo);
if (ghi!=glo)
cmap[i*3 +1] = (255 * (cmap[i*3 +1] - glo)) / (ghi-glo);
cmap[i*3 +1] = (255 * (cmap[i*3 +1] - glo)) / (ghi-glo);
if (rhi!=rlo)
cmap[i*3 +2] = (255 * (cmap[i*3 +2] - blo)) / (bhi-blo);
cmap[i*3 +2] = (255 * (cmap[i*3 +2] - blo)) / (bhi-blo);
}
gimp_image_set_cmap (image_ID, cmap, ncols);
}
typedef struct {
gint alpha;
guchar lut[256][3];
guchar min[3];
guchar max[3];
gboolean has_alpha;
gint alpha;
guchar lut[256][3];
guchar min[3];
guchar max[3];
gboolean has_alpha;
} AutoStretchParam_t;
static void
@ -197,18 +197,18 @@ find_min_max (const guchar *src,
gint bpp,
gpointer data)
{
AutoStretchParam_t *param = (AutoStretchParam_t*) data;
gint b;
AutoStretchParam_t *param = data;
gint b;
for (b = 0; b < param->alpha; b++)
{
if (!param->has_alpha || src[param->alpha])
{
if (src[b] < param->min[b])
param->min[b] = src[b];
if (src[b] > param->max[b])
param->max[b] = src[b];
}
{
if (src[b] < param->min[b])
param->min[b] = src[b];
if (src[b] > param->max[b])
param->max[b] = src[b];
}
}
}
@ -218,8 +218,8 @@ c_astretch_func (const guchar *src,
gint bpp,
gpointer data)
{
AutoStretchParam_t *param = (AutoStretchParam_t*) data;
gint b;
AutoStretchParam_t *param = data;
gint b;
for (b = 0; b < param->alpha; b++)
dest[b] = param->lut[src[b]][b];
@ -232,7 +232,7 @@ static void
c_astretch (GimpDrawable *drawable)
{
AutoStretchParam_t param;
gint b;
gint b;
param.has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
param.alpha = (param.has_alpha) ? drawable->bpp - 1 : drawable->bpp;
@ -250,10 +250,10 @@ c_astretch (GimpDrawable *drawable)
gint x;
if (range != 0)
for (x = param.min[b]; x <= param.max[b]; x++)
param.lut[x][b] = 255 * (x - param.min[b]) / range;
for (x = param.min[b]; x <= param.max[b]; x++)
param.lut[x][b] = 255 * (x - param.min[b]) / range;
else
param.lut[param.min[b]][b] = param.min[b];
param.lut[param.min[b]][b] = param.min[b];
}
gimp_rgn_iterate2 (drawable, run_mode, c_astretch_func, &param);

View File

@ -100,11 +100,11 @@ typedef struct
typedef struct
{
gint width;
gint height;
gint bpp;
gdouble scale;
guchar *bits;
gint width;
gint height;
gint bpp;
gdouble scale;
guchar *bits;
} mwPreview;
#define PREVIEW_SIZE 200
@ -521,7 +521,7 @@ cm_dialog (void)
default:
g_assert_not_reached ();
red_value = green_value = blue_value = 0.0;
red_value = green_value = blue_value = 0.0;
break;
}
}
@ -535,7 +535,7 @@ cm_dialog (void)
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
NULL);
hbox = gtk_hbox_new (FALSE, 6);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
@ -1043,7 +1043,7 @@ cm_load_file_callback (GtkWidget *widget,
g_signal_connect (filesel, "response",
G_CALLBACK (cm_load_file_response_callback),
mix);
mix);
g_signal_connect (filesel, "delete_event",
G_CALLBACK (gtk_true),
NULL);
@ -1075,12 +1075,12 @@ cm_load_file_response_callback (GtkFileSelection *fs,
fp = fopen (mix->filename, "r");
if (fp)
{
gchar buf[3][CM_LINE_SIZE];
{
gchar buf[3][CM_LINE_SIZE];
buf[0][0] = '\0';
buf[1][0] = '\0';
buf[2][0] = '\0';
buf[0][0] = '\0';
buf[1][0] = '\0';
buf[2][0] = '\0';
fgets (buf[0], CM_LINE_SIZE - 1, fp);
@ -1180,7 +1180,7 @@ cm_save_file_callback (GtkWidget *widget,
g_signal_connect (filesel, "response",
G_CALLBACK (cm_save_file_response_callback),
mix);
mix);
g_signal_connect (filesel, "delete_event",
G_CALLBACK (gtk_true),
NULL);

View File

@ -61,10 +61,8 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <gtk/gtk.h>
@ -647,9 +645,7 @@ nova_center_preview_expose (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
printf("Before\n");
nova_center_draw ((NovaCenter*) data, ALL);
printf("After\n");
return FALSE;
}