From 39bf72558c7801d78a9a5be55782bead8037a9a1 Mon Sep 17 00:00:00 2001 From: David Odin Date: Tue, 23 Dec 2003 22:07:06 +0000 Subject: [PATCH] small cosmetic changes, such as removing tabs. --- ChangeLog | 21 + plug-ins/common/AlienMap.c | 8 +- plug-ins/common/AlienMap2.c | 200 ++--- plug-ins/common/CEL.c | 360 ++++----- plug-ins/common/aa.c | 132 ++-- plug-ins/common/align_layers.c | 328 ++++---- plug-ins/common/animationplay.c | 1240 +++++++++++++++-------------- plug-ins/common/animoptimize.c | 1290 +++++++++++++++---------------- plug-ins/common/apply_lens.c | 178 ++--- plug-ins/common/autocrop.c | 104 +-- plug-ins/common/blinds.c | 24 +- plug-ins/common/blur.c | 392 +++++----- plug-ins/common/borderaverage.c | 214 ++--- plug-ins/common/bumpmap.c | 902 ++++++++++----------- plug-ins/common/bz2.c | 194 ++--- plug-ins/common/c_astretch.c | 86 +-- plug-ins/common/channel_mixer.c | 28 +- plug-ins/common/nova.c | 4 - 18 files changed, 2858 insertions(+), 2847 deletions(-) diff --git a/ChangeLog b/ChangeLog index f36d7fdc7a..ef8c79e6fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2003-12-22 DindinX + + * 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 * app/gui/user-install-dialog.c (user_install_dialog_run): added a diff --git a/plug-ins/common/AlienMap.c b/plug-ins/common/AlienMap.c index 43e5307556..f2b5294501 100644 --- a/plug-ins/common/AlienMap.c +++ b/plug-ins/common/AlienMap.c @@ -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) { diff --git a/plug-ins/common/AlienMap2.c b/plug-ins/common/AlienMap2.c index 779056c21a..462797ed4d 100644 --- a/plug-ins/common/AlienMap2.c +++ b/plug-ins/common/AlienMap2.c @@ -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_("/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_("/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) { diff --git a/plug-ins/common/CEL.c b/plug-ins/common/CEL.c index 0e09f6b0bc..b0f6ec6049 100644 --- a/plug-ins/common/CEL.c +++ b/plug-ins/common/CEL.c @@ -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 ", - "May 1998", - "/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 ", + "May 1998", + "/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 ", - "May 1998", - "/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 ", + "May 1998", + "/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); diff --git a/plug-ins/common/aa.c b/plug-ins/common/aa.c index 71aa8a9460..b00183bf26 100644 --- a/plug-ins/common/aa.c +++ b/plug-ins/common/aa.c @@ -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 ", - "Tim Newsome ", - "1997", - "/AA", - "RGB*, GRAY*", - GIMP_PLUGIN, - G_N_ELEMENTS (save_args), 0, - save_args, NULL); + "Tim Newsome ", + "Tim Newsome ", + "1997", + "/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); } diff --git a/plug-ins/common/align_layers.c b/plug-ins/common/align_layers.c index 2089921898..611afdf95d 100644 --- a/plug-ins/common/align_layers.c +++ b/plug-ins/common/align_layers.c @@ -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 ", - "Shuji Narazaki", - "1997", - N_("/Layer/Align _Visible Layers..."), - "RGB*,GRAY*", - GIMP_PLUGIN, - G_N_ELEMENTS (args), 0, - args, NULL); + "Align visible layers", + "Align visible layers", + "Shuji Narazaki ", + "Shuji Narazaki", + "1997", + N_("/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); diff --git a/plug-ins/common/animationplay.c b/plug-ins/common/animationplay.c index 487dd34f15..0f75bb3ddd 100644 --- a/plug-ins/common/animationplay.c +++ b/plug-ins/common/animationplay.c @@ -134,10 +134,10 @@ typedef enum /* 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 void do_playback (void); @@ -169,11 +169,11 @@ static DisposeType parse_disposal_tag (const char *str); static DisposeType get_frame_disposal (const guint whichframe); static guint32 get_frame_duration (const guint whichframe); static int is_disposal_tag (const char *str, - DisposeType *disposal, - int *taglength); + DisposeType *disposal, + int *taglength); static int is_ms_tag (const char *str, - int *duration, - int *taglength); + int *duration, + int *taglength); @@ -188,34 +188,38 @@ GimpPlugInInfo PLUG_IN_INFO = /* Global widgets'n'stuff */ -static GtkWidget *dlg = NULL; -static guchar *preview_data = NULL; -static GtkWidget *drawing_area = NULL; -static GtkWidget *shape_drawing_area = NULL; -static guchar *shape_drawing_area_data = NULL; -static guchar *drawing_area_data = NULL; -static GtkProgressBar *progress; -static guint width, height; -static guchar *preview_alpha1_data; -static guchar *preview_alpha2_data; -static gint32 image_id; -static gint32 total_frames; -static guint frame_number; -static gint32 *layers; +static GtkWidget *dlg = NULL; +static guchar *preview_data = NULL; +static GtkWidget *drawing_area = NULL; +static GtkWidget *shape_drawing_area = NULL; +static guchar *shape_drawing_area_data = NULL; +static guchar *drawing_area_data = NULL; +static GtkProgressBar *progress; +static guint width, height; +static guchar *preview_alpha1_data; +static guchar *preview_alpha2_data; +static gint32 image_id; +static gint32 total_frames; +static guint frame_number; +static gint32 *layers; static GimpDrawable *drawable; -static gboolean playing = FALSE; -static guint timer = 0; -static GimpImageBaseType imagetype; -static guchar *palette; -static gint ncolours; -static GtkWidget *psbutton; +static gboolean playing = FALSE; +static guint timer = 0; +static GimpImageBaseType imagetype; +static guchar *palette; +static gint ncolours; +static GtkWidget *psbutton; /* for shaping */ -static gchar *shape_preview_mask; -static GtkWidget *shape_window; -typedef struct _cursoroffset {gint x,y;} CursorOffset; -static gint shaping = 0; -static GdkWindow *root_win = NULL; +typedef struct +{ + gint x, y; +} CursorOffset; + +static gchar *shape_preview_mask; +static GtkWidget *shape_window; +static gint shaping = 0; +static GdkWindow *root_win = NULL; MAIN () @@ -231,16 +235,16 @@ query (void) }; gimp_install_procedure ("plug_in_animationplay", - "This plugin allows you to preview a GIMP layer-based animation.", - "", - "Adam D. Moss ", - "Adam D. Moss ", - "1997, 1998...", - N_("/Filters/Animation/_Playback..."), - "RGB*, INDEXED*, GRAY*", - GIMP_PLUGIN, - G_N_ELEMENTS (args), 0, - args, NULL); + "This plugin allows you to preview a GIMP layer-based animation.", + "", + "Adam D. Moss ", + "Adam D. Moss ", + "1997, 1998...", + N_("/Filters/Animation/_Playback..."), + "RGB*, INDEXED*, GRAY*", + GIMP_PLUGIN, + G_N_ELEMENTS (args), 0, + args, NULL); } static void @@ -273,7 +277,7 @@ run (const gchar *name, do_playback(); if (run_mode != GIMP_RUN_NONINTERACTIVE) - gimp_displays_flush(); + gimp_displays_flush(); } values[0].type = GIMP_PDB_STATUS; @@ -290,15 +294,15 @@ reshape_from_bitmap (gchar* bitmap) (memcmp(prev_bitmap, bitmap, (width*height)/8 +height))) { shape_mask = gdk_bitmap_create_from_data(shape_window->window, - bitmap, - width, height); + bitmap, + width, height); gtk_widget_shape_combine_mask (shape_window, shape_mask, 0, 0); g_object_unref (shape_mask); if (!prev_bitmap) - { - prev_bitmap = g_malloc ((width*height)/8 +height); - } + { + prev_bitmap = g_malloc ((width*height)/8 +height); + } memcpy (prev_bitmap, bitmap, (width*height)/8 +height); } } @@ -306,7 +310,7 @@ reshape_from_bitmap (gchar* bitmap) static gboolean shape_pressed (GtkWidget *widget, - GdkEventButton *event) + GdkEventButton *event) { CursorOffset *p; @@ -335,7 +339,7 @@ shape_pressed (GtkWidget *widget, static gboolean maybeblocked_expose (GtkWidget *widget, - GdkEventExpose *event) + GdkEventExpose *event) { if (playing) return TRUE; @@ -348,7 +352,7 @@ shape_released (GtkWidget *widget) { gtk_grab_remove (widget); gdk_display_pointer_ungrab (gtk_widget_get_display (widget), 0); - gdk_flush(); + gdk_flush (); return FALSE; } @@ -357,20 +361,18 @@ static gboolean shape_motion (GtkWidget *widget, GdkEventMotion *event) { - gint xp, yp; - CursorOffset * p; - GdkModifierType mask; + gint xp, yp; + CursorOffset *p; + GdkModifierType mask; gdk_window_get_pointer (root_win, &xp, &yp, &mask); - /* printf("%u %d\n", mask, event->state);fflush(stdout); */ - /* if a button is still held by the time we process this event... */ if (mask & (GDK_BUTTON1_MASK| - GDK_BUTTON2_MASK| - GDK_BUTTON3_MASK| - GDK_BUTTON4_MASK| - GDK_BUTTON5_MASK)) + GDK_BUTTON2_MASK| + GDK_BUTTON3_MASK| + GDK_BUTTON4_MASK| + GDK_BUTTON5_MASK)) { p = g_object_get_data (G_OBJECT (widget), "cursor-offset"); if (!p) @@ -390,14 +392,13 @@ shape_motion (GtkWidget *widget, static gboolean repaint_da (GtkWidget *darea, GdkEventExpose *event, - gpointer data) + gpointer data) { - /* printf("Repaint! Woohoo!\n");*/ gdk_draw_rgb_image (drawing_area->window, - drawing_area->style->white_gc, - 0, 0, width, height, - (total_frames==1)?GDK_RGB_DITHER_MAX:DITHERTYPE, - drawing_area_data, width * 3); + drawing_area->style->white_gc, + 0, 0, width, height, + (total_frames==1)?GDK_RGB_DITHER_MAX:DITHERTYPE, + drawing_area_data, width * 3); return TRUE; } @@ -406,14 +407,13 @@ repaint_da (GtkWidget *darea, static gboolean repaint_sda (GtkWidget *darea, GdkEventExpose *event, - gpointer data) + gpointer data) { - /*printf("Repaint! Woohoo!\n");*/ gdk_draw_rgb_image (shape_drawing_area->window, - shape_drawing_area->style->white_gc, - 0, 0, width, height, - (total_frames==1)?GDK_RGB_DITHER_MAX:DITHERTYPE, - shape_drawing_area_data, width * 3); + shape_drawing_area->style->white_gc, + 0, 0, width, height, + (total_frames==1)?GDK_RGB_DITHER_MAX:DITHERTYPE, + shape_drawing_area_data, width * 3); return TRUE; } @@ -421,9 +421,9 @@ repaint_sda (GtkWidget *darea, static gboolean preview_pressed (GtkWidget *widget, - GdkEventButton *event) + GdkEventButton *event) { - gint xp, yp; + gint xp, yp; GdkModifierType mask; if (shaping) @@ -441,15 +441,15 @@ preview_pressed (GtkWidget *widget, gtk_widget_show (shape_window); - gdk_window_set_back_pixmap(shape_window->window, NULL, 0); - gdk_window_set_back_pixmap(shape_drawing_area->window, NULL, 1); + gdk_window_set_back_pixmap (shape_window->window, NULL, 0); + gdk_window_set_back_pixmap (shape_drawing_area->window, NULL, 1); - show_frame(); + show_frame (); shaping = 1; - memset(shape_preview_mask, 0, (width*height)/8 + height); - render_frame(frame_number); - show_frame(); + memset (shape_preview_mask, 0, (width*height)/8 + height); + render_frame (frame_number); + show_frame (); repaint_da (NULL, NULL, NULL); @@ -461,18 +461,18 @@ preview_pressed (GtkWidget *widget, static void build_dialog (GimpImageBaseType basetype, - gchar *imagename) + gchar *imagename) { - gchar* windowname; - CursorOffset* icon_pos; - GtkWidget* button; - GtkWidget* frame; - GtkWidget* frame2; - GtkWidget* vbox; - GtkWidget* hbox; - GtkWidget* hbox2; - GtkWidget* eventbox; - GdkCursor* cursor; + gchar *windowname; + CursorOffset *icon_pos; + GtkWidget *button; + GtkWidget *frame; + GtkWidget *frame2; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *hbox2; + GtkWidget *eventbox; + GdkCursor *cursor; gimp_ui_init ("animationplay", TRUE); @@ -480,11 +480,11 @@ build_dialog (GimpImageBaseType basetype, dlg = gimp_dialog_new (windowname, "animationplay", NULL, 0, - gimp_standard_help_func, "filters/animationplay.html", + gimp_standard_help_func, "filters/animationplay.html", - GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, + GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, - NULL); + NULL); g_free (windowname); @@ -494,22 +494,16 @@ build_dialog (GimpImageBaseType basetype, { /* The 'playback' half of the dialog */ - - windowname = g_malloc (strlen (_("Playback: ")) + strlen (imagename) + 1); if (total_frames > 1) - { - strcpy (windowname, _("Playback: ")); - strcat (windowname, imagename); - } + windowname = g_strconcat (_("Playback: "), imagename); else - { - strcpy (windowname, imagename); - } + windowname = g_strdup (imagename); frame = gtk_frame_new (windowname); g_free (windowname); + gtk_container_set_border_width (GTK_CONTAINER (frame), 3); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), - frame, TRUE, TRUE, 0); + frame, TRUE, TRUE, 0); { hbox = gtk_hbox_new (FALSE, 5); @@ -517,78 +511,78 @@ build_dialog (GimpImageBaseType basetype, gtk_container_add (GTK_CONTAINER (frame), hbox); { - vbox = gtk_vbox_new (FALSE, 5); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 3); - gtk_container_add (GTK_CONTAINER (hbox), vbox); + vbox = gtk_vbox_new (FALSE, 5); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 3); + gtk_container_add (GTK_CONTAINER (hbox), vbox); - { - hbox2 = gtk_hbox_new (FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (hbox2), 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox2, TRUE, TRUE, 0); + { + hbox2 = gtk_hbox_new (FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (hbox2), 0); + gtk_box_pack_start (GTK_BOX (vbox), hbox2, TRUE, TRUE, 0); - { - psbutton = gtk_toggle_button_new_with_label ( _("Play/Stop")); - g_signal_connect (psbutton, "toggled", + { + psbutton = gtk_toggle_button_new_with_label ( _("Play/Stop")); + g_signal_connect (psbutton, "toggled", G_CALLBACK (playstop_callback), NULL); - gtk_box_pack_start (GTK_BOX (hbox2), psbutton, TRUE, TRUE, 0); - gtk_widget_show (psbutton); + gtk_box_pack_start (GTK_BOX (hbox2), psbutton, TRUE, TRUE, 0); + gtk_widget_show (psbutton); - button = gtk_button_new_with_label ( _("Rewind")); - g_signal_connect (button, "clicked", + button = gtk_button_new_with_label ( _("Rewind")); + g_signal_connect (button, "clicked", G_CALLBACK (rewind_callback), NULL); - gtk_box_pack_start (GTK_BOX (hbox2), button, TRUE, TRUE, 0); - gtk_widget_show (button); + gtk_box_pack_start (GTK_BOX (hbox2), button, TRUE, TRUE, 0); + gtk_widget_show (button); - button = gtk_button_new_with_label ( _("Step")); - g_signal_connect (button, "clicked", + button = gtk_button_new_with_label ( _("Step")); + g_signal_connect (button, "clicked", G_CALLBACK (step_callback), NULL); - gtk_box_pack_start (GTK_BOX (hbox2), button, TRUE, TRUE, 0); - gtk_widget_show (button); - } - /* If there aren't multiple frames, playback controls make no - sense */ - /* if (total_frames<=1) gtk_widget_set_sensitive (hbox2, FALSE); - gtk_widget_show(hbox2);*/ + gtk_box_pack_start (GTK_BOX (hbox2), button, TRUE, TRUE, 0); + gtk_widget_show (button); + } + /* If there aren't multiple frames, playback controls make no + sense */ + /* if (total_frames<=1) gtk_widget_set_sensitive (hbox2, FALSE); + gtk_widget_show(hbox2);*/ - if (total_frames>1) - gtk_widget_show(hbox2); + if (total_frames>1) + gtk_widget_show(hbox2); - hbox2 = gtk_hbox_new (TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (hbox2), 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0); - { - frame2 = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame2), GTK_SHADOW_IN); - gtk_box_pack_start (GTK_BOX (hbox2), frame2, FALSE, FALSE, 0); + hbox2 = gtk_hbox_new (TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (hbox2), 0); + gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0); + { + frame2 = gtk_frame_new (NULL); + gtk_frame_set_shadow_type (GTK_FRAME (frame2), GTK_SHADOW_IN); + gtk_box_pack_start (GTK_BOX (hbox2), frame2, FALSE, FALSE, 0); - { - eventbox = gtk_event_box_new(); - gtk_container_add (GTK_CONTAINER (frame2), GTK_WIDGET (eventbox)); + { + eventbox = gtk_event_box_new(); + gtk_container_add (GTK_CONTAINER (frame2), GTK_WIDGET (eventbox)); - { - drawing_area = gtk_drawing_area_new (); + { + drawing_area = gtk_drawing_area_new (); gtk_widget_set_size_request (drawing_area, width, height); gtk_container_add (GTK_CONTAINER (eventbox), GTK_WIDGET (drawing_area)); gtk_widget_show (drawing_area); - } - gtk_widget_show(eventbox); - gtk_widget_set_events (eventbox, - gtk_widget_get_events (eventbox) - | GDK_BUTTON_PRESS_MASK); - } - gtk_widget_show(frame2); - } - gtk_widget_show(hbox2); + } + gtk_widget_show(eventbox); + gtk_widget_set_events (eventbox, + gtk_widget_get_events (eventbox) + | GDK_BUTTON_PRESS_MASK); + } + gtk_widget_show(frame2); + } + gtk_widget_show(hbox2); - progress = GTK_PROGRESS_BAR (gtk_progress_bar_new ()); + progress = GTK_PROGRESS_BAR (gtk_progress_bar_new ()); gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (progress), TRUE, TRUE, 0); - if (total_frames>1) - gtk_widget_show (GTK_WIDGET (progress)); - } - gtk_widget_show(vbox); + if (total_frames>1) + gtk_widget_show (GTK_WIDGET (progress)); + } + gtk_widget_show(vbox); } gtk_widget_show(hbox); @@ -610,8 +604,8 @@ build_dialog (GimpImageBaseType basetype, } gtk_widget_show (shape_drawing_area); gtk_widget_set_events (shape_drawing_area, - gtk_widget_get_events (shape_drawing_area) - | GDK_BUTTON_PRESS_MASK); + gtk_widget_get_events (shape_drawing_area) + | GDK_BUTTON_PRESS_MASK); gtk_widget_realize (shape_window); gdk_window_set_back_pixmap(shape_window->window, NULL, 0); @@ -662,7 +656,7 @@ do_playback (void) else if (imagetype == GIMP_GRAY) { /* This is a bit sick, until this plugin ever gets - real GRAY support (not worth it?) */ + real GRAY support (not worth it?) */ palette = g_malloc(768); for (i=0;i<256;i++) { @@ -699,20 +693,19 @@ do_playback (void) static void render_frame (gint32 whichframe) { - GimpPixelRgn pixel_rgn; + GimpPixelRgn pixel_rgn; static guchar *rawframe = NULL; - static gint rawwidth=0, rawheight=0, rawbpp=0; - gint rawx=0, rawy=0; - guchar* srcptr; - guchar* destptr; - gint i,j,k; /* imaginative loop variables */ - DisposeType dispose; - + static gint rawwidth = 0, rawheight = 0, rawbpp = 0; + gint rawx = 0, rawy = 0; + guchar *srcptr; + guchar *destptr; + gint i, j, k; /* imaginative loop variables */ + DisposeType dispose; if (whichframe >= total_frames) { printf( "playback: Asked for frame number %d in a %d-frame animation!\n", - (int) (whichframe+1), (int) total_frames); + (int) (whichframe+1), (int) total_frames); exit(-1); } @@ -724,17 +717,17 @@ render_frame (gint32 whichframe) return; } - dispose = get_frame_disposal(frame_number); + dispose = get_frame_disposal (frame_number); /* Image has been closed/etc since we got the layer list? */ /* FIXME - How do we tell if a gimp_drawable_get() fails? */ - if (gimp_drawable_width(drawable->drawable_id)==0) + if (gimp_drawable_width (drawable->drawable_id) == 0) gtk_dialog_response (GTK_DIALOG (dlg), GTK_RESPONSE_CLOSE); if (((dispose==DISPOSE_REPLACE)||(whichframe==0)) && - gimp_drawable_has_alpha(drawable->drawable_id)) + gimp_drawable_has_alpha (drawable->drawable_id)) { - total_alpha_preview(preview_data); + total_alpha_preview (preview_data); } @@ -744,37 +737,38 @@ render_frame (gint32 whichframe) if ((rawwidth*rawheight*rawbpp) != ((gimp_drawable_width(drawable->drawable_id)* - gimp_drawable_height(drawable->drawable_id)* - gimp_drawable_bpp(drawable->drawable_id)))) + gimp_drawable_height(drawable->drawable_id)* + gimp_drawable_bpp(drawable->drawable_id)))) { - if (rawframe != NULL) g_free(rawframe); + if (rawframe != NULL) + g_free(rawframe); rawframe = g_malloc((gimp_drawable_width(drawable->drawable_id)) * - (gimp_drawable_height(drawable->drawable_id)) * - (gimp_drawable_bpp(drawable->drawable_id))); + (gimp_drawable_height(drawable->drawable_id)) * + (gimp_drawable_bpp(drawable->drawable_id))); } - rawwidth = gimp_drawable_width(drawable->drawable_id); + rawwidth = gimp_drawable_width(drawable->drawable_id); rawheight = gimp_drawable_height(drawable->drawable_id); - rawbpp = gimp_drawable_bpp(drawable->drawable_id); + rawbpp = gimp_drawable_bpp(drawable->drawable_id); /* Initialise and fetch the whole raw new frame */ gimp_pixel_rgn_init (&pixel_rgn, - drawable, - 0, 0, - drawable->width, drawable->height, - FALSE, - FALSE); + drawable, + 0, 0, + drawable->width, drawable->height, + FALSE, + FALSE); gimp_pixel_rgn_get_rect (&pixel_rgn, - rawframe, - 0, 0, - drawable->width, drawable->height); + rawframe, + 0, 0, + drawable->width, drawable->height); /* gimp_pixel_rgns_register (1, &pixel_rgn);*/ gimp_drawable_offsets (drawable->drawable_id, - &rawx, - &rawy); + &rawx, + &rawy); /* render... */ @@ -783,447 +777,446 @@ render_frame (gint32 whichframe) { case GIMP_RGB: if ((rawwidth==width) && - (rawheight==height) && - (rawx==0) && - (rawy==0)) - { - /* --- These cases are for the best cases, in --- */ - /* --- which this frame is the same size and position --- */ - /* --- as the preview buffer itself --- */ + (rawheight==height) && + (rawx==0) && + (rawy==0)) + { + /* --- These cases are for the best cases, in --- */ + /* --- which this frame is the same size and position --- */ + /* --- as the preview buffer itself --- */ - if (gimp_drawable_has_alpha (drawable->drawable_id)) - { /* alpha */ - destptr = preview_data; - srcptr = rawframe; + if (gimp_drawable_has_alpha (drawable->drawable_id)) + { /* alpha */ + destptr = preview_data; + srcptr = rawframe; - i = rawwidth*rawheight; - while (i--) - { - if (!(*(srcptr+3)&128)) - { - srcptr += 4; - destptr += 3; - continue; - } - *(destptr++) = *(srcptr++); - *(destptr++) = *(srcptr++); - *(destptr++) = *(srcptr++); - srcptr++; - } + i = rawwidth*rawheight; + while (i--) + { + if (!(*(srcptr+3)&128)) + { + srcptr += 4; + destptr += 3; + continue; + } + *(destptr++) = *(srcptr++); + *(destptr++) = *(srcptr++); + *(destptr++) = *(srcptr++); + srcptr++; + } - /* calculate the shape mask */ - if (shaping) - { - srcptr = rawframe + 3; - for (j=0;jwindow, - shape_drawing_area->style->white_gc, - 0, 0, width, height, - (total_frames==1)?GDK_RGB_DITHER_MAX - :DITHERTYPE, - preview_data, width * 3); - } - else - { - reshape_from_bitmap (shape_preview_mask); - gdk_draw_rgb_image (drawing_area->window, - drawing_area->style->white_gc, - 0, 0, width, height, - (total_frames==1)?GDK_RGB_DITHER_MAX - :DITHERTYPE, - preview_data, width * 3); - } - } + if (shaping) + { + /* opacify the shape mask */ + memset(shape_preview_mask, 255, + (rawwidth*rawheight)/8 + rawheight); + } + } + /* Display the preview buffer... finally. */ + if (shaping) + { + reshape_from_bitmap (shape_preview_mask); + gdk_draw_rgb_image (shape_drawing_area->window, + shape_drawing_area->style->white_gc, + 0, 0, width, height, + (total_frames==1)?GDK_RGB_DITHER_MAX + :DITHERTYPE, + preview_data, width * 3); + } + else + { + reshape_from_bitmap (shape_preview_mask); + gdk_draw_rgb_image (drawing_area->window, + drawing_area->style->white_gc, + 0, 0, width, height, + (total_frames==1)?GDK_RGB_DITHER_MAX + :DITHERTYPE, + preview_data, width * 3); + } + } else - { - /* --- These are suboptimal catch-all cases for when --- */ - /* --- this frame is bigger/smaller than the preview --- */ - /* --- buffer, and/or offset within it. --- */ + { + /* --- These are suboptimal catch-all cases for when --- */ + /* --- this frame is bigger/smaller than the preview --- */ + /* --- buffer, and/or offset within it. --- */ - if (gimp_drawable_has_alpha (drawable->drawable_id)) - { /* alpha */ + if (gimp_drawable_has_alpha (drawable->drawable_id)) + { /* alpha */ - srcptr = rawframe; + srcptr = rawframe; - for (j=rawy; j=0 && i=0 && j=0 && i=0 && j=0 && i=0 && j=0 && i=0 && j=0 && i=0 && j=0 && i=0 && jwindow, - shape_drawing_area->style->white_gc, - 0, top, width, bottom-top, - (total_frames==1)?GDK_RGB_DITHER_MAX - :DITHERTYPE, - &preview_data[3*top*width], width * 3); - } - else - { - reshape_from_bitmap (shape_preview_mask); - gdk_draw_rgb_image (shape_drawing_area->window, - shape_drawing_area->style->white_gc, - 0, 0, width, height, - (total_frames==1)?GDK_RGB_DITHER_MAX - :DITHERTYPE, - preview_data, width * 3); - } - } - else - { - if ((dispose!=DISPOSE_REPLACE)&&(whichframe!=0)) - { - int top, bottom; + reshape_from_bitmap (shape_preview_mask); + gdk_draw_rgb_image (shape_drawing_area->window, + shape_drawing_area->style->white_gc, + 0, top, width, bottom-top, + (total_frames==1)?GDK_RGB_DITHER_MAX + :DITHERTYPE, + &preview_data[3*top*width], width * 3); + } + else + { + reshape_from_bitmap (shape_preview_mask); + gdk_draw_rgb_image (shape_drawing_area->window, + shape_drawing_area->style->white_gc, + 0, 0, width, height, + (total_frames==1)?GDK_RGB_DITHER_MAX + :DITHERTYPE, + preview_data, width * 3); + } + } + else + { + if ((dispose!=DISPOSE_REPLACE)&&(whichframe!=0)) + { + int top, bottom; - top = (rawy < 0) ? 0 : rawy; - bottom = (rawy+rawheight) < height ? - (rawy+rawheight) : height-1; + top = (rawy < 0) ? 0 : rawy; + bottom = (rawy+rawheight) < height ? + (rawy+rawheight) : height-1; - gdk_draw_rgb_image (drawing_area->window, - drawing_area->style->white_gc, - 0, top, width, bottom-top, - (total_frames==1)?GDK_RGB_DITHER_MAX - :DITHERTYPE, - &preview_data[3*top*width], width * 3); - } - else - { - gdk_draw_rgb_image (drawing_area->window, - drawing_area->style->white_gc, - 0, 0, width, height, - (total_frames==1)?GDK_RGB_DITHER_MAX: - DITHERTYPE, - preview_data, width * 3); - } - } - } + gdk_draw_rgb_image (drawing_area->window, + drawing_area->style->white_gc, + 0, top, width, bottom-top, + (total_frames==1)?GDK_RGB_DITHER_MAX + :DITHERTYPE, + &preview_data[3*top*width], width * 3); + } + else + { + gdk_draw_rgb_image (drawing_area->window, + drawing_area->style->white_gc, + 0, 0, width, height, + (total_frames==1)?GDK_RGB_DITHER_MAX + :DITHERTYPE, + preview_data, width * 3); + } + } + } break; case GIMP_GRAY: case GIMP_INDEXED: if ((rawwidth==width) && - (rawheight==height) && - (rawx==0) && - (rawy==0)) - { - /* --- These cases are for the best cases, in --- */ - /* --- which this frame is the same size and position --- */ - /* --- as the preview buffer itself --- */ + (rawheight==height) && + (rawx==0) && + (rawy==0)) + { + /* --- These cases are for the best cases, in --- */ + /* --- which this frame is the same size and position --- */ + /* --- as the preview buffer itself --- */ - if (gimp_drawable_has_alpha (drawable->drawable_id)) - { /* alpha */ - destptr = preview_data; - srcptr = rawframe; + if (gimp_drawable_has_alpha (drawable->drawable_id)) + { /* alpha */ + destptr = preview_data; + srcptr = rawframe; - i = rawwidth*rawheight; - while (i--) - { - if (!(*(srcptr+1))) - { - srcptr += 2; - destptr += 3; - continue; - } + i = rawwidth*rawheight; + while (i--) + { + if (!(*(srcptr+1))) + { + srcptr += 2; + destptr += 3; + continue; + } - *(destptr++) = palette[3*(*(srcptr))]; - *(destptr++) = palette[1+3*(*(srcptr))]; - *(destptr++) = palette[2+3*(*(srcptr))]; - srcptr+=2; - } + *(destptr++) = palette[3*(*(srcptr))]; + *(destptr++) = palette[1+3*(*(srcptr))]; + *(destptr++) = palette[2+3*(*(srcptr))]; + srcptr+=2; + } - /* calculate the shape mask */ - if (shaping) - { - srcptr = rawframe + 1; - for (j=0;jwindow, - shape_drawing_area->style->white_gc, - 0, 0, width, height, - (total_frames==1)?GDK_RGB_DITHER_MAX: - DITHERTYPE, - preview_data, width * 3); - } - else - { - gdk_draw_rgb_image (drawing_area->window, - drawing_area->style->white_gc, - 0, 0, width, height, - (total_frames==1)?GDK_RGB_DITHER_MAX: - DITHERTYPE, - preview_data, width * 3); - } - } + /* Display the preview buffer... finally. */ + if (shaping) + { + reshape_from_bitmap (shape_preview_mask); + gdk_draw_rgb_image (shape_drawing_area->window, + shape_drawing_area->style->white_gc, + 0, 0, width, height, + (total_frames==1)?GDK_RGB_DITHER_MAX + :DITHERTYPE, + preview_data, width * 3); + } + else + { + gdk_draw_rgb_image (drawing_area->window, + drawing_area->style->white_gc, + 0, 0, width, height, + (total_frames==1)?GDK_RGB_DITHER_MAX + :DITHERTYPE, + preview_data, width * 3); + } + } else - { - /* --- These are suboptimal catch-all cases for when --- */ - /* --- this frame is bigger/smaller than the preview --- */ - /* --- buffer, and/or offset within it. --- */ + { + /* --- These are suboptimal catch-all cases for when --- */ + /* --- this frame is bigger/smaller than the preview --- */ + /* --- buffer, and/or offset within it. --- */ - if (gimp_drawable_has_alpha (drawable->drawable_id)) - { /* alpha */ + if (gimp_drawable_has_alpha (drawable->drawable_id)) + { /* alpha */ - srcptr = rawframe; + srcptr = rawframe; - for (j=rawy; j=0 && i=0 && j=0 && i=0 && j=0 && i=0 && j=0 && i=0 && j=0 && i=0 && j=0 && i=0 && jwindow, - shape_drawing_area->style->white_gc, - 0, top, width, bottom-top, - (total_frames==1)?GDK_RGB_DITHER_MAX - :DITHERTYPE, - &preview_data[3*top*width], width * 3); - } - else - { - reshape_from_bitmap (shape_preview_mask); - gdk_draw_rgb_image (shape_drawing_area->window, - shape_drawing_area->style->white_gc, - 0, 0, width, height, - (total_frames==1)?GDK_RGB_DITHER_MAX - :DITHERTYPE, - preview_data, width * 3); - } - } - else - { - if ((dispose!=DISPOSE_REPLACE)&&(whichframe!=0)) - { - int top, bottom; + reshape_from_bitmap (shape_preview_mask); + gdk_draw_rgb_image (shape_drawing_area->window, + shape_drawing_area->style->white_gc, + 0, top, width, bottom-top, + (total_frames==1)?GDK_RGB_DITHER_MAX + :DITHERTYPE, + &preview_data[3*top*width], width * 3); + } + else + { + reshape_from_bitmap (shape_preview_mask); + gdk_draw_rgb_image (shape_drawing_area->window, + shape_drawing_area->style->white_gc, + 0, 0, width, height, + (total_frames==1)?GDK_RGB_DITHER_MAX + :DITHERTYPE, + preview_data, width * 3); + } + } + else + { + if ((dispose!=DISPOSE_REPLACE)&&(whichframe!=0)) + { + int top, bottom; - top = (rawy < 0) ? 0 : rawy; - bottom = (rawy+rawheight) < height ? - (rawy+rawheight) : height-1; + top = (rawy < 0) ? 0 : rawy; + bottom = (rawy+rawheight) < height ? + (rawy+rawheight) : height-1; - gdk_draw_rgb_image (drawing_area->window, - drawing_area->style->white_gc, - 0, top, width, bottom-top, - (total_frames==1)?GDK_RGB_DITHER_MAX - :DITHERTYPE, - &preview_data[3*top*width], width * 3); - } - else - { - gdk_draw_rgb_image (drawing_area->window, - drawing_area->style->white_gc, - 0, 0, width, height, - (total_frames==1)?GDK_RGB_DITHER_MAX - :DITHERTYPE, - preview_data, width * 3); - } - } - } + gdk_draw_rgb_image (drawing_area->window, + drawing_area->style->white_gc, + 0, top, width, bottom-top, + (total_frames==1)?GDK_RGB_DITHER_MAX + :DITHERTYPE, + &preview_data[3*top*width], width * 3); + } + else + { + gdk_draw_rgb_image (drawing_area->window, + drawing_area->style->white_gc, + 0, 0, width, height, + (total_frames==1)?GDK_RGB_DITHER_MAX + :DITHERTYPE, + preview_data, width * 3); + } + } + } break; } @@ -1264,23 +1257,23 @@ init_preview_misc (void) for (i=0;i", - "Adam D. Moss ", - "1997-2003", - N_("/Filters/Animation/Optimize (for _GIF)"), - "RGB*, INDEXED*, GRAY*", - GIMP_PLUGIN, - G_N_ELEMENTS (args), + "This procedure applies various optimizations to" + " a GIMP layer-based animation in an attempt to" + " reduce the final file size. If a frame of the" + " animation can use the 'combine' mode, this" + " procedure attempts to maximize the number of" + " ajdacent pixels having the same color, which" + " improves the compression for some image formats" + " such as GIF or MNG.", + "", + "Adam D. Moss ", + "Adam D. Moss ", + "1997-2003", + N_("/Filters/Animation/Optimize (for _GIF)"), + "RGB*, INDEXED*, GRAY*", + GIMP_PLUGIN, + G_N_ELEMENTS (args), G_N_ELEMENTS (return_args), - args, return_args); + args, return_args); gimp_install_procedure ("plug_in_animationoptimize_diff", - "This procedure applies various optimizations to" - " a GIMP layer-based animation in an attempt to" - " reduce the final file size. If a frame of the" - " animation can use the 'combine' mode, this" - " procedure uses a simple difference between the" - " frames.", - "", - "Adam D. Moss ", - "Adam D. Moss ", - "1997-2001", - N_("/Filters/Animation/_Optimize (Difference)"), - "RGB*, INDEXED*, GRAY*", - GIMP_PLUGIN, - G_N_ELEMENTS (args), + "This procedure applies various optimizations to" + " a GIMP layer-based animation in an attempt to" + " reduce the final file size. If a frame of the" + " animation can use the 'combine' mode, this" + " procedure uses a simple difference between the" + " frames.", + "", + "Adam D. Moss ", + "Adam D. Moss ", + "1997-2001", + N_("/Filters/Animation/_Optimize (Difference)"), + "RGB*, INDEXED*, GRAY*", + GIMP_PLUGIN, + G_N_ELEMENTS (args), G_N_ELEMENTS (return_args), - args, return_args); + args, return_args); gimp_install_procedure ("plug_in_animationunoptimize", - "This procedure 'simplifies' a GIMP layer-based" - " animation that has been AnimationOptimized. This" - " makes the animation much easier to work with if," - " for example, the optimized version is all you" - " have.", - "", - "Adam D. Moss ", - "Adam D. Moss ", - "1997-2001", - N_("/Filters/Animation/_UnOptimize"), - "RGB*, INDEXED*, GRAY*", - GIMP_PLUGIN, - G_N_ELEMENTS (args), + "This procedure 'simplifies' a GIMP layer-based" + " animation that has been AnimationOptimized. This" + " makes the animation much easier to work with if," + " for example, the optimized version is all you" + " have.", + "", + "Adam D. Moss ", + "Adam D. Moss ", + "1997-2001", + N_("/Filters/Animation/_UnOptimize"), + "RGB*, INDEXED*, GRAY*", + GIMP_PLUGIN, + G_N_ELEMENTS (args), G_N_ELEMENTS (return_args), - args, return_args); + args, return_args); #ifdef EXPERIMENTAL_BACKDROP_CODE gimp_install_procedure ("plug_in_animation_remove_backdrop", - "This procedure attempts to remove the backdrop" - " from a GIMP layer-based animation, leaving" - " the foreground animation over transparency.", - "", - "Adam D. Moss ", - "Adam D. Moss ", - "2001", - N_("/Filters/Animation/_Remove Backdrop"), - "RGB*, INDEXED*, GRAY*", - GIMP_PLUGIN, - G_N_ELEMENTS (args), + "This procedure attempts to remove the backdrop" + " from a GIMP layer-based animation, leaving" + " the foreground animation over transparency.", + "", + "Adam D. Moss ", + "Adam D. Moss ", + "2001", + N_("/Filters/Animation/_Remove Backdrop"), + "RGB*, INDEXED*, GRAY*", + GIMP_PLUGIN, + G_N_ELEMENTS (args), G_N_ELEMENTS (return_args), - args, return_args); + args, return_args); gimp_install_procedure ("plug_in_animation_find_backdrop", - "This procedure attempts to remove the foreground" - " from a GIMP layer-based animation, leaving" - " a one-layered image containing only the" - " constant backdrop image.", - "", - "Adam D. Moss ", - "Adam D. Moss ", - "2001", - N_("/Filters/Animation/_Find Backdrop"), - "RGB*, INDEXED*, GRAY*", - GIMP_PLUGIN, - G_N_ELEMENTS (args), + "This procedure attempts to remove the foreground" + " from a GIMP layer-based animation, leaving" + " a one-layered image containing only the" + " constant backdrop image.", + "", + "Adam D. Moss ", + "Adam D. Moss ", + "2001", + N_("/Filters/Animation/_Find Backdrop"), + "RGB*, INDEXED*, GRAY*", + GIMP_PLUGIN, + G_N_ELEMENTS (args), G_N_ELEMENTS (return_args), - args, return_args); + args, return_args); #endif } @@ -318,7 +318,7 @@ run (const gchar *name, new_image_id = do_optimizations (run_mode, diff_only); if (run_mode != GIMP_RUN_NONINTERACTIVE) - gimp_displays_flush(); + gimp_displays_flush(); } values[0].type = GIMP_PDB_STATUS; @@ -363,10 +363,10 @@ compose_row (gint frame_num, if (cleanup) { if (line_buf) - { - g_free (line_buf); - line_buf = NULL; - } + { + g_free (line_buf); + line_buf = NULL; + } return; } @@ -377,8 +377,8 @@ compose_row (gint frame_num, } gimp_drawable_offsets (drawable->drawable_id, - &rawx, - &rawy); + &rawx, + &rawy); rawheight = gimp_drawable_height (drawable->drawable_id); @@ -393,23 +393,23 @@ compose_row (gint frame_num, if (line_buf) { - g_free(line_buf); + g_free (line_buf); line_buf = NULL; } - line_buf = g_malloc(rawwidth * rawbpp); + line_buf = g_malloc (rawwidth * rawbpp); /* Initialise and fetch the raw new frame row */ gimp_pixel_rgn_init (&pixel_rgn, - drawable, - 0, row_num - rawy, - rawwidth, 1, - FALSE, - FALSE); + drawable, + 0, row_num - rawy, + rawwidth, 1, + FALSE, + FALSE); gimp_pixel_rgn_get_rect (&pixel_rgn, - line_buf, - 0, row_num - rawy, - rawwidth, 1); + line_buf, + 0, row_num - rawy, + rawwidth, 1); /* render... */ @@ -418,18 +418,18 @@ compose_row (gint frame_num, for (i=rawx; i=0 && i= 128) - { - for (j=0; j= 128) + { + for (j=0; j best_count) - { - best_count = count[j][i]; - best_r = red[j][i]; - best_g = green[j][i]; - best_b = blue[j][i]; - } - } + for (j=0; j best_count) + { + best_count = count[j][i]; + best_r = red[j][i]; + best_g = green[j][i]; + best_b = blue[j][i]; + } + } - back_frame[width * pixelstep * row +i*pixelstep + 0] = best_r; - if (pixelstep == 4) - { - back_frame[width * pixelstep * row +i*pixelstep + 1] = - best_g; - back_frame[width * pixelstep * row +i*pixelstep + 2] = - best_b; - } - back_frame[width * pixelstep * row +i*pixelstep +pixelstep-1] = - (best_count == 0) ? 0 : 255; + back_frame[width * pixelstep * row +i*pixelstep + 0] = best_r; + if (pixelstep == 4) + { + back_frame[width * pixelstep * row +i*pixelstep + 1] = + best_g; + back_frame[width * pixelstep * row +i*pixelstep + 2] = + best_b; + } + back_frame[width * pixelstep * row +i*pixelstep +pixelstep-1] = + (best_count == 0) ? 0 : 255; - if (best_count == 0) - g_warning("yayyyy!"); - } - /* memcpy(&back_frame[width * pixelstep * row], - these_rows[0], - width * pixelstep);*/ - } + if (best_count == 0) + g_warning("yayyyy!"); + } + /* memcpy(&back_frame[width * pixelstep * row], + these_rows[0], + width * pixelstep);*/ + } for (this_frame_num=0; this_frame_numdrawable_id) == 0) - { - gimp_quit (); - } + /* Image has been closed/etc since we got the layer list? */ + /* FIXME - How do we tell if a gimp_drawable_get() fails? */ + if (gimp_drawable_width (drawable->drawable_id) == 0) + { + gimp_quit (); + } - this_delay = get_frame_duration (this_frame_num); - dispose = get_frame_disposal (this_frame_num); + this_delay = get_frame_duration (this_frame_num); + dispose = get_frame_disposal (this_frame_num); - for (row = 0; row < height; row++) - { - compose_row(this_frame_num, - dispose, - row, - &this_frame[pixelstep*width * row], - width, - drawable, - FALSE - ); - } + for (row = 0; row < height; row++) + { + compose_row (this_frame_num, + dispose, + row, + &this_frame[pixelstep*width * row], + width, + drawable, + FALSE + ); + } - /* clean up */ - gimp_drawable_detach(drawable); + /* clean up */ + gimp_drawable_detach(drawable); - if (opmode == OPFOREGROUND) - { - gint xit, yit, byteit; + if (opmode == OPFOREGROUND) + { + gint xit, yit, byteit; - for (yit=0; yitrbox_right) rbox_right=xit; - if (yitrbox_bottom) rbox_bottom=yit; - } - if (keep_pix) - { - if (xitbbox_right) bbox_right=xit; - if (yitbbox_bottom) bbox_bottom=yit; - } - else - { - /* pixel didn't change this frame - make - * it transparent in our optimized buffer! - */ - opti_frame[yit*width*pixelstep + xit*pixelstep - + pixelstep-1] = 0; - } - } /* xit */ - } /* yit */ + /* Check if 'this' and 'last' are transparent */ + if (!(this_frame[yit*width*pixelstep + xit*pixelstep + + pixelstep-1]&128) + && + !(last_frame[yit*width*pixelstep + xit*pixelstep + + pixelstep-1]&128)) + { + keep_pix = FALSE; + opaq_pix = FALSE; + goto decided; + } + /* Check if just 'this' is transparent */ + if ((last_frame[yit*width*pixelstep + xit*pixelstep + + pixelstep-1]&128) + && + !(this_frame[yit*width*pixelstep + xit*pixelstep + + pixelstep-1]&128)) + { + keep_pix = TRUE; + opaq_pix = FALSE; + can_combine = FALSE; + goto decided; + } + /* Check if just 'last' is transparent */ + if (!(last_frame[yit*width*pixelstep + xit*pixelstep + + pixelstep-1]&128) + && + (this_frame[yit*width*pixelstep + xit*pixelstep + + pixelstep-1]&128)) + { + keep_pix = TRUE; + opaq_pix = TRUE; + goto decided; + } + /* If 'last' and 'this' are opaque, we have + * to check if they're the same colour - we + * only have to keep the pixel if 'last' or + * 'this' are opaque and different. + */ + keep_pix = FALSE; + opaq_pix = TRUE; + for (byteit=0; byteitrbox_right) rbox_right=xit; + if (yitrbox_bottom) rbox_bottom=yit; + } + if (keep_pix) + { + if (xitbbox_right) bbox_right=xit; + if (yitbbox_bottom) bbox_bottom=yit; + } + else + { + /* pixel didn't change this frame - make + * it transparent in our optimized buffer! + */ + opti_frame[yit*width*pixelstep + xit*pixelstep + + pixelstep-1] = 0; + } + } /* xit */ + } /* yit */ - if (!can_combine) - { - bbox_left = rbox_left; - bbox_top = rbox_top; - bbox_right = rbox_right; - bbox_bottom = rbox_bottom; - } + if (!can_combine) + { + bbox_left = rbox_left; + bbox_top = rbox_top; + bbox_right = rbox_right; + bbox_bottom = rbox_bottom; + } - bbox_right++; - bbox_bottom++; + bbox_right++; + bbox_bottom++; - if (can_combine && !diff_only) - { - /* Try to optimize the pixel data for RLE or LZW compression - * by making some transparent pixels non-transparent if they - * would have the same color as the adjacent pixels. This - * gives a better compression if the algorithm compresses - * the image line by line. - * See: http://bugzilla.gnome.org/show_bug.cgi?id=66367 - * It may not be very efficient to add two additional passes - * over the pixels, but this hopefully makes the code easier - * to maintain and less error-prone. - */ - for (yit = bbox_top; yit < bbox_bottom; yit++) - { - /* Compare with previous pixels from left to right */ - for (xit = bbox_left + 1; xit < bbox_right; xit++) - { - if (!(opti_frame[yit*width*pixelstep - + xit*pixelstep - + pixelstep-1]&128) - && (opti_frame[yit*width*pixelstep - + (xit-1)*pixelstep - + pixelstep-1]&128) - && (last_frame[yit*width*pixelstep - + xit*pixelstep - + pixelstep-1]&128)) - { - for (byteit=0; byteit= bbox_left; xit--) - { - if (!(opti_frame[yit*width*pixelstep - + xit*pixelstep - + pixelstep-1]&128) - && (opti_frame[yit*width*pixelstep - + (xit+1)*pixelstep - + pixelstep-1]&128) - && (last_frame[yit*width*pixelstep - + xit*pixelstep - + pixelstep-1]&128)) - { - for (byteit=0; byteit= bbox_left; xit--) + { + if (!(opti_frame[yit*width*pixelstep + + xit*pixelstep + + pixelstep-1]&128) + && (opti_frame[yit*width*pixelstep + + (xit+1)*pixelstep + + pixelstep-1]&128) + && (last_frame[yit*width*pixelstep + + xit*pixelstep + + pixelstep-1]&128)) + { + for (byteit=0; byteit/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_("/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); diff --git a/plug-ins/common/autocrop.c b/plug-ins/common/autocrop.c index 91920831e2..99ecbe7955 100644 --- a/plug-ins/common/autocrop.c +++ b/plug-ins/common/autocrop.c @@ -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/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/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; diff --git a/plug-ins/common/blinds.c b/plug-ins/common/blinds.c index fc4201e9fb..6731f7de3e 100644 --- a/plug-ins/common/blinds.c +++ b/plug-ins/common/blinds.c @@ -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) diff --git a/plug-ins/common/blur.c b/plug-ins/common/blur.c index 09fd54d248..75cd764df3 100644 --- a/plug-ins/common/blur.c +++ b/plug-ins/common/blur.c @@ -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_("/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_("/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); diff --git a/plug-ins/common/borderaverage.c b/plug-ins/common/borderaverage.c index 9aec9c6049..6f1711b2cb 100644 --- a/plug-ins/common/borderaverage.c +++ b/plug-ins/common/borderaverage.c @@ -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_("/Filters/Colors/_Border Average..."), - "RGB*", - GIMP_PLUGIN, - G_N_ELEMENTS (args), + "Borderaverage", + "", + "Philipp Klaus", + "Internet Access AG", + "1998", + N_("/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< max) + { + max = cube[(i << (bucket_rexpo << 1)) + + (j << bucket_rexpo) + k]; + r = (i<>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); diff --git a/plug-ins/common/bumpmap.c b/plug-ins/common/bumpmap.c index edcddf807f..932e8a9a28 100644 --- a/plug-ins/common/bumpmap.c +++ b/plug-ins/common/bumpmap.c @@ -201,8 +201,8 @@ typedef struct gint bm_bpp; gint bm_has_alpha; - GimpPixelRgn src_rgn; - GimpPixelRgn bm_rgn; + GimpPixelRgn src_rgn; + GimpPixelRgn bm_rgn; bumpmap_params_t params; } bumpmap_interface_t; @@ -212,31 +212,31 @@ 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 bumpmap (void); static void bumpmap_init_params (bumpmap_params_t *params); static void bumpmap_row (guchar *src_row, - guchar *dest_row, - gint width, - gint bpp, - gint has_alpha, - guchar *bm_row1, - guchar *bm_row2, - guchar *bm_row3, - gint bm_width, - gint bm_xofs, - gboolean tiled, - gboolean row_in_bumpmap, - bumpmap_params_t *params); + guchar *dest_row, + gint width, + gint bpp, + gint has_alpha, + guchar *bm_row1, + guchar *bm_row2, + guchar *bm_row3, + gint bm_width, + gint bm_xofs, + gboolean tiled, + gboolean row_in_bumpmap, + bumpmap_params_t *params); static void bumpmap_convert_row (guchar *row, - gint width, - gint bpp, - gint has_alpha, - guchar *lut); + gint width, + gint bpp, + gint has_alpha, + guchar *lut); static gint bumpmap_dialog (void); static void dialog_init_preview (void); @@ -246,8 +246,8 @@ static gint dialog_preview_events (GtkWidget *widget, GdkEvent *event); static void dialog_scroll_src (void); static void dialog_scroll_bumpmap (void); static void dialog_get_rows (GimpPixelRgn *pr, guchar **rows, - gint x, gint y, - gint width, gint height); + gint x, gint y, + gint width, gint height); static void dialog_fill_src_rows (gint start, gint how_many, gint yofs); static void dialog_fill_bumpmap_rows (gint start, gint how_many, gint yofs); @@ -256,10 +256,10 @@ static void dialog_invert_callback (GtkWidget *widget, gpointer data); static void dialog_tiled_callback (GtkWidget *widget, gpointer data); static void dialog_map_type_callback (GtkWidget *widget, gpointer data); static gint dialog_constrain (gint32 image_id, gint32 drawable_id, - gpointer data); + gpointer data); static void dialog_bumpmap_callback (gint32 id, gpointer data); static void dialog_dscale_update (GtkAdjustment *adjustment, - gdouble *value); + gdouble *value); static void dialog_iscale_update_normal (GtkAdjustment *adjustment, gint *value); static void dialog_iscale_update_full (GtkAdjustment *adjustment, gint *value); @@ -358,40 +358,40 @@ query (void) }; gimp_install_procedure ("plug_in_bump_map", - "Create an embossing effect using an image as a " - "bump map", - "This plug-in uses the algorithm described by John " - "Schlag, \"Fast Embossing Effects on Raster Image " - "Data\" in Graphics GEMS IV (ISBN 0-12-336155-9). " - "It takes a drawable to be applied as a bump " - "map to another image and produces a nice embossing " - "effect.", - "Federico Mena Quintero, Jens Lautenbacher & Sven Neumann", - "Federico Mena Quintero, Jens Lautenbacher & Sven Neumann", - PLUG_IN_VERSION, - N_("/Filters/Map/_Bump Map..."), - "RGB*, GRAY*", - GIMP_PLUGIN, - G_N_ELEMENTS (args), 0, - args, NULL); + "Create an embossing effect using an image as a " + "bump map", + "This plug-in uses the algorithm described by John " + "Schlag, \"Fast Embossing Effects on Raster Image " + "Data\" in Graphics GEMS IV (ISBN 0-12-336155-9). " + "It takes a drawable to be applied as a bump " + "map to another image and produces a nice embossing " + "effect.", + "Federico Mena Quintero, Jens Lautenbacher & Sven Neumann", + "Federico Mena Quintero, Jens Lautenbacher & Sven Neumann", + PLUG_IN_VERSION, + N_("/Filters/Map/_Bump Map..."), + "RGB*, GRAY*", + GIMP_PLUGIN, + G_N_ELEMENTS (args), 0, + args, NULL); gimp_install_procedure ("plug_in_bump_map_tiled", - "Create an embossing effect using a tiled image " - "as a bump map", - "This plug-in uses the algorithm described by John " - "Schlag, \"Fast Embossing Effects on Raster Image " - "Data\" in Graphics GEMS IV (ISBN 0-12-336155-9). " - "It takes a drawable to be tiled and applied as a " - "bump map to another image and produces a nice " - "embossing effect.", - "Federico Mena Quintero, Jens Lautenbacher & Sven Neumann", - "Federico Mena Quintero, Jens Lautenbacher & Sven Neumann", - PLUG_IN_VERSION, - NULL, - "RGB*, GRAY*", - GIMP_PLUGIN, - G_N_ELEMENTS (args), 0, - args, NULL); + "Create an embossing effect using a tiled image " + "as a bump map", + "This plug-in uses the algorithm described by John " + "Schlag, \"Fast Embossing Effects on Raster Image " + "Data\" in Graphics GEMS IV (ISBN 0-12-336155-9). " + "It takes a drawable to be tiled and applied as a " + "bump map to another image and produces a nice " + "embossing effect.", + "Federico Mena Quintero, Jens Lautenbacher & Sven Neumann", + "Federico Mena Quintero, Jens Lautenbacher & Sven Neumann", + PLUG_IN_VERSION, + NULL, + "RGB*, GRAY*", + GIMP_PLUGIN, + G_N_ELEMENTS (args), 0, + args, NULL); } static void @@ -421,7 +421,7 @@ run (const gchar *name, drawable = gimp_drawable_get (param[2].data.d_drawable); gimp_drawable_mask_bounds (drawable->drawable_id, - &sel_x1, &sel_y1, &sel_x2, &sel_y2); + &sel_x1, &sel_y1, &sel_x2, &sel_y2); sel_width = sel_x2 - sel_x1; sel_height = sel_y2 - sel_y1; @@ -437,32 +437,32 @@ run (const gchar *name, /* Get information from the dialog */ if (!bumpmap_dialog ()) - return; + return; break; case GIMP_RUN_NONINTERACTIVE: /* Make sure all the arguments are present */ if (nparams != 14) - { - status = GIMP_PDB_CALLING_ERROR; - } + { + status = GIMP_PDB_CALLING_ERROR; + } else - { - bmvals.bumpmap_id = param[3].data.d_drawable; - bmvals.azimuth = param[4].data.d_float; - bmvals.elevation = param[5].data.d_float; - bmvals.depth = param[6].data.d_int32; - bmvals.depth = param[6].data.d_int32; - bmvals.xofs = param[7].data.d_int32; - bmvals.yofs = param[8].data.d_int32; - bmvals.waterlevel = param[9].data.d_int32; - bmvals.ambient = param[10].data.d_int32; - bmvals.compensate = param[11].data.d_int32; - bmvals.invert = param[12].data.d_int32; - bmvals.type = param[13].data.d_int32; - bmvals.tiled = strcmp (name, "plug_in_bump_map_tiled") == 0; - } + { + bmvals.bumpmap_id = param[3].data.d_drawable; + bmvals.azimuth = param[4].data.d_float; + bmvals.elevation = param[5].data.d_float; + bmvals.depth = param[6].data.d_int32; + bmvals.depth = param[6].data.d_int32; + bmvals.xofs = param[7].data.d_int32; + bmvals.yofs = param[8].data.d_int32; + bmvals.waterlevel = param[9].data.d_int32; + bmvals.ambient = param[10].data.d_int32; + bmvals.compensate = param[11].data.d_int32; + bmvals.invert = param[12].data.d_int32; + bmvals.type = param[13].data.d_int32; + bmvals.tiled = strcmp (name, "plug_in_bump_map_tiled") == 0; + } break; case GIMP_RUN_WITH_LAST_VALS: @@ -479,19 +479,19 @@ run (const gchar *name, if (status == GIMP_PDB_SUCCESS) { if ((gimp_drawable_is_rgb(drawable->drawable_id) || - gimp_drawable_is_gray(drawable->drawable_id))) - { - /* Run! */ - bumpmap (); + gimp_drawable_is_gray(drawable->drawable_id))) + { + /* Run! */ + bumpmap (); - /* If run mode is interactive, flush displays */ - if (run_mode != GIMP_RUN_NONINTERACTIVE) - gimp_displays_flush (); + /* If run mode is interactive, flush displays */ + if (run_mode != GIMP_RUN_NONINTERACTIVE) + gimp_displays_flush (); - /* Store data */ - if (run_mode == GIMP_RUN_INTERACTIVE) - gimp_set_data (name, &bmvals, sizeof (bumpmap_vals_t)); - } + /* Store data */ + if (run_mode == GIMP_RUN_INTERACTIVE) + gimp_set_data (name, &bmvals, sizeof (bumpmap_vals_t)); + } } else status = GIMP_PDB_EXECUTION_ERROR; @@ -574,11 +574,11 @@ bumpmap (void) /* Initialize pixel regions */ gimp_pixel_rgn_init (&src_rgn, drawable, - sel_x1, sel_y1, sel_width, sel_height, FALSE, FALSE); + sel_x1, sel_y1, sel_width, sel_height, FALSE, FALSE); gimp_pixel_rgn_init (&dest_rgn, drawable, - sel_x1, sel_y1, sel_width, sel_height, TRUE, TRUE); + sel_x1, sel_y1, sel_width, sel_height, TRUE, TRUE); gimp_pixel_rgn_init (&bm_rgn, bm_drawable, - 0, 0, bm_width, bm_height, FALSE, FALSE); + 0, 0, bm_width, bm_height, FALSE, FALSE); /* Bumpmap */ @@ -601,34 +601,34 @@ bumpmap (void) gimp_pixel_rgn_get_row (&src_rgn, src_row, sel_x1, y, sel_width); bumpmap_row (src_row, dest_row, sel_width, img_bpp, img_has_alpha, - bm_row1, bm_row2, bm_row3, bm_width, bmvals.xofs, - bmvals.tiled, - row_in_bumpmap, - ¶ms); + bm_row1, bm_row2, bm_row3, bm_width, bmvals.xofs, + bmvals.tiled, + row_in_bumpmap, + ¶ms); gimp_pixel_rgn_set_row (&dest_rgn, dest_row, sel_x1, y, sel_width); /* Next line */ if (bmvals.tiled || row_in_bumpmap) - { - bm_tmprow = bm_row1; - bm_row1 = bm_row2; - bm_row2 = bm_row3; - bm_row3 = bm_tmprow; + { + bm_tmprow = bm_row1; + bm_row1 = bm_row2; + bm_row2 = bm_row3; + bm_row3 = bm_tmprow; - if (++yofs2 == bm_height) - yofs2 = 0; + if (++yofs2 == bm_height) + yofs2 = 0; - if (bmvals.tiled) - yofs3 = MOD (yofs2 + 1, bm_height); - else - yofs3 = CLAMP (yofs2 + 1, 0, bm_height - 1); + if (bmvals.tiled) + yofs3 = MOD (yofs2 + 1, bm_height); + else + yofs3 = CLAMP (yofs2 + 1, 0, bm_height - 1); - gimp_pixel_rgn_get_row (&bm_rgn, bm_row3, 0, yofs3, bm_width); - bumpmap_convert_row (bm_row3, bm_width, bm_bpp, bm_has_alpha, - params.lut); - } + gimp_pixel_rgn_get_row (&bm_rgn, bm_row3, 0, yofs3, bm_width); + bumpmap_convert_row (bm_row3, bm_width, bm_bpp, bm_has_alpha, + params.lut); + } gimp_progress_update ((double) ++progress / sel_height); } @@ -682,42 +682,42 @@ bumpmap_init_params (bumpmap_params_t *params) for (i = 0; i < 256; i++) { switch (bmvals.type) - { - case SPHERICAL: - n = i / 255.0 - 1.0; - params->lut[i] = (int) (255.0 * sqrt(1.0 - n * n) + 0.5); - break; + { + case SPHERICAL: + n = i / 255.0 - 1.0; + params->lut[i] = (int) (255.0 * sqrt(1.0 - n * n) + 0.5); + break; - case SINUOSIDAL: - n = i / 255.0; - params->lut[i] = (int) (255.0 * (sin((-G_PI / 2.0) + G_PI * n) + 1.0) / - 2.0 + 0.5); - break; + case SINUOSIDAL: + n = i / 255.0; + params->lut[i] = (int) (255.0 * (sin((-G_PI / 2.0) + G_PI * n) + 1.0) / + 2.0 + 0.5); + break; - case LINEAR: - default: - params->lut[i] = i; - } + case LINEAR: + default: + params->lut[i] = i; + } if (bmvals.invert) - params->lut[i] = 255 - params->lut[i]; + params->lut[i] = 255 - params->lut[i]; } } static void bumpmap_row (guchar *src, - guchar *dest, - gint width, - gint bpp, - gint has_alpha, - guchar *bm_row1, - guchar *bm_row2, - guchar *bm_row3, - gint bm_width, - gint bm_xofs, - gboolean tiled, - gboolean row_in_bumpmap, - bumpmap_params_t *params) + guchar *dest, + gint width, + gint bpp, + gint has_alpha, + guchar *bm_row1, + guchar *bm_row2, + guchar *bm_row3, + gint bm_width, + gint bm_xofs, + gboolean tiled, + gboolean row_in_bumpmap, + bumpmap_params_t *params) { gint xofs1, xofs2, xofs3; gint shade; @@ -741,75 +741,75 @@ bumpmap_row (guchar *src, /* Calculate surface normal from bump map */ if (tiled || (row_in_bumpmap && - x >= - tmp && x < - tmp + bm_width)) - { - if (tiled) - { - xofs1 = MOD (xofs2 - 1, bm_width); - xofs3 = MOD (xofs2 + 1, bm_width); - } - else - { - xofs1 = CLAMP (xofs2 - 1, 0, bm_width - 1); - xofs3 = CLAMP (xofs2 + 1, 0, bm_width - 1); - } - nx = (bm_row1[xofs1] + bm_row2[xofs1] + bm_row3[xofs1] - - bm_row1[xofs3] - bm_row2[xofs3] - bm_row3[xofs3]); - ny = (bm_row3[xofs1] + bm_row3[xofs2] + bm_row3[xofs3] - - bm_row1[xofs1] - bm_row1[xofs2] - bm_row1[xofs3]); - } + x >= - tmp && x < - tmp + bm_width)) + { + if (tiled) + { + xofs1 = MOD (xofs2 - 1, bm_width); + xofs3 = MOD (xofs2 + 1, bm_width); + } + else + { + xofs1 = CLAMP (xofs2 - 1, 0, bm_width - 1); + xofs3 = CLAMP (xofs2 + 1, 0, bm_width - 1); + } + nx = (bm_row1[xofs1] + bm_row2[xofs1] + bm_row3[xofs1] - + bm_row1[xofs3] - bm_row2[xofs3] - bm_row3[xofs3]); + ny = (bm_row3[xofs1] + bm_row3[xofs2] + bm_row3[xofs3] - + bm_row1[xofs1] - bm_row1[xofs2] - bm_row1[xofs3]); + } else - { - nx = ny = 0; - } + { + nx = ny = 0; + } /* Shade */ if ((nx == 0) && (ny == 0)) - shade = params->background; + shade = params->background; else - { - ndotl = nx * params->lx + ny * params->ly + params->nzlz; + { + ndotl = nx * params->lx + ny * params->ly + params->nzlz; - if (ndotl < 0) - shade = params->compensation * bmvals.ambient; - else - { - shade = ndotl / sqrt(nx * nx + ny * ny + params->nz2); + if (ndotl < 0) + shade = params->compensation * bmvals.ambient; + else + { + shade = ndotl / sqrt(nx * nx + ny * ny + params->nz2); - shade = shade + MAX(0, (255 * params->compensation - shade)) * - bmvals.ambient / 255; - } - } + shade = shade + MAX(0, (255 * params->compensation - shade)) * + bmvals.ambient / 255; + } + } /* Paint */ if (bmvals.compensate) - for (k = pbpp; k; k--) - { - result = (*src++ * shade) / (params->compensation * 255); - *dest++ = MIN(255, result); - } + for (k = pbpp; k; k--) + { + result = (*src++ * shade) / (params->compensation * 255); + *dest++ = MIN(255, result); + } else - for (k = pbpp; k; k--) - *dest++ = *src++ * shade / 255; + for (k = pbpp; k; k--) + *dest++ = *src++ * shade / 255; if (has_alpha) - *dest++ = *src++; + *dest++ = *src++; /* Next pixel */ if (++xofs2 == bm_width) - xofs2 = 0; + xofs2 = 0; } } static void bumpmap_convert_row (guchar *row, - gint width, - gint bpp, - gint has_alpha, - guchar *lut) + gint width, + gint bpp, + gint has_alpha, + guchar *lut) { guchar *p; @@ -820,29 +820,29 @@ bumpmap_convert_row (guchar *row, if (bpp >= 3) for (; width; width--) { - if (has_alpha) - *p++ = lut[(gint) (bmvals.waterlevel + + if (has_alpha) + *p++ = lut[(gint) (bmvals.waterlevel + (((gint) (GIMP_RGB_INTENSITY (row[0], row[1], row[2]) + 0.5) - bmvals.waterlevel) * row[3]) / 255.0)]; - else - *p++ = lut[(gint) (GIMP_RGB_INTENSITY (row[0], + else + *p++ = lut[(gint) (GIMP_RGB_INTENSITY (row[0], row[1], row[2]) + 0.5)]; - row += 3 + has_alpha; + row += 3 + has_alpha; } else for (; width; width--) { - if (has_alpha) - *p++ = lut[bmvals.waterlevel + - ((row[0] - bmvals.waterlevel) * row[1]) / 255]; - else - *p++ = lut[*row]; + if (has_alpha) + *p++ = lut[bmvals.waterlevel + + ((row[0] - bmvals.waterlevel) * row[1]) / 255]; + else + *p++ = lut[*row]; - row += 1 + has_alpha; + row += 1 + has_alpha; } } @@ -874,17 +874,17 @@ bumpmap_dialog (void) dialog = gimp_dialog_new (_("Bump Map"), "bumpmap", NULL, 0, - gimp_standard_help_func, "filters/bumpmap.html", + gimp_standard_help_func, "filters/bumpmap.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); top_vbox = gtk_vbox_new (FALSE, 4); gtk_container_set_border_width (GTK_CONTAINER (top_vbox), 6); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), top_vbox, - FALSE, FALSE, 0); + FALSE, FALSE, 0); gtk_widget_show (top_vbox); hbox = gtk_hbox_new (FALSE, 6); @@ -905,7 +905,7 @@ bumpmap_dialog (void) gtk_frame_set_shadow_type (GTK_FRAME (pframe), GTK_SHADOW_IN); gtk_container_set_border_width (GTK_CONTAINER (pframe), 0); gtk_table_attach (GTK_TABLE (ptable), pframe, 0, 1, 0, 1, - GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0); + GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0); gtk_widget_show (pframe); bmint.preview_width = MIN (sel_width, PREVIEW_SIZE); @@ -913,7 +913,7 @@ bumpmap_dialog (void) bmint.preview = preview = gtk_preview_new (GTK_PREVIEW_COLOR); gtk_preview_size (GTK_PREVIEW (bmint.preview), - bmint.preview_width, bmint.preview_height); + bmint.preview_width, bmint.preview_height); gtk_container_add (GTK_CONTAINER (pframe), bmint.preview); gtk_widget_show (bmint.preview); @@ -923,7 +923,7 @@ bumpmap_dialog (void) { scrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (bmint.preview_adj_x)); gtk_table_attach (GTK_TABLE (ptable), scrollbar, 0, 1, 1, 2, - GTK_FILL | GTK_EXPAND, 0, 0, 0); + GTK_FILL | GTK_EXPAND, 0, 0, 0); gtk_widget_show (scrollbar); } @@ -933,15 +933,15 @@ bumpmap_dialog (void) { scrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (bmint.preview_adj_y)); gtk_table_attach (GTK_TABLE (ptable), scrollbar, 1, 2, 0,1, - 0, GTK_FILL | GTK_EXPAND, 0, 0); + 0, GTK_FILL | GTK_EXPAND, 0, 0); gtk_widget_show (scrollbar); } gtk_widget_set_events (bmint.preview, - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_MOTION_MASK | - GDK_POINTER_MOTION_HINT_MASK); + GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_BUTTON_MOTION_MASK | + GDK_POINTER_MOTION_HINT_MASK); g_signal_connect (bmint.preview, "event", G_CALLBACK (dialog_preview_events), @@ -958,14 +958,14 @@ bumpmap_dialog (void) /* Type of map */ frame = gimp_int_radio_group_new (TRUE, _("Map Type"), - G_CALLBACK (dialog_map_type_callback), - &bmvals.type, bmvals.type, + G_CALLBACK (dialog_map_type_callback), + &bmvals.type, bmvals.type, - _("_Linear Map"), LINEAR, NULL, - _("_Spherical Map"), SPHERICAL, NULL, - _("S_inuosidal Map"), SINUOSIDAL, NULL, + _("_Linear Map"), LINEAR, NULL, + _("_Spherical Map"), SPHERICAL, NULL, + _("S_inuosidal Map"), SINUOSIDAL, NULL, - NULL); + NULL); gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); @@ -979,7 +979,7 @@ bumpmap_dialog (void) button = gtk_check_button_new_with_mnemonic (_("Co_mpensate for Darkening")); gtk_box_pack_start (GTK_BOX (right_vbox), button, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), - bmvals.compensate ? TRUE : FALSE); + bmvals.compensate ? TRUE : FALSE); gtk_widget_show (button); g_signal_connect (button, "toggled", @@ -990,7 +990,7 @@ bumpmap_dialog (void) button = gtk_check_button_new_with_mnemonic (_("I_nvert Bumpmap")); gtk_box_pack_start (GTK_BOX (right_vbox), button, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), - bmvals.invert ? TRUE : FALSE); + bmvals.invert ? TRUE : FALSE); gtk_widget_show (button); g_signal_connect (button, "toggled", @@ -1001,7 +1001,7 @@ bumpmap_dialog (void) button = gtk_check_button_new_with_mnemonic (_("_Tile Bumpmap")); gtk_box_pack_start (GTK_BOX (right_vbox), button, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), - bmvals.tiled ? TRUE : FALSE); + bmvals.tiled ? TRUE : FALSE); gtk_widget_show (button); g_signal_connect (button, "toggled", @@ -1025,13 +1025,13 @@ bumpmap_dialog (void) option_menu = gtk_option_menu_new (); menu = gimp_drawable_menu_new (dialog_constrain, - dialog_bumpmap_callback, - NULL, - bmvals.bumpmap_id); + dialog_bumpmap_callback, + NULL, + bmvals.bumpmap_id); gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu); gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, - _("_Bump Map:"), 1.0, 0.5, - option_menu, 2, TRUE); + _("_Bump Map:"), 1.0, 0.5, + option_menu, 2, TRUE); sep = gtk_hseparator_new (); gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0); @@ -1049,28 +1049,28 @@ bumpmap_dialog (void) row = 0; adj = gimp_scale_entry_new (GTK_TABLE (table), 0, row++, - _("_Azimuth:"), SCALE_WIDTH, 6, - bmvals.azimuth, 0.0, 360.0, 1.0, 15.0, 2, - TRUE, 0, 0, - NULL, NULL); + _("_Azimuth:"), SCALE_WIDTH, 6, + bmvals.azimuth, 0.0, 360.0, 1.0, 15.0, 2, + TRUE, 0, 0, + NULL, NULL); g_signal_connect (adj, "value_changed", G_CALLBACK (dialog_dscale_update), &bmvals.azimuth); adj = gimp_scale_entry_new (GTK_TABLE (table), 0, row++, - _("_Elevation:"), SCALE_WIDTH, 6, - bmvals.elevation, 0.5, 90.0, 1.0, 5.0, 2, - TRUE, 0, 0, - NULL, NULL); + _("_Elevation:"), SCALE_WIDTH, 6, + bmvals.elevation, 0.5, 90.0, 1.0, 5.0, 2, + TRUE, 0, 0, + NULL, NULL); g_signal_connect (adj, "value_changed", G_CALLBACK (dialog_dscale_update), &bmvals.elevation); adj = gimp_scale_entry_new (GTK_TABLE (table), 0, row, - _("_Depth:"), SCALE_WIDTH, 6, - bmvals.depth, 1.0, 65.0, 1.0, 5.0, 0, - TRUE, 0, 0, - NULL, NULL); + _("_Depth:"), SCALE_WIDTH, 6, + bmvals.depth, 1.0, 65.0, 1.0, 5.0, 0, + TRUE, 0, 0, + NULL, NULL); g_signal_connect (adj, "value_changed", G_CALLBACK (dialog_iscale_update_normal), &bmvals.depth); @@ -1078,39 +1078,39 @@ bumpmap_dialog (void) bmint.offset_adj_x = adj = gimp_scale_entry_new (GTK_TABLE (table), 0, row++, - _("_X Offset:"), SCALE_WIDTH, 6, - bmvals.xofs, -1000.0, 1001.0, 1.0, 10.0, 0, - TRUE, 0, 0, - NULL, NULL); + _("_X Offset:"), SCALE_WIDTH, 6, + bmvals.xofs, -1000.0, 1001.0, 1.0, 10.0, 0, + TRUE, 0, 0, + NULL, NULL); g_signal_connect (adj, "value_changed", G_CALLBACK (dialog_iscale_update_normal), &bmvals.xofs); bmint.offset_adj_y = adj = gimp_scale_entry_new (GTK_TABLE (table), 0, row, - _("_Y Offset:"), SCALE_WIDTH, 6, - bmvals.yofs, -1000.0, 1001.0, 1.0, 10.0, 0, - TRUE, 0, 0, - NULL, NULL); + _("_Y Offset:"), SCALE_WIDTH, 6, + bmvals.yofs, -1000.0, 1001.0, 1.0, 10.0, 0, + TRUE, 0, 0, + NULL, NULL); g_signal_connect (adj, "value_changed", G_CALLBACK (dialog_iscale_update_normal), &bmvals.yofs); gtk_table_set_row_spacing (GTK_TABLE (table), row++, 8); adj = gimp_scale_entry_new (GTK_TABLE (table), 0, row++, - _("_Waterlevel:"), SCALE_WIDTH, 6, - bmvals.waterlevel, 0.0, 255.0, 1.0, 8.0, 0, - TRUE, 0, 0, - NULL, NULL); + _("_Waterlevel:"), SCALE_WIDTH, 6, + bmvals.waterlevel, 0.0, 255.0, 1.0, 8.0, 0, + TRUE, 0, 0, + NULL, NULL); g_signal_connect (adj, "value_changed", G_CALLBACK (dialog_iscale_update_full), &bmvals.waterlevel); adj = gimp_scale_entry_new (GTK_TABLE (table), 0, row++, - _("A_mbient:"), SCALE_WIDTH, 6, - bmvals.ambient, 0.0, 255.0, 1.0, 8.0, 0, - TRUE, 0, 0, - NULL, NULL); + _("A_mbient:"), SCALE_WIDTH, 6, + bmvals.ambient, 0.0, 255.0, 1.0, 8.0, 0, + TRUE, 0, 0, + NULL, NULL); g_signal_connect (adj, "value_changed", G_CALLBACK (dialog_iscale_update_normal), &bmvals.ambient); @@ -1155,19 +1155,19 @@ dialog_init_preview (void) for (x = 0; x < bmint.preview_width; x++) if ((x / GIMP_CHECK_SIZE) & 1) { - bmint.check_row_0[x] = GIMP_CHECK_DARK * 255; - bmint.check_row_1[x] = GIMP_CHECK_LIGHT * 255; + bmint.check_row_0[x] = GIMP_CHECK_DARK * 255; + bmint.check_row_1[x] = GIMP_CHECK_LIGHT * 255; } else { - bmint.check_row_0[x] = GIMP_CHECK_LIGHT * 255; - bmint.check_row_1[x] = GIMP_CHECK_DARK * 255; + bmint.check_row_0[x] = GIMP_CHECK_LIGHT * 255; + bmint.check_row_1[x] = GIMP_CHECK_DARK * 255; } /* Initialize source rows */ gimp_pixel_rgn_init (&bmint.src_rgn, drawable, - sel_x1, sel_y1, sel_width, sel_height, FALSE, FALSE); + sel_x1, sel_y1, sel_width, sel_height, FALSE, FALSE); bmint.src_rows = g_new (guchar *, bmint.preview_height); @@ -1175,8 +1175,8 @@ dialog_init_preview (void) bmint.src_rows[x] = g_new (guchar, sel_width * 4); dialog_fill_src_rows (0, - bmint.preview_height, - sel_y1 + bmint.preview_yofs); + bmint.preview_height, + sel_y1 + bmint.preview_yofs); /* Initialize bumpmap rows */ @@ -1188,7 +1188,7 @@ dialog_init_preview (void) static gint dialog_preview_events (GtkWidget *widget, - GdkEvent *event) + GdkEvent *event) { gint x, y; gint dx, dy; @@ -1202,22 +1202,22 @@ dialog_preview_events (GtkWidget *widget, { case GDK_BUTTON_PRESS: switch (bevent->button) - { - case 1: - case 2: - if (bevent->state & GDK_SHIFT_MASK) - bmint.drag_mode = DRAG_BUMPMAP; - else - bmint.drag_mode = DRAG_SCROLL; - break; + { + case 1: + case 2: + if (bevent->state & GDK_SHIFT_MASK) + bmint.drag_mode = DRAG_BUMPMAP; + else + bmint.drag_mode = DRAG_SCROLL; + break; - case 3: - bmint.drag_mode = DRAG_BUMPMAP; - break; + case 3: + bmint.drag_mode = DRAG_BUMPMAP; + break; - default: - return FALSE; - } + default: + return FALSE; + } bmint.mouse_x = x; bmint.mouse_y = y; @@ -1228,11 +1228,11 @@ dialog_preview_events (GtkWidget *widget, case GDK_BUTTON_RELEASE: if (bmint.drag_mode != DRAG_NONE) - { - gtk_grab_remove (widget); - bmint.drag_mode = DRAG_NONE; - dialog_update_preview (); - } + { + gtk_grab_remove (widget); + bmint.drag_mode = DRAG_NONE; + dialog_update_preview (); + } break; @@ -1244,62 +1244,62 @@ dialog_preview_events (GtkWidget *widget, bmint.mouse_y = y; if ((dx == 0) && (dy == 0)) - break; + break; switch (bmint.drag_mode) - { - case DRAG_SCROLL: - bmint.preview_xofs = CLAMP (bmint.preview_xofs - dx, - 0, - sel_width - bmint.preview_width); - g_signal_handlers_block_by_func (bmint.preview_adj_x, - dialog_iscale_update_normal, - &bmint.preview_xofs); - gtk_adjustment_set_value (GTK_ADJUSTMENT (bmint.preview_adj_x), - bmint.preview_xofs); - g_signal_handlers_unblock_by_func (bmint.preview_adj_x, - dialog_iscale_update_normal, - &bmint.preview_xofs); - bmint.preview_yofs = CLAMP (bmint.preview_yofs - dy, - 0, - sel_height - bmint.preview_height); - g_signal_handlers_block_by_func (bmint.preview_adj_y, - dialog_iscale_update_normal, - &bmint.preview_yofs); - gtk_adjustment_set_value (GTK_ADJUSTMENT (bmint.preview_adj_y), - bmint.preview_yofs); - g_signal_handlers_unblock_by_func (bmint.preview_adj_y, - dialog_iscale_update_normal, - &bmint.preview_yofs); + { + case DRAG_SCROLL: + bmint.preview_xofs = CLAMP (bmint.preview_xofs - dx, + 0, + sel_width - bmint.preview_width); + g_signal_handlers_block_by_func (bmint.preview_adj_x, + dialog_iscale_update_normal, + &bmint.preview_xofs); + gtk_adjustment_set_value (GTK_ADJUSTMENT (bmint.preview_adj_x), + bmint.preview_xofs); + g_signal_handlers_unblock_by_func (bmint.preview_adj_x, + dialog_iscale_update_normal, + &bmint.preview_xofs); + bmint.preview_yofs = CLAMP (bmint.preview_yofs - dy, + 0, + sel_height - bmint.preview_height); + g_signal_handlers_block_by_func (bmint.preview_adj_y, + dialog_iscale_update_normal, + &bmint.preview_yofs); + gtk_adjustment_set_value (GTK_ADJUSTMENT (bmint.preview_adj_y), + bmint.preview_yofs); + g_signal_handlers_unblock_by_func (bmint.preview_adj_y, + dialog_iscale_update_normal, + &bmint.preview_yofs); - break; + break; - case DRAG_BUMPMAP: - bmvals.xofs = CLAMP (bmvals.xofs - dx, -1000, 1000); - g_signal_handlers_block_by_func (bmint.offset_adj_x, - dialog_iscale_update_normal, - &bmvals.xofs); - gtk_adjustment_set_value (GTK_ADJUSTMENT (bmint.offset_adj_x), - bmvals.xofs); - g_signal_handlers_unblock_by_func (bmint.offset_adj_x, - dialog_iscale_update_normal, - &bmvals.xofs); + case DRAG_BUMPMAP: + bmvals.xofs = CLAMP (bmvals.xofs - dx, -1000, 1000); + g_signal_handlers_block_by_func (bmint.offset_adj_x, + dialog_iscale_update_normal, + &bmvals.xofs); + gtk_adjustment_set_value (GTK_ADJUSTMENT (bmint.offset_adj_x), + bmvals.xofs); + g_signal_handlers_unblock_by_func (bmint.offset_adj_x, + dialog_iscale_update_normal, + &bmvals.xofs); - bmvals.yofs = CLAMP (bmvals.yofs - dy, -1000, 1000); - g_signal_handlers_block_by_func (bmint.offset_adj_y, - dialog_iscale_update_normal, - &bmvals.yofs); - gtk_adjustment_set_value (GTK_ADJUSTMENT (bmint.offset_adj_y), - bmvals.yofs); - g_signal_handlers_unblock_by_func (bmint.offset_adj_y, - dialog_iscale_update_normal, - &bmvals.yofs); + bmvals.yofs = CLAMP (bmvals.yofs - dy, -1000, 1000); + g_signal_handlers_block_by_func (bmint.offset_adj_y, + dialog_iscale_update_normal, + &bmvals.yofs); + gtk_adjustment_set_value (GTK_ADJUSTMENT (bmint.offset_adj_y), + bmvals.yofs); + g_signal_handlers_unblock_by_func (bmint.offset_adj_y, + dialog_iscale_update_normal, + &bmvals.yofs); - break; + break; - default: - return FALSE; - } + default: + return FALSE; + } dialog_update_preview (); @@ -1344,9 +1344,9 @@ dialog_new_bumpmap (gboolean init_offsets) if (init_offsets) { gimp_drawable_offsets (bmint.bm_drawable->drawable_id, - &bump_offset_x, &bump_offset_y); + &bump_offset_x, &bump_offset_y); gimp_drawable_offsets (drawable->drawable_id, - &draw_offset_x, &draw_offset_y); + &draw_offset_x, &draw_offset_y); bmvals.xofs = draw_offset_x - bump_offset_x; bmvals.yofs = draw_offset_y - bump_offset_y; @@ -1357,12 +1357,12 @@ dialog_new_bumpmap (gboolean init_offsets) { adj->value = bmvals.xofs; g_signal_handlers_block_by_func (adj, - dialog_iscale_update_normal, - &bmvals.xofs); + dialog_iscale_update_normal, + &bmvals.xofs); gtk_adjustment_value_changed (adj); g_signal_handlers_unblock_by_func (adj, - dialog_iscale_update_normal, - &bmvals.xofs); + dialog_iscale_update_normal, + &bmvals.xofs); } adj = (GtkAdjustment *) bmint.offset_adj_y; @@ -1370,18 +1370,18 @@ dialog_new_bumpmap (gboolean init_offsets) { adj->value = bmvals.yofs; g_signal_handlers_block_by_func (adj, - dialog_iscale_update_normal, - &bmvals.yofs); + dialog_iscale_update_normal, + &bmvals.yofs); gtk_adjustment_value_changed (adj); g_signal_handlers_unblock_by_func (adj, - dialog_iscale_update_normal, - &bmvals.yofs); + dialog_iscale_update_normal, + &bmvals.yofs); } /* Initialize pixel region */ gimp_pixel_rgn_init (&bmint.bm_rgn, bmint.bm_drawable, - 0, 0, bmint.bm_width, bmint.bm_height, FALSE, FALSE); + 0, 0, bmint.bm_width, bmint.bm_height, FALSE, FALSE); /* Initialize row buffers */ @@ -1426,20 +1426,20 @@ dialog_update_preview (void) for (y = 0; y < bmint.preview_height; y++) { gint isfirst = ((y == - bmvals.yofs - bmint.preview_yofs - sel_y1) - && ! bmvals.tiled) ? 1 : 0; + && ! bmvals.tiled) ? 1 : 0; gint islast = (y == (- bmvals.yofs - bmint.preview_yofs - sel_y1 - + bmint.bm_height - 1) && ! bmvals.tiled) ? 1 : 0; + + bmint.bm_height - 1) && ! bmvals.tiled) ? 1 : 0; bumpmap_row (bmint.src_rows[y] + 4 * xofs, dest_row, - bmint.preview_width, 4, TRUE, - bmint.bm_rows[y + isfirst], - bmint.bm_rows[y + 1], - bmint.bm_rows[y + 2 - islast], - bmint.bm_width, xofs + bmvals.xofs, - bmvals.tiled, - y >= - bmvals.yofs - bmint.preview_yofs - sel_y1 && - y < (- bmvals.yofs - bmint.preview_yofs - sel_y1 - + bmint.bm_height), - &bmint.params); + bmint.preview_width, 4, TRUE, + bmint.bm_rows[y + isfirst], + bmint.bm_rows[y + 1], + bmint.bm_rows[y + 2 - islast], + bmint.bm_width, xofs + bmvals.xofs, + bmvals.tiled, + y >= - bmvals.yofs - bmint.preview_yofs - sel_y1 && + y < (- bmvals.yofs - bmint.preview_yofs - sel_y1 + + bmint.bm_height), + &bmint.params); /* Paint row */ @@ -1447,24 +1447,24 @@ dialog_update_preview (void) p = preview_row; if ((y / GIMP_CHECK_SIZE) & 1) - check_row = bmint.check_row_0; + check_row = bmint.check_row_0; else - check_row = bmint.check_row_1; + check_row = bmint.check_row_1; for (x = 0; x < bmint.preview_width; x++) - { - check = check_row[x]; + { + check = check_row[x]; - p[0] = check + ((sp[0] - check) * sp[3]) / 255; - p[1] = check + ((sp[1] - check) * sp[3]) / 255; - p[2] = check + ((sp[2] - check) * sp[3]) / 255; + p[0] = check + ((sp[0] - check) * sp[3]) / 255; + p[1] = check + ((sp[1] - check) * sp[3]) / 255; + p[2] = check + ((sp[2] - check) * sp[3]) / 255; - sp += 4; - p += 3; - } + sp += 4; + p += 3; + } gtk_preview_draw_row (GTK_PREVIEW(bmint.preview), - preview_row, 0, y, bmint.preview_width); + preview_row, 0, y, bmint.preview_width); } gtk_widget_queue_draw (bmint.preview); @@ -1492,8 +1492,8 @@ dialog_scroll_src (void) /* Scroll useful rows... */ if (ofs < bmint.preview_height) - for (y = (bmint.preview_height - 1); y >= ofs; y--) - SWAP_ROWS (bmint.src_rows[y], bmint.src_rows[y - ofs], tmp); + for (y = (bmint.preview_height - 1); y >= ofs; y--) + SWAP_ROWS (bmint.src_rows[y], bmint.src_rows[y - ofs], tmp); /* ... and get the new ones */ @@ -1506,16 +1506,16 @@ dialog_scroll_src (void) /* Scroll useful rows... */ if (ofs < bmint.preview_height) - for (y = 0; y < (bmint.preview_height - ofs); y++) - SWAP_ROWS (bmint.src_rows[y], bmint.src_rows[y + ofs], tmp); + for (y = 0; y < (bmint.preview_height - ofs); y++) + SWAP_ROWS (bmint.src_rows[y], bmint.src_rows[y + ofs], tmp); /* ... and get the new ones */ dialog_fill_src_rows ((bmint.preview_height - - MIN (ofs, bmint.preview_height)), - MIN (ofs, bmint.preview_height), - (sel_y1 + yofs + bmint.preview_height - - MIN (ofs, bmint.preview_height))); + MIN (ofs, bmint.preview_height)), + MIN (ofs, bmint.preview_height), + (sel_y1 + yofs + bmint.preview_height - + MIN (ofs, bmint.preview_height))); } bmint.src_yofs = yofs; @@ -1541,14 +1541,14 @@ dialog_scroll_bumpmap (void) /* Scroll useful rows... */ if (ofs < (bmint.preview_height + 2)) - for (y = (bmint.preview_height + 1); y >= ofs; y--) - SWAP_ROWS (bmint.bm_rows[y], bmint.bm_rows[y - ofs], tmp); + for (y = (bmint.preview_height + 1); y >= ofs; y--) + SWAP_ROWS (bmint.bm_rows[y], bmint.bm_rows[y - ofs], tmp); /* ... and get the new ones */ dialog_fill_bumpmap_rows (0, - MIN (ofs, bmint.preview_height + 2), - yofs); + MIN (ofs, bmint.preview_height + 2), + yofs); } else { @@ -1557,17 +1557,17 @@ dialog_scroll_bumpmap (void) /* Scroll useful rows... */ if (ofs < (bmint.preview_height + 2)) - for (y = 0; y < (bmint.preview_height + 2 - ofs); y++) - SWAP_ROWS (bmint.bm_rows[y], bmint.bm_rows[y + ofs], tmp); + for (y = 0; y < (bmint.preview_height + 2 - ofs); y++) + SWAP_ROWS (bmint.bm_rows[y], bmint.bm_rows[y + ofs], tmp); /* ... and get the new ones */ dialog_fill_bumpmap_rows ((bmint.preview_height + 2 - - MIN (ofs, bmint.preview_height + 2)), - MIN (ofs, bmint.preview_height + 2), - (yofs + bmint.preview_height + 2 - - MIN (ofs, bmint.preview_height + 2)) % - bmint.bm_height); + MIN (ofs, bmint.preview_height + 2)), + MIN (ofs, bmint.preview_height + 2), + (yofs + bmint.preview_height + 2 - + MIN (ofs, bmint.preview_height + 2)) % + bmint.bm_height); } bmint.bm_yofs = yofs; @@ -1575,11 +1575,11 @@ dialog_scroll_bumpmap (void) static void dialog_get_rows (GimpPixelRgn *pr, - guchar **rows, - gint x, - gint y, - gint width, - gint height) + guchar **rows, + gint x, + gint y, + gint width, + gint height) { /* This is shamelessly ripped off from gimp_pixel_rgn_get_rect(). * Its function is exactly the same, but it can fetch an image @@ -1614,32 +1614,32 @@ dialog_get_rows (GimpPixelRgn *pr, x = xstart; while (x < xend) - { - tile = gimp_drawable_get_tile2 (pr->drawable, pr->shadow, x, y); - gimp_tile_ref (tile); + { + tile = gimp_drawable_get_tile2 (pr->drawable, pr->shadow, x, y); + gimp_tile_ref (tile); - xstep = tile->ewidth - (x % tile_width); - ystep = tile->eheight - (y % tile_height); - xboundary = x + xstep; - yboundary = y + ystep; - xboundary = MIN (xboundary, xend); - yboundary = MIN (yboundary, yend); + xstep = tile->ewidth - (x % tile_width); + ystep = tile->eheight - (y % tile_height); + xboundary = x + xstep; + yboundary = y + ystep; + xboundary = MIN (xboundary, xend); + yboundary = MIN (yboundary, yend); - for (ty = y; ty < yboundary; ty++) - { - src = tile->data + tile->bpp * (tile->ewidth * (ty % tile_height) + - (x % tile_width)); - dest = rows[ty - ystart] + bpp * (x - xstart); + for (ty = y; ty < yboundary; ty++) + { + src = tile->data + tile->bpp * (tile->ewidth * (ty % tile_height) + + (x % tile_width)); + dest = rows[ty - ystart] + bpp * (x - xstart); - for (tx = x; tx < xboundary; tx++) - for (b = bpp; b; b--) - *dest++ = *src++; - } + for (tx = x; tx < xboundary; tx++) + for (b = bpp; b; b--) + *dest++ = *src++; + } - gimp_tile_unref (tile, FALSE); + gimp_tile_unref (tile, FALSE); - x += xstep; - } + x += xstep; + } y += ystep; } @@ -1647,8 +1647,8 @@ dialog_get_rows (GimpPixelRgn *pr, static void dialog_fill_src_rows (gint start, - gint how_many, - gint yofs) + gint how_many, + gint yofs) { gint x; gint y; @@ -1656,11 +1656,11 @@ dialog_fill_src_rows (gint start, guchar *p; dialog_get_rows (&bmint.src_rgn, - bmint.src_rows + start, - sel_x1, - yofs, - sel_width, - how_many); + bmint.src_rows + start, + sel_x1, + yofs, + sel_width, + how_many); /* Convert to RGBA. We move backwards! */ @@ -1670,32 +1670,32 @@ dialog_fill_src_rows (gint start, p = bmint.src_rows[y] + 4 * sel_width - 1; for (x = 0; x < sel_width; x++) - { - if (img_has_alpha) - *p-- = *sp--; - else - *p-- = 255; + { + if (img_has_alpha) + *p-- = *sp--; + else + *p-- = 255; - if (img_bpp < 3) - { - *p-- = *sp; - *p-- = *sp; - *p-- = *sp--; - } - else - { - *p-- = *sp--; - *p-- = *sp--; - *p-- = *sp--; - } - } + if (img_bpp < 3) + { + *p-- = *sp; + *p-- = *sp; + *p-- = *sp--; + } + else + { + *p-- = *sp--; + *p-- = *sp--; + *p-- = *sp--; + } + } } } static void dialog_fill_bumpmap_rows (gint start, - gint how_many, - gint yofs) + gint how_many, + gint yofs) { gint buf_row_ofs; gint remaining; @@ -1712,11 +1712,11 @@ dialog_fill_bumpmap_rows (gint start, this_pass = MIN (remaining, bmint.bm_height - yofs); dialog_get_rows (&bmint.bm_rgn, - bmint.bm_rows + buf_row_ofs, - 0, - yofs, - bmint.bm_width, - this_pass); + bmint.bm_rows + buf_row_ofs, + 0, + yofs, + bmint.bm_width, + this_pass); yofs = (yofs + this_pass) % bmint.bm_height; remaining -= this_pass; @@ -1728,10 +1728,10 @@ dialog_fill_bumpmap_rows (gint start, for (; how_many; how_many--) { bumpmap_convert_row (bmint.bm_rows[start], - bmint.bm_width, - bmint.bm_bpp, - bmint.bm_has_alpha, - bmint.params.lut); + bmint.bm_width, + bmint.bm_bpp, + bmint.bm_has_alpha, + bmint.params.lut); start++; } @@ -1739,7 +1739,7 @@ dialog_fill_bumpmap_rows (gint start, static void dialog_compensate_callback (GtkWidget *widget, - gpointer data) + gpointer data) { bmvals.compensate = GTK_TOGGLE_BUTTON (widget)->active; @@ -1748,7 +1748,7 @@ dialog_compensate_callback (GtkWidget *widget, static void dialog_invert_callback (GtkWidget *widget, - gpointer data) + gpointer data) { bmvals.invert = GTK_TOGGLE_BUTTON (widget)->active; @@ -1759,7 +1759,7 @@ dialog_invert_callback (GtkWidget *widget, static void dialog_tiled_callback (GtkWidget *widget, - gpointer data) + gpointer data) { bmvals.tiled = GTK_TOGGLE_BUTTON (widget)->active; @@ -1770,7 +1770,7 @@ dialog_tiled_callback (GtkWidget *widget, static void dialog_map_type_callback (GtkWidget *widget, - gpointer data) + gpointer data) { gimp_radio_button_update (widget, data); @@ -1784,19 +1784,19 @@ dialog_map_type_callback (GtkWidget *widget, static gint dialog_constrain (gint32 image_id, - gint32 drawable_id, - gpointer data) + gint32 drawable_id, + gpointer data) { if (drawable_id == -1) return TRUE; return (gimp_drawable_is_rgb (drawable_id) || - gimp_drawable_is_gray (drawable_id)); + gimp_drawable_is_gray (drawable_id)); } static void dialog_bumpmap_callback (gint32 id, - gpointer data) + gpointer data) { if (bmvals.bumpmap_id == id) { @@ -1812,7 +1812,7 @@ dialog_bumpmap_callback (gint32 id, static void dialog_dscale_update (GtkAdjustment *adjustment, - gdouble *value) + gdouble *value) { gimp_double_adjustment_update (adjustment, value); @@ -1821,7 +1821,7 @@ dialog_dscale_update (GtkAdjustment *adjustment, static void dialog_iscale_update_normal (GtkAdjustment *adjustment, - gint *value) + gint *value) { gimp_int_adjustment_update (adjustment, value); @@ -1830,7 +1830,7 @@ dialog_iscale_update_normal (GtkAdjustment *adjustment, static void dialog_iscale_update_full (GtkAdjustment *adjustment, - gint *value) + gint *value) { gimp_int_adjustment_update (adjustment, value); diff --git a/plug-ins/common/bz2.c b/plug-ins/common/bz2.c index 2bb7b869df..94ba760aca 100644 --- a/plug-ins/common/bz2.c +++ b/plug-ins/common/bz2.c @@ -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", "/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", "/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, '.'); + } } } diff --git a/plug-ins/common/c_astretch.c b/plug-ins/common/c_astretch.c index 9194f33e10..8010b96c1b 100644 --- a/plug-ins/common/c_astretch.c +++ b/plug-ins/common/c_astretch.c @@ -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_("/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_("/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;ialpha; 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, ¶m); diff --git a/plug-ins/common/channel_mixer.c b/plug-ins/common/channel_mixer.c index 60a395c2f0..1193511f53 100644 --- a/plug-ins/common/channel_mixer.c +++ b/plug-ins/common/channel_mixer.c @@ -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); diff --git a/plug-ins/common/nova.c b/plug-ins/common/nova.c index d13e2f8dd5..62a8143932 100644 --- a/plug-ins/common/nova.c +++ b/plug-ins/common/nova.c @@ -61,10 +61,8 @@ #include "config.h" -#include #include #include -#include #include @@ -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; }