app/core/core-enums.h more enum cleanup (ConvertPaletteType and

2002-03-18  Sven Neumann  <sven@gimp.org>

	* app/core/core-enums.h
	* app/core/core-types.h: more enum cleanup (ConvertPaletteType and
	ConvertDitherType this time).

	* app/core/gimpimage-convert.[ch]
	* app/gui/convert-dialog.c
	* tools/pdbgen/pdb/convert.pdb: changed accordingly.

	* app/pdb/convert_cmds.c
	* libgimp/gimpconvert_pdb.c
	* libgimp/gimpenums.h
	* plug-ins/script-fu/script-fu-constants.c
	* tools/pdbgen/enums.pl: regenerated.
This commit is contained in:
Sven Neumann 2002-03-18 13:55:19 +00:00 committed by Sven Neumann
parent 6a7cc3061e
commit f85c711c55
13 changed files with 268 additions and 224 deletions

View file

@ -1,3 +1,19 @@
2002-03-18 Sven Neumann <sven@gimp.org>
* app/core/core-enums.h
* app/core/core-types.h: more enum cleanup (ConvertPaletteType and
ConvertDitherType this time).
* app/core/gimpimage-convert.[ch]
* app/gui/convert-dialog.c
* tools/pdbgen/pdb/convert.pdb: changed accordingly.
* app/pdb/convert_cmds.c
* libgimp/gimpconvert_pdb.c
* libgimp/gimpenums.h
* plug-ins/script-fu/script-fu-constants.c
* tools/pdbgen/enums.pl: regenerated.
2002-03-18 Sven Neumann <sven@gimp.org> 2002-03-18 Sven Neumann <sven@gimp.org>
* app/core/core-enums.h * app/core/core-enums.h

View file

@ -163,6 +163,24 @@ typedef enum /*< skip >*/
GIMP_PATTERN_BUCKET_FILL GIMP_PATTERN_BUCKET_FILL
} GimpBucketFillMode; } GimpBucketFillMode;
typedef enum /*< skip >*/
{
GIMP_MAKE_PALETTE,
GIMP_REUSE_PALETTE,
GIMP_WEB_PALETTE,
GIMP_MONO_PALETTE,
GIMP_CUSTOM_PALETTE
} GimpConvertPaletteType;
typedef enum /*< skip >*/
{
GIMP_NO_DITHER,
GIMP_FS_DITHER,
GIMP_FSLOWBLEED_DITHER,
GIMP_FIXED_DITHER,
GIMP_NODESTRUCT_DITHER /* NEVER USE NODESTRUCT_DITHER EXPLICITLY */
} GimpConvertDitherType;
typedef enum /*< skip >*/ typedef enum /*< skip >*/
{ {
GIMP_FOREGROUND_FILL, GIMP_FOREGROUND_FILL,
@ -183,9 +201,9 @@ typedef enum /*< pdb-skip >*/ /*< skip >*/
typedef enum /*< pdb-skip >*/ /*< skip >*/ typedef enum /*< pdb-skip >*/ /*< skip >*/
{ {
GIMP_GRAD_RGB = 0, /* normal RGB */ GIMP_GRAD_RGB, /* normal RGB */
GIMP_GRAD_HSV_CCW, /* counterclockwise hue */ GIMP_GRAD_HSV_CCW, /* counterclockwise hue */
GIMP_GRAD_HSV_CW /* clockwise hue */ GIMP_GRAD_HSV_CW /* clockwise hue */
} GimpGradientSegmentColor; } GimpGradientSegmentColor;
typedef enum /*< skip >*/ typedef enum /*< skip >*/

View file

@ -73,24 +73,6 @@ typedef enum
FLATTEN_IMAGE FLATTEN_IMAGE
} MergeType; } MergeType;
typedef enum
{
MAKE_PALETTE = 0,
REUSE_PALETTE = 1,
WEB_PALETTE = 2,
MONO_PALETTE = 3,
CUSTOM_PALETTE = 4
} ConvertPaletteType;
typedef enum
{
NO_DITHER = 0,
FS_DITHER = 1,
FSLOWBLEED_DITHER = 2,
FIXED_DITHER = 3,
NODESTRUCT_DITHER = 4 /* NEVER USE NODESTRUCT_DITHER EXPLICITLY */
} ConvertDitherType;
typedef enum /*< pdb-skip >*/ /*< skip >*/ typedef enum /*< pdb-skip >*/ /*< skip >*/
{ {

View file

@ -513,11 +513,18 @@ typedef struct
static void zero_histogram_gray (CFHistogram); static void zero_histogram_gray (CFHistogram);
static void zero_histogram_rgb (CFHistogram); static void zero_histogram_rgb (CFHistogram);
static void generate_histogram_gray (CFHistogram, GimpLayer *, int alpha_dither); static void generate_histogram_gray (CFHistogram,
static void generate_histogram_rgb (CFHistogram, GimpLayer *, int col_limit, int alpha_dither); GimpLayer *,
int alpha_dither);
static void generate_histogram_rgb (CFHistogram,
GimpLayer *,
int col_limit,
int alpha_dither);
static QuantizeObj* initialize_median_cut (int, int, ConvertDitherType, static QuantizeObj* initialize_median_cut (int, int,
ConvertPaletteType, int); GimpConvertDitherType,
GimpConvertPaletteType,
int);
static void static void
compute_color_lin8 (QuantizeObj *quantobj, compute_color_lin8 (QuantizeObj *quantobj,
@ -705,17 +712,17 @@ remap_indexed_layer (GimpLayer *layer,
void void
gimp_image_convert (GimpImage *gimage, gimp_image_convert (GimpImage *gimage,
GimpImageBaseType new_type, GimpImageBaseType new_type,
/* The following three params used only for /* The following three params used only for
* new_type == GIMP_INDEXED * new_type == GIMP_INDEXED
*/ */
gint num_cols, gint num_cols,
ConvertDitherType dither, GimpConvertDitherType dither,
gint alpha_dither, gint alpha_dither,
gint remdups, gint remove_dups,
ConvertPaletteType palette_type, GimpConvertPaletteType palette_type,
GimpPalette *custom_palette) GimpPalette *custom_palette)
{ {
QuantizeObj *quantobj; QuantizeObj *quantobj;
GimpLayer *layer; GimpLayer *layer;
@ -728,7 +735,7 @@ gimp_image_convert (GimpImage *gimage,
g_return_if_fail (gimage != NULL); g_return_if_fail (gimage != NULL);
g_return_if_fail (GIMP_IS_IMAGE (gimage)); g_return_if_fail (GIMP_IS_IMAGE (gimage));
quantobj = NULL; quantobj = NULL;
theCustomPalette = custom_palette; theCustomPalette = custom_palette;
@ -760,14 +767,19 @@ gimp_image_convert (GimpImage *gimage,
/* fprintf(stderr, " TO INDEXED(%d) ", num_cols); */ /* fprintf(stderr, " TO INDEXED(%d) ", num_cols); */
/* don't dither if the input is grayscale and we are simply mapping every color */ /* don't dither if the input is grayscale and we are simply
if (old_type == GIMP_GRAY && num_cols == 256 && palette_type == MAKE_PALETTE) mapping every color */
dither = NO_DITHER; if (old_type == GIMP_GRAY &&
num_cols == 256 &&
palette_type == GIMP_MAKE_PALETTE)
{
dither = GIMP_NO_DITHER;
}
quantobj = initialize_median_cut (old_type, num_cols, dither, quantobj = initialize_median_cut (old_type, num_cols, dither,
palette_type, alpha_dither); palette_type, alpha_dither);
if (palette_type == MAKE_PALETTE) if (palette_type == GIMP_MAKE_PALETTE)
{ {
if (old_type == GIMP_GRAY) if (old_type == GIMP_GRAY)
zero_histogram_gray (quantobj->histogram); zero_histogram_gray (quantobj->histogram);
@ -789,9 +801,11 @@ gimp_image_convert (GimpImage *gimage,
layer = (GimpLayer *) list->data; layer = (GimpLayer *) list->data;
if (old_type == GIMP_GRAY) if (old_type == GIMP_GRAY)
generate_histogram_gray (quantobj->histogram, layer, alpha_dither); generate_histogram_gray (quantobj->histogram,
layer, alpha_dither);
else else
generate_histogram_rgb (quantobj->histogram, layer, num_cols, alpha_dither); generate_histogram_rgb (quantobj->histogram,
layer, num_cols, alpha_dither);
/* /*
* Note: generate_histogram_rgb may set needs_quantize if * Note: generate_histogram_rgb may set needs_quantize if
* the image contains more colours than the limit specified * the image contains more colours than the limit specified
@ -800,25 +814,26 @@ gimp_image_convert (GimpImage *gimage,
} }
} }
if ( if (
(old_type == GIMP_RGB) && (old_type == GIMP_RGB) &&
(!needs_quantize) && (!needs_quantize) &&
(palette_type == MAKE_PALETTE) (palette_type == GIMP_MAKE_PALETTE)
) )
{ {
/* If this is an RGB image, and the user wanted a custom-built /* If this is an RGB image, and the user wanted a custom-built
* generated palette, and this image has no more colours than * generated palette, and this image has no more colours than
* the user asked for, we don't need the first pass (quantization). * the user asked for, we don't need the first pass (quantization).
* *
* There's also no point in dithering, since there's no error to * There's also no point in dithering, since there's no error to
* spread. So we destroy the old quantobj and make a new one * spread. So we destroy the old quantobj and make a new one
* with the remapping function set to a special LUT-based * with the remapping function set to a special LUT-based
* no-dither remapper. * no-dither remapper.
*/ */
quantobj->delete_func (quantobj); quantobj->delete_func (quantobj);
quantobj = initialize_median_cut (old_type, num_cols, quantobj = initialize_median_cut (old_type, num_cols,
NODESTRUCT_DITHER, palette_type, GIMP_NODESTRUCT_DITHER,
palette_type,
alpha_dither); alpha_dither);
/* We can skip the first pass (palette creation) */ /* We can skip the first pass (palette creation) */
@ -924,8 +939,9 @@ gimp_image_convert (GimpImage *gimage,
g_free (gimage->cmap); g_free (gimage->cmap);
gimage->cmap = (unsigned char *) g_malloc (COLORMAP_SIZE); gimage->cmap = (unsigned char *) g_malloc (COLORMAP_SIZE);
if (remdups && if (remove_dups &&
((palette_type == WEB_PALETTE) || (palette_type == CUSTOM_PALETTE))) ((palette_type == GIMP_WEB_PALETTE) ||
(palette_type == GIMP_CUSTOM_PALETTE)))
{ {
int i,j; int i,j;
unsigned char old_palette [256 * 3]; unsigned char old_palette [256 * 3];
@ -945,7 +961,8 @@ gimp_image_convert (GimpImage *gimage,
#if 1 #if 1
/* Generate a remapping table */ /* Generate a remapping table */
make_remap_table (old_palette, new_palette, make_remap_table (old_palette, new_palette,
quantobj->index_used_count, remap_table, &num_entries); quantobj->index_used_count,
remap_table, &num_entries);
/* Convert all layers */ /* Convert all layers */
for (list = GIMP_LIST (gimage->layers)->list; for (list = GIMP_LIST (gimage->layers)->list;
@ -1168,7 +1185,9 @@ gimp_drawable_convert_grayscale (GimpDrawable *drawable,
for (col = 0; col < srcPR.w; col++) for (col = 0; col < srcPR.w; col++)
{ {
offset = *s++ * 3; offset = *s++ * 3;
val = INTENSITY (cmap[offset+0], cmap[offset+1], cmap[offset+2]); val = INTENSITY (cmap[offset+0],
cmap[offset+1],
cmap[offset+2]);
*d++ = (guchar) val; *d++ = (guchar) val;
if (has_alpha) if (has_alpha)
*d++ = *s++; *d++ = *s++;
@ -1202,8 +1221,8 @@ zero_histogram_gray (CFHistogram histogram)
static void static void
zero_histogram_rgb (CFHistogram histogram) zero_histogram_rgb (CFHistogram histogram)
{ {
memset(histogram, 0, memset (histogram, 0,
HIST_R_ELEMS * HIST_G_ELEMS * HIST_B_ELEMS * sizeof(ColorFreq)); HIST_R_ELEMS * HIST_G_ELEMS * HIST_B_ELEMS * sizeof(ColorFreq));
} }
@ -1220,7 +1239,11 @@ generate_histogram_gray (CFHistogram histogram,
has_alpha = gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)); has_alpha = gimp_drawable_has_alpha (GIMP_DRAWABLE (layer));
pixel_region_init (&srcPR, GIMP_DRAWABLE(layer)->tiles, 0, 0, GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height, FALSE); pixel_region_init (&srcPR, GIMP_DRAWABLE(layer)->tiles,
0, 0,
GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height,
FALSE);
for (pr = pixel_regions_register (1, &srcPR); for (pr = pixel_regions_register (1, &srcPR);
pr != NULL; pr != NULL;
pr = pixel_regions_process (pr)) pr = pixel_regions_process (pr))
@ -1291,10 +1314,10 @@ generate_histogram_rgb (CFHistogram histogram,
) )
|| (!has_alpha)) || (!has_alpha))
{ {
colfreq = HIST_RGB(histogram, colfreq = HIST_RGB (histogram,
data[RED_PIX], data[RED_PIX],
data[GREEN_PIX], data[GREEN_PIX],
data[BLUE_PIX]); data[BLUE_PIX]);
(*colfreq)++; (*colfreq)++;
} }
@ -1320,10 +1343,10 @@ generate_histogram_rgb (CFHistogram histogram,
) )
|| (!has_alpha)) || (!has_alpha))
{ {
colfreq = HIST_RGB(histogram, colfreq = HIST_RGB (histogram,
data[RED_PIX], data[RED_PIX],
data[GREEN_PIX], data[GREEN_PIX],
data[BLUE_PIX]); data[BLUE_PIX]);
(*colfreq)++; (*colfreq)++;
} }
data += srcPR.bytes; data += srcPR.bytes;
@ -1343,10 +1366,10 @@ generate_histogram_rgb (CFHistogram histogram,
((data[ALPHA_PIX] << 6) > (255 * DM[col&DM_WIDTHMASK][row&DM_HEIGHTMASK])) : ((data[ALPHA_PIX] << 6) > (255 * DM[col&DM_WIDTHMASK][row&DM_HEIGHTMASK])) :
(data[ALPHA_PIX] > 127))) || (!has_alpha)) (data[ALPHA_PIX] > 127))) || (!has_alpha))
{ {
colfreq = HIST_RGB(histogram, colfreq = HIST_RGB (histogram,
data[RED_PIX], data[RED_PIX],
data[GREEN_PIX], data[GREEN_PIX],
data[BLUE_PIX]); data[BLUE_PIX]);
(*colfreq)++; (*colfreq)++;
if (!needs_quantize) if (!needs_quantize)
@ -3868,8 +3891,8 @@ delete_median_cut (QuantizeObj *quantobj)
static QuantizeObj* static QuantizeObj*
initialize_median_cut (int type, initialize_median_cut (int type,
int num_colors, int num_colors,
ConvertDitherType dither_type, GimpConvertDitherType dither_type,
ConvertPaletteType palette_type, GimpConvertPaletteType palette_type,
int want_alpha_dither) int want_alpha_dither)
{ {
QuantizeObj * quantobj; QuantizeObj * quantobj;
@ -3877,7 +3900,7 @@ initialize_median_cut (int type,
/* Initialize the data structures */ /* Initialize the data structures */
quantobj = g_malloc (sizeof (QuantizeObj)); quantobj = g_malloc (sizeof (QuantizeObj));
if (type == GIMP_GRAY && palette_type == MAKE_PALETTE) if (type == GIMP_GRAY && palette_type == GIMP_MAKE_PALETTE)
quantobj->histogram = g_malloc (sizeof (ColorFreq) * 256); quantobj->histogram = g_malloc (sizeof (ColorFreq) * 256);
else else
quantobj->histogram = g_malloc (sizeof (ColorFreq) * quantobj->histogram = g_malloc (sizeof (ColorFreq) *
@ -3893,42 +3916,44 @@ initialize_median_cut (int type,
case GIMP_GRAY: case GIMP_GRAY:
switch (palette_type) switch (palette_type)
{ {
case MAKE_PALETTE: case GIMP_MAKE_PALETTE:
quantobj->first_pass = median_cut_pass1_gray; quantobj->first_pass = median_cut_pass1_gray;
break; break;
case WEB_PALETTE: case GIMP_WEB_PALETTE:
quantobj->first_pass = webpal_pass1; quantobj->first_pass = webpal_pass1;
break; break;
case CUSTOM_PALETTE: case GIMP_CUSTOM_PALETTE:
quantobj->first_pass = custompal_pass1; quantobj->first_pass = custompal_pass1;
needs_quantize=TRUE; needs_quantize=TRUE;
break; break;
case MONO_PALETTE: case GIMP_MONO_PALETTE:
default: default:
quantobj->first_pass = monopal_pass1; quantobj->first_pass = monopal_pass1;
} }
if (palette_type == WEB_PALETTE ||
palette_type == MONO_PALETTE || palette_type == CUSTOM_PALETTE) if (palette_type == GIMP_WEB_PALETTE ||
palette_type == GIMP_MONO_PALETTE ||
palette_type == GIMP_CUSTOM_PALETTE)
switch (dither_type) switch (dither_type)
{ {
case NODESTRUCT_DITHER: case GIMP_NODESTRUCT_DITHER:
default: default:
g_warning("Uh-oh, bad dither type, W1"); g_warning("Uh-oh, bad dither type, W1");
case NO_DITHER: case GIMP_NO_DITHER:
quantobj->second_pass_init = median_cut_pass2_rgb_init; quantobj->second_pass_init = median_cut_pass2_rgb_init;
quantobj->second_pass = median_cut_pass2_no_dither_rgb; quantobj->second_pass = median_cut_pass2_no_dither_rgb;
break; break;
case FS_DITHER: case GIMP_FS_DITHER:
quantobj->error_freedom = 0; quantobj->error_freedom = 0;
quantobj->second_pass_init = median_cut_pass2_rgb_init; quantobj->second_pass_init = median_cut_pass2_rgb_init;
quantobj->second_pass = median_cut_pass2_fs_dither_rgb; quantobj->second_pass = median_cut_pass2_fs_dither_rgb;
break; break;
case FSLOWBLEED_DITHER: case GIMP_FSLOWBLEED_DITHER:
quantobj->error_freedom = 1; quantobj->error_freedom = 1;
quantobj->second_pass_init = median_cut_pass2_rgb_init; quantobj->second_pass_init = median_cut_pass2_rgb_init;
quantobj->second_pass = median_cut_pass2_fs_dither_rgb; quantobj->second_pass = median_cut_pass2_fs_dither_rgb;
break; break;
case FIXED_DITHER: case GIMP_FIXED_DITHER:
quantobj->second_pass_init = median_cut_pass2_rgb_init; quantobj->second_pass_init = median_cut_pass2_rgb_init;
quantobj->second_pass = median_cut_pass2_fixed_dither_rgb; quantobj->second_pass = median_cut_pass2_fixed_dither_rgb;
break; break;
@ -3936,24 +3961,24 @@ initialize_median_cut (int type,
else else
switch (dither_type) switch (dither_type)
{ {
case NODESTRUCT_DITHER: case GIMP_NODESTRUCT_DITHER:
default: default:
g_warning("Uh-oh, bad dither type, W2"); g_warning("Uh-oh, bad dither type, W2");
case NO_DITHER: case GIMP_NO_DITHER:
quantobj->second_pass_init = median_cut_pass2_gray_init; quantobj->second_pass_init = median_cut_pass2_gray_init;
quantobj->second_pass = median_cut_pass2_no_dither_gray; quantobj->second_pass = median_cut_pass2_no_dither_gray;
break; break;
case FS_DITHER: case GIMP_FS_DITHER:
quantobj->error_freedom = 0; quantobj->error_freedom = 0;
quantobj->second_pass_init = median_cut_pass2_gray_init; quantobj->second_pass_init = median_cut_pass2_gray_init;
quantobj->second_pass = median_cut_pass2_fs_dither_gray; quantobj->second_pass = median_cut_pass2_fs_dither_gray;
break; break;
case FSLOWBLEED_DITHER: case GIMP_FSLOWBLEED_DITHER:
quantobj->error_freedom = 1; quantobj->error_freedom = 1;
quantobj->second_pass_init = median_cut_pass2_gray_init; quantobj->second_pass_init = median_cut_pass2_gray_init;
quantobj->second_pass = median_cut_pass2_fs_dither_gray; quantobj->second_pass = median_cut_pass2_fs_dither_gray;
break; break;
case FIXED_DITHER: case GIMP_FIXED_DITHER:
quantobj->second_pass_init = median_cut_pass2_gray_init; quantobj->second_pass_init = median_cut_pass2_gray_init;
quantobj->second_pass = median_cut_pass2_fixed_dither_gray; quantobj->second_pass = median_cut_pass2_fixed_dither_gray;
break; break;
@ -3962,48 +3987,49 @@ initialize_median_cut (int type,
case GIMP_RGB: case GIMP_RGB:
switch (palette_type) switch (palette_type)
{ {
case MAKE_PALETTE: case GIMP_MAKE_PALETTE:
quantobj->first_pass = median_cut_pass1_rgb; quantobj->first_pass = median_cut_pass1_rgb;
break; break;
case WEB_PALETTE: case GIMP_WEB_PALETTE:
quantobj->first_pass = webpal_pass1; quantobj->first_pass = webpal_pass1;
needs_quantize=TRUE; needs_quantize=TRUE;
break; break;
case CUSTOM_PALETTE: case GIMP_CUSTOM_PALETTE:
quantobj->first_pass = custompal_pass1; quantobj->first_pass = custompal_pass1;
needs_quantize=TRUE; needs_quantize=TRUE;
break; break;
case MONO_PALETTE: case GIMP_MONO_PALETTE:
default: default:
quantobj->first_pass = monopal_pass1; quantobj->first_pass = monopal_pass1;
} }
switch (dither_type) switch (dither_type)
{ {
case NO_DITHER: case GIMP_NO_DITHER:
quantobj->second_pass_init = median_cut_pass2_rgb_init; quantobj->second_pass_init = median_cut_pass2_rgb_init;
quantobj->second_pass = median_cut_pass2_no_dither_rgb; quantobj->second_pass = median_cut_pass2_no_dither_rgb;
break; break;
case FS_DITHER: case GIMP_FS_DITHER:
quantobj->error_freedom = 0; quantobj->error_freedom = 0;
quantobj->second_pass_init = median_cut_pass2_rgb_init; quantobj->second_pass_init = median_cut_pass2_rgb_init;
quantobj->second_pass = median_cut_pass2_fs_dither_rgb; quantobj->second_pass = median_cut_pass2_fs_dither_rgb;
break; break;
case FSLOWBLEED_DITHER: case GIMP_FSLOWBLEED_DITHER:
quantobj->error_freedom = 1; quantobj->error_freedom = 1;
quantobj->second_pass_init = median_cut_pass2_rgb_init; quantobj->second_pass_init = median_cut_pass2_rgb_init;
quantobj->second_pass = median_cut_pass2_fs_dither_rgb; quantobj->second_pass = median_cut_pass2_fs_dither_rgb;
break; break;
case NODESTRUCT_DITHER: case GIMP_NODESTRUCT_DITHER:
quantobj->second_pass_init = NULL; quantobj->second_pass_init = NULL;
quantobj->second_pass = median_cut_pass2_nodestruct_dither_rgb; quantobj->second_pass = median_cut_pass2_nodestruct_dither_rgb;
break; break;
case FIXED_DITHER: case GIMP_FIXED_DITHER:
quantobj->second_pass_init = median_cut_pass2_rgb_init; quantobj->second_pass_init = median_cut_pass2_rgb_init;
quantobj->second_pass = median_cut_pass2_fixed_dither_rgb; quantobj->second_pass = median_cut_pass2_fixed_dither_rgb;
break; break;
} }
break; break;
} }
quantobj->delete_func = delete_median_cut; quantobj->delete_func = delete_median_cut;
return quantobj; return quantobj;

View file

@ -23,17 +23,17 @@
#define MAXNUMCOLORS 256 #define MAXNUMCOLORS 256
void gimp_image_convert (GimpImage *gimage, void gimp_image_convert (GimpImage *gimage,
GimpImageBaseType new_type, GimpImageBaseType new_type,
/* The following params used only for /* The following params used only for
* new_type == GIMP_INDEXED * new_type == GIMP_INDEXED
*/ */
gint num_cols, gint num_cols,
ConvertDitherType dither, GimpConvertDitherType dither,
gint alpha_dither, gint alpha_dither,
gint remdups, gint remove_dups,
ConvertPaletteType palette_type, GimpConvertPaletteType palette_type,
GimpPalette *custom_palette); GimpPalette *custom_palette);
void gimp_drawable_convert_rgb (GimpDrawable *drawable, void gimp_drawable_convert_rgb (GimpDrawable *drawable,
TileManager *new_tiles, TileManager *new_tiles,

View file

@ -501,32 +501,32 @@ static void
indexed_ok_callback (GtkWidget *widget, indexed_ok_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
IndexedDialog *dialog; IndexedDialog *dialog;
ConvertPaletteType palette_type; GimpConvertPaletteType palette_type;
ConvertDitherType dither_type; GimpConvertDitherType dither_type;
GimpTool *active_tool; GimpTool *active_tool;
dialog = (IndexedDialog *) data; dialog = (IndexedDialog *) data;
if (dialog->webpal_flag) if (dialog->webpal_flag)
palette_type = WEB_PALETTE; palette_type = GIMP_WEB_PALETTE;
else if (dialog->custompal_flag) else if (dialog->custompal_flag)
palette_type = CUSTOM_PALETTE; palette_type = GIMP_CUSTOM_PALETTE;
else if (dialog->monopal_flag) else if (dialog->monopal_flag)
palette_type = MONO_PALETTE; palette_type = GIMP_MONO_PALETTE;
else if (dialog->makepal_flag) else if (dialog->makepal_flag)
palette_type = MAKE_PALETTE; palette_type = GIMP_MAKE_PALETTE;
else else
palette_type = REUSE_PALETTE; palette_type = GIMP_REUSE_PALETTE;
if (dialog->nodither_flag) if (dialog->nodither_flag)
dither_type = NO_DITHER; dither_type = GIMP_NO_DITHER;
else if (dialog->fsdither_flag) else if (dialog->fsdither_flag)
dither_type = FS_DITHER; dither_type = GIMP_FS_DITHER;
else if (dialog->fslowbleeddither_flag) else if (dialog->fslowbleeddither_flag)
dither_type = FSLOWBLEED_DITHER; dither_type = GIMP_FSLOWBLEED_DITHER;
else else
dither_type = FIXED_DITHER; dither_type = GIMP_FIXED_DITHER;
/* Close the dialogs when open because they're useless for indexed /* Close the dialogs when open because they're useless for indexed
* images and could crash the GIMP when used nevertheless * images and could crash the GIMP when used nevertheless

View file

@ -501,32 +501,32 @@ static void
indexed_ok_callback (GtkWidget *widget, indexed_ok_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
IndexedDialog *dialog; IndexedDialog *dialog;
ConvertPaletteType palette_type; GimpConvertPaletteType palette_type;
ConvertDitherType dither_type; GimpConvertDitherType dither_type;
GimpTool *active_tool; GimpTool *active_tool;
dialog = (IndexedDialog *) data; dialog = (IndexedDialog *) data;
if (dialog->webpal_flag) if (dialog->webpal_flag)
palette_type = WEB_PALETTE; palette_type = GIMP_WEB_PALETTE;
else if (dialog->custompal_flag) else if (dialog->custompal_flag)
palette_type = CUSTOM_PALETTE; palette_type = GIMP_CUSTOM_PALETTE;
else if (dialog->monopal_flag) else if (dialog->monopal_flag)
palette_type = MONO_PALETTE; palette_type = GIMP_MONO_PALETTE;
else if (dialog->makepal_flag) else if (dialog->makepal_flag)
palette_type = MAKE_PALETTE; palette_type = GIMP_MAKE_PALETTE;
else else
palette_type = REUSE_PALETTE; palette_type = GIMP_REUSE_PALETTE;
if (dialog->nodither_flag) if (dialog->nodither_flag)
dither_type = NO_DITHER; dither_type = GIMP_NO_DITHER;
else if (dialog->fsdither_flag) else if (dialog->fsdither_flag)
dither_type = FS_DITHER; dither_type = GIMP_FS_DITHER;
else if (dialog->fslowbleeddither_flag) else if (dialog->fslowbleeddither_flag)
dither_type = FSLOWBLEED_DITHER; dither_type = GIMP_FSLOWBLEED_DITHER;
else else
dither_type = FIXED_DITHER; dither_type = GIMP_FIXED_DITHER;
/* Close the dialogs when open because they're useless for indexed /* Close the dialogs when open because they're useless for indexed
* images and could crash the GIMP when used nevertheless * images and could crash the GIMP when used nevertheless

View file

@ -28,7 +28,7 @@
#include "pdb-types.h" #include "pdb-types.h"
#include "procedural_db.h" #include "procedural_db.h"
#include "core/core-types.h" #include "core/core-enums.h"
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpcontainer.h" #include "core/gimpcontainer.h"
#include "core/gimpdatafactory.h" #include "core/gimpdatafactory.h"
@ -152,7 +152,7 @@ convert_indexed_invoker (Gimp *gimp,
success = FALSE; success = FALSE;
dither_type = args[1].value.pdb_int; dither_type = args[1].value.pdb_int;
if (dither_type < NO_DITHER || dither_type > NODESTRUCT_DITHER) if (dither_type < GIMP_NO_DITHER || dither_type > GIMP_NODESTRUCT_DITHER)
success = FALSE; success = FALSE;
palette_type = args[2].value.pdb_int; palette_type = args[2].value.pdb_int;
@ -175,10 +175,10 @@ convert_indexed_invoker (Gimp *gimp,
{ {
switch (dither_type) switch (dither_type)
{ {
case NO_DITHER: case GIMP_NO_DITHER:
case FS_DITHER: case GIMP_FS_DITHER:
case FSLOWBLEED_DITHER: case GIMP_FSLOWBLEED_DITHER:
case FIXED_DITHER: case GIMP_FIXED_DITHER:
break; break;
default: default:
success = FALSE; success = FALSE;
@ -187,17 +187,17 @@ convert_indexed_invoker (Gimp *gimp,
switch (palette_type) switch (palette_type)
{ {
case MAKE_PALETTE: case GIMP_MAKE_PALETTE:
if (num_cols < 1 || num_cols > MAXNUMCOLORS) if (num_cols < 1 || num_cols > MAXNUMCOLORS)
success = FALSE; success = FALSE;
break; break;
case REUSE_PALETTE: case GIMP_REUSE_PALETTE:
case WEB_PALETTE: case GIMP_WEB_PALETTE:
case MONO_PALETTE: case GIMP_MONO_PALETTE:
break; break;
case CUSTOM_PALETTE: case GIMP_CUSTOM_PALETTE:
if (! gimp->palette_factory->container->num_children) if (! gimp->palette_factory->container->num_children)
gimp_data_factory_data_init (gimp->palette_factory, FALSE); gimp_data_factory_data_init (gimp->palette_factory, FALSE);
@ -238,12 +238,12 @@ static ProcArg convert_indexed_inargs[] =
{ {
GIMP_PDB_INT32, GIMP_PDB_INT32,
"palette_type", "palette_type",
"The type of palette to use: { MAKE_PALETTE (0), REUSE_PALETTE (1), WEB_PALETTE (2), MONO_PALETTE (3), CUSTOM_PALETTE (4) }" "The type of palette to use: { GIMP_MAKE_PALETTE (0), GIMP_REUSE_PALETTE (1), GIMP_WEB_PALETTE (2), GIMP_MONO_PALETTE (3), GIMP_CUSTOM_PALETTE (4) }"
}, },
{ {
GIMP_PDB_INT32, GIMP_PDB_INT32,
"num_cols", "num_cols",
"the number of colors to quantize to, ignored unless (palette_type == MAKE_PALETTE)" "the number of colors to quantize to, ignored unless (palette_type == GIMP_MAKE_PALETTE)"
}, },
{ {
GIMP_PDB_INT32, GIMP_PDB_INT32,
@ -253,12 +253,12 @@ static ProcArg convert_indexed_inargs[] =
{ {
GIMP_PDB_INT32, GIMP_PDB_INT32,
"remove_unused", "remove_unused",
"remove unused or duplicate colour entries from final palette, ignored if (palette_type == MAKE_PALETTE)" "remove unused or duplicate colour entries from final palette, ignored if (palette_type == GIMP_MAKE_PALETTE)"
}, },
{ {
GIMP_PDB_STRING, GIMP_PDB_STRING,
"palette", "palette",
"The name of the custom palette to use, ignored unless (palette_type == CUSTOM_PALETTE)" "The name of the custom palette to use, ignored unless (palette_type == GIMP_CUSTOM_PALETTE)"
} }
}; };

View file

@ -91,10 +91,10 @@ gimp_convert_grayscale (gint32 image_ID)
* @image_ID: The image. * @image_ID: The image.
* @dither_type: dither type (0=none, 1=fs, 2=fs/low-bleed 3=fixed). * @dither_type: dither type (0=none, 1=fs, 2=fs/low-bleed 3=fixed).
* @palette_type: The type of palette to use. * @palette_type: The type of palette to use.
* @num_cols: the number of colors to quantize to, ignored unless (palette_type == MAKE_PALETTE). * @num_cols: the number of colors to quantize to, ignored unless (palette_type == GIMP_MAKE_PALETTE).
* @alpha_dither: dither transparency to fake partial opacity. * @alpha_dither: dither transparency to fake partial opacity.
* @remove_unused: remove unused or duplicate colour entries from final palette, ignored if (palette_type == MAKE_PALETTE). * @remove_unused: remove unused or duplicate colour entries from final palette, ignored if (palette_type == GIMP_MAKE_PALETTE).
* @palette: The name of the custom palette to use, ignored unless (palette_type == CUSTOM_PALETTE). * @palette: The name of the custom palette to use, ignored unless (palette_type == GIMP_CUSTOM_PALETTE).
* *
* Convert specified image to and Indexed image * Convert specified image to and Indexed image
* *

View file

@ -45,24 +45,6 @@ typedef enum
GIMP_PATTERN_CLONE GIMP_PATTERN_CLONE
} GimpCloneType; } GimpCloneType;
typedef enum
{
GIMP_NO_DITHER,
GIMP_FS_DITHER,
GIMP_FSLOWBLEED_DITHER,
GIMP_FIXED_DITHER,
GIMP_NODESTRUCT_DITHER
} GimpConvertDitherType;
typedef enum
{
GIMP_MAKE_PALETTE,
GIMP_REUSE_PALETTE,
GIMP_WEB_PALETTE,
GIMP_MONO_PALETTE,
GIMP_CUSTOM_PALETTE
} GimpConvertPaletteType;
typedef enum typedef enum
{ {
GIMP_BLUR_CONVOLVE, GIMP_BLUR_CONVOLVE,
@ -121,6 +103,24 @@ typedef enum
GIMP_ALPHA_CHANNEL GIMP_ALPHA_CHANNEL
} GimpChannelType; } GimpChannelType;
typedef enum
{
GIMP_NO_DITHER,
GIMP_FS_DITHER,
GIMP_FSLOWBLEED_DITHER,
GIMP_FIXED_DITHER,
GIMP_NODESTRUCT_DITHER
} GimpConvertDitherType;
typedef enum
{
GIMP_MAKE_PALETTE,
GIMP_REUSE_PALETTE,
GIMP_WEB_PALETTE,
GIMP_MONO_PALETTE,
GIMP_CUSTOM_PALETTE
} GimpConvertPaletteType;
typedef enum typedef enum
{ {
GIMP_NORMAL_CONVOL, GIMP_NORMAL_CONVOL,

View file

@ -35,18 +35,6 @@ init_generated_constants (void)
setvar (cintern ("IMAGE-CLONE"), flocons (0), NIL); setvar (cintern ("IMAGE-CLONE"), flocons (0), NIL);
setvar (cintern ("PATTERN-CLONE"), flocons (1), NIL); setvar (cintern ("PATTERN-CLONE"), flocons (1), NIL);
setvar (cintern ("NO-DITHER"), flocons (0), NIL);
setvar (cintern ("FS-DITHER"), flocons (1), NIL);
setvar (cintern ("FSLOWBLEED-DITHER"), flocons (2), NIL);
setvar (cintern ("FIXED-DITHER"), flocons (3), NIL);
setvar (cintern ("NODESTRUCT-DITHER"), flocons (4), NIL);
setvar (cintern ("MAKE-PALETTE"), flocons (0), NIL);
setvar (cintern ("REUSE-PALETTE"), flocons (1), NIL);
setvar (cintern ("WEB-PALETTE"), flocons (2), NIL);
setvar (cintern ("MONO-PALETTE"), flocons (3), NIL);
setvar (cintern ("CUSTOM-PALETTE"), flocons (4), NIL);
setvar (cintern ("BLUR-CONVOLVE"), flocons (0), NIL); setvar (cintern ("BLUR-CONVOLVE"), flocons (0), NIL);
setvar (cintern ("SHARPEN-CONVOLVE"), flocons (1), NIL); setvar (cintern ("SHARPEN-CONVOLVE"), flocons (1), NIL);
setvar (cintern ("CUSTOM-CONVOLVE"), flocons (2), NIL); setvar (cintern ("CUSTOM-CONVOLVE"), flocons (2), NIL);
@ -84,6 +72,18 @@ init_generated_constants (void)
setvar (cintern ("INDEXED-CHANNEL"), flocons (4), NIL); setvar (cintern ("INDEXED-CHANNEL"), flocons (4), NIL);
setvar (cintern ("ALPHA-CHANNEL"), flocons (5), NIL); setvar (cintern ("ALPHA-CHANNEL"), flocons (5), NIL);
setvar (cintern ("NO-DITHER"), flocons (0), NIL);
setvar (cintern ("FS-DITHER"), flocons (1), NIL);
setvar (cintern ("FSLOWBLEED-DITHER"), flocons (2), NIL);
setvar (cintern ("FIXED-DITHER"), flocons (3), NIL);
setvar (cintern ("NODESTRUCT-DITHER"), flocons (4), NIL);
setvar (cintern ("MAKE-PALETTE"), flocons (0), NIL);
setvar (cintern ("REUSE-PALETTE"), flocons (1), NIL);
setvar (cintern ("WEB-PALETTE"), flocons (2), NIL);
setvar (cintern ("MONO-PALETTE"), flocons (3), NIL);
setvar (cintern ("CUSTOM-PALETTE"), flocons (4), NIL);
setvar (cintern ("NORMAL-CONVOL"), flocons (0), NIL); setvar (cintern ("NORMAL-CONVOL"), flocons (0), NIL);
setvar (cintern ("ABSOLUTE-CONVOL"), flocons (1), NIL); setvar (cintern ("ABSOLUTE-CONVOL"), flocons (1), NIL);
setvar (cintern ("NEGATIVE-CONVOL"), flocons (2), NIL); setvar (cintern ("NEGATIVE-CONVOL"), flocons (2), NIL);

View file

@ -196,28 +196,6 @@ package Gimp::CodeGen::enums;
CLIP_TO_BOTTOM_LAYER => '2', CLIP_TO_BOTTOM_LAYER => '2',
FLATTEN_IMAGE => '3' } FLATTEN_IMAGE => '3' }
}, },
ConvertPaletteType =>
{ contig => 1,
header => 'core/core-types.h',
symbols => [ qw(MAKE_PALETTE REUSE_PALETTE WEB_PALETTE
MONO_PALETTE CUSTOM_PALETTE) ],
mapping => { MAKE_PALETTE => '0',
REUSE_PALETTE => '1',
WEB_PALETTE => '2',
MONO_PALETTE => '3',
CUSTOM_PALETTE => '4' }
},
ConvertDitherType =>
{ contig => 1,
header => 'core/core-types.h',
symbols => [ qw(NO_DITHER FS_DITHER FSLOWBLEED_DITHER FIXED_DITHER
NODESTRUCT_DITHER) ],
mapping => { NO_DITHER => '0',
FS_DITHER => '1',
FSLOWBLEED_DITHER => '2',
FIXED_DITHER => '3',
NODESTRUCT_DITHER => '4' }
},
GimpImageBaseType => GimpImageBaseType =>
{ contig => 1, { contig => 1,
header => 'core/core-enums.h', header => 'core/core-enums.h',
@ -287,6 +265,30 @@ package Gimp::CodeGen::enums;
GIMP_BG_BUCKET_FILL => '1', GIMP_BG_BUCKET_FILL => '1',
GIMP_PATTERN_BUCKET_FILL => '2' } GIMP_PATTERN_BUCKET_FILL => '2' }
}, },
GimpConvertPaletteType =>
{ contig => 1,
header => 'core/core-enums.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' }
},
GimpConvertDitherType =>
{ contig => 1,
header => 'core/core-enums.h',
symbols => [ qw(GIMP_NO_DITHER GIMP_FS_DITHER
GIMP_FSLOWBLEED_DITHER GIMP_FIXED_DITHER
GIMP_NODESTRUCT_DITHER) ],
mapping => { GIMP_NO_DITHER => '0',
GIMP_FS_DITHER => '1',
GIMP_FSLOWBLEED_DITHER => '2',
GIMP_FIXED_DITHER => '3',
GIMP_NODESTRUCT_DITHER => '4' }
},
GimpFillType => GimpFillType =>
{ contig => 1, { contig => 1,
header => 'core/core-enums.h', header => 'core/core-enums.h',

View file

@ -84,21 +84,21 @@ HELP
@inargs = ( @inargs = (
&std_image_arg, &std_image_arg,
{ name => 'dither_type', type => 'enum ConvertDitherType', { name => 'dither_type', type => 'enum GimpConvertDitherType',
desc => 'dither type (0=none, 1=fs, 2=fs/low-bleed 3=fixed)' }, desc => 'dither type (0=none, 1=fs, 2=fs/low-bleed 3=fixed)' },
{ name => 'palette_type', type => 'enum ConvertPaletteType', { name => 'palette_type', type => 'enum GimpConvertPaletteType',
desc => 'The type of palette to use: { %%desc%% }', no_success => 1 }, desc => 'The type of palette to use: { %%desc%% }', no_success => 1 },
{ name => 'num_cols', type => 'int32', { name => 'num_cols', type => 'int32',
desc => 'the number of colors to quantize to, ignored unless desc => 'the number of colors to quantize to, ignored unless
(palette_type == MAKE_PALETTE)' }, (palette_type == GIMP_MAKE_PALETTE)' },
{ name => 'alpha_dither', type => 'boolean', { name => 'alpha_dither', type => 'boolean',
desc => 'dither transparency to fake partial opacity' }, desc => 'dither transparency to fake partial opacity' },
{ name => 'remove_unused', type => 'boolean', { name => 'remove_unused', type => 'boolean',
desc => 'remove unused or duplicate colour entries from final desc => 'remove unused or duplicate colour entries from final
palette, ignored if (palette_type == MAKE_PALETTE)' }, palette, ignored if (palette_type == GIMP_MAKE_PALETTE)' },
{ name => 'palette', type => 'string', { name => 'palette', type => 'string',
desc => 'The name of the custom palette to use, ignored unless desc => 'The name of the custom palette to use, ignored unless
(palette_type == CUSTOM_PALETTE)', (palette_type == GIMP_CUSTOM_PALETTE)',
alias => 'palette_name' } alias => 'palette_name' }
); );
@ -111,10 +111,10 @@ HELP
{ {
switch (dither_type) switch (dither_type)
{ {
case NO_DITHER: case GIMP_NO_DITHER:
case FS_DITHER: case GIMP_FS_DITHER:
case FSLOWBLEED_DITHER: case GIMP_FSLOWBLEED_DITHER:
case FIXED_DITHER: case GIMP_FIXED_DITHER:
break; break;
default: default:
success = FALSE; success = FALSE;
@ -123,17 +123,17 @@ HELP
switch (palette_type) switch (palette_type)
{ {
case MAKE_PALETTE: case GIMP_MAKE_PALETTE:
if (num_cols < 1 || num_cols > MAXNUMCOLORS) if (num_cols < 1 || num_cols > MAXNUMCOLORS)
success = FALSE; success = FALSE;
break; break;
case REUSE_PALETTE: case GIMP_REUSE_PALETTE:
case WEB_PALETTE: case GIMP_WEB_PALETTE:
case MONO_PALETTE: case GIMP_MONO_PALETTE:
break; break;
case CUSTOM_PALETTE: case GIMP_CUSTOM_PALETTE:
if (! gimp->palette_factory->container->num_children) if (! gimp->palette_factory->container->num_children)
gimp_data_factory_data_init (gimp->palette_factory, FALSE); gimp_data_factory_data_init (gimp->palette_factory, FALSE);