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-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
#include "tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
#include "base/gimplut.h"
|
|
|
|
#include "base/lut-funcs.h"
|
|
|
|
|
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
2001-05-26 00:04:54 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
#include "gimpposterizetool.h"
|
|
|
|
#include "tool_manager.h"
|
|
|
|
#include "tool_options.h"
|
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
#include "app_procs.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "gdisplay.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "image_map.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-16 08:37:09 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
typedef struct _PosterizeDialog PosterizeDialog;
|
1999-11-22 19:14:29 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
struct _PosterizeDialog
|
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
GtkWidget *shell;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
GtkAdjustment *levels_data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
GimpDrawable *drawable;
|
2001-05-25 07:57:08 +08:00
|
|
|
ImageMap *image_map;
|
1999-02-16 16:53:54 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
gint levels;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
gboolean preview;
|
|
|
|
|
|
|
|
GimpLut *lut;
|
|
|
|
};
|
1999-04-13 01:55:06 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
|
|
|
static void gimp_posterize_tool_class_init (GimpPosterizeToolClass *klass);
|
|
|
|
static void gimp_posterize_tool_init (GimpPosterizeTool *bc_tool);
|
|
|
|
|
|
|
|
static void gimp_posterize_tool_initialize (GimpTool *tool,
|
|
|
|
GDisplay *gdisp);
|
|
|
|
static void gimp_posterize_tool_control (GimpTool *tool,
|
|
|
|
ToolAction action,
|
|
|
|
GDisplay *gdisp);
|
2000-12-31 12:07:42 +08:00
|
|
|
|
|
|
|
static PosterizeDialog * posterize_dialog_new (void);
|
|
|
|
|
|
|
|
static void posterize_preview (PosterizeDialog *pd);
|
|
|
|
static void posterize_reset_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void posterize_ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void posterize_cancel_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void posterize_preview_update (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void posterize_levels_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* the posterize tool options */
|
2001-07-18 04:50:01 +08:00
|
|
|
static GimpToolOptions *posterize_options = NULL;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
|
|
|
/* the posterize tool dialog */
|
|
|
|
static PosterizeDialog *posterize_dialog = NULL;
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
static GimpImageMapToolClass *parent_class = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
/* functions */
|
1999-06-22 06:12:07 +08:00
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
void
|
2001-07-07 20:17:23 +08:00
|
|
|
gimp_posterize_tool_register (Gimp *gimp)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2001-07-07 20:17:23 +08:00
|
|
|
tool_manager_register_tool (gimp,
|
|
|
|
GIMP_TYPE_POSTERIZE_TOOL,
|
2001-05-25 07:57:08 +08:00
|
|
|
FALSE,
|
|
|
|
"gimp:posterize_tool",
|
|
|
|
_("Posterize"),
|
|
|
|
_("Reduce image to a fixed numer of colors"),
|
|
|
|
N_("/Image/Colors/Posterize..."), NULL,
|
|
|
|
NULL, "tools/posterize.html",
|
2001-08-06 00:08:19 +08:00
|
|
|
GIMP_STOCK_TOOL_POSTERIZE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
GType
|
2001-05-25 07:57:08 +08:00
|
|
|
gimp_posterize_tool_get_type (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static GType tool_type = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
if (! tool_type)
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static const GTypeInfo tool_info =
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
|
|
|
sizeof (GimpPosterizeToolClass),
|
2001-08-14 22:53:55 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_posterize_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpPosterizeTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_posterize_tool_init,
|
2001-05-25 07:57:08 +08:00
|
|
|
};
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_IMAGE_MAP_TOOL,
|
|
|
|
"GimpPosterizeTool",
|
|
|
|
&tool_info, 0);
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
return tool_type;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
static void
|
|
|
|
gimp_posterize_tool_class_init (GimpPosterizeToolClass *klass)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
GimpToolClass *tool_class;
|
1999-06-26 19:16:47 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
tool_class = GIMP_TOOL_CLASS (klass);
|
1999-06-22 06:12:07 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
tool_class->initialize = gimp_posterize_tool_initialize;
|
|
|
|
tool_class->control = gimp_posterize_tool_control;
|
2000-09-29 09:22:27 +08:00
|
|
|
}
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
static void
|
|
|
|
gimp_posterize_tool_init (GimpPosterizeTool *bc_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-05-25 07:57:08 +08:00
|
|
|
GimpTool *tool;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
tool = GIMP_TOOL (bc_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
if (! posterize_options)
|
|
|
|
{
|
|
|
|
posterize_options = tool_options_new ();
|
|
|
|
|
|
|
|
tool_manager_register_tool_options (GIMP_TYPE_POSTERIZE_TOOL,
|
2001-07-18 04:50:01 +08:00
|
|
|
(GimpToolOptions *) posterize_options);
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_posterize_tool_initialize (GimpTool *tool,
|
|
|
|
GDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-05-25 07:57:08 +08:00
|
|
|
if (! gdisp)
|
|
|
|
{
|
|
|
|
posterize_dialog_hide ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
if (gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-16 08:37:09 +08:00
|
|
|
g_message (_("Posterize does not operate on indexed drawables."));
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The posterize dialog */
|
|
|
|
if (!posterize_dialog)
|
1999-11-22 19:14:29 +08:00
|
|
|
posterize_dialog = posterize_dialog_new ();
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
|
|
|
if (!GTK_WIDGET_VISIBLE (posterize_dialog->shell))
|
|
|
|
gtk_widget_show (posterize_dialog->shell);
|
1999-06-26 19:16:47 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
posterize_dialog->levels = 3;
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
posterize_dialog->drawable = gimp_image_active_drawable (gdisp->gimage);
|
1999-06-26 19:16:47 +08:00
|
|
|
posterize_dialog->image_map =
|
|
|
|
image_map_create (gdisp, posterize_dialog->drawable);
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (posterize_dialog->levels_data), 3);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (posterize_dialog->preview)
|
|
|
|
posterize_preview (posterize_dialog);
|
|
|
|
}
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
static void
|
|
|
|
gimp_posterize_tool_control (GimpTool *tool,
|
|
|
|
ToolAction action,
|
|
|
|
GDisplay *gdisp)
|
|
|
|
{
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case PAUSE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RESUME:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HALT:
|
|
|
|
posterize_dialog_hide ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GIMP_TOOL_CLASS (parent_class)->control)
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
posterize_dialog_hide (void)
|
|
|
|
{
|
|
|
|
if (posterize_dialog)
|
|
|
|
posterize_cancel_callback (NULL, (gpointer) posterize_dialog);
|
|
|
|
}
|
|
|
|
|
1999-06-23 23:24:46 +08:00
|
|
|
/**********************/
|
|
|
|
/* Posterize dialog */
|
|
|
|
/**********************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static PosterizeDialog *
|
1999-11-22 19:14:29 +08:00
|
|
|
posterize_dialog_new (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
PosterizeDialog *pd;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *label;
|
1999-11-22 19:14:29 +08:00
|
|
|
GtkWidget *spinbutton;
|
1997-11-25 06:05:25 +08:00
|
|
|
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
|
|
|
pd = g_new (PosterizeDialog, 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
pd->preview = TRUE;
|
1999-09-28 01:58:10 +08:00
|
|
|
pd->levels = 3;
|
|
|
|
pd->lut = gimp_lut_new ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The shell and main vbox */
|
1999-09-28 01:58:10 +08:00
|
|
|
pd->shell =
|
|
|
|
gimp_dialog_new (_("Posterize"), "posterize",
|
2001-05-25 07:57:08 +08:00
|
|
|
tool_manager_help_func, NULL,
|
1999-09-28 01:58:10 +08:00
|
|
|
GTK_WIN_POS_NONE,
|
|
|
|
FALSE, TRUE, FALSE,
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-08-04 03:43:19 +08:00
|
|
|
GTK_STOCK_OK, posterize_ok_callback,
|
2000-01-07 00:40:17 +08:00
|
|
|
pd, NULL, NULL, TRUE, FALSE,
|
2001-08-05 04:38:54 +08:00
|
|
|
GIMP_STOCK_RESET, posterize_reset_callback,
|
2000-01-07 00:40:17 +08:00
|
|
|
pd, NULL, NULL, TRUE, FALSE,
|
2001-08-04 03:43:19 +08:00
|
|
|
GTK_STOCK_CANCEL, posterize_cancel_callback,
|
2000-01-07 00:40:17 +08:00
|
|
|
pd, NULL, NULL, FALSE, TRUE,
|
1999-09-28 01:58:10 +08:00
|
|
|
|
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 2);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
1999-09-28 01:58:10 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (pd->shell)->vbox), vbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Horizontal box for levels 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 (_("Posterize Levels:"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
/* levels spinbutton */
|
|
|
|
data = gtk_adjustment_new (3, 2, 256, 1.0, 10.0, 0.0);
|
|
|
|
pd->levels_data = GTK_ADJUSTMENT (data);
|
|
|
|
|
|
|
|
spinbutton = gtk_spin_button_new (pd->levels_data, 1.0, 0);
|
|
|
|
gtk_widget_set_usize (spinbutton, 75, -1);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
|
|
|
|
2001-08-01 10:57:58 +08:00
|
|
|
g_signal_connect (G_OBJECT (pd->levels_data), "value_changed",
|
|
|
|
G_CALLBACK (posterize_levels_adjustment_update),
|
|
|
|
pd);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
|
|
|
gtk_widget_show (spinbutton);
|
1997-11-25 06:05:25 +08:00
|
|
|
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 */
|
1998-12-16 08:37:09 +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), pd->preview);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
|
|
|
|
|
2001-08-01 10:57:58 +08:00
|
|
|
g_signal_connect (G_OBJECT (toggle), "toggled",
|
|
|
|
G_CALLBACK (posterize_preview_update),
|
|
|
|
pd);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_widget_show (toggle);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_widget_show (pd->shell);
|
|
|
|
|
|
|
|
return pd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
posterize_preview (PosterizeDialog *pd)
|
|
|
|
{
|
2001-07-08 01:36:00 +08:00
|
|
|
GimpTool *active_tool;
|
|
|
|
|
|
|
|
active_tool = tool_manager_get_active (the_gimp);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (!pd->image_map)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
|
|
|
g_warning ("posterize_preview(): No image map");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-03-31 15:23:50 +08:00
|
|
|
active_tool->preserve = TRUE;
|
2001-01-15 05:11:52 +08:00
|
|
|
posterize_lut_setup (pd->lut, pd->levels, gimp_drawable_bytes (pd->drawable));
|
1999-11-22 19:14:29 +08:00
|
|
|
image_map_apply (pd->image_map, (ImageMapApplyFunc) gimp_lut_process_2,
|
1999-02-16 16:53:54 +08:00
|
|
|
(void *) pd->lut);
|
1998-03-31 15:23:50 +08:00
|
|
|
active_tool->preserve = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
static void
|
|
|
|
posterize_reset_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
PosterizeDialog *pd;
|
|
|
|
|
|
|
|
pd = (PosterizeDialog *) data;
|
|
|
|
|
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (pd->levels_data), 3);
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
|
|
|
posterize_ok_callback (GtkWidget *widget,
|
1999-11-22 19:14:29 +08:00
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
PosterizeDialog *pd;
|
2001-07-08 01:36:00 +08:00
|
|
|
GimpTool *active_tool;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
pd = (PosterizeDialog *) data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-03-29 07:02:05 +08:00
|
|
|
gimp_dialog_hide (pd->shell);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
active_tool = tool_manager_get_active (the_gimp);
|
|
|
|
|
1998-03-31 15:23:50 +08:00
|
|
|
active_tool->preserve = TRUE;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (!pd->preview)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
|
|
|
posterize_lut_setup( pd->lut, pd->levels,
|
|
|
|
gimp_drawable_bytes (pd->drawable));
|
|
|
|
image_map_apply (pd->image_map, (ImageMapApplyFunc) gimp_lut_process_2,
|
2000-12-31 12:07:42 +08:00
|
|
|
(gpointer) pd->lut);
|
1999-11-22 19:14:29 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (pd->image_map)
|
|
|
|
image_map_commit (pd->image_map);
|
|
|
|
|
1998-03-31 15:23:50 +08:00
|
|
|
active_tool->preserve = FALSE;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
pd->image_map = NULL;
|
1999-06-26 19:16:47 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
active_tool->gdisp = NULL;
|
1999-06-26 19:16:47 +08:00
|
|
|
active_tool->drawable = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
posterize_cancel_callback (GtkWidget *widget,
|
1999-11-22 19:14:29 +08:00
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
PosterizeDialog *pd;
|
2001-07-08 01:36:00 +08:00
|
|
|
GimpTool *active_tool;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
pd = (PosterizeDialog *) data;
|
|
|
|
|
2000-03-29 07:02:05 +08:00
|
|
|
gimp_dialog_hide (pd->shell);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
active_tool = tool_manager_get_active (the_gimp);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (pd->image_map)
|
|
|
|
{
|
1998-03-31 15:23:50 +08:00
|
|
|
active_tool->preserve = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
image_map_abort (pd->image_map);
|
1998-03-31 15:23:50 +08:00
|
|
|
active_tool->preserve = FALSE;
|
1999-06-23 23:24:46 +08:00
|
|
|
|
|
|
|
pd->image_map = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
gdisplays_flush ();
|
|
|
|
}
|
1999-06-26 19:16:47 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
active_tool->gdisp = NULL;
|
1999-06-26 19:16:47 +08:00
|
|
|
active_tool->drawable = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-11-22 19:14:29 +08:00
|
|
|
posterize_preview_update (GtkWidget *widget,
|
1997-11-25 06:05:25 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
PosterizeDialog *pd;
|
2001-07-08 01:36:00 +08:00
|
|
|
GimpTool *active_tool;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
pd = (PosterizeDialog *) data;
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
if (GTK_TOGGLE_BUTTON (widget)->active)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
pd->preview = TRUE;
|
|
|
|
posterize_preview (pd);
|
|
|
|
}
|
|
|
|
else
|
2000-06-13 17:13:16 +08:00
|
|
|
{
|
|
|
|
pd->preview = FALSE;
|
|
|
|
if (pd->image_map)
|
|
|
|
{
|
2001-07-08 01:36:00 +08:00
|
|
|
active_tool = tool_manager_get_active (the_gimp);
|
|
|
|
|
2000-06-13 17:13:16 +08:00
|
|
|
active_tool->preserve = TRUE;
|
|
|
|
image_map_clear (pd->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
|
|
|
posterize_levels_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
PosterizeDialog *pd;
|
|
|
|
|
|
|
|
pd = (PosterizeDialog *) data;
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
if (pd->levels != adjustment->value)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
pd->levels = adjustment->value;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (pd->preview)
|
|
|
|
posterize_preview (pd);
|
|
|
|
}
|
|
|
|
}
|