2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-24 14:05:25 -08:00
|
|
|
* 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 2 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, write to the Free Software
|
1998-04-12 22:44:11 -07:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-24 14:05:25 -08:00
|
|
|
*/
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2000-04-27 10:27:28 -07:00
|
|
|
#include "config.h"
|
|
|
|
|
|
2007-12-30 09:54:51 -08:00
|
|
|
#include <gegl.h>
|
2000-12-29 07:22:01 -08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2008-01-27 09:39:01 -08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2001-01-24 14:36:18 -08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
2002-05-03 05:45:22 -07:00
|
|
|
#include "tools-types.h"
|
2001-05-24 16:57:08 -07:00
|
|
|
|
|
|
|
|
#include "base/gimphistogram.h"
|
2002-08-26 04:35:56 -07:00
|
|
|
#include "base/threshold.h"
|
2001-05-24 16:57:08 -07:00
|
|
|
|
2008-01-25 03:42:07 -08:00
|
|
|
#include "gegl/gimpthresholdconfig.h"
|
|
|
|
|
|
2001-05-24 16:57:08 -07:00
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
|
#include "core/gimpdrawable-histogram.h"
|
|
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
|
2003-08-21 18:42:57 -07:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2002-09-07 10:27:32 -07:00
|
|
|
#include "widgets/gimphistogrambox.h"
|
2001-05-24 16:57:08 -07:00
|
|
|
#include "widgets/gimphistogramview.h"
|
|
|
|
|
|
2001-09-25 16:23:09 -07:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
|
2003-10-24 01:12:21 -07:00
|
|
|
#include "gimphistogramoptions.h"
|
2001-05-24 16:57:08 -07:00
|
|
|
#include "gimpthresholdtool.h"
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2003-03-25 08:38:19 -08:00
|
|
|
#include "gimp-intl.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-14 16:23:52 -07:00
|
|
|
|
2000-04-27 10:27:28 -07:00
|
|
|
|
2001-05-24 16:57:08 -07:00
|
|
|
/* local function prototypes */
|
1999-11-22 03:14:29 -08:00
|
|
|
|
2008-01-03 11:23:35 -08:00
|
|
|
static void gimp_threshold_tool_finalize (GObject *object);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2008-01-03 11:23:35 -08:00
|
|
|
static gboolean gimp_threshold_tool_initialize (GimpTool *tool,
|
|
|
|
|
GimpDisplay *display,
|
|
|
|
|
GError **error);
|
2002-08-26 04:35:56 -07:00
|
|
|
|
2008-01-30 10:31:43 -08:00
|
|
|
static GeglNode * gimp_threshold_tool_get_operation (GimpImageMapTool *im_tool,
|
|
|
|
|
GObject **config);
|
2008-01-03 11:23:35 -08:00
|
|
|
static void gimp_threshold_tool_map (GimpImageMapTool *im_tool);
|
|
|
|
|
static void gimp_threshold_tool_dialog (GimpImageMapTool *im_tool);
|
2008-01-30 10:31:43 -08:00
|
|
|
|
|
|
|
|
static void gimp_threshold_tool_config_notify (GObject *object,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
GimpThresholdTool *t_tool);
|
2002-08-26 04:35:56 -07:00
|
|
|
|
2008-01-03 11:23:35 -08:00
|
|
|
static void gimp_threshold_tool_histogram_range (GimpHistogramView *view,
|
|
|
|
|
gint start,
|
|
|
|
|
gint end,
|
|
|
|
|
GimpThresholdTool *t_tool);
|
|
|
|
|
static void gimp_threshold_tool_auto_clicked (GtkWidget *button,
|
|
|
|
|
GimpThresholdTool *t_tool);
|
2000-12-30 20:07:42 -08:00
|
|
|
|
|
|
|
|
|
2005-12-13 01:13:50 -08:00
|
|
|
G_DEFINE_TYPE (GimpThresholdTool, gimp_threshold_tool,
|
2006-05-15 02:46:31 -07:00
|
|
|
GIMP_TYPE_IMAGE_MAP_TOOL)
|
2001-05-24 16:57:08 -07:00
|
|
|
|
2005-12-13 01:13:50 -08:00
|
|
|
#define parent_class gimp_threshold_tool_parent_class
|
2001-05-24 16:57:08 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2002-03-28 19:50:29 -08:00
|
|
|
gimp_threshold_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 04:31:08 -07:00
|
|
|
gpointer data)
|
2001-05-24 16:57:08 -07:00
|
|
|
{
|
2002-03-28 19:50:29 -08:00
|
|
|
(* callback) (GIMP_TYPE_THRESHOLD_TOOL,
|
2003-10-24 01:12:21 -07:00
|
|
|
GIMP_TYPE_HISTOGRAM_OPTIONS,
|
|
|
|
|
gimp_histogram_options_gui,
|
2003-06-28 04:20:37 -07:00
|
|
|
0,
|
2002-03-21 04:17:17 -08:00
|
|
|
"gimp-threshold-tool",
|
2001-11-20 15:00:47 -08:00
|
|
|
_("Threshold"),
|
2006-09-18 11:00:22 -07:00
|
|
|
_("Threshold Tool: Reduce image to two colors using a threshold"),
|
2004-04-29 06:19:28 -07:00
|
|
|
N_("_Threshold..."), NULL,
|
2003-08-21 18:42:57 -07:00
|
|
|
NULL, GIMP_HELP_TOOL_THRESHOLD,
|
2002-03-28 19:50:29 -08:00
|
|
|
GIMP_STOCK_TOOL_THRESHOLD,
|
2002-05-03 04:31:08 -07:00
|
|
|
data);
|
2001-05-24 16:57:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_threshold_tool_class_init (GimpThresholdToolClass *klass)
|
|
|
|
|
{
|
2005-12-13 01:13:50 -08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
|
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
|
2001-05-24 16:57:08 -07:00
|
|
|
|
2008-01-03 11:23:35 -08:00
|
|
|
object_class->finalize = gimp_threshold_tool_finalize;
|
2002-08-26 04:35:56 -07:00
|
|
|
|
2008-01-03 11:23:35 -08:00
|
|
|
tool_class->initialize = gimp_threshold_tool_initialize;
|
2002-08-26 04:35:56 -07:00
|
|
|
|
2008-01-03 11:23:35 -08:00
|
|
|
im_tool_class->shell_desc = _("Apply Threshold");
|
2004-02-25 05:55:45 -08:00
|
|
|
|
2008-01-03 11:23:35 -08:00
|
|
|
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;
|
2001-05-24 16:57:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2002-08-26 04:35:56 -07:00
|
|
|
gimp_threshold_tool_init (GimpThresholdTool *t_tool)
|
2001-05-24 16:57:08 -07:00
|
|
|
{
|
2008-01-08 17:06:46 -08:00
|
|
|
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (t_tool);
|
|
|
|
|
|
2007-05-23 06:49:06 -07:00
|
|
|
t_tool->threshold = g_slice_new0 (Threshold);
|
2008-02-04 13:41:57 -08:00
|
|
|
t_tool->histogram = gimp_histogram_new ();
|
2002-08-26 04:35:56 -07:00
|
|
|
|
2008-01-08 17:06:46 -08:00
|
|
|
im_tool->apply_func = (GimpImageMapApplyFunc) threshold;
|
|
|
|
|
im_tool->apply_data = t_tool->threshold;
|
2001-05-24 16:57:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2002-08-26 04:35:56 -07:00
|
|
|
gimp_threshold_tool_finalize (GObject *object)
|
2001-05-24 16:57:08 -07:00
|
|
|
{
|
2003-10-24 01:12:21 -07:00
|
|
|
GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (object);
|
2002-08-26 04:35:56 -07:00
|
|
|
|
2007-05-23 06:49:06 -07:00
|
|
|
g_slice_free (Threshold, t_tool->threshold);
|
2001-05-24 16:57:08 -07:00
|
|
|
|
2008-02-04 13:41:57 -08:00
|
|
|
if (t_tool->histogram)
|
2001-05-24 16:57:08 -07:00
|
|
|
{
|
2008-02-04 13:41:57 -08:00
|
|
|
gimp_histogram_unref (t_tool->histogram);
|
|
|
|
|
t_tool->histogram = NULL;
|
2001-05-24 16:57:08 -07:00
|
|
|
}
|
|
|
|
|
|
2002-08-26 04:35:56 -07:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-05-24 16:57:08 -07:00
|
|
|
}
|
|
|
|
|
|
2004-01-21 08:07:48 -08:00
|
|
|
static gboolean
|
2006-09-26 13:55:40 -07:00
|
|
|
gimp_threshold_tool_initialize (GimpTool *tool,
|
|
|
|
|
GimpDisplay *display,
|
|
|
|
|
GError **error)
|
2001-05-24 16:57:08 -07:00
|
|
|
{
|
2007-07-19 07:59:51 -07:00
|
|
|
GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (tool);
|
|
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (display->image);
|
2003-02-03 15:54:19 -08:00
|
|
|
|
2003-11-13 03:23:01 -08:00
|
|
|
if (! drawable)
|
2004-01-21 08:07:48 -08:00
|
|
|
return FALSE;
|
2003-11-13 03:23:01 -08:00
|
|
|
|
2003-02-03 15:54:19 -08:00
|
|
|
if (gimp_drawable_is_indexed (drawable))
|
2001-05-24 16:57:08 -07:00
|
|
|
{
|
2006-09-26 13:55:40 -07:00
|
|
|
g_set_error (error, 0, 0,
|
|
|
|
|
_("Threshold does not operate on indexed layers."));
|
2004-01-21 08:07:48 -08:00
|
|
|
return FALSE;
|
2002-08-26 04:35:56 -07:00
|
|
|
}
|
2001-05-24 16:57:08 -07:00
|
|
|
|
2008-01-27 09:39:01 -08:00
|
|
|
gimp_config_reset (GIMP_CONFIG (t_tool->config));
|
|
|
|
|
|
2006-09-26 13:55:40 -07:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
|
2001-05-24 16:57:08 -07:00
|
|
|
|
2008-02-04 13:41:57 -08:00
|
|
|
gimp_drawable_calculate_histogram (drawable, t_tool->histogram);
|
2003-10-31 18:39:34 -08:00
|
|
|
gimp_histogram_view_set_histogram (t_tool->histogram_box->view,
|
2008-02-04 13:41:57 -08:00
|
|
|
t_tool->histogram);
|
1999-06-23 08:24:46 -07:00
|
|
|
|
2002-08-26 04:35:56 -07:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
|
2004-01-21 08:07:48 -08:00
|
|
|
|
|
|
|
|
return TRUE;
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-02-28 21:11:19 -08:00
|
|
|
}
|
|
|
|
|
|
2008-01-03 11:23:35 -08:00
|
|
|
static GeglNode *
|
2008-01-30 10:31:43 -08:00
|
|
|
gimp_threshold_tool_get_operation (GimpImageMapTool *image_map_tool,
|
|
|
|
|
GObject **config)
|
2008-01-03 11:23:35 -08:00
|
|
|
{
|
2008-01-25 03:42:07 -08:00
|
|
|
GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
|
|
|
|
|
GeglNode *node;
|
|
|
|
|
|
|
|
|
|
node = g_object_new (GEGL_TYPE_NODE,
|
2008-01-03 11:36:23 -08:00
|
|
|
"operation", "gimp-threshold",
|
|
|
|
|
NULL);
|
2008-01-25 03:42:07 -08:00
|
|
|
|
|
|
|
|
t_tool->config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG, NULL);
|
|
|
|
|
|
2008-01-30 10:31:43 -08:00
|
|
|
*config = G_OBJECT (t_tool->config);
|
|
|
|
|
|
|
|
|
|
g_signal_connect_object (t_tool->config, "notify",
|
|
|
|
|
G_CALLBACK (gimp_threshold_tool_config_notify),
|
|
|
|
|
G_OBJECT (t_tool), 0);
|
|
|
|
|
|
2008-01-25 03:42:07 -08:00
|
|
|
gegl_node_set (node,
|
|
|
|
|
"config", t_tool->config,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
return node;
|
2008-01-03 11:23:35 -08:00
|
|
|
}
|
|
|
|
|
|
1997-11-24 14:05:25 -08:00
|
|
|
static void
|
2002-08-26 04:35:56 -07:00
|
|
|
gimp_threshold_tool_map (GimpImageMapTool *image_map_tool)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2008-02-03 15:50:55 -08:00
|
|
|
GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
|
|
|
|
|
GimpDrawable *drawable = image_map_tool->drawable;
|
2002-08-26 04:35:56 -07:00
|
|
|
|
2008-02-03 15:50:55 -08:00
|
|
|
gimp_threshold_config_to_cruft (t_tool->config, t_tool->threshold,
|
|
|
|
|
gimp_drawable_is_rgb (drawable));
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
2002-08-26 04:35:56 -07:00
|
|
|
|
1999-06-23 08:24:46 -07:00
|
|
|
/**********************/
|
|
|
|
|
/* Threshold dialog */
|
|
|
|
|
/**********************/
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2002-08-26 04:35:56 -07:00
|
|
|
static void
|
|
|
|
|
gimp_threshold_tool_dialog (GimpImageMapTool *image_map_tool)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2008-02-04 13:41:57 -08:00
|
|
|
GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
|
|
|
|
|
GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (image_map_tool);
|
|
|
|
|
GimpThresholdConfig *config = t_tool->config;
|
|
|
|
|
GtkWidget *vbox;
|
|
|
|
|
GtkWidget *hbox;
|
|
|
|
|
GtkWidget *menu;
|
|
|
|
|
GtkWidget *box;
|
|
|
|
|
GtkWidget *button;
|
2002-08-26 04:35:56 -07:00
|
|
|
|
2004-03-04 17:31:33 -08:00
|
|
|
vbox = image_map_tool->main_vbox;
|
|
|
|
|
|
2004-06-02 10:56:02 -07:00
|
|
|
hbox = gtk_hbox_new (FALSE, 6);
|
2004-03-04 17:31:33 -08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
|
|
menu = gimp_prop_enum_stock_box_new (G_OBJECT (tool_options),
|
|
|
|
|
"histogram-scale", "gimp-histogram",
|
|
|
|
|
0, 0);
|
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), menu, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (menu);
|
|
|
|
|
|
2004-06-20 15:04:10 -07:00
|
|
|
box = gimp_histogram_box_new ();
|
2004-03-04 17:31:33 -08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), box, TRUE, TRUE, 0);
|
2002-10-14 18:15:43 -07:00
|
|
|
gtk_widget_show (box);
|
2002-08-28 12:47:07 -07:00
|
|
|
|
2002-10-14 18:15:43 -07:00
|
|
|
t_tool->histogram_box = GIMP_HISTOGRAM_BOX (box);
|
1999-11-22 03:14:29 -08:00
|
|
|
|
2008-02-04 13:41:57 -08:00
|
|
|
gimp_histogram_view_set_range (t_tool->histogram_box->view,
|
|
|
|
|
config->low * 255.999,
|
|
|
|
|
config->high * 255.999);
|
|
|
|
|
|
2005-05-27 09:51:39 -07:00
|
|
|
g_signal_connect (t_tool->histogram_box->view, "range-changed",
|
2002-09-07 10:27:32 -07:00
|
|
|
G_CALLBACK (gimp_threshold_tool_histogram_range),
|
2002-08-26 04:35:56 -07:00
|
|
|
t_tool);
|
2003-10-24 01:12:21 -07:00
|
|
|
|
|
|
|
|
gimp_histogram_options_connect_view (GIMP_HISTOGRAM_OPTIONS (tool_options),
|
2003-10-31 18:39:34 -08:00
|
|
|
t_tool->histogram_box->view);
|
2006-04-25 11:02:30 -07:00
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 6);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
|
|
button = gtk_button_new_with_mnemonic (_("_Auto"));
|
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
|
gimp_help_set_help_data (button, _("Automatically adjust to optimal "
|
|
|
|
|
"binarization threshold"), NULL);
|
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
|
|
g_signal_connect (button, "clicked",
|
|
|
|
|
G_CALLBACK (gimp_threshold_tool_auto_clicked),
|
|
|
|
|
t_tool);
|
1999-11-22 03:14:29 -08:00
|
|
|
}
|
|
|
|
|
|
1997-11-24 14:05:25 -08:00
|
|
|
static void
|
2008-01-30 10:31:43 -08:00
|
|
|
gimp_threshold_tool_config_notify (GObject *object,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
GimpThresholdTool *t_tool)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2008-01-30 10:31:43 -08:00
|
|
|
GimpThresholdConfig *config = GIMP_THRESHOLD_CONFIG (object);
|
1999-11-22 03:14:29 -08:00
|
|
|
|
2008-02-04 13:41:57 -08:00
|
|
|
if (! t_tool->histogram_box)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gimp_histogram_view_set_range (t_tool->histogram_box->view,
|
|
|
|
|
config->low * 255.999,
|
|
|
|
|
config->high * 255.999);
|
2008-01-25 03:42:07 -08:00
|
|
|
|
2008-01-30 10:31:43 -08:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2002-09-07 10:27:32 -07:00
|
|
|
gimp_threshold_tool_histogram_range (GimpHistogramView *widget,
|
|
|
|
|
gint start,
|
|
|
|
|
gint end,
|
|
|
|
|
GimpThresholdTool *t_tool)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2008-01-25 03:42:07 -08:00
|
|
|
gdouble low = start / 255.0;
|
|
|
|
|
gdouble high = end / 255.0;
|
|
|
|
|
|
|
|
|
|
if (low != t_tool->config->low ||
|
|
|
|
|
high != t_tool->config->high)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2008-01-25 03:42:07 -08:00
|
|
|
g_object_set (t_tool->config,
|
|
|
|
|
"low", low,
|
|
|
|
|
"high", high,
|
|
|
|
|
NULL);
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
}
|
2006-04-25 11:02:30 -07:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_threshold_tool_auto_clicked (GtkWidget *button,
|
|
|
|
|
GimpThresholdTool *t_tool)
|
|
|
|
|
{
|
2008-02-03 15:50:55 -08:00
|
|
|
GimpDrawable *drawable = GIMP_IMAGE_MAP_TOOL (t_tool)->drawable;
|
|
|
|
|
gdouble low;
|
|
|
|
|
|
2008-02-04 13:41:57 -08:00
|
|
|
low = gimp_histogram_get_threshold (t_tool->histogram,
|
2008-02-03 15:50:55 -08:00
|
|
|
gimp_drawable_is_rgb (drawable) ?
|
|
|
|
|
GIMP_HISTOGRAM_RGB :
|
|
|
|
|
GIMP_HISTOGRAM_VALUE,
|
|
|
|
|
0, 255);
|
2006-04-25 11:02:30 -07:00
|
|
|
|
|
|
|
|
gimp_histogram_view_set_range (t_tool->histogram_box->view,
|
2008-01-25 03:42:07 -08:00
|
|
|
low, 255.0);
|
2006-04-25 11:02:30 -07:00
|
|
|
}
|