1997-11-25 06:05:25 +08: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 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include "apptypes.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "appenv.h"
|
|
|
|
#include "drawable.h"
|
|
|
|
#include "gdisplay.h"
|
1999-09-28 01:58:10 +08:00
|
|
|
#include "gimpui.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "threshold.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-15 07:23:52 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
|
1999-06-22 06:12:07 +08:00
|
|
|
#define HISTOGRAM_WIDTH 256
|
1997-11-25 06:05:25 +08:00
|
|
|
#define HISTOGRAM_HEIGHT 150
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
#define LOW 0x1
|
|
|
|
#define HIGH 0x2
|
|
|
|
#define HISTORGAM 0x4
|
|
|
|
#define ALL (LOW | HIGH | HISTOGRAM)
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* the threshold structures */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
typedef struct _Threshold Threshold;
|
1999-11-22 19:14:29 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
struct _Threshold
|
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
gint x, y; /* coords for last mouse click */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* the threshold tool options */
|
1999-04-13 01:55:06 +08:00
|
|
|
static ToolOptions *threshold_options = NULL;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
|
|
|
/* the threshold tool dialog */
|
|
|
|
static ThresholdDialog *threshold_dialog = NULL;
|
|
|
|
|
|
|
|
/* threshold action functions */
|
1999-07-03 01:40:10 +08:00
|
|
|
static void threshold_control (Tool *, ToolAction, gpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
static ThresholdDialog * threshold_dialog_new (void);
|
1999-06-23 23:24:46 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
static void threshold_update (ThresholdDialog *,
|
|
|
|
gint);
|
1999-06-22 06:12:07 +08:00
|
|
|
static void threshold_preview (ThresholdDialog *);
|
1999-11-22 19:14:29 +08:00
|
|
|
static void threshold_reset_callback (GtkWidget *, gpointer);
|
1999-06-22 06:12:07 +08:00
|
|
|
static void threshold_ok_callback (GtkWidget *, gpointer);
|
|
|
|
static void threshold_cancel_callback (GtkWidget *, gpointer);
|
|
|
|
static void threshold_preview_update (GtkWidget *, gpointer);
|
1999-11-22 19:14:29 +08:00
|
|
|
static void threshold_low_threshold_adjustment_update (GtkAdjustment *,
|
|
|
|
gpointer);
|
|
|
|
static void threshold_high_threshold_adjustment_update (GtkAdjustment *,
|
|
|
|
gpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-06-22 06:12:07 +08:00
|
|
|
static void threshold (PixelRegion *, PixelRegion *, void *);
|
1999-11-22 19:14:29 +08:00
|
|
|
static void threshold_histogram_range (HistogramWidget *, gint, gint,
|
|
|
|
gpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
/* threshold machinery */
|
|
|
|
|
moved a bunch of PDB stuff here
* app/color_cmds.c: moved a bunch of PDB stuff here
* app/color_balance.[ch]: removed PDB proc, exported TransferMode
enum, ColorBalanceDialog, color_balance_create_lookup_tables, and
color_balance
* app/curves.[ch]: removed PDB procs, exported SMOOTH and GFREE
#defines, CurvesDialog, curves_lut_func and curves_calculate_curve
* app/desaturate.[ch]: removed PDB proc, exported desaturate
* app/equalize.[ch]: removed PDB proc, exported equalize
* app/histogram_tool.[ch]: removed PDB proc, exported HISTOGRAM_WIDTH
and HISTOGRAM_HEIGHT #defines, HistogramToolDialog,
histogram_tool_histogram_range
* app/hue_saturation.[ch]: removed PDB proc, exported HueRange enum,
HueSaturationDialog, hue_saturation_calculate_transfers,
hue_saturation
* app/invert.[ch]: remove PDB proc, export invert
* app/threshold.[ch]: remove PDB proc, export ThresholdDialog and
threshold_2
* internal_procs.c: changes for pdbgen
* app/gimprc.c: removed leftover declaration
* app/image_map.h: add #include "gimpdrawableF.h"
* app/lut_funcs.h: add ALPHA_LUT to ChannelLutType
-Yosh
1999-04-21 13:39:57 +08:00
|
|
|
void
|
1999-11-22 19:14:29 +08:00
|
|
|
threshold_2 (void *data,
|
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 13:11:19 +08:00
|
|
|
PixelRegion *srcPR,
|
|
|
|
PixelRegion *destPR)
|
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
/* this function just re-orders the arguments so we can use
|
|
|
|
* pixel_regions_process_paralell
|
|
|
|
*/
|
|
|
|
threshold (srcPR, destPR, data);
|
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 13:11:19 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
|
|
|
threshold (PixelRegion *srcPR,
|
|
|
|
PixelRegion *destPR,
|
1999-11-22 19:14:29 +08:00
|
|
|
void *data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
unsigned char *src, *s;
|
|
|
|
unsigned char *dest, *d;
|
|
|
|
int has_alpha, alpha;
|
|
|
|
int w, h, b;
|
|
|
|
int value;
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
td = (ThresholdDialog *) data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
h = srcPR->h;
|
|
|
|
src = srcPR->data;
|
|
|
|
dest = destPR->data;
|
|
|
|
has_alpha = (srcPR->bytes == 2 || srcPR->bytes == 4);
|
|
|
|
alpha = has_alpha ? srcPR->bytes - 1 : srcPR->bytes;
|
|
|
|
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
w = srcPR->w;
|
|
|
|
s = src;
|
|
|
|
d = dest;
|
|
|
|
while (w--)
|
|
|
|
{
|
|
|
|
if (td->color)
|
|
|
|
{
|
|
|
|
value = MAX (s[RED_PIX], s[GREEN_PIX]);
|
|
|
|
value = MAX (value, s[BLUE_PIX]);
|
|
|
|
|
|
|
|
value = (value >= td->low_threshold && value <= td->high_threshold ) ? 255 : 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
value = (s[GRAY_PIX] >= td->low_threshold && s[GRAY_PIX] <= td->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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* threshold action functions */
|
|
|
|
|
|
|
|
static void
|
1999-06-22 06:12:07 +08:00
|
|
|
threshold_control (Tool *tool,
|
|
|
|
ToolAction action,
|
|
|
|
gpointer gdisp_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
switch (action)
|
|
|
|
{
|
1999-06-22 06:12:07 +08:00
|
|
|
case PAUSE:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
|
|
|
case RESUME:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
|
|
|
case HALT:
|
2000-09-29 09:22:27 +08:00
|
|
|
threshold_dialog_hide ();
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Tool *
|
1999-11-22 19:14:29 +08:00
|
|
|
tools_new_threshold (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
Tool * tool;
|
|
|
|
Threshold * private;
|
|
|
|
|
|
|
|
/* The tool options */
|
1999-04-13 01:55:06 +08:00
|
|
|
if (! threshold_options)
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
2000-02-01 05:27:00 +08:00
|
|
|
threshold_options = tool_options_new (_("Threshold"));
|
1999-04-13 01:55:06 +08:00
|
|
|
tools_register (THRESHOLD, threshold_options);
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-03 01:40:10 +08:00
|
|
|
tool = tools_new_tool (THRESHOLD);
|
2000-06-23 08:14:07 +08:00
|
|
|
private = g_new0 (Threshold, 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-03 01:40:10 +08:00
|
|
|
tool->scroll_lock = TRUE; /* Disallow scrolling */
|
|
|
|
tool->preserve = FALSE; /* Don't preserve on drawable change */
|
1999-06-22 06:12:07 +08:00
|
|
|
|
1999-07-03 01:40:10 +08:00
|
|
|
tool->private = (void *) private;
|
1999-06-26 19:16:47 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
tool->control_func = threshold_control;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return tool;
|
|
|
|
}
|
|
|
|
|
2000-09-29 09:22:27 +08:00
|
|
|
void
|
|
|
|
threshold_dialog_hide (void)
|
|
|
|
{
|
|
|
|
if (threshold_dialog)
|
|
|
|
threshold_cancel_callback (NULL, (gpointer) threshold_dialog);
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
|
|
|
tools_free_threshold (Tool *tool)
|
|
|
|
{
|
|
|
|
Threshold * thresh;
|
|
|
|
|
|
|
|
thresh = (Threshold *) tool->private;
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
/* Close the threshold dialog */
|
2000-09-29 09:22:27 +08:00
|
|
|
threshold_dialog_hide ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
g_free (thresh);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-06-22 04:17:21 +08:00
|
|
|
threshold_initialize (GDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
if (drawable_indexed (gimage_active_drawable (gdisp->gimage)))
|
|
|
|
{
|
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-15 07:23:52 +08:00
|
|
|
g_message (_("Threshold does not operate on indexed drawables."));
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The threshold dialog */
|
|
|
|
if (!threshold_dialog)
|
1999-11-22 19:14:29 +08:00
|
|
|
threshold_dialog = threshold_dialog_new ();
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
|
|
|
if (!GTK_WIDGET_VISIBLE (threshold_dialog->shell))
|
|
|
|
gtk_widget_show (threshold_dialog->shell);
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
threshold_dialog->low_threshold = 127;
|
|
|
|
threshold_dialog->high_threshold = 255;
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
threshold_dialog->drawable = gimage_active_drawable (gdisp->gimage);
|
|
|
|
threshold_dialog->color = drawable_color (threshold_dialog->drawable);
|
1999-06-26 19:16:47 +08:00
|
|
|
threshold_dialog->image_map =
|
|
|
|
image_map_create (gdisp, threshold_dialog->drawable);
|
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 13:11:19 +08:00
|
|
|
|
1999-06-26 19:16:47 +08:00
|
|
|
gimp_histogram_calculate_drawable (threshold_dialog->hist,
|
|
|
|
threshold_dialog->drawable);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
|
|
|
gtk_signal_handler_block_by_data (GTK_OBJECT (threshold_dialog->histogram),
|
|
|
|
threshold_dialog);
|
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 13:11:19 +08:00
|
|
|
histogram_widget_update (threshold_dialog->histogram,
|
|
|
|
threshold_dialog->hist);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_signal_handler_unblock_by_data (GTK_OBJECT (threshold_dialog->histogram),
|
|
|
|
threshold_dialog);
|
|
|
|
|
|
|
|
threshold_update (threshold_dialog, ALL);
|
1999-06-26 19:16:47 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (threshold_dialog->preview)
|
|
|
|
threshold_preview (threshold_dialog);
|
|
|
|
}
|
|
|
|
|
1999-06-23 23:24:46 +08:00
|
|
|
/**********************/
|
|
|
|
/* Threshold dialog */
|
|
|
|
/**********************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static ThresholdDialog *
|
1999-11-22 19:14:29 +08:00
|
|
|
threshold_dialog_new (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
1999-11-22 19:14:29 +08:00
|
|
|
GtkWidget *spinbutton;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *toggle;
|
1999-11-22 19:14:29 +08:00
|
|
|
GtkObject *data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
td = g_new (ThresholdDialog, 1);
|
|
|
|
td->preview = TRUE;
|
|
|
|
td->low_threshold = 127;
|
1997-11-25 06:05:25 +08:00
|
|
|
td->high_threshold = 255;
|
1999-09-28 01:58:10 +08:00
|
|
|
td->hist = gimp_histogram_new ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The shell and main vbox */
|
1999-09-28 01:58:10 +08:00
|
|
|
td->shell =
|
|
|
|
gimp_dialog_new (_("Threshold"), "threshold",
|
|
|
|
tools_help_func, NULL,
|
|
|
|
GTK_WIN_POS_NONE,
|
|
|
|
FALSE, TRUE, FALSE,
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
_("OK"), threshold_ok_callback,
|
2000-01-07 00:40:17 +08:00
|
|
|
td, NULL, NULL, TRUE, FALSE,
|
1999-12-02 21:00:18 +08:00
|
|
|
_("Reset"), threshold_reset_callback,
|
2000-01-07 00:40:17 +08:00
|
|
|
td, NULL, NULL, TRUE, FALSE,
|
1999-09-28 01:58:10 +08:00
|
|
|
_("Cancel"), threshold_cancel_callback,
|
2000-01-07 00:40:17 +08:00
|
|
|
td, NULL, NULL, FALSE, TRUE,
|
1999-09-28 01:58:10 +08:00
|
|
|
|
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
1999-09-28 01:58:10 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (td->shell)->vbox), vbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Horizontal box for threshold text widget */
|
1999-11-22 19:14:29 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
label = gtk_label_new (_("Threshold Range:"));
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
/* low threshold spinbutton */
|
|
|
|
data = gtk_adjustment_new (td->low_threshold, 0.0, 255.0, 1.0, 10.0, 0.0);
|
|
|
|
td->low_threshold_data = GTK_ADJUSTMENT (data);
|
|
|
|
|
|
|
|
spinbutton = gtk_spin_button_new (td->low_threshold_data, 1.0, 0);
|
|
|
|
gtk_widget_set_usize (spinbutton, 75, -1);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (td->low_threshold_data), "value_changed",
|
|
|
|
GTK_SIGNAL_FUNC (threshold_low_threshold_adjustment_update),
|
1997-11-25 06:05:25 +08:00
|
|
|
td);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
|
|
|
/* high threshold spinbutton */
|
|
|
|
data = gtk_adjustment_new (td->high_threshold, 0.0, 255.0, 1.0, 10.0, 0.0);
|
|
|
|
td->high_threshold_data = GTK_ADJUSTMENT (data);
|
|
|
|
|
|
|
|
spinbutton = gtk_spin_button_new (td->high_threshold_data, 1.0, 0);
|
|
|
|
gtk_widget_set_usize (spinbutton, 75, -1);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (td->high_threshold_data), "value_changed",
|
|
|
|
GTK_SIGNAL_FUNC (threshold_high_threshold_adjustment_update),
|
1997-11-25 06:05:25 +08:00
|
|
|
td);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
/* The threshold histogram */
|
1999-11-22 19:14:29 +08:00
|
|
|
hbox = gtk_hbox_new (TRUE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, FALSE, 0);
|
|
|
|
|
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 13:11:19 +08:00
|
|
|
td->histogram = histogram_widget_new (HISTOGRAM_WIDTH, HISTOGRAM_HEIGHT);
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (td->histogram));
|
|
|
|
|
2000-12-25 00:55:13 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (td->histogram), "range_changed",
|
1999-11-22 19:14:29 +08:00
|
|
|
GTK_SIGNAL_FUNC (threshold_histogram_range),
|
|
|
|
td);
|
|
|
|
|
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 13:11:19 +08:00
|
|
|
gtk_widget_show (GTK_WIDGET(td->histogram));
|
1999-11-22 19:14:29 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
/* Horizontal box for preview */
|
1999-11-22 19:14:29 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The preview toggle */
|
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-15 07:23:52 +08:00
|
|
|
toggle = gtk_check_button_new_with_label (_("Preview"));
|
1999-01-16 01:35:04 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), td->preview);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (toggle), "toggled",
|
1999-11-22 19:14:29 +08:00
|
|
|
GTK_SIGNAL_FUNC (threshold_preview_update),
|
1997-11-25 06:05:25 +08:00
|
|
|
td);
|
|
|
|
|
|
|
|
gtk_widget_show (toggle);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_widget_show (td->shell);
|
|
|
|
|
|
|
|
return td;
|
|
|
|
}
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
static void
|
|
|
|
threshold_update (ThresholdDialog *td,
|
|
|
|
gint update)
|
|
|
|
{
|
|
|
|
if (update & LOW)
|
|
|
|
{
|
|
|
|
gtk_adjustment_set_value (td->low_threshold_data, td->low_threshold);
|
|
|
|
}
|
|
|
|
if (update & HIGH)
|
|
|
|
{
|
|
|
|
gtk_adjustment_set_value (td->high_threshold_data, td->high_threshold);
|
|
|
|
}
|
|
|
|
if (update & HISTOGRAM)
|
|
|
|
{
|
|
|
|
histogram_widget_range (td->histogram,
|
|
|
|
td->low_threshold,
|
|
|
|
td->high_threshold);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
|
|
|
threshold_preview (ThresholdDialog *td)
|
|
|
|
{
|
|
|
|
if (!td->image_map)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
|
|
|
g_warning ("threshold_preview(): No image map");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
active_tool->preserve = TRUE;
|
|
|
|
image_map_apply (td->image_map, threshold, td);
|
|
|
|
active_tool->preserve = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
threshold_reset_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
|
|
|
|
td = (ThresholdDialog *) data;
|
|
|
|
|
|
|
|
td->low_threshold = 127.0;
|
|
|
|
td->high_threshold = 255.0;
|
|
|
|
|
|
|
|
threshold_update (td, ALL);
|
|
|
|
|
|
|
|
if (td->preview)
|
|
|
|
threshold_preview (td);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
threshold_ok_callback (GtkWidget *widget,
|
1999-11-22 19:14:29 +08:00
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
td = (ThresholdDialog *) data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-03-29 07:02:05 +08:00
|
|
|
gimp_dialog_hide (td->shell);
|
|
|
|
|
1998-04-02 12:51:44 +08:00
|
|
|
active_tool->preserve = TRUE;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (!td->preview)
|
|
|
|
image_map_apply (td->image_map, threshold, (void *) td);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (td->image_map)
|
|
|
|
image_map_commit (td->image_map);
|
|
|
|
|
1998-04-02 12:51:44 +08:00
|
|
|
active_tool->preserve = FALSE;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
td->image_map = NULL;
|
1999-06-26 19:16:47 +08:00
|
|
|
|
|
|
|
active_tool->gdisp_ptr = NULL;
|
|
|
|
active_tool->drawable = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
threshold_cancel_callback (GtkWidget *widget,
|
1999-11-22 19:14:29 +08:00
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
td = (ThresholdDialog *) data;
|
|
|
|
|
2000-03-29 07:02:05 +08:00
|
|
|
gimp_dialog_hide (td->shell);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (td->image_map)
|
|
|
|
{
|
1998-04-02 12:51:44 +08:00
|
|
|
active_tool->preserve = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
image_map_abort (td->image_map);
|
1998-04-02 12:51:44 +08:00
|
|
|
active_tool->preserve = FALSE;
|
1999-06-23 23:24:46 +08:00
|
|
|
|
|
|
|
td->image_map = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
gdisplays_flush ();
|
|
|
|
}
|
1999-06-26 19:16:47 +08:00
|
|
|
|
|
|
|
active_tool->gdisp_ptr = NULL;
|
|
|
|
active_tool->drawable = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-11-22 19:14:29 +08:00
|
|
|
threshold_preview_update (GtkWidget *widget,
|
1997-11-25 06:05:25 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
|
|
|
|
td = (ThresholdDialog *) data;
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
if (GTK_TOGGLE_BUTTON (widget)->active)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
td->preview = TRUE;
|
|
|
|
threshold_preview (td);
|
|
|
|
}
|
|
|
|
else
|
2000-06-13 17:13:16 +08:00
|
|
|
{
|
|
|
|
td->preview = FALSE;
|
|
|
|
if (td->image_map)
|
|
|
|
{
|
|
|
|
active_tool->preserve = TRUE;
|
|
|
|
image_map_clear (td->image_map);
|
|
|
|
active_tool->preserve = FALSE;
|
|
|
|
gdisplays_flush ();
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-11-22 19:14:29 +08:00
|
|
|
threshold_low_threshold_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
|
|
|
|
td = (ThresholdDialog *) data;
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
if (td->low_threshold != adjustment->value)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
td->low_threshold = adjustment->value;
|
|
|
|
|
|
|
|
threshold_update (td, HISTOGRAM);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (td->preview)
|
|
|
|
threshold_preview (td);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-11-22 19:14:29 +08:00
|
|
|
threshold_high_threshold_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
|
|
|
|
td = (ThresholdDialog *) data;
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
if (td->high_threshold != adjustment->value)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
td->high_threshold = adjustment->value;
|
|
|
|
|
|
|
|
threshold_update (td, HISTOGRAM);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (td->preview)
|
|
|
|
threshold_preview (td);
|
|
|
|
}
|
|
|
|
}
|
1999-11-22 19:14:29 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
threshold_histogram_range (HistogramWidget *widget,
|
|
|
|
gint start,
|
|
|
|
gint end,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
|
|
|
|
td = (ThresholdDialog *) data;
|
|
|
|
|
|
|
|
td->low_threshold = start;
|
|
|
|
td->high_threshold = end;
|
|
|
|
|
|
|
|
threshold_update (td, LOW | HIGH);
|
|
|
|
|
|
|
|
if (td->preview)
|
|
|
|
threshold_preview (td);
|
|
|
|
}
|