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
|
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include "appenv.h"
|
|
|
|
#include "actionarea.h"
|
|
|
|
#include "drawable.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "gdisplay.h"
|
|
|
|
#include "interface.h"
|
|
|
|
#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"
|
|
|
|
|
1999-06-22 06:12:07 +08:00
|
|
|
#define TEXT_WIDTH 45
|
|
|
|
#define HISTOGRAM_WIDTH 256
|
1997-11-25 06:05:25 +08:00
|
|
|
#define HISTOGRAM_HEIGHT 150
|
|
|
|
|
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;
|
1997-11-25 06:05:25 +08:00
|
|
|
struct _Threshold
|
|
|
|
{
|
|
|
|
int x, y; /* coords for last mouse click */
|
|
|
|
};
|
|
|
|
|
1999-04-13 01:55:06 +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;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* 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-06-22 06:12:07 +08:00
|
|
|
static ThresholdDialog * threshold_new_dialog (void);
|
1999-06-23 23:24:46 +08:00
|
|
|
|
1999-06-22 06:12:07 +08:00
|
|
|
static void threshold_preview (ThresholdDialog *);
|
|
|
|
static void threshold_ok_callback (GtkWidget *, gpointer);
|
|
|
|
static void threshold_cancel_callback (GtkWidget *, gpointer);
|
|
|
|
static gint threshold_delete_callback (GtkWidget *, GdkEvent *,
|
|
|
|
gpointer);
|
|
|
|
static void threshold_preview_update (GtkWidget *, gpointer);
|
|
|
|
static void threshold_low_threshold_text_update (GtkWidget *, gpointer);
|
|
|
|
static void threshold_high_threshold_text_update (GtkWidget *, gpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-06-22 06:12:07 +08:00
|
|
|
static void threshold (PixelRegion *, PixelRegion *, void *);
|
|
|
|
static void threshold_histogram_range (HistogramWidget *, int, int, void *);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
|
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
|
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
|
|
|
threshold_2 (void *user_data,
|
|
|
|
PixelRegion *srcPR,
|
|
|
|
PixelRegion *destPR)
|
|
|
|
{
|
|
|
|
/* this function just re-orders the arguments so we can use
|
|
|
|
pixel_regions_process_paralell */
|
|
|
|
threshold(srcPR, destPR, user_data);
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
|
|
|
threshold (PixelRegion *srcPR,
|
|
|
|
PixelRegion *destPR,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
unsigned char *src, *s;
|
|
|
|
unsigned char *dest, *d;
|
|
|
|
int has_alpha, alpha;
|
|
|
|
int w, h, b;
|
|
|
|
int value;
|
|
|
|
|
|
|
|
td = (ThresholdDialog *) user_data;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
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
|
|
|
threshold_histogram_range (HistogramWidget *w,
|
|
|
|
int start,
|
1997-11-25 06:05:25 +08:00
|
|
|
int end,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
char text[12];
|
|
|
|
|
|
|
|
td = (ThresholdDialog *) user_data;
|
|
|
|
|
|
|
|
td->low_threshold = start;
|
|
|
|
td->high_threshold = end;
|
|
|
|
sprintf (text, "%d", start);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (td->low_threshold_text), text);
|
|
|
|
sprintf (text, "%d", end);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (td->high_threshold_text), text);
|
|
|
|
|
|
|
|
if (td->preview)
|
|
|
|
threshold_preview (td);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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:
|
1997-11-25 06:05:25 +08:00
|
|
|
if (threshold_dialog)
|
1999-06-23 23:24:46 +08:00
|
|
|
threshold_cancel_callback (NULL, (gpointer) threshold_dialog);
|
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 *
|
|
|
|
tools_new_threshold ()
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
1999-04-13 01:55:06 +08:00
|
|
|
threshold_options = tool_options_new (_("Threshold Options"));
|
|
|
|
tools_register (THRESHOLD, threshold_options);
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The threshold dialog */
|
1999-04-13 01:55:06 +08:00
|
|
|
if (! threshold_dialog)
|
1997-11-25 06:05:25 +08:00
|
|
|
threshold_dialog = threshold_new_dialog ();
|
|
|
|
else
|
|
|
|
if (!GTK_WIDGET_VISIBLE (threshold_dialog->shell))
|
|
|
|
gtk_widget_show (threshold_dialog->shell);
|
|
|
|
|
1999-07-03 01:40:10 +08:00
|
|
|
tool = tools_new_tool (THRESHOLD);
|
|
|
|
private = g_new (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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tools_free_threshold (Tool *tool)
|
|
|
|
{
|
|
|
|
Threshold * thresh;
|
|
|
|
|
|
|
|
thresh = (Threshold *) tool->private;
|
|
|
|
|
|
|
|
/* Close the color select dialog */
|
|
|
|
if (threshold_dialog)
|
1998-04-02 12:51:44 +08:00
|
|
|
threshold_cancel_callback (NULL, (gpointer) threshold_dialog);
|
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)
|
|
|
|
threshold_dialog = threshold_new_dialog ();
|
|
|
|
else
|
|
|
|
if (!GTK_WIDGET_VISIBLE (threshold_dialog->shell))
|
|
|
|
gtk_widget_show (threshold_dialog->shell);
|
|
|
|
|
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);
|
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);
|
|
|
|
histogram_widget_range (threshold_dialog->histogram,
|
|
|
|
threshold_dialog->low_threshold,
|
|
|
|
threshold_dialog->high_threshold);
|
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 *
|
1997-11-25 06:05:25 +08:00
|
|
|
threshold_new_dialog ()
|
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *toggle;
|
|
|
|
|
1999-06-23 23:24:46 +08:00
|
|
|
static ActionAreaItem action_items[] =
|
|
|
|
{
|
|
|
|
{ N_("OK"), threshold_ok_callback, NULL, NULL },
|
|
|
|
{ N_("Cancel"), threshold_cancel_callback, NULL, NULL }
|
|
|
|
};
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
td = g_malloc (sizeof (ThresholdDialog));
|
|
|
|
td->preview = TRUE;
|
|
|
|
td->low_threshold = 127;
|
|
|
|
td->high_threshold = 255;
|
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->hist = gimp_histogram_new();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The shell and main vbox */
|
|
|
|
td->shell = gtk_dialog_new ();
|
1998-01-26 06:13:00 +08:00
|
|
|
gtk_window_set_wmclass (GTK_WINDOW (td->shell), "threshold", "Gimp");
|
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
|
|
|
gtk_window_set_title (GTK_WINDOW (td->shell), _("Threshold"));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* handle the wm close signal */
|
|
|
|
gtk_signal_connect (GTK_OBJECT (td->shell), "delete_event",
|
|
|
|
GTK_SIGNAL_FUNC (threshold_delete_callback),
|
|
|
|
td);
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 2);
|
1998-12-04 07:01:44 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (td->shell)->vbox), vbox, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
/* Horizontal box for threshold text widget */
|
|
|
|
hbox = gtk_hbox_new (TRUE, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
|
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
|
|
|
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);
|
|
|
|
|
|
|
|
/* low threshold text */
|
|
|
|
td->low_threshold_text = gtk_entry_new ();
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (td->low_threshold_text), "127");
|
|
|
|
gtk_widget_set_usize (td->low_threshold_text, TEXT_WIDTH, 25);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), td->low_threshold_text, FALSE, FALSE, 0);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (td->low_threshold_text), "changed",
|
|
|
|
(GtkSignalFunc) threshold_low_threshold_text_update,
|
|
|
|
td);
|
|
|
|
gtk_widget_show (td->low_threshold_text);
|
|
|
|
|
|
|
|
/* high threshold text */
|
|
|
|
td->high_threshold_text = gtk_entry_new ();
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (td->high_threshold_text), "255");
|
|
|
|
gtk_widget_set_usize (td->high_threshold_text, TEXT_WIDTH, 25);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), td->high_threshold_text, FALSE, FALSE, 0);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (td->high_threshold_text), "changed",
|
|
|
|
(GtkSignalFunc) threshold_high_threshold_text_update,
|
|
|
|
td);
|
|
|
|
gtk_widget_show (td->high_threshold_text);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
/* The threshold histogram */
|
|
|
|
hbox = gtk_hbox_new (TRUE, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (td->histogram), "rangechanged",
|
|
|
|
(GtkSignalFunc) threshold_histogram_range,
|
|
|
|
(void*)td);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET(td->histogram));
|
|
|
|
gtk_widget_show (GTK_WIDGET(td->histogram));
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
/* Horizontal box for preview */
|
|
|
|
hbox = gtk_hbox_new (TRUE, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
/* 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);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), toggle, TRUE, FALSE, 0);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (toggle), "toggled",
|
|
|
|
(GtkSignalFunc) threshold_preview_update,
|
|
|
|
td);
|
|
|
|
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_widget_show (toggle);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
/* The action area */
|
|
|
|
action_items[0].user_data = td;
|
|
|
|
action_items[1].user_data = td;
|
|
|
|
build_action_area (GTK_DIALOG (td->shell), action_items, 2, 0);
|
|
|
|
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_widget_show (td->shell);
|
|
|
|
|
|
|
|
/* This code is so far removed from the histogram creation because the
|
|
|
|
function histogram_range requires a non-NULL drawable, and that
|
|
|
|
doesn't happen until after the top-level dialog is shown. */
|
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_range (td->histogram, td->low_threshold, td->high_threshold);
|
1997-11-25 06:05:25 +08:00
|
|
|
return td;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
threshold_preview (ThresholdDialog *td)
|
|
|
|
{
|
|
|
|
if (!td->image_map)
|
1999-06-06 07:41:45 +08:00
|
|
|
g_warning ("threshold_preview(): No image map");
|
1997-11-25 06:05:25 +08:00
|
|
|
image_map_apply (td->image_map, threshold, (void *) td);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
threshold_ok_callback (GtkWidget *widget,
|
|
|
|
gpointer client_data)
|
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
|
|
|
|
td = (ThresholdDialog *) client_data;
|
|
|
|
|
|
|
|
if (GTK_WIDGET_VISIBLE (td->shell))
|
|
|
|
gtk_widget_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);
|
|
|
|
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 gint
|
|
|
|
threshold_delete_callback (GtkWidget *w,
|
|
|
|
GdkEvent *e,
|
|
|
|
gpointer client_data)
|
|
|
|
{
|
|
|
|
threshold_cancel_callback (w, client_data);
|
|
|
|
|
1998-03-13 06:01:43 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
threshold_cancel_callback (GtkWidget *widget,
|
|
|
|
gpointer client_data)
|
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
|
|
|
|
td = (ThresholdDialog *) client_data;
|
|
|
|
if (GTK_WIDGET_VISIBLE (td->shell))
|
|
|
|
gtk_widget_hide (td->shell);
|
|
|
|
|
|
|
|
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
|
|
|
|
threshold_preview_update (GtkWidget *w,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
|
|
|
|
td = (ThresholdDialog *) data;
|
|
|
|
|
|
|
|
if (GTK_TOGGLE_BUTTON (w)->active)
|
|
|
|
{
|
|
|
|
td->preview = TRUE;
|
|
|
|
threshold_preview (td);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
td->preview = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
threshold_low_threshold_text_update (GtkWidget *w,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
char *str;
|
|
|
|
int value;
|
|
|
|
|
|
|
|
td = (ThresholdDialog *) data;
|
|
|
|
str = gtk_entry_get_text (GTK_ENTRY (w));
|
|
|
|
value = BOUNDS (((int) atof (str)), 0, td->high_threshold);
|
|
|
|
|
|
|
|
if (value != td->low_threshold)
|
|
|
|
{
|
|
|
|
td->low_threshold = value;
|
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_range (td->histogram,
|
|
|
|
td->low_threshold,
|
|
|
|
td->high_threshold);
|
1997-11-25 06:05:25 +08:00
|
|
|
if (td->preview)
|
|
|
|
threshold_preview (td);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
threshold_high_threshold_text_update (GtkWidget *w,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ThresholdDialog *td;
|
|
|
|
char *str;
|
|
|
|
int value;
|
|
|
|
|
|
|
|
td = (ThresholdDialog *) data;
|
|
|
|
str = gtk_entry_get_text (GTK_ENTRY (w));
|
|
|
|
value = BOUNDS (((int) atof (str)), td->low_threshold, 255);
|
|
|
|
|
|
|
|
if (value != td->high_threshold)
|
|
|
|
{
|
|
|
|
td->high_threshold = value;
|
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_range (td->histogram,
|
|
|
|
td->low_threshold,
|
|
|
|
td->high_threshold);
|
1997-11-25 06:05:25 +08:00
|
|
|
if (td->preview)
|
|
|
|
threshold_preview (td);
|
|
|
|
}
|
|
|
|
}
|