app: remove the legacy colorize code
This commit is contained in:
@ -26,8 +26,6 @@ libappbase_a_SOURCES = \
|
|||||||
boundary.h \
|
boundary.h \
|
||||||
color-balance.c \
|
color-balance.c \
|
||||||
color-balance.h \
|
color-balance.h \
|
||||||
colorize.c \
|
|
||||||
colorize.h \
|
|
||||||
cpercep.c \
|
cpercep.c \
|
||||||
cpercep.h \
|
cpercep.h \
|
||||||
curves.c \
|
curves.c \
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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__ */
|
|
@ -21,18 +21,11 @@
|
|||||||
|
|
||||||
#include "core-types.h"
|
#include "core-types.h"
|
||||||
|
|
||||||
#include "base/colorize.h"
|
|
||||||
|
|
||||||
#include "gegl/gimpcolorizeconfig.h"
|
#include "gegl/gimpcolorizeconfig.h"
|
||||||
|
|
||||||
/* temp */
|
|
||||||
#include "gimp.h"
|
|
||||||
#include "gimpimage.h"
|
|
||||||
|
|
||||||
#include "gimpdrawable.h"
|
#include "gimpdrawable.h"
|
||||||
#include "gimpdrawable-operation.h"
|
#include "gimpdrawable-operation.h"
|
||||||
#include "gimpdrawable-colorize.h"
|
#include "gimpdrawable-colorize.h"
|
||||||
#include "gimpdrawable-process.h"
|
|
||||||
|
|
||||||
#include "gimp-intl.h"
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
@ -46,44 +39,30 @@ gimp_drawable_colorize (GimpDrawable *drawable,
|
|||||||
gdouble saturation,
|
gdouble saturation,
|
||||||
gdouble lightness)
|
gdouble lightness)
|
||||||
{
|
{
|
||||||
GimpColorizeConfig *config;
|
GeglNode *node;
|
||||||
|
GObject *config;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
||||||
g_return_if_fail (! gimp_drawable_is_indexed (drawable));
|
g_return_if_fail (! gimp_drawable_is_indexed (drawable));
|
||||||
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (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,
|
config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG,
|
||||||
"hue", hue / 360.0,
|
"hue", hue / 360.0,
|
||||||
"saturation", saturation / 100.0,
|
"saturation", saturation / 100.0,
|
||||||
"lightness", lightness / 100.0,
|
"lightness", lightness / 100.0,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (gimp_use_gegl (gimp_item_get_image (GIMP_ITEM (drawable))->gimp))
|
gegl_node_set (node,
|
||||||
{
|
"config", config,
|
||||||
GeglNode *node;
|
NULL);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref (config);
|
g_object_unref (config);
|
||||||
|
|
||||||
|
gimp_drawable_apply_operation (drawable, progress, C_("undo-type", "Colorize"),
|
||||||
|
node, TRUE);
|
||||||
|
g_object_unref (node);
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,6 @@
|
|||||||
|
|
||||||
#include "gimp-gegl-types.h"
|
#include "gimp-gegl-types.h"
|
||||||
|
|
||||||
/* temp cruft */
|
|
||||||
#include "base/colorize.h"
|
|
||||||
|
|
||||||
#include "gimpcolorizeconfig.h"
|
#include "gimpcolorizeconfig.h"
|
||||||
|
|
||||||
|
|
||||||
@ -145,20 +142,3 @@ gimp_colorize_config_set_property (GObject *object,
|
|||||||
break;
|
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);
|
|
||||||
}
|
|
||||||
|
@ -52,9 +52,5 @@ struct _GimpColorizeConfigClass
|
|||||||
|
|
||||||
GType gimp_colorize_config_get_type (void) G_GNUC_CONST;
|
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__ */
|
#endif /* __GIMP_COLORIZE_CONFIG_H__ */
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
|
|
||||||
#include "tools-types.h"
|
#include "tools-types.h"
|
||||||
|
|
||||||
#include "base/colorize.h"
|
|
||||||
|
|
||||||
#include "gegl/gimpcolorizeconfig.h"
|
#include "gegl/gimpcolorizeconfig.h"
|
||||||
|
|
||||||
#include "core/gimpdrawable.h"
|
#include "core/gimpdrawable.h"
|
||||||
@ -51,15 +49,12 @@
|
|||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
|
|
||||||
static void gimp_colorize_tool_finalize (GObject *object);
|
|
||||||
|
|
||||||
static gboolean gimp_colorize_tool_initialize (GimpTool *tool,
|
static gboolean gimp_colorize_tool_initialize (GimpTool *tool,
|
||||||
GimpDisplay *display,
|
GimpDisplay *display,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
static GeglNode * gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool,
|
static GeglNode * gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool,
|
||||||
GObject **config);
|
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_dialog (GimpImageMapTool *im_tool);
|
||||||
|
|
||||||
static void gimp_colorize_tool_config_notify (GObject *object,
|
static void gimp_colorize_tool_config_notify (GObject *object,
|
||||||
@ -98,12 +93,9 @@ gimp_colorize_tool_register (GimpToolRegisterCallback callback,
|
|||||||
static void
|
static void
|
||||||
gimp_colorize_tool_class_init (GimpColorizeToolClass *klass)
|
gimp_colorize_tool_class_init (GimpColorizeToolClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
||||||
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
||||||
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_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;
|
tool_class->initialize = gimp_colorize_tool_initialize;
|
||||||
|
|
||||||
im_tool_class->dialog_desc = _("Colorize the Image");
|
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->export_dialog_title = _("Export Colorize Settings");
|
||||||
|
|
||||||
im_tool_class->get_operation = gimp_colorize_tool_get_operation;
|
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;
|
im_tool_class->dialog = gimp_colorize_tool_dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_colorize_tool_init (GimpColorizeTool *col_tool)
|
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
|
static gboolean
|
||||||
@ -196,14 +169,6 @@ gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool,
|
|||||||
return node;
|
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 */
|
/* Hue-Saturation dialog */
|
||||||
|
@ -38,7 +38,6 @@ struct _GimpColorizeTool
|
|||||||
GimpImageMapTool parent_instance;
|
GimpImageMapTool parent_instance;
|
||||||
|
|
||||||
GimpColorizeConfig *config;
|
GimpColorizeConfig *config;
|
||||||
Colorize *colorize;
|
|
||||||
|
|
||||||
/* dialog */
|
/* dialog */
|
||||||
GtkAdjustment *hue_data;
|
GtkAdjustment *hue_data;
|
||||||
|
Reference in New Issue
Block a user