1997-11-24 22:05:25 +00:00
|
|
|
/* The GIMP -- an 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 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-13 05:44:11 +00:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2000-04-27 17:27:28 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2001-01-24 22:36:18 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-05-03 12:45:22 +00:00
|
|
|
#include "tools-types.h"
|
2001-05-24 23:57:08 +00:00
|
|
|
|
|
|
|
#include "base/gimphistogram.h"
|
2002-08-26 11:35:56 +00:00
|
|
|
#include "base/threshold.h"
|
2001-05-24 23:57:08 +00:00
|
|
|
|
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpdrawable-histogram.h"
|
|
|
|
#include "core/gimpimage.h"
|
2002-08-26 11:35:56 +00:00
|
|
|
#include "core/gimpimagemap.h"
|
2001-05-24 23:57:08 +00:00
|
|
|
|
|
|
|
#include "widgets/gimphistogramview.h"
|
|
|
|
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2001-05-24 23:57:08 +00:00
|
|
|
#include "gimpthresholdtool.h"
|
|
|
|
#include "tool_manager.h"
|
2000-12-16 21:37:03 +00:00
|
|
|
|
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 23:23:52 +00:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
2000-04-27 17:27:28 +00:00
|
|
|
|
1999-06-21 22:12:07 +00:00
|
|
|
#define HISTOGRAM_WIDTH 256
|
1997-11-24 22:05:25 +00:00
|
|
|
#define HISTOGRAM_HEIGHT 150
|
|
|
|
|
1999-11-22 11:14:29 +00:00
|
|
|
#define LOW 0x1
|
|
|
|
#define HIGH 0x2
|
2001-05-24 23:57:08 +00:00
|
|
|
#define HISTOGRAM 0x4
|
1999-11-22 11:14:29 +00:00
|
|
|
#define ALL (LOW | HIGH | HISTOGRAM)
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-05-24 23:57:08 +00:00
|
|
|
/* local function prototypes */
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2001-05-24 23:57:08 +00:00
|
|
|
static void gimp_threshold_tool_class_init (GimpThresholdToolClass *klass);
|
|
|
|
static void gimp_threshold_tool_init (GimpThresholdTool *threshold_tool);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
static void gimp_threshold_tool_finalize (GObject *object);
|
|
|
|
|
|
|
|
static void gimp_threshold_tool_initialize (GimpTool *tool,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
|
|
|
|
static void gimp_threshold_tool_map (GimpImageMapTool *image_map_tool);
|
|
|
|
static void gimp_threshold_tool_dialog (GimpImageMapTool *image_map_tool);
|
|
|
|
static void gimp_threshold_tool_reset (GimpImageMapTool *image_map_tool);
|
|
|
|
|
|
|
|
static void threshold_update (GimpThresholdTool *t_tool,
|
|
|
|
gint update);
|
2000-12-31 04:07:42 +00:00
|
|
|
static void threshold_low_threshold_adjustment_update (GtkAdjustment *adj,
|
|
|
|
gpointer data);
|
|
|
|
static void threshold_high_threshold_adjustment_update (GtkAdjustment *adj,
|
|
|
|
gpointer data);
|
2002-08-26 11:35:56 +00:00
|
|
|
static void threshold_histogram_range (GimpHistogramView *,
|
|
|
|
gint ,
|
|
|
|
gint ,
|
|
|
|
gpointer );
|
2000-12-31 04:07:42 +00:00
|
|
|
|
|
|
|
|
2001-05-24 23:57:08 +00:00
|
|
|
static GimpImageMapToolClass *parent_class = NULL;
|
|
|
|
|
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
/* public functions */
|
2001-05-24 23:57:08 +00:00
|
|
|
|
|
|
|
void
|
2002-03-29 03:50:29 +00:00
|
|
|
gimp_threshold_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 11:31:08 +00:00
|
|
|
gpointer data)
|
2001-05-24 23:57:08 +00:00
|
|
|
{
|
2002-03-29 03:50:29 +00:00
|
|
|
(* callback) (GIMP_TYPE_THRESHOLD_TOOL,
|
2001-11-20 23:00:47 +00:00
|
|
|
NULL,
|
|
|
|
FALSE,
|
2002-03-21 12:17:17 +00:00
|
|
|
"gimp-threshold-tool",
|
2001-11-20 23:00:47 +00:00
|
|
|
_("Threshold"),
|
|
|
|
_("Reduce image to two colors using a threshold"),
|
2001-12-03 17:59:48 +00:00
|
|
|
N_("/Layer/Colors/Threshold..."), NULL,
|
2001-11-20 23:00:47 +00:00
|
|
|
NULL, "tools/threshold.html",
|
2002-03-29 03:50:29 +00:00
|
|
|
GIMP_STOCK_TOOL_THRESHOLD,
|
2002-05-03 11:31:08 +00:00
|
|
|
data);
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
GType
|
2001-05-24 23:57:08 +00:00
|
|
|
gimp_threshold_tool_get_type (void)
|
|
|
|
{
|
2001-08-14 14:53:55 +00:00
|
|
|
static GType tool_type = 0;
|
2001-05-24 23:57:08 +00:00
|
|
|
|
|
|
|
if (! tool_type)
|
|
|
|
{
|
2001-08-14 14:53:55 +00:00
|
|
|
static const GTypeInfo tool_info =
|
2001-05-24 23:57:08 +00:00
|
|
|
{
|
|
|
|
sizeof (GimpThresholdToolClass),
|
2001-08-14 14:53:55 +00:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_threshold_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpThresholdTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_threshold_tool_init,
|
2001-05-24 23:57:08 +00:00
|
|
|
};
|
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_IMAGE_MAP_TOOL,
|
|
|
|
"GimpThresholdTool",
|
|
|
|
&tool_info, 0);
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return tool_type;
|
|
|
|
}
|
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-05-24 23:57:08 +00:00
|
|
|
static void
|
|
|
|
gimp_threshold_tool_class_init (GimpThresholdToolClass *klass)
|
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
GObjectClass *object_class;
|
|
|
|
GimpToolClass *tool_class;
|
|
|
|
GimpImageMapToolClass *image_map_tool_class;
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
image_map_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
object_class->finalize = gimp_threshold_tool_finalize;
|
|
|
|
|
|
|
|
tool_class->initialize = gimp_threshold_tool_initialize;
|
|
|
|
|
|
|
|
image_map_tool_class->map = gimp_threshold_tool_map;
|
|
|
|
image_map_tool_class->dialog = gimp_threshold_tool_dialog;
|
|
|
|
image_map_tool_class->reset = gimp_threshold_tool_reset;
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-26 11:35:56 +00:00
|
|
|
gimp_threshold_tool_init (GimpThresholdTool *t_tool)
|
2001-05-24 23:57:08 +00:00
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
GimpImageMapTool *image_map_tool;
|
|
|
|
|
|
|
|
image_map_tool = GIMP_IMAGE_MAP_TOOL (t_tool);
|
|
|
|
|
2002-08-28 19:47:07 +00:00
|
|
|
image_map_tool->shell_desc = _("Apply Threshold");
|
2002-08-26 11:35:56 +00:00
|
|
|
|
GimpViewableDialogs everywhere, cleanup:
2002-09-01 Michael Natterer <mitch@gimp.org>
GimpViewableDialogs everywhere, cleanup:
* libgimpwidgets/gimpstock.c: added texts for the RESIZE, SCALE
and CROP stock items.
* app/widgets/gimpviewabledialog.c: update the title when the
viewable's name changes.
* app/gui/color-notebook.[ch]: added color_notebook_viewable_new()
which creates a GimpViewableDialog.
* app/widgets/gimpgradienteditor.[ch]
* app/gui/colormap-editor-commands.c
* app/gui/file-new-dialog.c
* app/gui/gradient-editor-commands.c
* app/gui/palette-editor-commands.c
* app/undo_history.c: use GimpViewableDialogs and the new
color_notebook constructor.
* app/gui/convert-dialog.c: #include "widgets/gimpviewabledialog.h"
* app/gui/image-commands.c
* app/gui/info-dialog.c
* app/gui/resize-dialog.c: minor cleanups.
* app/gui/info-window.c: cleaned up the whole thing, esp. the
"Extended" page. Added HSV color display to the color picker
frame. Set the icons as frame titles, stuff...
* app/tools/gimpimagemaptool.[ch]: removed "shell_title",
"shell_name" and "stock_id" from the GimpImageMapTool struct
because they can be obtained from the tool's GimpToolInfo object.
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpcolorbalancetool.c
* app/tools/gimpcurvestool.c
* app/tools/gimphuesaturationtool.c
* app/tools/gimplevelstool.c
* app/tools/gimpposterizetool.c
* app/tools/gimpthresholdtool.c: changed accordingly.
* app/tools/gimphistogramtool.c: same here: take values from
tool->tool_info instead of hardcoding them.
* app/tools/gimpcroptool.[ch]: removed the static crop dialog
variables and added them to the GimpCropTool struct. Feels safer
and makes the callback code much simpler. Use stock items for the
dialog's "Resize" and "Crop" buttons.
* app/tools/gimpmeasuretool.c
* app/tools/gimprotatetool.c: for consistency don't name the tools
"Blah Tool", also the dialog titles need to match the menu
entries.
Unrelated:
* libgimpwidgets/gimpwidgets.c: the recently changed, gtk-doc
comment was correct, as gtk-doc takes the parameter names from
the header, not the .c file.
* app/tools/gimptransformtool.c: set the transform tool's state to
TRANSFORM_CREATING after changing displays, so the initial matrix
components are saved correctly for the "Reset" function.
2002-09-01 08:44:57 +00:00
|
|
|
t_tool->threshold = g_new0 (Threshold, 1);
|
|
|
|
t_tool->hist = gimp_histogram_new ();
|
2002-08-26 11:35:56 +00:00
|
|
|
|
|
|
|
t_tool->threshold->low_threshold = 127;
|
|
|
|
t_tool->threshold->high_threshold = 255;
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-26 11:35:56 +00:00
|
|
|
gimp_threshold_tool_finalize (GObject *object)
|
2001-05-24 23:57:08 +00:00
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
GimpThresholdTool *t_tool;
|
|
|
|
|
|
|
|
t_tool = GIMP_THRESHOLD_TOOL (object);
|
|
|
|
|
|
|
|
if (t_tool->threshold)
|
2001-05-24 23:57:08 +00:00
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
g_free (t_tool->threshold);
|
|
|
|
t_tool->threshold = NULL;
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
if (t_tool->hist)
|
2001-05-24 23:57:08 +00:00
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
gimp_histogram_free (t_tool->hist);
|
|
|
|
t_tool->hist = NULL;
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-26 11:35:56 +00:00
|
|
|
gimp_threshold_tool_initialize (GimpTool *tool,
|
|
|
|
GimpDisplay *gdisp)
|
2001-05-24 23:57:08 +00:00
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
GimpThresholdTool *t_tool;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
|
|
|
|
t_tool = GIMP_THRESHOLD_TOOL (tool);
|
|
|
|
|
2002-08-28 19:47:07 +00:00
|
|
|
if (! gdisp)
|
|
|
|
{
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
|
2001-05-24 23:57:08 +00:00
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
g_message (_("Threshold does not operate on indexed drawables."));
|
|
|
|
return;
|
|
|
|
}
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
drawable = gimp_image_active_drawable (gdisp->gimage);
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
t_tool->threshold->color = gimp_drawable_is_rgb (drawable);
|
|
|
|
t_tool->threshold->low_threshold = 127;
|
|
|
|
t_tool->threshold->high_threshold = 255;
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
gimp_drawable_calculate_histogram (drawable, t_tool->hist);
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
g_signal_handlers_block_by_func (G_OBJECT (t_tool->histogram),
|
|
|
|
threshold_histogram_range,
|
|
|
|
t_tool);
|
|
|
|
gimp_histogram_view_update (t_tool->histogram, t_tool->hist);
|
|
|
|
g_signal_handlers_unblock_by_func (G_OBJECT (t_tool->histogram),
|
|
|
|
threshold_histogram_range,
|
|
|
|
t_tool);
|
1999-06-23 15:24:46 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
threshold_update (t_tool, ALL);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
|
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-03-01 05:11:19 +00:00
|
|
|
}
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
static void
|
2002-08-26 11:35:56 +00:00
|
|
|
gimp_threshold_tool_map (GimpImageMapTool *image_map_tool)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
GimpThresholdTool *t_tool;
|
|
|
|
|
|
|
|
t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
|
|
|
|
|
|
|
|
gimp_image_map_apply (image_map_tool->image_map,
|
|
|
|
threshold,
|
|
|
|
t_tool->threshold);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
|
1999-06-23 15:24:46 +00:00
|
|
|
/**********************/
|
|
|
|
/* Threshold dialog */
|
|
|
|
/**********************/
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
static void
|
|
|
|
gimp_threshold_tool_dialog (GimpImageMapTool *image_map_tool)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
GimpThresholdTool *t_tool;
|
|
|
|
GtkWidget *hbox;
|
2002-08-28 19:47:07 +00:00
|
|
|
GtkWidget *vbox;
|
2002-08-26 11:35:56 +00:00
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkObject *data;
|
|
|
|
|
|
|
|
t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-08-28 19:47:07 +00:00
|
|
|
hbox = gtk_hbox_new (TRUE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (image_map_tool->main_vbox), hbox);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, FALSE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
1999-11-22 11:14:29 +00:00
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
2002-08-28 19:47:07 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-11-22 11:14:29 +00:00
|
|
|
label = gtk_label_new (_("Threshold Range:"));
|
1997-11-24 22:05:25 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
1999-11-22 11:14:29 +00:00
|
|
|
/* low threshold spinbutton */
|
2002-08-26 11:35:56 +00:00
|
|
|
data = gtk_adjustment_new (t_tool->threshold->low_threshold,
|
|
|
|
0.0, 255.0, 1.0, 10.0, 0.0);
|
|
|
|
t_tool->low_threshold_data = GTK_ADJUSTMENT (data);
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
spinbutton = gtk_spin_button_new (t_tool->low_threshold_data, 1.0, 0);
|
1999-11-22 11:14:29 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
2001-08-14 16:33:28 +00:00
|
|
|
gtk_widget_show (spinbutton);
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
g_signal_connect (G_OBJECT (t_tool->low_threshold_data), "value_changed",
|
2001-08-14 16:33:28 +00:00
|
|
|
G_CALLBACK (threshold_low_threshold_adjustment_update),
|
2002-08-26 11:35:56 +00:00
|
|
|
t_tool);
|
1999-11-22 11:14:29 +00:00
|
|
|
|
|
|
|
/* high threshold spinbutton */
|
2002-08-26 11:35:56 +00:00
|
|
|
data = gtk_adjustment_new (t_tool->threshold->high_threshold,
|
|
|
|
0.0, 255.0, 1.0, 10.0, 0.0);
|
|
|
|
t_tool->high_threshold_data = GTK_ADJUSTMENT (data);
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
spinbutton = gtk_spin_button_new (t_tool->high_threshold_data, 1.0, 0);
|
1999-11-22 11:14:29 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
2001-08-14 16:33:28 +00:00
|
|
|
gtk_widget_show (spinbutton);
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
g_signal_connect (G_OBJECT (t_tool->high_threshold_data), "value_changed",
|
2001-08-14 16:33:28 +00:00
|
|
|
G_CALLBACK (threshold_high_threshold_adjustment_update),
|
2002-08-26 11:35:56 +00:00
|
|
|
t_tool);
|
1999-11-22 11:14:29 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
/* The threshold histogram */
|
|
|
|
frame = gtk_frame_new (NULL);
|
2002-08-26 11:35:56 +00:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2002-08-28 19:47:07 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
2001-08-14 16:33:28 +00:00
|
|
|
gtk_widget_show (frame);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
t_tool->histogram = gimp_histogram_view_new (HISTOGRAM_WIDTH,
|
|
|
|
HISTOGRAM_HEIGHT);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (t_tool->histogram));
|
|
|
|
gtk_widget_show (GTK_WIDGET (t_tool->histogram));
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
g_signal_connect (G_OBJECT (t_tool->histogram), "range_changed",
|
2001-08-14 16:33:28 +00:00
|
|
|
G_CALLBACK (threshold_histogram_range),
|
2002-08-26 11:35:56 +00:00
|
|
|
t_tool);
|
1999-11-22 11:14:29 +00:00
|
|
|
}
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
static void
|
2002-08-26 11:35:56 +00:00
|
|
|
gimp_threshold_tool_reset (GimpImageMapTool *image_map_tool)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
GimpThresholdTool *t_tool;
|
2001-07-07 17:36:00 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
t_tool->threshold->low_threshold = 127.0;
|
|
|
|
t_tool->threshold->high_threshold = 255.0;
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
threshold_update (t_tool, ALL);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-26 11:35:56 +00:00
|
|
|
threshold_update (GimpThresholdTool *t_tool,
|
|
|
|
gint update)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
if (update & LOW)
|
|
|
|
gtk_adjustment_set_value (t_tool->low_threshold_data,
|
|
|
|
t_tool->threshold->low_threshold);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
if (update & HIGH)
|
|
|
|
gtk_adjustment_set_value (t_tool->high_threshold_data,
|
|
|
|
t_tool->threshold->high_threshold);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
if (update & HISTOGRAM)
|
|
|
|
gimp_histogram_view_range (t_tool->histogram,
|
|
|
|
t_tool->threshold->low_threshold,
|
|
|
|
t_tool->threshold->high_threshold);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-11-22 11:14:29 +00:00
|
|
|
threshold_low_threshold_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
gpointer data)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
GimpThresholdTool *t_tool;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
t_tool = GIMP_THRESHOLD_TOOL (data);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
if (t_tool->threshold->low_threshold != adjustment->value)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
t_tool->threshold->low_threshold = adjustment->value;
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
threshold_update (t_tool, HISTOGRAM);
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-11-22 11:14:29 +00:00
|
|
|
threshold_high_threshold_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
gpointer data)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
GimpThresholdTool *t_tool;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
t_tool = GIMP_THRESHOLD_TOOL (data);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
if (t_tool->threshold->high_threshold != adjustment->value)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
t_tool->threshold->high_threshold = adjustment->value;
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
threshold_update (t_tool, HISTOGRAM);
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
}
|
1999-11-22 11:14:29 +00:00
|
|
|
|
|
|
|
static void
|
2001-10-17 11:33:43 +00:00
|
|
|
threshold_histogram_range (GimpHistogramView *widget,
|
|
|
|
gint start,
|
|
|
|
gint end,
|
|
|
|
gpointer data)
|
1999-11-22 11:14:29 +00:00
|
|
|
{
|
2002-08-26 11:35:56 +00:00
|
|
|
GimpThresholdTool *t_tool;
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
t_tool = GIMP_THRESHOLD_TOOL (data);
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
t_tool->threshold->low_threshold = start;
|
|
|
|
t_tool->threshold->high_threshold = end;
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
threshold_update (t_tool, LOW | HIGH);
|
1999-11-22 11:14:29 +00:00
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
|
1999-11-22 11:14:29 +00:00
|
|
|
}
|