mirror of https://github.com/GNOME/gimp.git
app: remove the legacy threshold code
This commit is contained in:
parent
7aa7f168b8
commit
e3c720ad20
|
@ -52,8 +52,6 @@ libappbase_a_SOURCES = \
|
|||
siox.h \
|
||||
temp-buf.c \
|
||||
temp-buf.h \
|
||||
threshold.c \
|
||||
threshold.h \
|
||||
tile.c \
|
||||
tile.h \
|
||||
tile-private.h \
|
||||
|
|
|
@ -1,81 +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 <glib-object.h>
|
||||
|
||||
#include "base-types.h"
|
||||
|
||||
#include "pixel-region.h"
|
||||
#include "threshold.h"
|
||||
|
||||
|
||||
void
|
||||
threshold (Threshold *tr,
|
||||
PixelRegion *srcPR,
|
||||
PixelRegion *destPR)
|
||||
{
|
||||
const guchar *src, *s;
|
||||
guchar *dest, *d;
|
||||
gboolean has_alpha;
|
||||
gint alpha;
|
||||
gint w, h, b;
|
||||
gint value;
|
||||
|
||||
h = srcPR->h;
|
||||
src = srcPR->data;
|
||||
dest = destPR->data;
|
||||
has_alpha = pixel_region_has_alpha (srcPR);
|
||||
alpha = has_alpha ? srcPR->bytes - 1 : srcPR->bytes;
|
||||
|
||||
while (h--)
|
||||
{
|
||||
w = srcPR->w;
|
||||
s = src;
|
||||
d = dest;
|
||||
|
||||
while (w--)
|
||||
{
|
||||
if (tr->color)
|
||||
{
|
||||
value = MAX (s[RED], s[GREEN]);
|
||||
value = MAX (value, s[BLUE]);
|
||||
|
||||
value = (value >= tr->low_threshold &&
|
||||
value <= tr->high_threshold ) ? 255 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = (s[GRAY] >= tr->low_threshold &&
|
||||
s[GRAY] <= tr->high_threshold) ? 255 : 0;
|
||||
}
|
||||
|
||||
for (b = 0; b < alpha; b++)
|
||||
d[b] = value;
|
||||
|
||||
if (has_alpha)
|
||||
d[alpha] = s[alpha];
|
||||
|
||||
s += srcPR->bytes;
|
||||
d += destPR->bytes;
|
||||
}
|
||||
|
||||
src += srcPR->rowstride;
|
||||
dest += destPR->rowstride;
|
||||
}
|
||||
}
|
|
@ -1,35 +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 __THRESHOLD_H__
|
||||
#define __THRESHOLD_H__
|
||||
|
||||
|
||||
struct _Threshold
|
||||
{
|
||||
gboolean color;
|
||||
gint low_threshold;
|
||||
gint high_threshold;
|
||||
};
|
||||
|
||||
|
||||
void threshold (Threshold *tr,
|
||||
PixelRegion *srcPR,
|
||||
PixelRegion *destPR);
|
||||
|
||||
|
||||
#endif /* __THRESHOLD_H__ */
|
|
@ -21,18 +21,11 @@
|
|||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "base/threshold.h"
|
||||
|
||||
#include "gegl/gimpthresholdconfig.h"
|
||||
|
||||
/* temp */
|
||||
#include "gimp.h"
|
||||
#include "gimpimage.h"
|
||||
|
||||
#include "gimpdrawable.h"
|
||||
#include "gimpdrawable-operation.h"
|
||||
#include "gimpdrawable-threshold.h"
|
||||
#include "gimpdrawable-process.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
@ -45,42 +38,29 @@ gimp_drawable_threshold (GimpDrawable *drawable,
|
|||
gint low,
|
||||
gint high)
|
||||
{
|
||||
GimpThresholdConfig *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:threshold",
|
||||
NULL);
|
||||
|
||||
config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG,
|
||||
"low", low / 255.0,
|
||||
"high", high / 255.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:threshold",
|
||||
NULL);
|
||||
gegl_node_set (node,
|
||||
"config", config,
|
||||
NULL);
|
||||
|
||||
g_object_unref (config);
|
||||
|
||||
gimp_drawable_apply_operation (drawable, progress, _("Threshold"),
|
||||
node, TRUE);
|
||||
g_object_unref (node);
|
||||
}
|
||||
else
|
||||
{
|
||||
Threshold cruft;
|
||||
|
||||
gimp_threshold_config_to_cruft (config, &cruft,
|
||||
gimp_drawable_is_rgb (drawable));
|
||||
|
||||
gimp_drawable_process (drawable, progress, _("Threshold"),
|
||||
(PixelProcessorFunc) threshold, &cruft);
|
||||
}
|
||||
|
||||
g_object_unref (config);
|
||||
}
|
||||
|
|
|
@ -26,9 +26,6 @@
|
|||
|
||||
#include "gimp-gegl-types.h"
|
||||
|
||||
/* temp cruft */
|
||||
#include "base/threshold.h"
|
||||
|
||||
#include "gimpthresholdconfig.h"
|
||||
|
||||
|
||||
|
@ -131,19 +128,3 @@ gimp_threshold_config_set_property (GObject *object,
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* temp cruft */
|
||||
|
||||
void
|
||||
gimp_threshold_config_to_cruft (GimpThresholdConfig *config,
|
||||
Threshold *cruft,
|
||||
gboolean color)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_THRESHOLD_CONFIG (config));
|
||||
g_return_if_fail (cruft != NULL);
|
||||
|
||||
cruft->low_threshold = config->low * 255.999;
|
||||
cruft->high_threshold = config->high * 255.999;
|
||||
cruft->color = color;
|
||||
}
|
||||
|
|
|
@ -51,10 +51,5 @@ struct _GimpThresholdConfigClass
|
|||
|
||||
GType gimp_threshold_config_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/* temp cruft */
|
||||
void gimp_threshold_config_to_cruft (GimpThresholdConfig *config,
|
||||
Threshold *cruft,
|
||||
gboolean color);
|
||||
|
||||
|
||||
#endif /* __GIMP_THRESHOLD_CONFIG_H__ */
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "tools-types.h"
|
||||
|
||||
#include "base/gimphistogram.h"
|
||||
#include "base/threshold.h"
|
||||
|
||||
#include "gegl/gimpthresholdconfig.h"
|
||||
|
||||
|
@ -57,7 +56,6 @@ static gboolean gimp_threshold_tool_initialize (GimpTool *tool,
|
|||
|
||||
static GeglNode * gimp_threshold_tool_get_operation (GimpImageMapTool *im_tool,
|
||||
GObject **config);
|
||||
static void gimp_threshold_tool_map (GimpImageMapTool *im_tool);
|
||||
static void gimp_threshold_tool_dialog (GimpImageMapTool *im_tool);
|
||||
|
||||
static void gimp_threshold_tool_config_notify (GObject *object,
|
||||
|
@ -112,20 +110,13 @@ gimp_threshold_tool_class_init (GimpThresholdToolClass *klass)
|
|||
im_tool_class->export_dialog_title = _("Export Threshold Settings");
|
||||
|
||||
im_tool_class->get_operation = gimp_threshold_tool_get_operation;
|
||||
im_tool_class->map = gimp_threshold_tool_map;
|
||||
im_tool_class->dialog = gimp_threshold_tool_dialog;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_threshold_tool_init (GimpThresholdTool *t_tool)
|
||||
{
|
||||
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (t_tool);
|
||||
|
||||
t_tool->threshold = g_slice_new0 (Threshold);
|
||||
t_tool->histogram = gimp_histogram_new ();
|
||||
|
||||
im_tool->apply_func = (GimpImageMapApplyFunc) threshold;
|
||||
im_tool->apply_data = t_tool->threshold;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -133,8 +124,6 @@ gimp_threshold_tool_finalize (GObject *object)
|
|||
{
|
||||
GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (object);
|
||||
|
||||
g_slice_free (Threshold, t_tool->threshold);
|
||||
|
||||
if (t_tool->histogram)
|
||||
{
|
||||
gimp_histogram_unref (t_tool->histogram);
|
||||
|
@ -205,16 +194,6 @@ gimp_threshold_tool_get_operation (GimpImageMapTool *image_map_tool,
|
|||
return node;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_threshold_tool_map (GimpImageMapTool *image_map_tool)
|
||||
{
|
||||
GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
|
||||
GimpDrawable *drawable = image_map_tool->drawable;
|
||||
|
||||
gimp_threshold_config_to_cruft (t_tool->config, t_tool->threshold,
|
||||
gimp_drawable_is_rgb (drawable));
|
||||
}
|
||||
|
||||
|
||||
/**********************/
|
||||
/* Threshold dialog */
|
||||
|
|
Loading…
Reference in New Issue