From 009417e450955d64e22dd78fe3f94697c1381ef8 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 27 Sep 2016 23:51:33 +0200 Subject: [PATCH] app: reorder and rename indexed conversion parameters to make more sense --- app/actions/image-commands.c | 37 ++++++------ app/core/gimpimage-convert-indexed.c | 85 ++++++++++++++-------------- app/core/gimpimage-convert-indexed.h | 10 ++-- app/dialogs/convert-indexed-dialog.c | 36 ++++++------ app/dialogs/convert-indexed-dialog.h | 12 ++-- app/pdb/image-convert-cmds.c | 6 +- tools/pdbgen/pdb/image_convert.pdb | 6 +- 7 files changed, 96 insertions(+), 96 deletions(-) diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c index 3af84e673f..bd213a87ba 100644 --- a/app/actions/image-commands.c +++ b/app/actions/image-commands.c @@ -81,12 +81,12 @@ static void image_convert_indexed_callback (GtkWidget *dialog, GimpImage *image, - gint n_colors, + GimpConvertPaletteType palette_type, + gint max_colors, + gboolean remove_duplicates, GimpConvertDitherType dither_type, gboolean dither_alpha, gboolean dither_text_layers, - gboolean remove_dups, - GimpConvertPaletteType palette_type, GimpPalette *custom_palette, gpointer user_data); @@ -142,15 +142,14 @@ static GimpUnit image_resize_unit = GIMP_UNIT_PIXEL; static GimpUnit image_scale_unit = GIMP_UNIT_PIXEL; static GimpInterpolationType image_scale_interp = -1; -static gint image_convert_indexed_n_colors = 256; +static GimpConvertPaletteType image_convert_indexed_palette_type = GIMP_MAKE_PALETTE; +static gint image_convert_indexed_max_colors = 256; +static gboolean image_convert_indexed_remove_duplicates = TRUE; static GimpConvertDitherType image_convert_indexed_dither_type = GIMP_NO_DITHER; static gboolean image_convert_indexed_dither_alpha = FALSE; static gboolean image_convert_indexed_dither_text_layers = FALSE; -static gboolean image_convert_indexed_remove_dups = TRUE; -static GimpConvertPaletteType image_convert_indexed_palette_type = GIMP_MAKE_PALETTE; static GimpPalette *image_convert_indexed_custom_palette = NULL; - /* public functions */ void @@ -262,12 +261,12 @@ image_convert_base_type_cmd_callback (GtkAction *action, dialog = convert_indexed_dialog_new (image, action_data_get_context (data), widget, - image_convert_indexed_n_colors, + image_convert_indexed_palette_type, + image_convert_indexed_max_colors, + image_convert_indexed_remove_duplicates, image_convert_indexed_dither_type, image_convert_indexed_dither_alpha, image_convert_indexed_dither_text_layers, - image_convert_indexed_remove_dups, - image_convert_indexed_palette_type, image_convert_indexed_custom_palette, image_convert_indexed_callback, display); @@ -922,12 +921,12 @@ image_properties_cmd_callback (GtkAction *action, static void image_convert_indexed_callback (GtkWidget *dialog, GimpImage *image, - gint n_colors, + GimpConvertPaletteType palette_type, + gint max_colors, + gboolean remove_duplicates, GimpConvertDitherType dither_type, gboolean dither_alpha, gboolean dither_text_layers, - gboolean remove_dups, - GimpConvertPaletteType palette_type, GimpPalette *custom_palette, gpointer user_data) { @@ -939,12 +938,12 @@ image_convert_indexed_callback (GtkWidget *dialog, g_object_remove_weak_pointer (G_OBJECT (image_convert_indexed_custom_palette), (gpointer) &image_convert_indexed_custom_palette); - image_convert_indexed_n_colors = n_colors; + image_convert_indexed_palette_type = palette_type; + image_convert_indexed_max_colors = max_colors; + image_convert_indexed_remove_duplicates = remove_duplicates; image_convert_indexed_dither_type = dither_type; image_convert_indexed_dither_alpha = dither_alpha; image_convert_indexed_dither_text_layers = dither_text_layers; - image_convert_indexed_remove_dups = remove_dups; - image_convert_indexed_palette_type = palette_type; image_convert_indexed_custom_palette = custom_palette; if (image_convert_indexed_custom_palette) @@ -955,12 +954,12 @@ image_convert_indexed_callback (GtkWidget *dialog, _("Converting to indexed colors")); if (! gimp_image_convert_indexed (image, - image_convert_indexed_n_colors, + image_convert_indexed_palette_type, + image_convert_indexed_max_colors, + image_convert_indexed_remove_duplicates, image_convert_indexed_dither_type, image_convert_indexed_dither_alpha, image_convert_indexed_dither_text_layers, - image_convert_indexed_remove_dups, - image_convert_indexed_palette_type, image_convert_indexed_custom_palette, progress, &error)) diff --git a/app/core/gimpimage-convert-indexed.c b/app/core/gimpimage-convert-indexed.c index 032f604b4c..657a7cc4fa 100644 --- a/app/core/gimpimage-convert-indexed.c +++ b/app/core/gimpimage-convert-indexed.c @@ -482,7 +482,7 @@ struct _QuantizeObj gulong index_used_count[256]; /* how many times an index was used */ CFHistogram histogram; /* holds the histogram */ - gboolean want_alpha_dither; + gboolean want_dither_alpha; gint error_freedom; /* 0=much bleed, 1=controlled bleed */ GimpProgress *progress; @@ -520,21 +520,21 @@ static void zero_histogram_gray (CFHistogram histogram); static void zero_histogram_rgb (CFHistogram histogram); static void generate_histogram_gray (CFHistogram hostogram, GimpLayer *layer, - gboolean alpha_dither); + gboolean dither_alpha); static void generate_histogram_rgb (CFHistogram histogram, GimpLayer *layer, gint col_limit, - gboolean alpha_dither, + gboolean dither_alpha, GimpProgress *progress, gint nth_layer, gint n_layers); static QuantizeObj * initialize_median_cut (GimpImageBaseType old_type, - gint num_cols, + gint max_colors, GimpConvertDitherType dither_type, GimpConvertPaletteType palette_type, GimpPalette *custom_palette, - gboolean alpha_dither, + gboolean dither_alpha, GimpProgress *progress); static void compute_color_lin8 (QuantizeObj *quantobj, @@ -750,12 +750,12 @@ color_quicksort (const void *c1, gboolean gimp_image_convert_indexed (GimpImage *image, - gint num_cols, - GimpConvertDitherType dither, - gboolean alpha_dither, - gboolean text_layer_dither, - gboolean remove_dups, GimpConvertPaletteType palette_type, + gint max_colors, + gboolean remove_duplicates, + GimpConvertDitherType dither_type, + gboolean dither_alpha, + gboolean dither_text_layers, GimpPalette *custom_palette, GimpProgress *progress, GError **error) @@ -829,15 +829,15 @@ gimp_image_convert_indexed (GimpImage *image, * every color */ if (old_type == GIMP_GRAY && - num_cols == 256 && + max_colors == 256 && palette_type == GIMP_MAKE_PALETTE) { - dither = GIMP_NO_DITHER; + dither_type = GIMP_NO_DITHER; } - quantobj = initialize_median_cut (old_type, num_cols, dither, + quantobj = initialize_median_cut (old_type, max_colors, dither_type, palette_type, custom_palette, - alpha_dither, + dither_alpha, progress); if (palette_type == GIMP_MAKE_PALETTE) @@ -864,7 +864,7 @@ gimp_image_convert_indexed (GimpImage *image, if (old_type == GIMP_GRAY) { generate_histogram_gray (quantobj->histogram, - layer, alpha_dither); + layer, dither_alpha); } else { @@ -873,7 +873,7 @@ gimp_image_convert_indexed (GimpImage *image, * specified by the user. */ generate_histogram_rgb (quantobj->histogram, - layer, num_cols, alpha_dither, + layer, max_colors, dither_alpha, progress, nth_layer, n_layers); } } @@ -901,11 +901,11 @@ gimp_image_convert_indexed (GimpImage *image, */ quantobj->delete_func (quantobj); - quantobj = initialize_median_cut (old_type, num_cols, + quantobj = initialize_median_cut (old_type, max_colors, GIMP_NODESTRUCT_DITHER, palette_type, custom_palette, - alpha_dither, + dither_alpha, progress); /* We can skip the first pass (palette creation) */ @@ -966,7 +966,7 @@ gimp_image_convert_indexed (GimpImage *image, gboolean quantize; if (gimp_item_is_text_layer (GIMP_ITEM (layer))) - quantize = text_layer_dither; + quantize = dither_text_layers; else quantize = TRUE; @@ -1001,7 +1001,7 @@ gimp_image_convert_indexed (GimpImage *image, } /* Set the final palette on the image */ - if (remove_dups && (palette_type != GIMP_MAKE_PALETTE)) + if (remove_duplicates && (palette_type != GIMP_MAKE_PALETTE)) { guchar colormap[GIMP_IMAGE_COLORMAP_SIZE]; gint i, j; @@ -1091,7 +1091,7 @@ zero_histogram_rgb (CFHistogram histogram) static void generate_histogram_gray (CFHistogram histogram, GimpLayer *layer, - gboolean alpha_dither) + gboolean dither_alpha) { GeglBufferIterator *iter; const Babl *format; @@ -1142,7 +1142,7 @@ static void generate_histogram_rgb (CFHistogram histogram, GimpLayer *layer, gint col_limit, - gboolean alpha_dither, + gboolean dither_alpha, GimpProgress *progress, gint nth_layer, gint n_layers) @@ -1194,7 +1194,7 @@ generate_histogram_rgb (CFHistogram histogram, if (needs_quantize) { - if (alpha_dither) + if (dither_alpha) { /* if alpha-dithering, we need to be deterministic w.r.t. offsets */ @@ -1262,7 +1262,7 @@ generate_histogram_rgb (CFHistogram histogram, if (has_alpha) { - if (alpha_dither) + if (dither_alpha) { if (data[ALPHA] < DM[col & DM_WIDTHMASK][row & DM_HEIGHTMASK]) @@ -2817,7 +2817,7 @@ median_cut_pass2_no_dither_gray (QuantizeObj *quantobj, gint dest_bpp; gint has_alpha; gulong *index_used_count = quantobj->index_used_count; - gboolean alpha_dither = quantobj->want_alpha_dither; + gboolean dither_alpha = quantobj->want_dither_alpha; gint offsetx, offsety; gimp_item_get_offset (GIMP_ITEM (layer), &offsetx, &offsety); @@ -2865,7 +2865,7 @@ median_cut_pass2_no_dither_gray (QuantizeObj *quantobj, { gboolean transparent = FALSE; - if (alpha_dither) + if (dither_alpha) { gint dither_x = (col + offsetx + src_roi->x) & DM_WIDTHMASK; gint dither_y = (row + offsety + src_roi->y) & DM_HEIGHTMASK; @@ -2923,7 +2923,7 @@ median_cut_pass2_fixed_dither_gray (QuantizeObj *quantobj, Color *color1; Color *color2; gulong *index_used_count = quantobj->index_used_count; - gboolean alpha_dither = quantobj->want_alpha_dither; + gboolean dither_alpha = quantobj->want_dither_alpha; gint offsetx, offsety; gimp_item_get_offset (GIMP_ITEM (layer), &offsetx, &offsety); @@ -3036,7 +3036,7 @@ median_cut_pass2_fixed_dither_gray (QuantizeObj *quantobj, { gboolean transparent = FALSE; - if (alpha_dither) + if (dither_alpha) { if (src[ALPHA_G] < dmval) transparent = TRUE; @@ -3089,7 +3089,7 @@ median_cut_pass2_no_dither_rgb (QuantizeObj *quantobj, gint green_pix = GREEN; gint blue_pix = BLUE; gint alpha_pix = ALPHA; - gboolean alpha_dither = quantobj->want_alpha_dither; + gboolean dither_alpha = quantobj->want_dither_alpha; gint offsetx, offsety; gulong *index_used_count = quantobj->index_used_count; glong total_size = 0; @@ -3147,10 +3147,11 @@ median_cut_pass2_no_dither_rgb (QuantizeObj *quantobj, { gboolean transparent = FALSE; - if (alpha_dither) + if (dither_alpha) { gint dither_x = (col + offsetx + src_roi->x) & DM_WIDTHMASK; gint dither_y = (row + offsety + src_roi->y) & DM_HEIGHTMASK; + if ((src[alpha_pix]) < DM[dither_x][dither_y]) transparent = TRUE; } @@ -3224,7 +3225,7 @@ median_cut_pass2_fixed_dither_rgb (QuantizeObj *quantobj, gint green_pix = GREEN; gint blue_pix = BLUE; gint alpha_pix = ALPHA; - gboolean alpha_dither = quantobj->want_alpha_dither; + gboolean dither_alpha = quantobj->want_dither_alpha; gint offsetx, offsety; gulong *index_used_count = quantobj->index_used_count; glong total_size = 0; @@ -3286,7 +3287,7 @@ median_cut_pass2_fixed_dither_rgb (QuantizeObj *quantobj, { gboolean transparent = FALSE; - if (alpha_dither) + if (dither_alpha) { if (src[alpha_pix] < dmval) transparent = TRUE; @@ -3446,7 +3447,7 @@ median_cut_pass2_nodestruct_dither_rgb (QuantizeObj *quantobj, gint src_bpp; gint dest_bpp; gint has_alpha; - gboolean alpha_dither = quantobj->want_alpha_dither; + gboolean dither_alpha = quantobj->want_dither_alpha; gint red_pix = RED; gint green_pix = GREEN; gint blue_pix = BLUE; @@ -3492,7 +3493,7 @@ median_cut_pass2_nodestruct_dither_rgb (QuantizeObj *quantobj, if (has_alpha) { - if (alpha_dither) + if (dither_alpha) { gint dither_x = (col + src_roi->x + offsetx) & DM_WIDTHMASK; gint dither_y = (row + src_roi->y + offsety) & DM_HEIGHTMASK; @@ -3676,7 +3677,7 @@ median_cut_pass2_fs_dither_gray (QuantizeObj *quantobj, gint odd_row; gboolean has_alpha; gint offsetx, offsety; - gboolean alpha_dither = quantobj->want_alpha_dither; + gboolean dither_alpha = quantobj->want_dither_alpha; gint width, height; gulong *index_used_count = quantobj->index_used_count; @@ -3766,7 +3767,7 @@ median_cut_pass2_fs_dither_gray (QuantizeObj *quantobj, if (odd_row) { - if (alpha_dither) + if (dither_alpha) { gint dither_x = ((width-col)+offsetx-1) & DM_WIDTHMASK; gint dither_y = (row+offsety) & DM_HEIGHTMASK; @@ -3795,7 +3796,7 @@ median_cut_pass2_fs_dither_gray (QuantizeObj *quantobj, } else { - if (alpha_dither) + if (dither_alpha) { gint dither_x = (col + offsetx) & DM_WIDTHMASK; gint dither_y = (row + offsety) & DM_HEIGHTMASK; @@ -3937,7 +3938,7 @@ median_cut_pass2_fs_dither_rgb (QuantizeObj *quantobj, gint blue_pix = BLUE; gint alpha_pix = ALPHA; gint offsetx, offsety; - gboolean alpha_dither = quantobj->want_alpha_dither; + gboolean dither_alpha = quantobj->want_dither_alpha; gulong *index_used_count = quantobj->index_used_count; gint global_rmax = 0, global_rmin = G_MAXINT; gint global_gmax = 0, global_gmin = G_MAXINT; @@ -4054,7 +4055,7 @@ median_cut_pass2_fs_dither_rgb (QuantizeObj *quantobj, if (odd_row) { - if (alpha_dither) + if (dither_alpha) { gint dither_x = ((width-col)+offsetx-1) & DM_WIDTHMASK; gint dither_y = (row+offsety) & DM_HEIGHTMASK; @@ -4083,7 +4084,7 @@ median_cut_pass2_fs_dither_rgb (QuantizeObj *quantobj, } else { - if (alpha_dither) + if (dither_alpha) { gint dither_x = (col + offsetx) & DM_WIDTHMASK; gint dither_y = (row + offsety) & DM_HEIGHTMASK; @@ -4321,7 +4322,7 @@ initialize_median_cut (GimpImageBaseType type, GimpConvertDitherType dither_type, GimpConvertPaletteType palette_type, GimpPalette *custom_palette, - gboolean want_alpha_dither, + gboolean want_dither_alpha, GimpProgress *progress) { QuantizeObj *quantobj; @@ -4337,7 +4338,7 @@ initialize_median_cut (GimpImageBaseType type, quantobj->custom_palette = custom_palette; quantobj->desired_number_of_colors = num_colors; - quantobj->want_alpha_dither = want_alpha_dither; + quantobj->want_dither_alpha = want_dither_alpha; quantobj->progress = progress; switch (type) diff --git a/app/core/gimpimage-convert-indexed.h b/app/core/gimpimage-convert-indexed.h index c60747ce72..7ae2ff133d 100644 --- a/app/core/gimpimage-convert-indexed.h +++ b/app/core/gimpimage-convert-indexed.h @@ -23,12 +23,12 @@ gboolean gimp_image_convert_indexed (GimpImage *image, - gint num_cols, - GimpConvertDitherType dither, - gboolean alpha_dither, - gboolean text_layer_dither, - gboolean remove_dups, GimpConvertPaletteType palette_type, + gint max_colors, + gboolean remove_duplicates, + GimpConvertDitherType dither_type, + gboolean dither_alpha, + gboolean dither_text_layers, GimpPalette *custom_palette, GimpProgress *progress, GError **error); diff --git a/app/dialogs/convert-indexed-dialog.c b/app/dialogs/convert-indexed-dialog.c index 15ccf4c90b..f39c4033c2 100644 --- a/app/dialogs/convert-indexed-dialog.c +++ b/app/dialogs/convert-indexed-dialog.c @@ -45,12 +45,12 @@ typedef struct { GimpImage *image; - gint n_colors; + GimpConvertPaletteType palette_type; + gint max_colors; + gboolean remove_duplicates; GimpConvertDitherType dither_type; gboolean dither_alpha; gboolean dither_text_layers; - gboolean remove_dups; - GimpConvertPaletteType palette_type; GimpPalette *custom_palette; GimpConvertIndexedCallback callback; gpointer user_data; @@ -79,12 +79,12 @@ GtkWidget * convert_indexed_dialog_new (GimpImage *image, GimpContext *context, GtkWidget *parent, - gint n_colors, + GimpConvertPaletteType palette_type, + gint max_colors, + gboolean remove_duplicates, GimpConvertDitherType dither_type, gboolean dither_alpha, gboolean dither_text_layers, - gboolean remove_dups, - GimpConvertPaletteType palette_type, GimpPalette *custom_palette, GimpConvertIndexedCallback callback, gpointer user_data) @@ -113,12 +113,12 @@ convert_indexed_dialog_new (GimpImage *image, private = g_slice_new0 (IndexedDialog); private->image = image; - private->n_colors = n_colors; + private->palette_type = palette_type; + private->max_colors = max_colors; + private->remove_duplicates = remove_duplicates; private->dither_type = dither_type; private->dither_alpha = dither_alpha; private->dither_text_layers = dither_text_layers; - private->remove_dups = remove_dups; - private->palette_type = palette_type; private->custom_palette = custom_palette; private->callback = callback; private->user_data = user_data; @@ -194,11 +194,11 @@ convert_indexed_dialog_new (GimpImage *image, gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); - if (private->n_colors == 256 && gimp_image_has_alpha (image)) - private->n_colors = 255; + if (private->max_colors == 256 && gimp_image_has_alpha (image)) + private->max_colors = 255; adjustment = (GtkAdjustment *) - gtk_adjustment_new (private->n_colors, 2, 256, 1, 8, 0); + gtk_adjustment_new (private->max_colors, 2, 256, 1, 8, 0); spinbutton = gtk_spin_button_new (adjustment, 1.0, 0); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton); @@ -207,7 +207,7 @@ convert_indexed_dialog_new (GimpImage *image, g_signal_connect (adjustment, "value-changed", G_CALLBACK (gimp_int_adjustment_update), - &private->n_colors); + &private->max_colors); /* custom palette */ if (palette_box) @@ -222,13 +222,13 @@ convert_indexed_dialog_new (GimpImage *image, toggle = gtk_check_button_new_with_mnemonic (_("_Remove unused colors " "from colormap")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), - private->remove_dups); + private->remove_duplicates); gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 3); gtk_widget_show (toggle); g_signal_connect (toggle, "toggled", G_CALLBACK (gimp_toggle_button_update), - &private->remove_dups); + &private->remove_duplicates); g_object_bind_property (button, "active", toggle, "sensitive", @@ -304,12 +304,12 @@ convert_dialog_response (GtkWidget *dialog, { private->callback (dialog, private->image, - private->n_colors, + private->palette_type, + private->max_colors, + private->remove_duplicates, private->dither_type, private->dither_alpha, private->dither_text_layers, - private->remove_dups, - private->palette_type, private->custom_palette, private->user_data); } diff --git a/app/dialogs/convert-indexed-dialog.h b/app/dialogs/convert-indexed-dialog.h index 14ca627967..b91141974d 100644 --- a/app/dialogs/convert-indexed-dialog.h +++ b/app/dialogs/convert-indexed-dialog.h @@ -21,12 +21,12 @@ typedef void (* GimpConvertIndexedCallback) (GtkWidget *dialog, GimpImage *image, - gint n_colors, + GimpConvertPaletteType palette_type, + gint max_colors, + gboolean remove_duplicates, GimpConvertDitherType dither_type, gboolean dither_alpha, gboolean dither_text_layers, - gboolean remove_dups, - GimpConvertPaletteType palette_type, GimpPalette *custom_palette, gpointer user_data); @@ -34,12 +34,12 @@ typedef void (* GimpConvertIndexedCallback) (GtkWidget *dialog, GtkWidget * convert_indexed_dialog_new (GimpImage *image, GimpContext *context, GtkWidget *parent, - gint n_colors, + GimpConvertPaletteType palette_type, + gint max_colors, + gboolean remove_duplicates, GimpConvertDitherType dither_type, gboolean dither_alpha, gboolean dither_text_layers, - gboolean remove_dups, - GimpConvertPaletteType palette_type, GimpPalette *custom_palette, GimpConvertIndexedCallback callback, gpointer user_data); diff --git a/app/pdb/image-convert-cmds.c b/app/pdb/image-convert-cmds.c index adadb9e040..6148f2aa5f 100644 --- a/app/pdb/image-convert-cmds.c +++ b/app/pdb/image-convert-cmds.c @@ -173,9 +173,9 @@ image_convert_indexed_invoker (GimpProcedure *procedure, if (success) success = gimp_image_convert_indexed (image, - num_cols, dither_type, - alpha_dither, FALSE, remove_unused, - palette_type, pal, + palette_type, num_cols, remove_unused, + dither_type, alpha_dither, FALSE, + pal, NULL, error); } diff --git a/tools/pdbgen/pdb/image_convert.pdb b/tools/pdbgen/pdb/image_convert.pdb index 7d37bec5ed..5bb58419d9 100644 --- a/tools/pdbgen/pdb/image_convert.pdb +++ b/tools/pdbgen/pdb/image_convert.pdb @@ -164,9 +164,9 @@ HELP if (success) success = gimp_image_convert_indexed (image, - num_cols, dither_type, - alpha_dither, FALSE, remove_unused, - palette_type, pal, + palette_type, num_cols, remove_unused, + dither_type, alpha_dither, FALSE, + pal, NULL, error); } CODE