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-01-14 20:41:00 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-01-14 20:41:00 +08:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpbrush.h"
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
|
|
|
#include "gimpconvolvetool.h"
|
|
|
|
#include "paint_options.h"
|
|
|
|
#include "tool_manager.h"
|
|
|
|
#include "tool_options.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "drawable.h"
|
|
|
|
#include "gdisplay.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "pixel_region.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "selection.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "temp_buf.h"
|
2001-01-25 06:36:18 +08: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-15 07:23:52 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
#include "pixmaps2.h"
|
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
#define FIELD_COLS 4
|
|
|
|
#define MIN_BLUR 64 /* (8/9 original pixel) */
|
|
|
|
#define MAX_BLUR 0.25 /* (1/33 original pixel) */
|
|
|
|
#define MIN_SHARPEN -512
|
|
|
|
#define MAX_SHARPEN -64
|
|
|
|
|
1999-07-20 06:42:49 +08:00
|
|
|
/* defaults */
|
1999-11-13 09:02:27 +08:00
|
|
|
#define DEFAULT_CONVOLVE_RATE 50.0
|
|
|
|
#define DEFAULT_CONVOLVE_TYPE BLUR_CONVOLVE
|
1999-07-20 06:42:49 +08:00
|
|
|
|
2000-11-06 20:40:07 +08:00
|
|
|
|
|
|
|
/* Different clip relationships between a blur-blob and edges:
|
|
|
|
see convolve_motion */
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
CONVOLVE_NCLIP, /* Left or top edge */
|
|
|
|
CONVOLVE_NOT_CLIPPED, /* No edges */
|
|
|
|
CONVOLVE_PCLIP /* Right or bottom edge */
|
|
|
|
} ConvolveClipType;
|
|
|
|
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* the convolve structures */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
typedef struct _ConvolveOptions ConvolveOptions;
|
2000-01-14 20:41:00 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
struct _ConvolveOptions
|
|
|
|
{
|
1999-04-22 22:34:00 +08:00
|
|
|
PaintOptions paint_options;
|
1999-04-13 01:55:06 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
ConvolveType type;
|
1999-04-09 06:25:54 +08:00
|
|
|
ConvolveType type_d;
|
1999-04-28 05:06:00 +08:00
|
|
|
GtkWidget *type_w[2];
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2000-01-14 20:41:00 +08:00
|
|
|
gdouble rate;
|
|
|
|
gdouble rate_d;
|
1999-11-13 09:02:27 +08:00
|
|
|
GtkObject *rate_w;
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
/* forward function declarations */
|
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
static void gimp_convolve_tool_class_init (GimpConvolveToolClass *klass);
|
|
|
|
static void gimp_convolve_tool_init (GimpConvolveTool *tool);
|
|
|
|
|
|
|
|
static void calculate_matrix (ConvolveType type,
|
|
|
|
gdouble rate);
|
|
|
|
static void integer_matrix (gfloat *source,
|
|
|
|
gint *dest,
|
|
|
|
gint size);
|
|
|
|
static void copy_matrix (gfloat *src,
|
|
|
|
gfloat *dest,
|
|
|
|
gint size);
|
|
|
|
static gint sum_matrix (gint *matrix,
|
|
|
|
gint size);
|
|
|
|
|
|
|
|
static void gimp_convolve_tool_paint (GimpPaintTool *paint_tool,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
PaintState state);
|
|
|
|
static void gimp_convolve_tool_cursor_update (GimpTool *tool,
|
|
|
|
GdkEventMotion *mevent,
|
|
|
|
GDisplay *gdisp);
|
|
|
|
static void gimp_convolve_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
GDisplay *gdisp);
|
|
|
|
static void gimp_convolve_tool_motion (GimpPaintTool *paint_tool,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
PaintPressureOptions *pressure_options,
|
|
|
|
ConvolveType type,
|
|
|
|
gdouble rate);
|
|
|
|
|
|
|
|
static ConvolveOptions * convolve_options_new (void);
|
|
|
|
static void convolve_options_reset (ToolOptions *options);
|
|
|
|
|
|
|
|
|
|
|
|
/* The parent class */
|
|
|
|
static GimpPaintToolClass *parent_class;
|
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
/* the convolve tool options */
|
|
|
|
static ConvolveOptions * convolve_options = NULL;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* local variables */
|
2000-01-14 20:41:00 +08:00
|
|
|
static gint matrix [25];
|
|
|
|
static gint matrix_size;
|
|
|
|
static gint matrix_divisor;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-20 06:42:49 +08:00
|
|
|
static ConvolveType non_gui_type;
|
2000-01-14 20:41:00 +08:00
|
|
|
static gdouble non_gui_rate;
|
1999-07-20 06:42:49 +08:00
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
static gfloat custom_matrix [25] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0,
|
|
|
|
0, 0, 1, 0, 0,
|
|
|
|
0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0,
|
|
|
|
};
|
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
static gfloat blur_matrix [25] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
0, 0, 0, 0, 0,
|
|
|
|
0, 1, 1, 1, 0,
|
|
|
|
0, 1, MIN_BLUR, 1, 0,
|
|
|
|
0, 1, 1, 1, 0,
|
|
|
|
0, 0 ,0, 0, 0,
|
|
|
|
};
|
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
static gfloat sharpen_matrix [25] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
0, 0, 0, 0, 0,
|
|
|
|
0, 1, 1, 1, 0,
|
|
|
|
0, 1, MIN_SHARPEN, 1, 0,
|
|
|
|
0, 1, 1, 1, 0,
|
|
|
|
0, 0, 0, 0, 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
/* global functions */
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
void
|
|
|
|
gimp_convolve_tool_register (void)
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
2001-04-19 21:01:44 +08:00
|
|
|
tool_manager_register_tool (GIMP_TYPE_CONVOLVE_TOOL,
|
|
|
|
TRUE,
|
|
|
|
"gimp:convolve_tool",
|
|
|
|
_("Convolve"),
|
|
|
|
_("Blur or Sharpen"),
|
|
|
|
N_("/Tools/Paint Tools/Convolve"), "B",
|
|
|
|
NULL, "tools/convolve.html",
|
|
|
|
(const gchar **) blur_bits);
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
GtkType
|
|
|
|
gimp_convolve_tool_get_type (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-04-19 21:01:44 +08:00
|
|
|
static GtkType tool_type = 0;
|
1999-04-13 01:55:06 +08:00
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
if (! tool_type)
|
|
|
|
{
|
|
|
|
GtkTypeInfo tool_info =
|
|
|
|
{
|
|
|
|
"GimpConvolveTool",
|
|
|
|
sizeof (GimpConvolveTool),
|
|
|
|
sizeof (GimpConvolveToolClass),
|
|
|
|
(GtkClassInitFunc) gimp_convolve_tool_class_init,
|
|
|
|
(GtkObjectInitFunc) gimp_convolve_tool_init,
|
|
|
|
/* reserved_1 */ NULL,
|
|
|
|
/* reserved_2 */ NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
tool_type = gtk_type_unique (GIMP_TYPE_PAINT_TOOL, &tool_info);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
return tool_type;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
/* static functions */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
static void
|
|
|
|
gimp_convolve_tool_class_init (GimpConvolveToolClass *klass)
|
|
|
|
{
|
|
|
|
GimpPaintToolClass *paint_tool_class;
|
|
|
|
GimpDrawToolClass *draw_tool_class;
|
|
|
|
GimpToolClass *tool_class;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
paint_tool_class = (GimpPaintToolClass *) klass;
|
|
|
|
draw_tool_class = (GimpDrawToolClass *) klass;
|
|
|
|
tool_class = (GimpToolClass *) klass;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
parent_class = gtk_type_class (GIMP_TYPE_PAINT_TOOL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
tool_class->cursor_update = gimp_convolve_tool_cursor_update;
|
|
|
|
tool_class->modifier_key = gimp_convolve_tool_modifier_key;
|
2000-01-14 20:41:00 +08:00
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
paint_tool_class->paint = gimp_convolve_tool_paint;
|
|
|
|
}
|
2000-01-14 20:41:00 +08:00
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
static void
|
|
|
|
gimp_convolve_tool_init (GimpConvolveTool *convolve)
|
|
|
|
{
|
|
|
|
GimpTool *tool;
|
|
|
|
GimpPaintTool *paint_tool;
|
2000-01-14 20:41:00 +08:00
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
tool = GIMP_TOOL (convolve);
|
|
|
|
paint_tool = GIMP_PAINT_TOOL (convolve);
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
if (! convolve_options)
|
|
|
|
{
|
|
|
|
convolve_options = convolve_options_new ();
|
|
|
|
|
|
|
|
tool_manager_register_tool_options (GIMP_TYPE_CONVOLVE_TOOL,
|
|
|
|
(ToolOptions *) convolve_options);
|
|
|
|
}
|
|
|
|
|
|
|
|
tool->tool_cursor = GIMP_BLUR_TOOL_CURSOR;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
static void
|
|
|
|
gimp_convolve_tool_paint (GimpPaintTool *paint_tool,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
PaintState state)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case MOTION_PAINT:
|
2001-04-19 21:01:44 +08:00
|
|
|
gimp_convolve_tool_motion (paint_tool, drawable,
|
|
|
|
convolve_options->paint_options.pressure_options,
|
|
|
|
convolve_options->type,
|
|
|
|
convolve_options->rate);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-12-31 12:07:42 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-04-27 10:09:03 +08:00
|
|
|
static void
|
2001-04-19 21:01:44 +08:00
|
|
|
gimp_convolve_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
GDisplay *gdisp)
|
1999-04-27 10:09:03 +08:00
|
|
|
{
|
1999-04-28 05:06:00 +08:00
|
|
|
switch (kevent->keyval)
|
1999-04-27 10:09:03 +08:00
|
|
|
{
|
1999-11-20 08:30:41 +08:00
|
|
|
case GDK_Alt_L:
|
|
|
|
case GDK_Alt_R:
|
1999-04-27 10:09:03 +08:00
|
|
|
break;
|
1999-11-20 08:30:41 +08:00
|
|
|
case GDK_Shift_L:
|
|
|
|
case GDK_Shift_R:
|
|
|
|
if (kevent->state & GDK_CONTROL_MASK) /* reset tool toggle */
|
|
|
|
{
|
|
|
|
switch (convolve_options->type)
|
|
|
|
{
|
|
|
|
case BLUR_CONVOLVE:
|
2000-06-14 22:22:47 +08:00
|
|
|
gtk_toggle_button_set_active
|
|
|
|
(GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]),
|
|
|
|
TRUE);
|
1999-11-20 08:30:41 +08:00
|
|
|
break;
|
|
|
|
case SHARPEN_CONVOLVE:
|
2000-06-14 22:22:47 +08:00
|
|
|
gtk_toggle_button_set_active
|
|
|
|
(GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]),
|
|
|
|
TRUE);
|
1999-11-20 08:30:41 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-06-08 06:38:20 +08:00
|
|
|
break;
|
1999-11-20 08:30:41 +08:00
|
|
|
case GDK_Control_L:
|
|
|
|
case GDK_Control_R:
|
|
|
|
if ( !(kevent->state & GDK_SHIFT_MASK) ) /* shift enables line draw mode */
|
1999-04-28 05:06:00 +08:00
|
|
|
{
|
1999-11-20 08:30:41 +08:00
|
|
|
switch (convolve_options->type)
|
|
|
|
{
|
|
|
|
case BLUR_CONVOLVE:
|
2000-06-14 22:22:47 +08:00
|
|
|
gtk_toggle_button_set_active
|
|
|
|
(GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]),
|
|
|
|
TRUE);
|
1999-11-20 08:30:41 +08:00
|
|
|
break;
|
|
|
|
case SHARPEN_CONVOLVE:
|
2000-06-14 22:22:47 +08:00
|
|
|
gtk_toggle_button_set_active
|
|
|
|
(GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]),
|
|
|
|
TRUE);
|
1999-11-20 08:30:41 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1999-04-28 05:06:00 +08:00
|
|
|
}
|
1999-11-20 08:30:41 +08:00
|
|
|
break;
|
1999-04-27 10:09:03 +08:00
|
|
|
}
|
2000-06-14 22:22:47 +08:00
|
|
|
|
|
|
|
tool->toggled = (convolve_options->type == SHARPEN_CONVOLVE);
|
1999-04-27 10:09:03 +08:00
|
|
|
}
|
|
|
|
|
2000-07-30 00:12:40 +08:00
|
|
|
static void
|
2001-04-19 21:01:44 +08:00
|
|
|
gimp_convolve_tool_cursor_update (GimpTool *tool,
|
|
|
|
GdkEventMotion *mevent,
|
|
|
|
GDisplay *gdisp)
|
2000-07-30 00:12:40 +08:00
|
|
|
{
|
|
|
|
tool->toggled = (convolve_options->type == SHARPEN_CONVOLVE);
|
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
if (GIMP_TOOL_CLASS (parent_class)->cursor_update)
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, mevent, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2001-04-19 21:01:44 +08:00
|
|
|
gimp_convolve_tool_motion (GimpPaintTool *paint_tool,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
PaintPressureOptions *pressure_options,
|
|
|
|
ConvolveType type,
|
|
|
|
double rate)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-04-19 21:01:44 +08:00
|
|
|
TempBuf *area;
|
|
|
|
guchar *temp_data;
|
|
|
|
PixelRegion srcPR;
|
|
|
|
PixelRegion destPR;
|
|
|
|
gdouble scale;
|
|
|
|
ConvolveClipType area_hclip = CONVOLVE_NOT_CLIPPED;
|
|
|
|
ConvolveClipType area_vclip = CONVOLVE_NOT_CLIPPED;
|
|
|
|
gint marginx = 0;
|
|
|
|
gint marginy = 0;
|
2000-11-05 01:54:01 +08:00
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
if (! gimp_drawable_gimage (drawable))
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* If the image type is indexed, don't convolve */
|
2001-01-15 05:11:52 +08:00
|
|
|
if (gimp_drawable_is_indexed (drawable))
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
2000-11-05 01:54:01 +08:00
|
|
|
/* If the brush is smaller than the convolution matrix, don't convolve */
|
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
if ((paint_tool->brush->mask->width < matrix_size) ||
|
|
|
|
(paint_tool->brush->mask->height < matrix_size))
|
2000-11-05 01:54:01 +08:00
|
|
|
return;
|
|
|
|
|
1999-09-09 09:47:54 +08:00
|
|
|
if (pressure_options->size)
|
2001-04-19 21:01:44 +08:00
|
|
|
scale = paint_tool->curpressure;
|
1999-09-09 09:47:54 +08:00
|
|
|
else
|
|
|
|
scale = 1.0;
|
|
|
|
|
2000-11-05 01:54:01 +08:00
|
|
|
/* Get image region around current brush (mask bbox + 1 pixel) */
|
2001-04-19 21:01:44 +08:00
|
|
|
if (! (area = gimp_paint_tool_get_paint_area (paint_tool, drawable, scale)))
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
2000-11-05 01:54:01 +08:00
|
|
|
/* configure the source pixel region */
|
2001-01-15 05:11:52 +08:00
|
|
|
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
|
2000-04-28 01:27:28 +08:00
|
|
|
area->x, area->y, area->width, area->height, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-11-05 01:54:01 +08:00
|
|
|
/* Configure the destination pixel region - a paint_core TempBuf */
|
|
|
|
|
|
|
|
destPR.bytes = area->bytes;
|
|
|
|
destPR.tiles = NULL;
|
|
|
|
destPR.x = 0;
|
|
|
|
destPR.y = 0;
|
|
|
|
destPR.w = area->width;
|
|
|
|
destPR.h = area->height;
|
1997-11-25 06:05:25 +08:00
|
|
|
destPR.rowstride = area->width * destPR.bytes;
|
2000-11-05 01:54:01 +08:00
|
|
|
destPR.data = temp_buf_data (area);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-13 09:02:27 +08:00
|
|
|
if (pressure_options->rate)
|
2001-04-19 21:01:44 +08:00
|
|
|
rate = rate * 2.0 * paint_tool->curpressure;
|
1999-11-13 09:02:27 +08:00
|
|
|
|
|
|
|
calculate_matrix (type, rate);
|
2000-11-05 01:54:01 +08:00
|
|
|
|
|
|
|
/* Image region near edges? If so, paint area will be clipped */
|
|
|
|
/* with respect to brush mask + 1 pixel border (# 19285) */
|
2001-04-19 21:01:44 +08:00
|
|
|
|
|
|
|
if ((marginx = (gint) paint_tool->curx - paint_tool->brush->mask->width / 2 - 1) != area->x)
|
2000-11-05 01:54:01 +08:00
|
|
|
area_hclip = CONVOLVE_NCLIP;
|
2001-04-19 21:01:44 +08:00
|
|
|
else if ((marginx = area->width - paint_tool->brush->mask->width - 2) != 0)
|
|
|
|
area_hclip = CONVOLVE_PCLIP;
|
2000-11-05 01:54:01 +08:00
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
if ((marginy = (gint) paint_tool->cury - paint_tool->brush->mask->height / 2 - 1) != area->y)
|
2000-11-05 01:54:01 +08:00
|
|
|
area_vclip = CONVOLVE_NCLIP;
|
2001-04-19 21:01:44 +08:00
|
|
|
else if ((marginy = area->height - paint_tool->brush->mask->height - 2) != 0)
|
|
|
|
area_vclip = CONVOLVE_PCLIP;
|
1999-02-05 07:28:09 +08:00
|
|
|
|
2000-11-05 01:54:01 +08:00
|
|
|
/* Has the TempBuf been clipped by a canvas edge or two ? */
|
2001-04-19 21:01:44 +08:00
|
|
|
if ((area_hclip == CONVOLVE_NOT_CLIPPED) &&
|
|
|
|
(area_vclip == CONVOLVE_NOT_CLIPPED))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-11-05 01:54:01 +08:00
|
|
|
/* No clipping... */
|
|
|
|
/* Standard case: copy src to temp. convolve temp to dest. */
|
|
|
|
/* Brush defines pipe size and no edge adjustments are needed. */
|
|
|
|
|
|
|
|
/* If the source has no alpha, then add alpha pixels */
|
|
|
|
/* Because paint_core.c is alpha-only code. See below. */
|
|
|
|
|
|
|
|
PixelRegion tempPR;
|
|
|
|
|
|
|
|
tempPR.x = 0;
|
|
|
|
tempPR.y = 0;
|
|
|
|
tempPR.w = area->width;
|
|
|
|
tempPR.h = area->height;
|
|
|
|
tempPR.tiles = NULL;
|
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
if (! gimp_drawable_has_alpha (drawable))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-11-05 01:54:01 +08:00
|
|
|
/* note: this particular approach needlessly convolves the totally-
|
1997-12-08 09:13:10 +08:00
|
|
|
opaque alpha channel. A faster approach would be to keep
|
|
|
|
tempPR the same number of bytes as srcPR, and extend the
|
|
|
|
paint_core_replace_canvas API to handle non-alpha images. */
|
|
|
|
|
2000-11-05 01:54:01 +08:00
|
|
|
tempPR.bytes = srcPR.bytes + 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
tempPR.rowstride = tempPR.bytes * tempPR.w;
|
2000-11-05 01:54:01 +08:00
|
|
|
temp_data = g_malloc (tempPR.h * tempPR.rowstride);
|
|
|
|
tempPR.data = temp_data;
|
1997-11-25 06:05:25 +08:00
|
|
|
add_alpha_region (&srcPR, &tempPR);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-11-05 01:54:01 +08:00
|
|
|
tempPR.bytes = srcPR.bytes;
|
1997-11-25 06:05:25 +08:00
|
|
|
tempPR.rowstride = tempPR.bytes * tempPR.w;
|
2000-11-05 01:54:01 +08:00
|
|
|
temp_data = g_malloc (tempPR.h * tempPR.rowstride);
|
|
|
|
tempPR.data = temp_data;
|
1997-11-25 06:05:25 +08:00
|
|
|
copy_region (&srcPR, &tempPR);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convolve the region */
|
2000-11-05 01:54:01 +08:00
|
|
|
|
|
|
|
tempPR.x = 0;
|
|
|
|
tempPR.y = 0;
|
|
|
|
tempPR.w = area->width;
|
|
|
|
tempPR.h = area->height;
|
|
|
|
tempPR.data = temp_data;
|
2001-04-19 21:01:44 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
convolve_region (&tempPR, &destPR, matrix, matrix_size,
|
Actually use the enum types GimpImageType, GimpImageBaseType,
* app/*.[ch]: Actually use the enum types GimpImageType,
GimpImageBaseType, LayerModeEffects, PaintApplicationMode,
BrushApplicationMode, GimpFillType and ConvertPaletteType, instead
of just int or gint. Hopefully I catched most of the places
where these should be used.
Add an enum ConvolutionType, suffix the too general constants
NORMAL, ABSOLUTE and NEGATIVE with _CONVOL. Use NORMAL_MODE
instead of NORMAL in some places (this was what was intended). Fix
some minor gccisms.
* app/apptypes.h: New file. This file contains the above
enumeration types, and some opaque struct typedefs. It was
necessary to collect these in one header that doesn't include
other headers, because when we started using the above mentioned
types in the headers, all hell broke loose because of the
spaghetti-like cross-inclusion mess between headers.
(An example: Header A includes header B, which includes header C
which includes A. B uses a type defined in A. This is not defined,
because A hasn't defined it yet at the point where it includes B,
and A included from B of course is skipped as we already are
reading A.)
1999-08-19 07:41:39 +08:00
|
|
|
matrix_divisor, NORMAL_CONVOL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Free the allocated temp space */
|
|
|
|
g_free (temp_data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-04-19 21:01:44 +08:00
|
|
|
/* TempBuf clipping has occured on at least one edge...
|
|
|
|
* Edge case: expand area under brush margin px on near edge(s), convolve
|
|
|
|
* expanded buffers. copy src -> ovrsz1 convolve ovrsz1 -> ovrsz2
|
|
|
|
* copy-with-crop ovrsz2 -> dest
|
|
|
|
*/
|
2000-11-05 01:54:01 +08:00
|
|
|
PixelRegion ovrsz1PR;
|
|
|
|
PixelRegion ovrsz2PR;
|
|
|
|
guchar *ovrsz1_data = NULL;
|
|
|
|
guchar *ovrsz2_data = NULL;
|
2001-04-19 21:01:44 +08:00
|
|
|
guchar *fillcolor;
|
|
|
|
|
|
|
|
fillcolor = gimp_drawable_get_color_at
|
|
|
|
(drawable,
|
|
|
|
CLAMP ((gint) paint_tool->curx, 0, gimp_drawable_width (drawable) - 1),
|
|
|
|
CLAMP ((gint) paint_tool->cury, 0, gimp_drawable_height (drawable) - 1));
|
2000-11-05 01:54:01 +08:00
|
|
|
|
|
|
|
marginx *= (marginx < 0) ? -1 : 0;
|
|
|
|
marginy *= (marginy < 0) ? -1 : 0;
|
|
|
|
|
|
|
|
ovrsz2PR.x = 0;
|
|
|
|
ovrsz2PR.y = 0;
|
|
|
|
ovrsz2PR.w = area->width + marginx;
|
|
|
|
ovrsz2PR.h = area->height + marginy;
|
2001-01-15 05:11:52 +08:00
|
|
|
ovrsz2PR.bytes = (gimp_drawable_has_alpha (drawable))? srcPR.bytes : srcPR.bytes + 1;
|
2000-11-05 01:54:01 +08:00
|
|
|
ovrsz2PR.offx = 0;
|
|
|
|
ovrsz2PR.offy = 0;
|
|
|
|
ovrsz2PR.rowstride = ovrsz2PR.bytes * ovrsz2PR.w;
|
|
|
|
ovrsz2PR.tiles = NULL;
|
|
|
|
ovrsz2_data = g_malloc (ovrsz2PR.h * ovrsz2PR.rowstride);
|
|
|
|
ovrsz2PR.data = ovrsz2_data;
|
|
|
|
|
|
|
|
ovrsz1PR.x = 0;
|
|
|
|
ovrsz1PR.y = 0;
|
|
|
|
ovrsz1PR.w = area->width + marginx;
|
|
|
|
ovrsz1PR.h = area->height + marginy;
|
2001-01-15 05:11:52 +08:00
|
|
|
ovrsz1PR.bytes = (gimp_drawable_has_alpha (drawable))? srcPR.bytes : srcPR.bytes + 1;
|
2000-11-05 01:54:01 +08:00
|
|
|
ovrsz1PR.offx = 0;
|
|
|
|
ovrsz1PR.offy = 0;
|
|
|
|
ovrsz1PR.rowstride = ovrsz2PR.bytes * ovrsz2PR.w;
|
|
|
|
ovrsz1PR.tiles = NULL;
|
|
|
|
ovrsz1_data = g_malloc (ovrsz1PR.h * ovrsz1PR.rowstride);
|
|
|
|
ovrsz1PR.data = ovrsz1_data;
|
2001-04-19 21:01:44 +08:00
|
|
|
|
2000-11-05 01:54:01 +08:00
|
|
|
color_region (&ovrsz1PR, (const guchar *)fillcolor);
|
|
|
|
|
|
|
|
ovrsz1PR.x = (area_hclip == CONVOLVE_NCLIP)? marginx : 0;
|
|
|
|
ovrsz1PR.y = (area_vclip == CONVOLVE_NCLIP)? marginy : 0;
|
|
|
|
ovrsz1PR.w = area->width;
|
|
|
|
ovrsz1PR.h = area->height;
|
|
|
|
ovrsz1PR.data = ovrsz1_data + (ovrsz1PR.rowstride * ovrsz1PR.y) + (ovrsz1PR.bytes * ovrsz1PR.x);
|
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
if (! gimp_drawable_has_alpha (drawable))
|
2000-11-05 01:54:01 +08:00
|
|
|
add_alpha_region (&srcPR, &ovrsz1PR);
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2000-11-05 01:54:01 +08:00
|
|
|
copy_region (&srcPR, &ovrsz1PR);
|
|
|
|
|
|
|
|
/* Convolve the region */
|
|
|
|
|
|
|
|
ovrsz1PR.x = 0;
|
|
|
|
ovrsz1PR.y = 0;
|
|
|
|
ovrsz1PR.w = area->width + marginx;
|
|
|
|
ovrsz1PR.h = area->height + marginy;
|
|
|
|
ovrsz1PR.data = ovrsz1_data;
|
2001-04-19 21:01:44 +08:00
|
|
|
|
2000-11-05 01:54:01 +08:00
|
|
|
convolve_region (&ovrsz1PR, &ovrsz2PR, matrix, matrix_size,
|
|
|
|
matrix_divisor, NORMAL_CONVOL);
|
|
|
|
|
|
|
|
/* Crop and copy to destination */
|
|
|
|
|
|
|
|
ovrsz2PR.x = (area_hclip == CONVOLVE_NCLIP)? marginx : 0;
|
|
|
|
ovrsz2PR.y = (area_vclip == CONVOLVE_NCLIP)? marginy : 0;
|
|
|
|
ovrsz2PR.w = area->width;
|
|
|
|
ovrsz2PR.h = area->height;
|
|
|
|
ovrsz2PR.data = ovrsz2_data + (ovrsz2PR.rowstride * ovrsz2PR.y) + (ovrsz2PR.bytes * ovrsz2PR.x);
|
2001-04-19 21:01:44 +08:00
|
|
|
|
2000-11-05 01:54:01 +08:00
|
|
|
copy_region (&ovrsz2PR, &destPR);
|
2001-04-19 21:01:44 +08:00
|
|
|
|
2000-11-05 01:54:01 +08:00
|
|
|
g_free(ovrsz1_data);
|
|
|
|
g_free(ovrsz2_data);
|
|
|
|
g_free(fillcolor);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* paste the newly painted canvas to the gimage which is being worked on */
|
2001-04-19 21:01:44 +08:00
|
|
|
gimp_paint_tool_replace_canvas (paint_tool, drawable, OPAQUE_OPACITY,
|
|
|
|
(gint) (gimp_context_get_opacity (NULL) * 255),
|
|
|
|
pressure_options->pressure ? PRESSURE : SOFT,
|
|
|
|
scale, INCREMENTAL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
calculate_matrix (ConvolveType type,
|
2001-04-19 21:01:44 +08:00
|
|
|
gdouble rate)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-04-19 21:01:44 +08:00
|
|
|
gfloat percent;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* find percent of tool pressure */
|
1999-11-13 09:02:27 +08:00
|
|
|
percent = MIN (rate / 100.0, 1.0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* get the appropriate convolution matrix and size and divisor */
|
|
|
|
switch (type)
|
|
|
|
{
|
1999-04-19 05:22:41 +08:00
|
|
|
case BLUR_CONVOLVE:
|
1997-11-25 06:05:25 +08:00
|
|
|
matrix_size = 5;
|
|
|
|
blur_matrix [12] = MIN_BLUR + percent * (MAX_BLUR - MIN_BLUR);
|
|
|
|
copy_matrix (blur_matrix, custom_matrix, matrix_size);
|
|
|
|
break;
|
|
|
|
|
1999-04-19 05:22:41 +08:00
|
|
|
case SHARPEN_CONVOLVE:
|
1997-11-25 06:05:25 +08:00
|
|
|
matrix_size = 5;
|
|
|
|
sharpen_matrix [12] = MIN_SHARPEN + percent * (MAX_SHARPEN - MIN_SHARPEN);
|
|
|
|
copy_matrix (sharpen_matrix, custom_matrix, matrix_size);
|
|
|
|
break;
|
|
|
|
|
1999-04-19 05:22:41 +08:00
|
|
|
case CUSTOM_CONVOLVE:
|
1997-11-25 06:05:25 +08:00
|
|
|
matrix_size = 5;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
integer_matrix (custom_matrix, matrix, matrix_size);
|
|
|
|
matrix_divisor = sum_matrix (matrix, matrix_size);
|
|
|
|
|
|
|
|
if (!matrix_divisor)
|
|
|
|
matrix_divisor = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-12-31 12:07:42 +08:00
|
|
|
integer_matrix (gfloat *source,
|
|
|
|
gint *dest,
|
|
|
|
gint size)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-12-31 12:07:42 +08:00
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
#define PRECISION 10000
|
|
|
|
|
|
|
|
for (i = 0; i < size*size; i++)
|
2000-12-31 12:07:42 +08:00
|
|
|
*dest++ = (gint) (*source ++ * PRECISION);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-12-31 12:07:42 +08:00
|
|
|
copy_matrix (gfloat *src,
|
|
|
|
gfloat *dest,
|
|
|
|
gint size)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-12-31 12:07:42 +08:00
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (i = 0; i < size*size; i++)
|
|
|
|
*dest++ = *src++;
|
|
|
|
}
|
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
static gint
|
2000-12-31 12:07:42 +08:00
|
|
|
sum_matrix (gint *matrix,
|
|
|
|
gint size)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-12-31 12:07:42 +08:00
|
|
|
gint sum = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
size *= size;
|
|
|
|
|
|
|
|
while (size --)
|
|
|
|
sum += *matrix++;
|
|
|
|
|
|
|
|
return sum;
|
|
|
|
}
|
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
#if 0 /* Leave these to the STUBs */
|
2000-12-31 12:07:42 +08:00
|
|
|
static gpointer
|
2001-04-19 21:01:44 +08:00
|
|
|
convolve_non_gui_paint_func (GimpPaintTool *paint_tool,
|
1998-01-22 15:02:57 +08:00
|
|
|
GimpDrawable *drawable,
|
2000-12-31 12:07:42 +08:00
|
|
|
PaintState state)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-04-19 21:01:44 +08:00
|
|
|
convolve_motion (paint_tool, drawable, &non_gui_pressure_options,
|
1999-11-13 09:02:27 +08:00
|
|
|
non_gui_type, non_gui_rate);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1999-07-20 06:42:49 +08:00
|
|
|
gboolean
|
|
|
|
convolve_non_gui_default (GimpDrawable *drawable,
|
2000-12-31 12:07:42 +08:00
|
|
|
gint num_strokes,
|
|
|
|
gdouble *stroke_array)
|
1999-07-20 06:42:49 +08:00
|
|
|
{
|
2000-12-31 12:07:42 +08:00
|
|
|
gdouble rate = DEFAULT_CONVOLVE_RATE;
|
|
|
|
ConvolveType type = DEFAULT_CONVOLVE_TYPE;
|
1999-07-20 06:42:49 +08:00
|
|
|
ConvolveOptions *options = convolve_options;
|
|
|
|
|
1999-11-13 09:02:27 +08:00
|
|
|
if (options)
|
1999-07-20 06:42:49 +08:00
|
|
|
{
|
1999-11-13 09:02:27 +08:00
|
|
|
rate = options->rate;
|
1999-07-20 06:42:49 +08:00
|
|
|
type = options->type;
|
|
|
|
}
|
|
|
|
|
1999-11-13 09:02:27 +08:00
|
|
|
return convolve_non_gui (drawable, rate, type, num_strokes, stroke_array);
|
1999-07-20 06:42:49 +08:00
|
|
|
}
|
|
|
|
|
1999-04-19 05:22:41 +08:00
|
|
|
gboolean
|
|
|
|
convolve_non_gui (GimpDrawable *drawable,
|
2001-04-19 21:01:44 +08:00
|
|
|
gdouble rate,
|
1999-07-20 06:42:49 +08:00
|
|
|
ConvolveType type,
|
2000-12-31 12:07:42 +08:00
|
|
|
gint num_strokes,
|
|
|
|
gdouble *stroke_array)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-12-31 12:07:42 +08:00
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-19 21:01:44 +08:00
|
|
|
if (gimp_paint_tool_init (&non_gui_paint_core, drawable,
|
|
|
|
stroke_array[0], stroke_array[1]))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-20 06:42:49 +08:00
|
|
|
non_gui_type = type;
|
1999-11-13 09:02:27 +08:00
|
|
|
non_gui_rate = rate;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
|
|
|
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
|
|
|
|
|
1999-07-23 07:11:46 +08:00
|
|
|
convolve_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (i = 1; i < num_strokes; i++)
|
|
|
|
{
|
|
|
|
non_gui_paint_core.curx = stroke_array[i * 2 + 0];
|
|
|
|
non_gui_paint_core.cury = stroke_array[i * 2 + 1];
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
paint_core_interpolate (&non_gui_paint_core, drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
non_gui_paint_core.lastx = non_gui_paint_core.curx;
|
|
|
|
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
|
|
|
}
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
paint_core_cleanup ();
|
2001-04-19 21:01:44 +08:00
|
|
|
|
1999-04-19 05:22:41 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-12-31 12:07:42 +08:00
|
|
|
|
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-04-19 21:01:44 +08:00
|
|
|
|
|
|
|
#endif /* 0 - non-gui functions */
|
|
|
|
|
|
|
|
static ConvolveOptions *
|
|
|
|
convolve_options_new (void)
|
|
|
|
{
|
|
|
|
ConvolveOptions *options;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *scale;
|
|
|
|
GtkWidget *frame;
|
|
|
|
|
|
|
|
options = g_new0 (ConvolveOptions, 1);
|
|
|
|
|
|
|
|
paint_options_init ((PaintOptions *) options,
|
|
|
|
GIMP_TYPE_CONVOLVE_TOOL,
|
|
|
|
convolve_options_reset);
|
|
|
|
|
|
|
|
options->type = options->type_d = DEFAULT_CONVOLVE_TYPE;
|
|
|
|
options->rate = options->rate_d = DEFAULT_CONVOLVE_RATE;
|
|
|
|
|
|
|
|
/* the main vbox */
|
|
|
|
vbox = ((ToolOptions *) options)->main_vbox;
|
|
|
|
|
|
|
|
/* the rate scale */
|
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Rate:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
options->rate_w =
|
|
|
|
gtk_adjustment_new (options->rate_d, 0.0, 100.0, 1.0, 1.0, 0.0);
|
|
|
|
scale = gtk_hscale_new (GTK_ADJUSTMENT (options->rate_w));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0);
|
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP);
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (options->rate_w), "value_changed",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_double_adjustment_update),
|
|
|
|
&options->rate);
|
|
|
|
gtk_widget_show (scale);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
frame = gimp_radio_group_new2 (TRUE, _("Convolve Type"),
|
|
|
|
gimp_radio_button_update,
|
|
|
|
&options->type, (gpointer) options->type,
|
|
|
|
|
|
|
|
_("Blur"), (gpointer) BLUR_CONVOLVE,
|
|
|
|
&options->type_w[0],
|
|
|
|
_("Sharpen"), (gpointer) SHARPEN_CONVOLVE,
|
|
|
|
&options->type_w[1],
|
|
|
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
convolve_options_reset (ToolOptions *tool_options)
|
|
|
|
{
|
|
|
|
ConvolveOptions *options;
|
|
|
|
|
|
|
|
options = (ConvolveOptions *) tool_options;
|
|
|
|
|
|
|
|
paint_options_reset (tool_options);
|
|
|
|
|
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->rate_w),
|
|
|
|
options->rate_d);
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d]), TRUE);
|
|
|
|
}
|