app, pdb, libgimp: rename values of enum GimpConvertPaletteType

This commit is contained in:
Michael Natterer 2017-02-26 20:55:00 +01:00
parent ed1ab140fb
commit fb3d1e4508
15 changed files with 137 additions and 69 deletions

View File

@ -223,7 +223,7 @@ gimp_dialog_config_class_init (GimpDialogConfigClass *klass)
"Default palette type for indexed conversion",
IMAGE_CONVERT_INDEXED_PALETTE_TYPE_BLURB,
GIMP_TYPE_CONVERT_PALETTE_TYPE,
GIMP_MAKE_PALETTE,
GIMP_CONVERT_PALETTE_GENERATE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_INT (object_class,

View File

@ -778,10 +778,10 @@ gimp_image_convert_indexed (GimpImage *image,
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (palette_type == GIMP_CUSTOM_PALETTE)
if (palette_type == GIMP_CONVERT_PALETTE_CUSTOM)
{
if (! custom_palette)
palette_type = GIMP_MONO_PALETTE;
palette_type = GIMP_CONVERT_PALETTE_MONO;
if (gimp_palette_get_n_colors (custom_palette) == 0)
{
@ -830,7 +830,7 @@ gimp_image_convert_indexed (GimpImage *image,
*/
if (old_type == GIMP_GRAY &&
max_colors == 256 &&
palette_type == GIMP_MAKE_PALETTE)
palette_type == GIMP_CONVERT_PALETTE_GENERATE)
{
dither_type = GIMP_CONVERT_DITHER_NONE;
}
@ -840,7 +840,7 @@ gimp_image_convert_indexed (GimpImage *image,
dither_alpha,
progress);
if (palette_type == GIMP_MAKE_PALETTE)
if (palette_type == GIMP_CONVERT_PALETTE_GENERATE)
{
if (old_type == GIMP_GRAY)
zero_histogram_gray (quantobj->histogram);
@ -885,7 +885,7 @@ gimp_image_convert_indexed (GimpImage *image,
if (old_type == GIMP_RGB &&
! needs_quantize &&
palette_type == GIMP_MAKE_PALETTE)
palette_type == GIMP_CONVERT_PALETTE_GENERATE)
{
gint i;
@ -922,7 +922,7 @@ gimp_image_convert_indexed (GimpImage *image,
quantobj->first_pass (quantobj);
}
if (palette_type == GIMP_MAKE_PALETTE)
if (palette_type == GIMP_CONVERT_PALETTE_GENERATE)
qsort (quantobj->cmap,
quantobj->actual_number_of_colors, sizeof (Color),
color_quicksort);
@ -1004,7 +1004,7 @@ gimp_image_convert_indexed (GimpImage *image,
}
/* Set the final palette on the image */
if (remove_duplicates && (palette_type != GIMP_MAKE_PALETTE))
if (remove_duplicates && (palette_type != GIMP_CONVERT_PALETTE_GENERATE))
{
guchar colormap[GIMP_IMAGE_COLORMAP_SIZE];
gint i, j;
@ -4333,7 +4333,7 @@ initialize_median_cut (GimpImageBaseType type,
/* Initialize the data structures */
quantobj = g_new (QuantizeObj, 1);
if (type == GIMP_GRAY && palette_type == GIMP_MAKE_PALETTE)
if (type == GIMP_GRAY && palette_type == GIMP_CONVERT_PALETTE_GENERATE)
quantobj->histogram = g_new (ColorFreq, 256);
else
quantobj->histogram = g_new (ColorFreq,
@ -4349,23 +4349,23 @@ initialize_median_cut (GimpImageBaseType type,
case GIMP_GRAY:
switch (palette_type)
{
case GIMP_MAKE_PALETTE:
case GIMP_CONVERT_PALETTE_GENERATE:
quantobj->first_pass = median_cut_pass1_gray;
break;
case GIMP_WEB_PALETTE:
case GIMP_CONVERT_PALETTE_WEB:
quantobj->first_pass = webpal_pass1;
break;
case GIMP_CUSTOM_PALETTE:
case GIMP_CONVERT_PALETTE_CUSTOM:
quantobj->first_pass = custompal_pass1;
needs_quantize = TRUE;
break;
case GIMP_MONO_PALETTE:
case GIMP_CONVERT_PALETTE_MONO:
default:
quantobj->first_pass = monopal_pass1;
}
if (palette_type == GIMP_WEB_PALETTE ||
palette_type == GIMP_CUSTOM_PALETTE)
if (palette_type == GIMP_CONVERT_PALETTE_WEB ||
palette_type == GIMP_CONVERT_PALETTE_CUSTOM)
{
switch (dither_type)
{
@ -4424,18 +4424,18 @@ initialize_median_cut (GimpImageBaseType type,
case GIMP_RGB:
switch (palette_type)
{
case GIMP_MAKE_PALETTE:
case GIMP_CONVERT_PALETTE_GENERATE:
quantobj->first_pass = median_cut_pass1_rgb;
break;
case GIMP_WEB_PALETTE:
case GIMP_CONVERT_PALETTE_WEB:
quantobj->first_pass = webpal_pass1;
needs_quantize = TRUE;
break;
case GIMP_CUSTOM_PALETTE:
case GIMP_CONVERT_PALETTE_CUSTOM:
quantobj->first_pass = custompal_pass1;
needs_quantize = TRUE;
break;
case GIMP_MONO_PALETTE:
case GIMP_CONVERT_PALETTE_MONO:
default:
quantobj->first_pass = monopal_pass1;
}

View File

@ -167,10 +167,10 @@ convert_indexed_dialog_new (GimpImage *image,
frame =
gimp_enum_radio_frame_new_with_range (GIMP_TYPE_CONVERT_PALETTE_TYPE,
GIMP_MAKE_PALETTE,
GIMP_CONVERT_PALETTE_GENERATE,
(palette_box ?
GIMP_CUSTOM_PALETTE :
GIMP_MONO_PALETTE),
GIMP_CONVERT_PALETTE_CUSTOM :
GIMP_CONVERT_PALETTE_MONO),
gtk_label_new (_("Colormap")),
G_CALLBACK (gimp_radio_button_update),
&private->palette_type,
@ -184,7 +184,7 @@ convert_indexed_dialog_new (GimpImage *image,
/* max n_colors */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gimp_enum_radio_frame_add (GTK_FRAME (frame), hbox,
GIMP_MAKE_PALETTE, TRUE);
GIMP_CONVERT_PALETTE_GENERATE, TRUE);
gtk_widget_show (hbox);
label = gtk_label_new_with_mnemonic (_("_Maximum number of colors:"));
@ -210,7 +210,7 @@ convert_indexed_dialog_new (GimpImage *image,
if (palette_box)
{
gimp_enum_radio_frame_add (GTK_FRAME (frame), palette_box,
GIMP_CUSTOM_PALETTE, TRUE);
GIMP_CONVERT_PALETTE_CUSTOM, TRUE);
gtk_widget_show (palette_box);
}

View File

@ -140,12 +140,12 @@ image_convert_indexed_invoker (GimpProcedure *procedure,
{
switch (palette_type)
{
case GIMP_MAKE_PALETTE:
case GIMP_CONVERT_PALETTE_GENERATE:
if (num_cols < 1 || num_cols > MAXNUMCOLORS)
success = FALSE;
break;
case GIMP_CUSTOM_PALETTE:
case GIMP_CONVERT_PALETTE_CUSTOM:
pal = gimp_pdb_get_palette (gimp, palette, FALSE, error);
if (! pal)
{
@ -343,12 +343,12 @@ register_image_convert_procs (GimpPDB *pdb)
"palette type",
"The type of palette to use",
GIMP_TYPE_CONVERT_PALETTE_TYPE,
GIMP_MAKE_PALETTE,
GIMP_CONVERT_PALETTE_GENERATE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("num-cols",
"num cols",
"The number of colors to quantize to, ignored unless (palette_type == GIMP_MAKE_PALETTE)",
"The number of colors to quantize to, ignored unless (palette_type == GIMP_CONVERT_PALETTE_GENERATE)",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
@ -360,13 +360,13 @@ register_image_convert_procs (GimpPDB *pdb)
gimp_procedure_add_argument (procedure,
g_param_spec_boolean ("remove-unused",
"remove unused",
"Remove unused or duplicate color entries from final palette, ignored if (palette_type == GIMP_MAKE_PALETTE)",
"Remove unused or duplicate color entries from final palette, ignored if (palette_type == GIMP_CONVERT_PALETTE_GENERATE)",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("palette",
"palette",
"The name of the custom palette to use, ignored unless (palette_type == GIMP_CUSTOM_PALETTE)",
"The name of the custom palette to use, ignored unless (palette_type == GIMP_CONVERT_PALETTE_CUSTOM)",
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));

View File

@ -191,11 +191,15 @@ export_convert_indexed (gint32 image_ID,
/* check alpha */
g_free (gimp_image_get_layers (image_ID, &nlayers));
if (nlayers > 1 || gimp_drawable_has_alpha (*drawable_ID))
gimp_image_convert_indexed (image_ID, GIMP_CONVERT_DITHER_NONE,
GIMP_MAKE_PALETTE, 255, FALSE, FALSE, "");
gimp_image_convert_indexed (image_ID,
GIMP_CONVERT_DITHER_NONE,
GIMP_CONVERT_PALETTE_GENERATE,
255, FALSE, FALSE, "");
else
gimp_image_convert_indexed (image_ID, GIMP_CONVERT_DITHER_NONE,
GIMP_MAKE_PALETTE, 256, FALSE, FALSE, "");
gimp_image_convert_indexed (image_ID,
GIMP_CONVERT_DITHER_NONE,
GIMP_CONVERT_PALETTE_GENERATE,
256, FALSE, FALSE, "");
}
static void
@ -205,8 +209,10 @@ export_convert_bitmap (gint32 image_ID,
if (gimp_image_base_type (image_ID) == GIMP_INDEXED)
gimp_image_convert_rgb (image_ID);
gimp_image_convert_indexed (image_ID, GIMP_CONVERT_DITHER_FS,
GIMP_MAKE_PALETTE, 2, FALSE, FALSE, "");
gimp_image_convert_indexed (image_ID,
GIMP_CONVERT_DITHER_FS,
GIMP_CONVERT_PALETTE_GENERATE,
2, FALSE, FALSE, "");
}
static void

View File

@ -101,10 +101,10 @@ gimp_image_convert_grayscale (gint32 image_ID)
* @image_ID: The image.
* @dither_type: The dither type to use.
* @palette_type: The type of palette to use.
* @num_cols: The number of colors to quantize to, ignored unless (palette_type == GIMP_MAKE_PALETTE).
* @num_cols: The number of colors to quantize to, ignored unless (palette_type == GIMP_CONVERT_PALETTE_GENERATE).
* @alpha_dither: Dither transparency to fake partial opacity.
* @remove_unused: Remove unused or duplicate color entries from final palette, ignored if (palette_type == GIMP_MAKE_PALETTE).
* @palette: The name of the custom palette to use, ignored unless (palette_type == GIMP_CUSTOM_PALETTE).
* @remove_unused: Remove unused or duplicate color entries from final palette, ignored if (palette_type == GIMP_CONVERT_PALETTE_GENERATE).
* @palette: The name of the custom palette to use, ignored unless (palette_type == GIMP_CONVERT_PALETTE_CUSTOM).
*
* Convert specified image to and Indexed image
*

View File

@ -57,6 +57,8 @@ gimp_base_init (GimpUnitVtable *vtable)
(gpointer) GIMP_TYPE_CHANNEL_TYPE_COMPAT);
g_type_set_qdata (GIMP_TYPE_CLONE_TYPE, quark,
(gpointer) GIMP_TYPE_CLONE_TYPE_COMPAT);
g_type_set_qdata (GIMP_TYPE_CONVERT_PALETTE_TYPE, quark,
(gpointer) GIMP_TYPE_CONVERT_PALETTE_TYPE_COMPAT);
g_type_set_qdata (GIMP_TYPE_CONVOLVE_TYPE, quark,
(gpointer) GIMP_TYPE_CONVOLVE_TYPE_COMPAT);
g_type_set_qdata (GIMP_TYPE_DESATURATE_MODE, quark,

View File

@ -437,19 +437,19 @@ gimp_convert_palette_type_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_MAKE_PALETTE, "GIMP_MAKE_PALETTE", "make-palette" },
{ GIMP_WEB_PALETTE, "GIMP_WEB_PALETTE", "web-palette" },
{ GIMP_MONO_PALETTE, "GIMP_MONO_PALETTE", "mono-palette" },
{ GIMP_CUSTOM_PALETTE, "GIMP_CUSTOM_PALETTE", "custom-palette" },
{ GIMP_CONVERT_PALETTE_GENERATE, "GIMP_CONVERT_PALETTE_GENERATE", "generate" },
{ GIMP_CONVERT_PALETTE_WEB, "GIMP_CONVERT_PALETTE_WEB", "web" },
{ GIMP_CONVERT_PALETTE_MONO, "GIMP_CONVERT_PALETTE_MONO", "mono" },
{ GIMP_CONVERT_PALETTE_CUSTOM, "GIMP_CONVERT_PALETTE_CUSTOM", "custom" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_MAKE_PALETTE, NC_("convert-palette-type", "Generate optimum palette"), NULL },
{ GIMP_WEB_PALETTE, NC_("convert-palette-type", "Use web-optimized palette"), NULL },
{ GIMP_MONO_PALETTE, NC_("convert-palette-type", "Use black and white (1-bit) palette"), NULL },
{ GIMP_CUSTOM_PALETTE, NC_("convert-palette-type", "Use custom palette"), NULL },
{ GIMP_CONVERT_PALETTE_GENERATE, NC_("convert-palette-type", "Generate optimum palette"), NULL },
{ GIMP_CONVERT_PALETTE_WEB, NC_("convert-palette-type", "Use web-optimized palette"), NULL },
{ GIMP_CONVERT_PALETTE_MONO, NC_("convert-palette-type", "Use black and white (1-bit) palette"), NULL },
{ GIMP_CONVERT_PALETTE_CUSTOM, NC_("convert-palette-type", "Use custom palette"), NULL },
{ 0, NULL, NULL }
};

View File

@ -241,11 +241,19 @@ GType gimp_convert_palette_type_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_MAKE_PALETTE, /*< desc="Generate optimum palette" >*/
GIMP_REUSE_PALETTE, /*< skip >*/
GIMP_WEB_PALETTE, /*< desc="Use web-optimized palette" >*/
GIMP_MONO_PALETTE, /*< desc="Use black and white (1-bit) palette" >*/
GIMP_CUSTOM_PALETTE /*< desc="Use custom palette" >*/
GIMP_CONVERT_PALETTE_GENERATE, /*< desc="Generate optimum palette" >*/
GIMP_CONVERT_PALETTE_REUSE, /*< skip >*/
GIMP_CONVERT_PALETTE_WEB, /*< desc="Use web-optimized palette" >*/
GIMP_CONVERT_PALETTE_MONO, /*< desc="Use black and white (1-bit) palette" >*/
GIMP_CONVERT_PALETTE_CUSTOM, /*< desc="Use custom palette" >*/
#ifndef GIMP_DISABLE_DEPRECATED
GIMP_MAKE_PALETTE = GIMP_CONVERT_PALETTE_GENERATE, /*< skip, pdb-skip >*/
GIMP_REUSE_PALETTE = GIMP_CONVERT_PALETTE_REUSE, /*< skip, pdb-skip >*/
GIMP_WEB_PALETTE = GIMP_CONVERT_PALETTE_WEB, /*< skip, pdb-skip >*/
GIMP_MONO_PALETTE = GIMP_CONVERT_PALETTE_MONO, /*< skip, pdb-skip >*/
GIMP_CUSTOM_PALETTE = GIMP_CONVERT_PALETTE_CUSTOM /*< skip, pdb-skip >*/
#endif /* GIMP_DISABLE_DEPRECATED */
} GimpConvertPaletteType;

View File

@ -216,6 +216,42 @@ gimp_convert_dither_type_compat_get_type (void)
return type;
}
GType
gimp_convert_palette_type_compat_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_MAKE_PALETTE, "GIMP_MAKE_PALETTE", "make-palette" },
{ GIMP_REUSE_PALETTE, "GIMP_REUSE_PALETTE", "reuse-palette" },
{ GIMP_WEB_PALETTE, "GIMP_WEB_PALETTE", "web-palette" },
{ GIMP_MONO_PALETTE, "GIMP_MONO_PALETTE", "mono-palette" },
{ GIMP_CUSTOM_PALETTE, "GIMP_CUSTOM_PALETTE", "custom-palette" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_MAKE_PALETTE, "GIMP_MAKE_PALETTE", NULL },
{ GIMP_REUSE_PALETTE, "GIMP_REUSE_PALETTE", NULL },
{ GIMP_WEB_PALETTE, "GIMP_WEB_PALETTE", NULL },
{ GIMP_MONO_PALETTE, "GIMP_MONO_PALETTE", NULL },
{ GIMP_CUSTOM_PALETTE, "GIMP_CUSTOM_PALETTE", NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("GimpConvertPaletteTypeCompat", values);
gimp_type_set_translation_domain (type, GETTEXT_PACKAGE "-libgimp");
gimp_type_set_translation_context (type, "convert-palette-type-compat");
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
gimp_convolve_type_compat_get_type (void)
{

View File

@ -107,6 +107,20 @@ typedef enum
} GimpConvertDitherTypeCompat;
#define GIMP_TYPE_CONVERT_PALETTE_TYPE_COMPAT (gimp_convert_palette_type_compat_get_type ())
GType gimp_convert_palette_type_compat_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_MAKE_PALETTE,
GIMP_REUSE_PALETTE,
GIMP_WEB_PALETTE,
GIMP_MONO_PALETTE,
GIMP_CUSTOM_PALETTE
} GimpConvertPaletteTypeCompat;
#define GIMP_TYPE_CONVOLVE_TYPE_COMPAT (gimp_convolve_type_compat_get_type ())
GType gimp_convolve_type_compat_get_type (void) G_GNUC_CONST;

View File

@ -310,7 +310,7 @@ ico_dialog_update_icon_preview (GtkWidget *dialog,
gimp_image_convert_indexed (tmp_image,
GIMP_CONVERT_DITHER_FS,
GIMP_MAKE_PALETTE,
GIMP_CONVERT_PALETTE_GENERATE,
1 << bpp, TRUE, FALSE, "dummy");
cmap = gimp_image_get_colormap (tmp_image, &num_colors);
@ -348,7 +348,7 @@ ico_dialog_update_icon_preview (GtkWidget *dialog,
gimp_image_convert_indexed (tmp_image,
GIMP_CONVERT_DITHER_FS,
GIMP_MAKE_PALETTE,
GIMP_CONVERT_PALETTE_GENERATE,
(1 << bpp) - 1, TRUE, FALSE, "dummy");
}

View File

@ -648,7 +648,7 @@ ico_image_get_reduced_buf (guint32 layer,
{
gimp_image_convert_indexed (tmp_image,
GIMP_CONVERT_DITHER_FS,
GIMP_MAKE_PALETTE,
GIMP_CONVERT_PALETTE_GENERATE,
1 << bpp, TRUE, FALSE, "dummy");
cmap = gimp_image_get_colormap (tmp_image, num_colors);
@ -687,7 +687,7 @@ ico_image_get_reduced_buf (guint32 layer,
gimp_image_convert_indexed (tmp_image,
GIMP_CONVERT_DITHER_FS,
GIMP_MAKE_PALETTE,
GIMP_CONVERT_PALETTE_GENERATE,
(1<<bpp) - 1, TRUE, FALSE, "dummy");
g_free (cmap);
cmap = gimp_image_get_colormap (tmp_image, num_colors);

View File

@ -136,14 +136,15 @@ package Gimp::CodeGen::enums;
GimpConvertPaletteType =>
{ contig => 1,
header => 'libgimpbase/gimpbaseenums.h',
symbols => [ qw(GIMP_MAKE_PALETTE GIMP_REUSE_PALETTE
GIMP_WEB_PALETTE GIMP_MONO_PALETTE
GIMP_CUSTOM_PALETTE) ],
mapping => { GIMP_MAKE_PALETTE => '0',
GIMP_REUSE_PALETTE => '1',
GIMP_WEB_PALETTE => '2',
GIMP_MONO_PALETTE => '3',
GIMP_CUSTOM_PALETTE => '4' }
symbols => [ qw(GIMP_CONVERT_PALETTE_GENERATE
GIMP_CONVERT_PALETTE_REUSE
GIMP_CONVERT_PALETTE_WEB GIMP_CONVERT_PALETTE_MONO
GIMP_CONVERT_PALETTE_CUSTOM) ],
mapping => { GIMP_CONVERT_PALETTE_GENERATE => '0',
GIMP_CONVERT_PALETTE_REUSE => '1',
GIMP_CONVERT_PALETTE_WEB => '2',
GIMP_CONVERT_PALETTE_MONO => '3',
GIMP_CONVERT_PALETTE_CUSTOM => '4' }
},
GimpConvolveType =>
{ contig => 1,

View File

@ -109,15 +109,16 @@ HELP
desc => 'The type of palette to use' },
{ name => 'num_cols', type => 'int32',
desc => 'The number of colors to quantize to, ignored unless
(palette_type == GIMP_MAKE_PALETTE)' },
(palette_type == GIMP_CONVERT_PALETTE_GENERATE)' },
{ name => 'alpha_dither', type => 'boolean',
desc => 'Dither transparency to fake partial opacity' },
{ name => 'remove_unused', type => 'boolean',
desc => 'Remove unused or duplicate color entries from final
palette, ignored if (palette_type == GIMP_MAKE_PALETTE)' },
palette, ignored if (palette_type ==
GIMP_CONVERT_PALETTE_GENERATE)' },
{ name => 'palette', type => 'string',
desc => 'The name of the custom palette to use, ignored unless
(palette_type == GIMP_CUSTOM_PALETTE)' }
(palette_type == GIMP_CONVERT_PALETTE_CUSTOM)' }
);
%invoke = (
@ -131,12 +132,12 @@ HELP
{
switch (palette_type)
{
case GIMP_MAKE_PALETTE:
case GIMP_CONVERT_PALETTE_GENERATE:
if (num_cols < 1 || num_cols > MAXNUMCOLORS)
success = FALSE;
break;
case GIMP_CUSTOM_PALETTE:
case GIMP_CONVERT_PALETTE_CUSTOM:
pal = gimp_pdb_get_palette (gimp, palette, FALSE, error);
if (! pal)
{