app: remove the legacy colorize code

This commit is contained in:
Michael Natterer
2012-03-14 00:44:46 +01:00
parent e3c720ad20
commit aa07344d56
8 changed files with 13 additions and 275 deletions

View File

@ -26,8 +26,6 @@ libappbase_a_SOURCES = \
boundary.h \
color-balance.c \
color-balance.h \
colorize.c \
colorize.h \
cpercep.c \
cpercep.h \
curves.c \

View File

@ -1,134 +0,0 @@
/* 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/>.
*/
#include "config.h"
#include <cairo.h>
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
#include "base-types.h"
#include "colorize.h"
#include "pixel-region.h"
void
colorize_init (Colorize *colorize)
{
gint i;
g_return_if_fail (colorize != NULL);
colorize->hue = 180.0;
colorize->saturation = 50.0;
colorize->lightness = 0.0;
for (i = 0; i < 256; i ++)
{
colorize->lum_red_lookup[i] = i * GIMP_RGB_LUMINANCE_RED;
colorize->lum_green_lookup[i] = i * GIMP_RGB_LUMINANCE_GREEN;
colorize->lum_blue_lookup[i] = i * GIMP_RGB_LUMINANCE_BLUE;
}
}
void
colorize_calculate (Colorize *colorize)
{
GimpHSL hsl;
GimpRGB rgb;
gint i;
g_return_if_fail (colorize != NULL);
hsl.h = colorize->hue / 360.0;
hsl.s = colorize->saturation / 100.0;
/* Calculate transfers */
for (i = 0; i < 256; i ++)
{
hsl.l = (gdouble) i / 255.0;
gimp_hsl_to_rgb (&hsl, &rgb);
/* this used to read i * rgb.r,g,b in GIMP 2.4, but this produced
* darkened results, multiplying with 255 is correct and preserves
* the lightness unless modified with the slider.
*/
colorize->final_red_lookup[i] = 255.0 * rgb.r;
colorize->final_green_lookup[i] = 255.0 * rgb.g;
colorize->final_blue_lookup[i] = 255.0 * rgb.b;
}
}
void
colorize (Colorize *colorize,
PixelRegion *srcPR,
PixelRegion *destPR)
{
const guchar *src, *s;
guchar *dest, *d;
gboolean alpha;
gint w, h;
gint lum;
/* Set the transfer arrays (for speed) */
h = srcPR->h;
src = srcPR->data;
dest = destPR->data;
alpha = pixel_region_has_alpha (srcPR);
while (h--)
{
w = srcPR->w;
s = src;
d = dest;
while (w--)
{
lum = (colorize->lum_red_lookup[s[RED]] +
colorize->lum_green_lookup[s[GREEN]] +
colorize->lum_blue_lookup[s[BLUE]]); /* luminosity */
if (colorize->lightness > 0)
{
lum = (gdouble) lum * (100.0 - colorize->lightness) / 100.0;
lum += 255 - (100.0 - colorize->lightness) * 255.0 / 100.0;
}
else if (colorize->lightness < 0)
{
lum = (gdouble) lum * (colorize->lightness + 100.0) / 100.0;
}
d[RED] = colorize->final_red_lookup[lum];
d[GREEN] = colorize->final_green_lookup[lum];
d[BLUE] = colorize->final_blue_lookup[lum];
if (alpha)
d[ALPHA] = s[ALPHA];
s += srcPR->bytes;
d += destPR->bytes;
}
src += srcPR->rowstride;
dest += destPR->rowstride;
}
}

View File

@ -1,45 +0,0 @@
/* 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 __COLORIZE_H__
#define __COLORIZE_H__
struct _Colorize
{
gdouble hue;
gdouble saturation;
gdouble lightness;
gint lum_red_lookup[256];
gint lum_green_lookup[256];
gint lum_blue_lookup[256];
gint final_red_lookup[256];
gint final_green_lookup[256];
gint final_blue_lookup[256];
};
void colorize_init (Colorize *colorize);
void colorize_calculate (Colorize *colorize);
void colorize (Colorize *colorize,
PixelRegion *srcPR,
PixelRegion *destPR);
#endif /* __COLORIZE_H__ */

View File

@ -21,18 +21,11 @@
#include "core-types.h"
#include "base/colorize.h"
#include "gegl/gimpcolorizeconfig.h"
/* temp */
#include "gimp.h"
#include "gimpimage.h"
#include "gimpdrawable.h"
#include "gimpdrawable-operation.h"
#include "gimpdrawable-colorize.h"
#include "gimpdrawable-process.h"
#include "gimp-intl.h"
@ -46,44 +39,30 @@ gimp_drawable_colorize (GimpDrawable *drawable,
gdouble saturation,
gdouble lightness)
{
GimpColorizeConfig *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:colorize",
NULL);
config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG,
"hue", hue / 360.0,
"saturation", saturation / 100.0,
"lightness", lightness / 100.0,
NULL);
if (gimp_use_gegl (gimp_item_get_image (GIMP_ITEM (drawable))->gimp))
{
GeglNode *node;
node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp:colorize",
NULL);
gegl_node_set (node,
"config", config,
NULL);
gimp_drawable_apply_operation (drawable, progress, C_("undo-type", "Colorize"),
node, TRUE);
g_object_unref (node);
}
else
{
Colorize cruft;
colorize_init (&cruft);
gimp_colorize_config_to_cruft (config, &cruft);
gimp_drawable_process (drawable, progress, C_("undo-type", "Colorize"),
(PixelProcessorFunc) colorize, &cruft);
}
gegl_node_set (node,
"config", config,
NULL);
g_object_unref (config);
gimp_drawable_apply_operation (drawable, progress, C_("undo-type", "Colorize"),
node, TRUE);
g_object_unref (node);
}

View File

@ -26,9 +26,6 @@
#include "gimp-gegl-types.h"
/* temp cruft */
#include "base/colorize.h"
#include "gimpcolorizeconfig.h"
@ -145,20 +142,3 @@ gimp_colorize_config_set_property (GObject *object,
break;
}
}
/* temp cruft */
void
gimp_colorize_config_to_cruft (GimpColorizeConfig *config,
Colorize *cruft)
{
g_return_if_fail (GIMP_IS_COLORIZE_CONFIG (config));
g_return_if_fail (cruft != NULL);
cruft->hue = config->hue * 360.0;
cruft->saturation = config->saturation * 100.0;
cruft->lightness = config->lightness * 100.0;
colorize_calculate (cruft);
}

View File

@ -52,9 +52,5 @@ struct _GimpColorizeConfigClass
GType gimp_colorize_config_get_type (void) G_GNUC_CONST;
/* temp cruft */
void gimp_colorize_config_to_cruft (GimpColorizeConfig *config,
Colorize *cruft);
#endif /* __GIMP_COLORIZE_CONFIG_H__ */

View File

@ -27,8 +27,6 @@
#include "tools-types.h"
#include "base/colorize.h"
#include "gegl/gimpcolorizeconfig.h"
#include "core/gimpdrawable.h"
@ -51,15 +49,12 @@
/* local function prototypes */
static void gimp_colorize_tool_finalize (GObject *object);
static gboolean gimp_colorize_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static GeglNode * gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config);
static void gimp_colorize_tool_map (GimpImageMapTool *im_tool);
static void gimp_colorize_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_colorize_tool_config_notify (GObject *object,
@ -98,12 +93,9 @@ gimp_colorize_tool_register (GimpToolRegisterCallback callback,
static void
gimp_colorize_tool_class_init (GimpColorizeToolClass *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_colorize_tool_finalize;
tool_class->initialize = gimp_colorize_tool_initialize;
im_tool_class->dialog_desc = _("Colorize the Image");
@ -112,31 +104,12 @@ gimp_colorize_tool_class_init (GimpColorizeToolClass *klass)
im_tool_class->export_dialog_title = _("Export Colorize Settings");
im_tool_class->get_operation = gimp_colorize_tool_get_operation;
im_tool_class->map = gimp_colorize_tool_map;
im_tool_class->dialog = gimp_colorize_tool_dialog;
}
static void
gimp_colorize_tool_init (GimpColorizeTool *col_tool)
{
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (col_tool);
col_tool->colorize = g_slice_new0 (Colorize);
colorize_init (col_tool->colorize);
im_tool->apply_func = (GimpImageMapApplyFunc) colorize;
im_tool->apply_data = col_tool->colorize;
}
static void
gimp_colorize_tool_finalize (GObject *object)
{
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (object);
g_slice_free (Colorize, col_tool->colorize);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gboolean
@ -196,14 +169,6 @@ gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool,
return node;
}
static void
gimp_colorize_tool_map (GimpImageMapTool *image_map_tool)
{
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
gimp_colorize_config_to_cruft (col_tool->config, col_tool->colorize);
}
/***************************/
/* Hue-Saturation dialog */

View File

@ -38,7 +38,6 @@ struct _GimpColorizeTool
GimpImageMapTool parent_instance;
GimpColorizeConfig *config;
Colorize *colorize;
/* dialog */
GtkAdjustment *hue_data;