app: remove the legacy posterize code

This commit is contained in:
Michael Natterer 2012-03-14 00:09:21 +01:00
parent 70b26d1ecb
commit 7aa7f168b8
5 changed files with 13 additions and 126 deletions

View File

@ -236,52 +236,6 @@ threshold_lut_new (gdouble value,
return lut;
}
/* --------------- posterize ---------------- */
static gfloat
posterize_lut_func (gint *ilevels,
gint n_channels,
gint channel,
gfloat value)
{
gint levels;
/* don't posterize the alpha channel */
if ((n_channels == 2 || n_channels == 4) && channel == n_channels -1)
return value;
if (*ilevels < 2)
levels = 2;
else
levels = *ilevels;
value = RINT (value * (levels - 1.0)) / (levels - 1.0);
return value;
}
void
posterize_lut_setup (GimpLut *lut,
gint levels,
gint n_channels)
{
g_return_if_fail (lut != NULL);
gimp_lut_setup_exact (lut,
(GimpLutFunc) posterize_lut_func, &levels, n_channels);
}
GimpLut *
posterize_lut_new (gint levels,
gint n_channels)
{
GimpLut *lut = gimp_lut_new ();
posterize_lut_setup (lut, levels, n_channels);
return lut;
}
/* --------------- equalize ------------- */
typedef struct

View File

@ -38,12 +38,6 @@ GimpLut * intersect_lut_new (gdouble value,
GimpLut * threshold_lut_new (gdouble value,
gint n_channels);
GimpLut * posterize_lut_new (gint levels,
gint n_channels);
void posterize_lut_setup (GimpLut *lut,
gint levels,
gint n_channels);
GimpLut * equalize_lut_new (GimpHistogram *histogram,
gint n_channels);

View File

@ -21,19 +21,11 @@
#include "core-types.h"
#include "base/gimplut.h"
#include "base/lut-funcs.h"
#include "gegl/gimpposterizeconfig.h"
/* temp */
#include "gimp.h"
#include "gimpimage.h"
#include "gimpdrawable.h"
#include "gimpdrawable-operation.h"
#include "gimpdrawable-posterize.h"
#include "gimpdrawable-process.h"
#include "gimp-intl.h"
@ -45,40 +37,28 @@ gimp_drawable_posterize (GimpDrawable *drawable,
GimpProgress *progress,
gint levels)
{
GimpPosterizeConfig *config;
GeglNode *node;
GObject *config;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (! gimp_drawable_is_indexed (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp:posterize",
NULL);
config = g_object_new (GIMP_TYPE_POSTERIZE_CONFIG,
"levels", levels,
NULL);
if (gimp_use_gegl (gimp_item_get_image (GIMP_ITEM (drawable))->gimp))
{
GeglNode *node;
node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp:posterize",
NULL);
gegl_node_set (node,
"config", config,
NULL);
gimp_drawable_apply_operation (drawable, progress, _("Posterize"),
node, TRUE);
g_object_unref (node);
}
else
{
GimpLut *lut;
lut = posterize_lut_new (config->levels, gimp_drawable_bytes (drawable));
gimp_drawable_process_lut (drawable, progress, _("Posterize"), lut);
gimp_lut_free (lut);
}
gegl_node_set (node,
"config", config,
NULL);
g_object_unref (config);
gimp_drawable_apply_operation (drawable, progress, _("Posterize"),
node, TRUE);
g_object_unref (node);
}

View File

@ -26,9 +26,6 @@
#include "tools-types.h"
#include "base/gimplut.h"
#include "base/lut-funcs.h"
#include "gegl/gimpposterizeconfig.h"
#include "core/gimpdrawable.h"
@ -48,15 +45,12 @@
#define SLIDER_WIDTH 200
static void gimp_posterize_tool_finalize (GObject *object);
static gboolean gimp_posterize_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static GeglNode * gimp_posterize_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config);
static void gimp_posterize_tool_map (GimpImageMapTool *im_tool);
static void gimp_posterize_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_posterize_tool_config_notify (GObject *object,
@ -92,44 +86,20 @@ gimp_posterize_tool_register (GimpToolRegisterCallback callback,
static void
gimp_posterize_tool_class_init (GimpPosterizeToolClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
object_class->finalize = gimp_posterize_tool_finalize;
tool_class->initialize = gimp_posterize_tool_initialize;
im_tool_class->dialog_desc = _("Posterize (Reduce Number of Colors)");
im_tool_class->get_operation = gimp_posterize_tool_get_operation;
im_tool_class->map = gimp_posterize_tool_map;
im_tool_class->dialog = gimp_posterize_tool_dialog;
}
static void
gimp_posterize_tool_init (GimpPosterizeTool *posterize_tool)
{
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (posterize_tool);
posterize_tool->lut = gimp_lut_new ();
im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
im_tool->apply_data = posterize_tool->lut;
}
static void
gimp_posterize_tool_finalize (GObject *object)
{
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (object);
if (posterize_tool->lut)
{
gimp_lut_free (posterize_tool->lut);
posterize_tool->lut = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gboolean
@ -194,16 +164,6 @@ gimp_posterize_tool_get_operation (GimpImageMapTool *image_map_tool,
return node;
}
static void
gimp_posterize_tool_map (GimpImageMapTool *image_map_tool)
{
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
posterize_lut_setup (posterize_tool->lut,
posterize_tool->config->levels,
gimp_drawable_bytes (image_map_tool->drawable));
}
/**********************/
/* Posterize dialog */

View File

@ -38,7 +38,6 @@ struct _GimpPosterizeTool
GimpImageMapTool parent_instance;
GimpPosterizeConfig *config;
GimpLut *lut;
/* dialog */
GtkAdjustment *levels_data;