minor cleanup.

2008-04-04  Sven Neumann  <sven@gimp.org>

	* app/core/gimpimage-convert.[ch]
	(gimp_image_convert_set_dither_matrix): minor cleanup.

	* tools/pdbgen/pdb/convert.pdb: changed accordingly.

	* app/pdb/convert_cmds.c: regenerated.


svn path=/trunk/; revision=25353
This commit is contained in:
Sven Neumann 2008-04-04 06:29:35 +00:00 committed by Sven Neumann
parent 953a62b63d
commit 6f2e776871
5 changed files with 53 additions and 32 deletions

View File

@ -1,3 +1,12 @@
2008-04-04 Sven Neumann <sven@gimp.org>
* app/core/gimpimage-convert.[ch]
(gimp_image_convert_set_dither_matrix): minor cleanup.
* tools/pdbgen/pdb/convert.pdb: changed accordingly.
* app/pdb/convert_cmds.c: regenerated.
2008-04-03 Michael Natterer <mitch@gimp.org>
* app/pdb/gimppdb-utils.c

View File

@ -4157,18 +4157,18 @@ delete_median_cut (QuantizeObj *quantobj)
void
gimp_image_convert_set_dither_matrix (gint width,
gint height,
const guchar *source)
gimp_image_convert_set_dither_matrix (const guchar *matrix,
gint width,
gint height)
{
gint x;
gint y;
/* if source is invalid, restore the default matrix */
if (source == NULL || width == 0 || height == 0)
/* if matrix is invalid, restore the default matrix */
if (matrix == NULL || width == 0 || height == 0)
{
source = (guchar *) (&DM_ORIGINAL);
width = DM_WIDTH;
matrix = (const guchar *) DM_ORIGINAL;
width = DM_WIDTH;
height = DM_HEIGHT;
}
@ -4179,8 +4179,8 @@ gimp_image_convert_set_dither_matrix (gint width,
{
for (x = 0; x < DM_WIDTH; x++)
{
DM[x][y] = source[((x % width) * height) + (y % height)];
}
DM[x][y] = matrix[((x % width) * height) + (y % height)];
}
}
}

View File

@ -37,9 +37,9 @@ gboolean gimp_image_convert (GimpImage *image,
GimpProgress *progress,
GError **error);
void gimp_image_convert_set_dither_matrix (gint width,
gint height,
const guchar *source);
void gimp_image_convert_set_dither_matrix (const guchar *matrix,
gint width,
gint height);
#endif /* __GIMP_IMAGE_CONVERT_H__ */

View File

@ -54,7 +54,8 @@ image_convert_rgb_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_image_base_type (image) != GIMP_RGB)
success = gimp_image_convert (image, GIMP_RGB, 0, 0, FALSE, FALSE, 0, NULL,
success = gimp_image_convert (image, GIMP_RGB,
0, 0, FALSE, FALSE, 0, NULL,
NULL, error);
else
success = FALSE;
@ -79,7 +80,8 @@ image_convert_grayscale_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp_image_base_type (image) != GIMP_GRAY)
success = gimp_image_convert (image, GIMP_GRAY, 0, 0, FALSE, FALSE, 0, NULL,
success = gimp_image_convert (image, GIMP_GRAY,
0, 0, FALSE, FALSE, 0, NULL,
NULL, error);
else
success = FALSE;
@ -115,7 +117,7 @@ image_convert_indexed_invoker (GimpProcedure *procedure,
if (success)
{
GimpPalette *pal = NULL;
GimpPalette *palette = NULL;
if (gimp_image_base_type (image) != GIMP_INDEXED)
{
@ -127,12 +129,12 @@ image_convert_indexed_invoker (GimpProcedure *procedure,
break;
case GIMP_CUSTOM_PALETTE:
pal = gimp_pdb_get_palette (gimp, palette, FALSE, error);
if (! pal)
palette = gimp_pdb_get_palette (gimp, palette, FALSE, error);
if (! palette)
{
success = FALSE;
}
else if (pal->n_colors > 256)
else if (palette->n_colors > MAXNUMCOLORS)
{
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_INVALID_ARGUMENT,
_("Cannot convert to a palette "
@ -146,11 +148,15 @@ image_convert_indexed_invoker (GimpProcedure *procedure,
}
}
else
success = FALSE;
{
success = FALSE;
}
if (success)
success = gimp_image_convert (image, GIMP_INDEXED, num_cols, dither_type,
alpha_dither, remove_unused, palette_type, pal,
success = gimp_image_convert (image, GIMP_INDEXED,
num_cols, dither_type,
alpha_dither, remove_unused,
palette_type, palette,
NULL, error);
}
@ -178,7 +184,7 @@ image_convert_set_dither_matrix_invoker (GimpProcedure *procedure,
if (success)
{
gimp_image_convert_set_dither_matrix (width, height, (guchar *) matrix);
gimp_image_convert_set_dither_matrix (matrix, width, height);
}
return gimp_procedure_get_return_values (procedure, success);

View File

@ -37,7 +37,8 @@ HELP
code => <<'CODE'
{
if (gimp_image_base_type (image) != GIMP_RGB)
success = gimp_image_convert (image, GIMP_RGB, 0, 0, FALSE, FALSE, 0, NULL,
success = gimp_image_convert (image, GIMP_RGB,
0, 0, FALSE, FALSE, 0, NULL,
NULL, error);
else
success = FALSE;
@ -66,7 +67,8 @@ HELP
code => <<'CODE'
{
if (gimp_image_base_type (image) != GIMP_GRAY)
success = gimp_image_convert (image, GIMP_GRAY, 0, 0, FALSE, FALSE, 0, NULL,
success = gimp_image_convert (image, GIMP_GRAY,
0, 0, FALSE, FALSE, 0, NULL,
NULL, error);
else
success = FALSE;
@ -119,7 +121,7 @@ HELP
%invoke = (
code => <<'CODE'
{
GimpPalette *pal = NULL;
GimpPalette *palette = NULL;
if (gimp_image_base_type (image) != GIMP_INDEXED)
{
@ -131,12 +133,12 @@ HELP
break;
case GIMP_CUSTOM_PALETTE:
pal = gimp_pdb_get_palette (gimp, palette, FALSE, error);
if (! pal)
palette = gimp_pdb_get_palette (gimp, palette, FALSE, error);
if (! palette)
{
success = FALSE;
}
else if (pal->n_colors > 256)
else if (palette->n_colors > MAXNUMCOLORS)
{
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_INVALID_ARGUMENT,
_("Cannot convert to a palette "
@ -150,11 +152,15 @@ HELP
}
}
else
success = FALSE;
{
success = FALSE;
}
if (success)
success = gimp_image_convert (image, GIMP_INDEXED, num_cols, dither_type,
alpha_dither, remove_unused, palette_type, pal,
success = gimp_image_convert (image, GIMP_INDEXED,
num_cols, dither_type,
alpha_dither, remove_unused,
palette_type, palette,
NULL, error);
}
CODE
@ -186,7 +192,7 @@ HELP
%invoke = (
code => <<'CODE'
{
gimp_image_convert_set_dither_matrix (width, height, (guchar *) matrix);
gimp_image_convert_set_dither_matrix (matrix, width, height);
}
CODE
);