use gboolean instead of gint for "alpha_dither" and "remove_dups" in all

2004-01-31  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpimage-convert.[ch]: use gboolean instead of gint
	for "alpha_dither" and "remove_dups" in all public and private
	functions. Properly prototyped private functions. Minor cleanup.

	* app/gui/convert-dialog.c: pass FALSE instead of 0.

	* tools/pdbgen/pdb/convert.pdb: ditto. Also cleaned up a bit: use
	generated checks and documentation for enums, removed duplicate
	check for enum range (spotted by Kevin Cozens).

	* app/pdb/convert_cmds.c
	* libgimp/gimpconvert_pdb.c: regenerated.
This commit is contained in:
Michael Natterer 2004-01-31 16:23:25 +00:00 committed by Michael Natterer
parent de522ba5a9
commit 6f1680ab1c
8 changed files with 168 additions and 155 deletions

View File

@ -1,3 +1,18 @@
2004-01-31 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-convert.[ch]: use gboolean instead of gint
for "alpha_dither" and "remove_dups" in all public and private
functions. Properly prototyped private functions. Minor cleanup.
* app/gui/convert-dialog.c: pass FALSE instead of 0.
* tools/pdbgen/pdb/convert.pdb: ditto. Also cleaned up a bit: use
generated checks and documentation for enums, removed duplicate
check for enum range (spotted by Kevin Cozens).
* app/pdb/convert_cmds.c
* libgimp/gimpconvert_pdb.c: regenerated.
2004-01-31 Manish Singh <yosh@gimp.org>
* app/base/cpu-accel.c: Make the assembly PIC safe. Fixes #132999.

View File

@ -477,7 +477,7 @@ struct _QuantizeObj
gulong index_used_count[256]; /* how many times an index was used */
CFHistogram histogram; /* holds the histogram */
int want_alpha_dither;
gboolean want_alpha_dither;
int error_freedom; /* 0=much bleed, 1=controlled bleed */
};
@ -514,20 +514,21 @@ typedef struct
static void zero_histogram_gray (CFHistogram);
static void zero_histogram_rgb (CFHistogram);
static void generate_histogram_gray (CFHistogram,
GimpLayer *,
int alpha_dither);
static void generate_histogram_rgb (CFHistogram,
GimpLayer *,
int col_limit,
int alpha_dither);
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);
static void generate_histogram_rgb (CFHistogram histogram,
GimpLayer *layer,
gint col_limit,
gboolean alpha_dither);
static QuantizeObj* initialize_median_cut (int, int,
GimpConvertDitherType,
GimpConvertPaletteType,
int);
static QuantizeObj* initialize_median_cut (GimpImageBaseType old_type,
gint num_cols,
GimpConvertDitherType dither_type,
GimpConvertPaletteType palette_type,
gboolean alpha_dither);
static void
compute_color_lin8 (QuantizeObj *quantobj,
@ -742,8 +743,8 @@ gimp_image_convert (GimpImage *gimage,
*/
gint num_cols,
GimpConvertDitherType dither,
gint alpha_dither,
gint remove_dups,
gboolean alpha_dither,
gboolean remove_dups,
GimpConvertPaletteType palette_type,
GimpPalette *custom_palette)
{
@ -800,7 +801,7 @@ gimp_image_convert (GimpImage *gimage,
gimp_image_undo_push_image_colormap (gimage, NULL);
/* initialize the colour conversion routines */
cpercep_init_conversions();
cpercep_init_conversions ();
/* Convert to indexed? Build histogram if necessary. */
if (new_type == GIMP_INDEXED)
@ -810,7 +811,8 @@ gimp_image_convert (GimpImage *gimage,
/* fprintf(stderr, " TO INDEXED(%d) ", num_cols); */
/* don't dither if the input is grayscale and we are simply
mapping every color */
* mapping every color
*/
if (old_type == GIMP_GRAY &&
num_cols == 256 &&
palette_type == GIMP_MAKE_PALETTE)
@ -856,11 +858,9 @@ gimp_image_convert (GimpImage *gimage,
}
}
if (
(old_type == GIMP_RGB) &&
(!needs_quantize) &&
(palette_type == GIMP_MAKE_PALETTE)
)
if (old_type == GIMP_RGB &&
! needs_quantize &&
palette_type == GIMP_MAKE_PALETTE)
{
/* If this is an RGB image, and the user wanted a custom-built
* generated palette, and this image has no more colours than
@ -893,7 +893,7 @@ gimp_image_convert (GimpImage *gimage,
}
if (palette_type == GIMP_MAKE_PALETTE)
qsort (quantobj->cmap, quantobj->actual_number_of_colors, sizeof(Color),
qsort (quantobj->cmap, quantobj->actual_number_of_colors, sizeof (Color),
color_quicksort);
}
@ -1017,6 +1017,7 @@ gimp_image_convert (GimpImage *gimage,
gimage->cmap[j] = new_palette[j]; j++;
gimage->cmap[j] = new_palette[j]; j++;
}
gimage->num_cols = num_entries;
}
else
@ -1029,6 +1030,7 @@ gimp_image_convert (GimpImage *gimage,
gimage->cmap[j++] = quantobj->cmap[i].green;
gimage->cmap[j++] = quantobj->cmap[i].blue;
}
gimage->num_cols = quantobj->actual_number_of_colors;
}
break;
@ -1258,7 +1260,7 @@ zero_histogram_rgb (CFHistogram histogram)
static void
generate_histogram_gray (CFHistogram histogram,
GimpLayer *layer,
int alpha_dither)
gboolean alpha_dither)
{
PixelRegion srcPR;
guchar *data;
@ -1292,8 +1294,8 @@ generate_histogram_gray (CFHistogram histogram,
static void
generate_histogram_rgb (CFHistogram histogram,
GimpLayer *layer,
int col_limit,
int alpha_dither)
gint col_limit,
gboolean alpha_dither)
{
PixelRegion srcPR;
guchar *data;
@ -2867,7 +2869,7 @@ median_cut_pass2_no_dither_gray (QuantizeObj *quantobj,
gint pixel;
gint has_alpha;
gulong *index_used_count = quantobj->index_used_count;
gint alpha_dither = quantobj->want_alpha_dither;
gboolean alpha_dither = quantobj->want_alpha_dither;
gint offsetx, offsety;
gpointer pr;
@ -2943,7 +2945,7 @@ median_cut_pass2_fixed_dither_gray (QuantizeObj *quantobj,
gint re, R;
gulong *index_used_count = quantobj->index_used_count;
gboolean has_alpha;
gint alpha_dither = quantobj->want_alpha_dither;
gboolean alpha_dither = quantobj->want_alpha_dither;
gint offsetx, offsety;
gpointer pr;
@ -3035,7 +3037,7 @@ median_cut_pass2_no_dither_rgb (QuantizeObj *quantobj,
gint green_pix = GREEN_PIX;
gint blue_pix = BLUE_PIX;
gint alpha_pix = ALPHA_PIX;
gint alpha_dither = quantobj->want_alpha_dither;
gboolean alpha_dither = quantobj->want_alpha_dither;
gint offsetx, offsety;
gulong *index_used_count = quantobj->index_used_count;
@ -3124,7 +3126,7 @@ median_cut_pass2_fixed_dither_rgb (QuantizeObj *quantobj,
gint green_pix = GREEN_PIX;
gint blue_pix = BLUE_PIX;
gint alpha_pix = ALPHA_PIX;
gint alpha_dither = quantobj->want_alpha_dither;
gboolean alpha_dither = quantobj->want_alpha_dither;
gint offsetx, offsety;
gulong *index_used_count = quantobj->index_used_count;
@ -3232,7 +3234,7 @@ median_cut_pass2_nodestruct_dither_rgb (QuantizeObj *quantobj,
guchar *src, *dest;
gint row, col;
gboolean has_alpha;
gint alpha_dither = quantobj->want_alpha_dither;
gboolean alpha_dither = quantobj->want_alpha_dither;
gpointer pr;
gint red_pix = RED_PIX;
gint green_pix = GREEN_PIX;
@ -3437,7 +3439,7 @@ median_cut_pass2_fs_dither_gray (QuantizeObj *quantobj,
gint odd_row;
gboolean has_alpha;
gint offsetx, offsety;
gint alpha_dither = quantobj->want_alpha_dither;
gboolean alpha_dither = quantobj->want_alpha_dither;
gint width, height;
gulong *index_used_count = quantobj->index_used_count;
@ -3663,7 +3665,7 @@ median_cut_pass2_fs_dither_rgb (QuantizeObj *quantobj,
gint blue_pix = BLUE_PIX;
gint alpha_pix = ALPHA_PIX;
gint offsetx, offsety;
gint alpha_dither = quantobj->want_alpha_dither;
gboolean alpha_dither = quantobj->want_alpha_dither;
gulong *index_used_count = quantobj->index_used_count;
gint global_rmax = 0, global_rmin = G_MAXINT;
gint global_gmax = 0, global_gmin = G_MAXINT;
@ -3977,12 +3979,12 @@ delete_median_cut (QuantizeObj *quantobj)
/**************************************************************/
static QuantizeObj*
initialize_median_cut (int type,
int num_colors,
static QuantizeObj *
initialize_median_cut (GimpImageBaseType type,
gint num_colors,
GimpConvertDitherType dither_type,
GimpConvertPaletteType palette_type,
int want_alpha_dither)
gboolean want_alpha_dither)
{
QuantizeObj * quantobj;
@ -4023,6 +4025,7 @@ initialize_median_cut (int type,
if (palette_type == GIMP_WEB_PALETTE ||
palette_type == GIMP_MONO_PALETTE ||
palette_type == GIMP_CUSTOM_PALETTE)
{
switch (dither_type)
{
case GIMP_NODESTRUCT_DITHER:
@ -4047,7 +4050,9 @@ initialize_median_cut (int type,
quantobj->second_pass = median_cut_pass2_fixed_dither_rgb;
break;
}
}
else
{
switch (dither_type)
{
case GIMP_NODESTRUCT_DITHER:
@ -4072,7 +4077,9 @@ initialize_median_cut (int type,
quantobj->second_pass = median_cut_pass2_fixed_dither_gray;
break;
}
}
break;
case GIMP_RGB:
switch (palette_type)
{
@ -4117,6 +4124,9 @@ initialize_median_cut (int type,
break;
}
break;
default:
break;
}
quantobj->delete_func = delete_median_cut;

View File

@ -30,8 +30,8 @@ void gimp_image_convert (GimpImage *gimage,
*/
gint num_cols,
GimpConvertDitherType dither,
gint alpha_dither,
gint remove_dups,
gboolean alpha_dither,
gboolean remove_dups,
GimpConvertPaletteType palette_type,
GimpPalette *custom_palette);

View File

@ -85,7 +85,7 @@ convert_to_rgb (GimpImage *gimage)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gimp_image_convert (gimage, GIMP_RGB, 0, 0, 0, 0, 0, NULL);
gimp_image_convert (gimage, GIMP_RGB, 0, 0, FALSE, FALSE, 0, NULL);
gimp_image_flush (gimage);
}
@ -94,7 +94,7 @@ convert_to_grayscale (GimpImage* gimage)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gimp_image_convert (gimage, GIMP_GRAY, 0, 0, 0, 0, 0, NULL);
gimp_image_convert (gimage, GIMP_GRAY, 0, 0, FALSE, FALSE, 0, NULL);
gimp_image_flush (gimage);
}

View File

@ -85,7 +85,7 @@ convert_to_rgb (GimpImage *gimage)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gimp_image_convert (gimage, GIMP_RGB, 0, 0, 0, 0, 0, NULL);
gimp_image_convert (gimage, GIMP_RGB, 0, 0, FALSE, FALSE, 0, NULL);
gimp_image_flush (gimage);
}
@ -94,7 +94,7 @@ convert_to_grayscale (GimpImage* gimage)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gimp_image_convert (gimage, GIMP_GRAY, 0, 0, 0, 0, 0, NULL);
gimp_image_convert (gimage, GIMP_GRAY, 0, 0, FALSE, FALSE, 0, NULL);
gimp_image_flush (gimage);
}

View File

@ -59,8 +59,12 @@ image_convert_rgb_invoker (Gimp *gimp,
success = FALSE;
if (success)
if ((success = (gimp_image_base_type (gimage) != GIMP_RGB)))
gimp_image_convert ((void *) gimage, GIMP_RGB, 0, 0, 0, 1, 0, NULL);
{
if (gimp_image_base_type (gimage) != GIMP_RGB)
gimp_image_convert (gimage, GIMP_RGB, 0, 0, FALSE, FALSE, 0, NULL);
else
success = FALSE;
}
return procedural_db_return_args (&image_convert_rgb_proc, success);
}
@ -102,8 +106,12 @@ image_convert_grayscale_invoker (Gimp *gimp,
success = FALSE;
if (success)
if ((success = (gimp_image_base_type (gimage) != GIMP_GRAY)))
gimp_image_convert ((void *) gimage, GIMP_GRAY, 0, 0, 0, 1, 0, NULL);
{
if (gimp_image_base_type (gimage) != GIMP_GRAY)
gimp_image_convert (gimage, GIMP_GRAY, 0, 0, FALSE, FALSE, 0, NULL);
else
success = FALSE;
}
return procedural_db_return_args (&image_convert_grayscale_proc, success);
}
@ -155,6 +163,8 @@ image_convert_indexed_invoker (Gimp *gimp,
success = FALSE;
palette_type = args[2].value.pdb_int;
if (palette_type < GIMP_MAKE_PALETTE || palette_type > GIMP_CUSTOM_PALETTE)
success = FALSE;
num_cols = args[3].value.pdb_int;
@ -170,20 +180,8 @@ image_convert_indexed_invoker (Gimp *gimp,
{
GimpPalette *palette = NULL;
if ((success = (gimp_image_base_type (gimage) != GIMP_INDEXED)))
if (gimp_image_base_type (gimage) != GIMP_INDEXED)
{
switch (dither_type)
{
case GIMP_NO_DITHER:
case GIMP_FS_DITHER:
case GIMP_FSLOWBLEED_DITHER:
case GIMP_FIXED_DITHER:
break;
default:
success = FALSE;
break;
}
switch (palette_type)
{
case GIMP_MAKE_PALETTE:
@ -191,11 +189,6 @@ image_convert_indexed_invoker (Gimp *gimp,
success = FALSE;
break;
case GIMP_REUSE_PALETTE:
case GIMP_WEB_PALETTE:
case GIMP_MONO_PALETTE:
break;
case GIMP_CUSTOM_PALETTE:
if (! gimp->palette_factory->container->num_children)
gimp_data_factory_data_init (gimp->palette_factory, FALSE);
@ -210,9 +203,13 @@ image_convert_indexed_invoker (Gimp *gimp,
break;
default:
success = FALSE;
break;
}
}
else
{
success = FALSE;
}
if (success)
gimp_image_convert (gimage, GIMP_INDEXED, num_cols, dither_type,
@ -232,7 +229,7 @@ static ProcArg image_convert_indexed_inargs[] =
{
GIMP_PDB_INT32,
"dither_type",
"dither type (0=none, 1=fs, 2=fs/low-bleed 3=fixed)"
"The dither type to use: { GIMP_NO_DITHER (0), GIMP_FS_DITHER (1), GIMP_FSLOWBLEED_DITHER (2), GIMP_FIXED_DITHER (3) }"
},
{
GIMP_PDB_INT32,
@ -242,17 +239,17 @@ static ProcArg image_convert_indexed_inargs[] =
{
GIMP_PDB_INT32,
"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_MAKE_PALETTE)"
},
{
GIMP_PDB_INT32,
"alpha_dither",
"dither transparency to fake partial opacity"
"Dither transparency to fake partial opacity"
},
{
GIMP_PDB_INT32,
"remove_unused",
"remove unused or duplicate colour entries from final palette, ignored if (palette_type == GIMP_MAKE_PALETTE)"
"Remove unused or duplicate colour entries from final palette, ignored if (palette_type == GIMP_MAKE_PALETTE)"
},
{
GIMP_PDB_STRING,

View File

@ -91,11 +91,11 @@ gimp_image_convert_grayscale (gint32 image_ID)
/**
* gimp_image_convert_indexed:
* @image_ID: The image.
* @dither_type: dither type (0=none, 1=fs, 2=fs/low-bleed 3=fixed).
* @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).
* @alpha_dither: dither transparency to fake partial opacity.
* @remove_unused: remove unused or duplicate colour entries from final palette, ignored if (palette_type == GIMP_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.
* @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 == GIMP_CUSTOM_PALETTE).
*
* Convert specified image to and Indexed image

View File

@ -27,8 +27,12 @@ sub simple_invoke {
my $type = shift;
%invoke = (
code => <<CODE
if ((success = (gimp_image_base_type (gimage) != $type)))
gimp_image_convert ((void *) gimage, $type, 0, 0, 0, 1, 0, NULL);
{
if (gimp_image_base_type (gimage) != $type)
gimp_image_convert (gimage, $type, 0, 0, FALSE, FALSE, 0, NULL);
else
success = FALSE;
}
CODE
);
}
@ -85,16 +89,16 @@ HELP
@inargs = (
&std_image_arg,
{ name => 'dither_type', type => 'enum GimpConvertDitherType',
desc => 'dither type (0=none, 1=fs, 2=fs/low-bleed 3=fixed)' },
desc => 'The dither type to use: { %%desc%% }' },
{ 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%% }' },
{ 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 == GIMP_MAKE_PALETTE)' },
{ name => 'alpha_dither', type => 'boolean',
desc => 'dither transparency to fake partial opacity' },
desc => 'Dither transparency to fake partial opacity' },
{ 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 == GIMP_MAKE_PALETTE)' },
{ name => 'palette', type => 'string',
desc => 'The name of the custom palette to use, ignored unless
@ -107,20 +111,8 @@ HELP
{
GimpPalette *palette = NULL;
if ((success = (gimp_image_base_type (gimage) != GIMP_INDEXED)))
if (gimp_image_base_type (gimage) != GIMP_INDEXED)
{
switch (dither_type)
{
case GIMP_NO_DITHER:
case GIMP_FS_DITHER:
case GIMP_FSLOWBLEED_DITHER:
case GIMP_FIXED_DITHER:
break;
default:
success = FALSE;
break;
}
switch (palette_type)
{
case GIMP_MAKE_PALETTE:
@ -128,11 +120,6 @@ HELP
success = FALSE;
break;
case GIMP_REUSE_PALETTE:
case GIMP_WEB_PALETTE:
case GIMP_MONO_PALETTE:
break;
case GIMP_CUSTOM_PALETTE:
if (! gimp->palette_factory->container->num_children)
gimp_data_factory_data_init (gimp->palette_factory, FALSE);
@ -147,9 +134,13 @@ HELP
break;
default:
success = FALSE;
break;
}
}
else
{
success = FALSE;
}
if (success)
gimp_image_convert (gimage, GIMP_INDEXED, num_cols, dither_type,