app: move indexed conversion to gimpimage-convert-indexed.[ch]

It's so much code and takes so many additional parameters over RGB and
GRAY conversion, it got its own place and function now.
This commit is contained in:
Michael Natterer 2016-04-29 10:34:03 +02:00
parent 4086932e8d
commit ef8b802032
10 changed files with 4584 additions and 4477 deletions

View File

@ -195,9 +195,7 @@ image_convert_base_type_cmd_callback (GtkAction *action,
if (dialog)
gtk_widget_destroy (dialog);
if (! gimp_image_convert_type (image, value,
0, 0, FALSE, FALSE, FALSE, 0, NULL,
NULL, &error))
if (! gimp_image_convert_type (image, value, NULL, &error))
{
gimp_message_literal (image->gimp,
G_OBJECT (widget), GIMP_MESSAGE_WARNING,

View File

@ -218,6 +218,8 @@ libappcore_a_sources = \
gimpimage-color-profile.h \
gimpimage-colormap.c \
gimpimage-colormap.h \
gimpimage-convert-indexed.c \
gimpimage-convert-indexed.h \
gimpimage-convert-fsdither.h \
gimpimage-convert-data.h \
gimpimage-convert-precision.c \

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,41 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_IMAGE_CONVERT_INDEXED_H__
#define __GIMP_IMAGE_CONVERT_INDEXED_H__
#define MAXNUMCOLORS 256
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,
GimpPalette *custom_palette,
GimpProgress *progress,
GError **error);
void gimp_image_convert_indexed_set_dither_matrix (const guchar *matrix,
gint width,
gint height);
#endif /* __GIMP_IMAGE_CONVERT_INDEXED_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -19,27 +19,10 @@
#define __GIMP_IMAGE_CONVERT_TYPE_H__
#define MAXNUMCOLORS 256
gboolean gimp_image_convert_type (GimpImage *image,
GimpImageBaseType new_type,
/* The following params used only for
* new_type == GIMP_INDEXED
*/
gint num_cols,
GimpConvertDitherType dither,
gboolean alpha_dither,
gboolean text_layer_dither,
gboolean remove_dups,
GimpConvertPaletteType palette_type,
GimpPalette *custom_palette,
GimpProgress *progress,
GError **error);
void gimp_image_convert_type_set_dither_matrix (const guchar *matrix,
gint width,
gint height);
gboolean gimp_image_convert_type (GimpImage *image,
GimpImageBaseType new_type,
GimpProgress *progress,
GError **error);
#endif /* __GIMP_IMAGE_CONVERT_TYPE_H__ */

View File

@ -29,7 +29,7 @@
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "core/gimpimage.h"
#include "core/gimpimage-convert-type.h"
#include "core/gimpimage-convert-indexed.h"
#include "core/gimplist.h"
#include "core/gimppalette.h"
#include "core/gimpprogress.h"
@ -309,16 +309,15 @@ convert_dialog_response (GtkWidget *widget,
_("Converting to indexed colors"));
/* Convert the image to indexed color */
if (! gimp_image_convert_type (dialog->image,
GIMP_INDEXED,
dialog->num_colors,
dialog->dither_type,
dialog->alpha_dither,
dialog->text_layer_dither,
dialog->remove_dups,
dialog->palette_type,
dialog->custom_palette,
progress, &error))
if (! gimp_image_convert_indexed (dialog->image,
dialog->num_colors,
dialog->dither_type,
dialog->alpha_dither,
dialog->text_layer_dither,
dialog->remove_dups,
dialog->palette_type,
dialog->custom_palette,
progress, &error))
{
gimp_message_literal (dialog->image->gimp, G_OBJECT (dialog->dialog),
GIMP_MESSAGE_WARNING, error->message);

View File

@ -28,6 +28,7 @@
#include "pdb-types.h"
#include "core/gimp.h"
#include "core/gimpimage-convert-indexed.h"
#include "core/gimpimage-convert-precision.h"
#include "core/gimpimage-convert-type.h"
#include "core/gimpimage.h"
@ -63,9 +64,7 @@ image_convert_rgb_invoker (GimpProcedure *procedure,
{
if (gimp_pdb_image_is_not_base_type (image, GIMP_RGB, error))
{
success = gimp_image_convert_type (image, GIMP_RGB,
0, 0, FALSE, FALSE, FALSE, 0, NULL,
NULL, error);
success = gimp_image_convert_type (image, GIMP_RGB, NULL, error);
}
else
{
@ -94,9 +93,7 @@ image_convert_grayscale_invoker (GimpProcedure *procedure,
{
if (gimp_pdb_image_is_not_base_type (image, GIMP_GRAY, error))
{
success = gimp_image_convert_type (image, GIMP_GRAY,
0, 0, FALSE, FALSE, FALSE, 0, NULL,
NULL, error);
success = gimp_image_convert_type (image, GIMP_GRAY, NULL, error);
}
else
{
@ -175,11 +172,11 @@ image_convert_indexed_invoker (GimpProcedure *procedure,
}
if (success)
success = gimp_image_convert_type (image, GIMP_INDEXED,
num_cols, dither_type,
alpha_dither, FALSE, remove_unused,
palette_type, pal,
NULL, error);
success = gimp_image_convert_indexed (image,
num_cols, dither_type,
alpha_dither, FALSE, remove_unused,
palette_type, pal,
NULL, error);
}
return gimp_procedure_get_return_values (procedure, success,
@ -209,7 +206,7 @@ image_convert_set_dither_matrix_invoker (GimpProcedure *procedure,
{
if (width == 0 || height == 0 || matrix_length == width * height)
{
gimp_image_convert_type_set_dither_matrix (matrix, width, height);
gimp_image_convert_indexed_set_dither_matrix (matrix, width, height);
}
else
{

View File

@ -141,6 +141,7 @@ app/core/gimpimage.c
app/core/gimpimage-arrange.c
app/core/gimpimage-color-profile.c
app/core/gimpimage-colormap.c
app/core/gimpimage-convert-indexed.c
app/core/gimpimage-convert-precision.c
app/core/gimpimage-convert-type.c
app/core/gimpimage-crop.c

View File

@ -37,9 +37,7 @@ HELP
{
if (gimp_pdb_image_is_not_base_type (image, GIMP_RGB, error))
{
success = gimp_image_convert_type (image, GIMP_RGB,
0, 0, FALSE, FALSE, FALSE, 0, NULL,
NULL, error);
success = gimp_image_convert_type (image, GIMP_RGB, NULL, error);
}
else
{
@ -71,9 +69,7 @@ HELP
{
if (gimp_pdb_image_is_not_base_type (image, GIMP_GRAY, error))
{
success = gimp_image_convert_type (image, GIMP_GRAY,
0, 0, FALSE, FALSE, FALSE, 0, NULL,
NULL, error);
success = gimp_image_convert_type (image, GIMP_GRAY, NULL, error);
}
else
{
@ -168,11 +164,11 @@ HELP
}
if (success)
success = gimp_image_convert_type (image, GIMP_INDEXED,
num_cols, dither_type,
alpha_dither, FALSE, remove_unused,
palette_type, pal,
NULL, error);
success = gimp_image_convert_indexed (image,
num_cols, dither_type,
alpha_dither, FALSE, remove_unused,
palette_type, pal,
NULL, error);
}
CODE
);
@ -205,7 +201,7 @@ HELP
{
if (width == 0 || height == 0 || matrix_length == width * height)
{
gimp_image_convert_type_set_dither_matrix (matrix, width, height);
gimp_image_convert_indexed_set_dither_matrix (matrix, width, height);
}
else
{
@ -259,6 +255,7 @@ CODE
@headers = qw("core/gimp.h"
"core/gimpimage.h"
"core/gimpimage-convert-indexed.h"
"core/gimpimage-convert-precision.h"
"core/gimpimage-convert-type.h"
"core/gimpitemstack.h"