General cleanup of the selection tools and their PDB wrappers:

2001-10-22  Michael Natterer  <mitch@gimp.org>

	General cleanup of the selection tools and their PDB wrappers:

	* app/core/Makefile.am
	* app/core/gimpimage-contiguous-region.[ch]
	* app/core/gimpimage-mask-select.[ch]: new files providing a clean,
	uniform API for the selection functionalities. Changed order of
	parameters to be consistent, removed code duplication.

	The region returned by the "by_color" function is not really
	contiguous but the API is so similar to "by_seed" and it's used
	in the same context so it's fair enough to put them together.

	Also, I'm not sure if the two is_pixel_sufficiently_different()
	I've optimized away were meant to do *exactly* the same. Added
	a comment there to remember the former difference.

	* app/core/gimpchannel.[ch] (gimp_channel_feather): removed the
	"output" channel parameter and made it optionally push an undo
	(like the other channel operations do).

	* app/core/gimpimage-mask.c: call gimp_channel_feather() with
	"push_undo == TRUE", removed some useless comments.

	* app/tools/gimpbycolorselecttool.[ch]
	* app/tools/gimpellipseselecttool.[ch]
	* app/tools/gimpfreeselecttool.[ch]
	* app/tools/gimpfuzzyselecttool.[ch]
	* app/tools/gimprectselecttool.[ch]: removed all the actual
	selection functionality and call the new gimp_image_mask_select_*()
	and gimp_image_contiguous_region_*() functions instead.

	* app/tools/gimpbezierselecttool.c
	* app/tools/gimpiscissorstool.c: use new function
	gimp_image_mask_select_channel() instead of doing the same manually.

	* app/tools/gimpbucketfilltool.c: find_contiguous_region() ->
	gimp_image_contiguous_region_by_seed().

	* tools/pdbgen/Makefile.am
	* tools/pdbgen/groups.pl
	* tools/pdbgen/pdb/selection_tools.pdb: added new group "Selection
	Tools" which depends only on "core/" stuff (not on "tools/" any
	more, brrrr).

	* tools/pdbgen/pdb/text_tool.pdb: don't include "appenv.h"

	* tools/pdbgen/pdb/tools.pdb: removed the selection tools.

	* app/pdb/Makefile.am
	* app/pdb/selection_tools_cmds.c: new file.

	* app/pdb/internal_procs.c
	* app/pdb/text_tool_cmds.c
	* app/pdb/tools_cmds.c: regenerated.

	* libgimp/Makefile.am
	* libgimp/gimp_pdb.h
	* libgimp/gimpselectiontools_pdb.[ch]: new files.

	* libgimp/gimptools_pdb.[ch]: regenerated

	Misc cleanups:

	* app/app_procs.c: call splash_create() with "no_splash_image"
	as parameter.

	* app/display/gimpdisplay-render.c
	* app/display/gximage.c: don't include "appenv.h".

	* app/gui/gui.c: call session_restore() only if "restore_session"
	is TRUE.

	* app/gui/session.c: don't "if(restore_session)" here and don't
	include "appenv.h"

	* app/gui/splash.[ch]: added "gboolean show_image" parameter to
	splash_create(), don't include "appenv.h"

	* app/tools/gimppainttool.[ch]: added a "GimpGradient" parameter
	to gimp_paint_tool_get_color_from_gradient().

	* app/tools/gimppaintbrushtool.c: pass the gradient.

	* app/tools/gimpselectiontool.c
	* app/tools/gimptransformtool.c
	* app/tools/tool_manager.c: s/GDisplay/GimpDisplay/.

	* app/widgets/gimpcontainergridview.[ch]: removed the "white_style"
	class variable and don't fiddle around with colors and styles...

	* themes/Default/gtkrc: ...do the same here with a simple rc style.
This commit is contained in:
Michael Natterer 2001-10-22 12:13:44 +00:00 committed by Michael Natterer
parent 6b65454438
commit 99e78c7074
71 changed files with 3414 additions and 3547 deletions

View File

@ -1,3 +1,97 @@
2001-10-22 Michael Natterer <mitch@gimp.org>
General cleanup of the selection tools and their PDB wrappers:
* app/core/Makefile.am
* app/core/gimpimage-contiguous-region.[ch]
* app/core/gimpimage-mask-select.[ch]: new files providing a clean,
uniform API for the selection functionalities. Changed order of
parameters to be consistent, removed code duplication.
The region returned by the "by_color" function is not really
contiguous but the API is so similar to "by_seed" and it's used
in the same context so it's fair enough to put them together.
Also, I'm not sure if the two is_pixel_sufficiently_different()
I've optimized away were meant to do *exactly* the same. Added
a comment there to remember the former difference.
* app/core/gimpchannel.[ch] (gimp_channel_feather): removed the
"output" channel parameter and made it optionally push an undo
(like the other channel operations do).
* app/core/gimpimage-mask.c: call gimp_channel_feather() with
"push_undo == TRUE", removed some useless comments.
* app/tools/gimpbycolorselecttool.[ch]
* app/tools/gimpellipseselecttool.[ch]
* app/tools/gimpfreeselecttool.[ch]
* app/tools/gimpfuzzyselecttool.[ch]
* app/tools/gimprectselecttool.[ch]: removed all the actual
selection functionality and call the new gimp_image_mask_select_*()
and gimp_image_contiguous_region_*() functions instead.
* app/tools/gimpbezierselecttool.c
* app/tools/gimpiscissorstool.c: use new function
gimp_image_mask_select_channel() instead of doing the same manually.
* app/tools/gimpbucketfilltool.c: find_contiguous_region() ->
gimp_image_contiguous_region_by_seed().
* tools/pdbgen/Makefile.am
* tools/pdbgen/groups.pl
* tools/pdbgen/pdb/selection_tools.pdb: added new group "Selection
Tools" which depends only on "core/" stuff (not on "tools/" any
more, brrrr).
* tools/pdbgen/pdb/text_tool.pdb: don't include "appenv.h"
* tools/pdbgen/pdb/tools.pdb: removed the selection tools.
* app/pdb/Makefile.am
* app/pdb/selection_tools_cmds.c: new file.
* app/pdb/internal_procs.c
* app/pdb/text_tool_cmds.c
* app/pdb/tools_cmds.c: regenerated.
* libgimp/Makefile.am
* libgimp/gimp_pdb.h
* libgimp/gimpselectiontools_pdb.[ch]: new files.
* libgimp/gimptools_pdb.[ch]: regenerated
Misc cleanups:
* app/app_procs.c: call splash_create() with "no_splash_image"
as parameter.
* app/display/gimpdisplay-render.c
* app/display/gximage.c: don't include "appenv.h".
* app/gui/gui.c: call session_restore() only if "restore_session"
is TRUE.
* app/gui/session.c: don't "if(restore_session)" here and don't
include "appenv.h"
* app/gui/splash.[ch]: added "gboolean show_image" parameter to
splash_create(), don't include "appenv.h"
* app/tools/gimppainttool.[ch]: added a "GimpGradient" parameter
to gimp_paint_tool_get_color_from_gradient().
* app/tools/gimppaintbrushtool.c: pass the gradient.
* app/tools/gimpselectiontool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c: s/GDisplay/GimpDisplay/.
* app/widgets/gimpcontainergridview.[ch]: removed the "white_style"
class variable and don't fiddle around with colors and styles...
* themes/Default/gtkrc: ...do the same here with a simple rc style.
2001-10-19 Michael Natterer <mitch@gimp.org>
* app/Makefile.am: link the app in a different order as some init

View File

@ -137,7 +137,7 @@ app_init (gint gimp_argc,
get_standard_colormaps ();
if (! no_splash)
splash_create ();
splash_create (! no_splash_image);
}
/* initialize lowlevel stuff */

View File

@ -68,6 +68,8 @@ libappcore_a_sources = @STRIP_BEGIN@ \
gimpimage.h \
gimpimage-colorhash.c \
gimpimage-colorhash.h \
gimpimage-contiguous-region.c \
gimpimage-contiguous-region.h \
gimpimage-convert.c \
gimpimage-convert.h \
gimpimage-convert-fsdither.h \
@ -77,6 +79,8 @@ libappcore_a_sources = @STRIP_BEGIN@ \
gimpimage-duplicate.h \
gimpimage-mask.c \
gimpimage-mask.h \
gimpimage-mask-select.c \
gimpimage-mask-select.h \
gimpimage-new.c \
gimpimage-new.h \
gimpimage-undo.c \

View File

@ -95,11 +95,11 @@ enum
/* forward function declarations */
static void gimp_transform_tool_bounds (GimpTransformTool *tool,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_recalc (GimpTransformTool *tool,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_doit (GimpTransformTool *tool,
GDisplay *gdisp);
GimpDisplay *gdisp);
static gdouble gimp_transform_tool_cubic (gdouble dx,
gint jm1,
gint j,
@ -114,23 +114,23 @@ static void gimp_transform_tool_finalize (GObject *object);
static void gimp_transform_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_control (GimpTool *tool,
ToolAction action,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_draw (GimpDrawTool *draw_tool);
@ -234,7 +234,7 @@ gimp_transform_tool_init (GimpTransformTool *tr_tool)
TileManager *
gimp_transform_tool_transform (GimpTransformTool *tool,
GDisplay *gdisp,
GimpDisplay *gdisp,
TransformState state)
{
TileManager *retval;
@ -319,9 +319,9 @@ gimp_transform_tool_finalize (GObject *object)
}
static void
gimp_transform_tool_control (GimpTool *tool,
ToolAction action,
GDisplay *gdisp)
gimp_transform_tool_control (GimpTool *tool,
ToolAction action,
GimpDisplay *gdisp)
{
GimpDrawTool *dr_tool;
GimpTransformTool *tr_tool;
@ -351,9 +351,9 @@ gimp_transform_tool_control (GimpTool *tool,
}
static void
gimp_transform_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
gimp_transform_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GimpDisplay *gdisp)
{
GimpTransformTool *gt_tool;
GimpDrawable *drawable;
@ -529,9 +529,9 @@ gimp_transform_tool_button_press (GimpTool *tool,
}
static void
gimp_transform_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
gimp_transform_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GimpDisplay *gdisp)
{
GimpTransformTool *gt_tool;
gint i;
@ -590,7 +590,7 @@ gimp_transform_tool_button_release (GimpTool *tool,
static void
gimp_transform_tool_doit (GimpTransformTool *gt_tool,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpTool *tool;
TileManager *new_tiles;
@ -710,9 +710,9 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool,
}
static void
gimp_transform_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
gimp_transform_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GimpDisplay *gdisp)
{
GimpTransformTool *tr_tool;
@ -747,9 +747,9 @@ gimp_transform_tool_motion (GimpTool *tool,
}
static void
gimp_transform_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
gimp_transform_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GimpDisplay *gdisp)
{
GimpTransformTool *tr_tool;
GimpDrawable *drawable;
@ -790,7 +790,7 @@ gimp_transform_tool_cursor_update (GimpTool *tool,
static void
gimp_transform_tool_draw (GimpDrawTool *dr_tool)
{
GDisplay *gdisp;
GimpDisplay *gdisp;
GimpTransformTool *tr_tool;
GimpTool *tool;
gint x1, y1, x2, y2, x3, y3, x4, y4;
@ -942,7 +942,7 @@ gimp_transform_tool_transform_bounding_box (GimpTransformTool *tr_tool)
void
gimp_transform_tool_reset (GimpTransformTool *tr_tool,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpTool *tool;
@ -966,11 +966,11 @@ gimp_transform_tool_reset (GimpTransformTool *tr_tool,
static void
gimp_transform_tool_bounds (GimpTransformTool *tr_tool,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
TileManager *tiles;
GimpDrawable *drawable;
gint offset_x, offset_y;
TileManager *tiles;
GimpDrawable *drawable;
gint offset_x, offset_y;
tiles = tr_tool->original;
drawable = gimp_image_active_drawable (gdisp->gimage);
@ -1115,7 +1115,7 @@ gimp_transform_tool_setup_grid (GimpTransformTool *tr_tool)
static void
gimp_transform_tool_recalc (GimpTransformTool *tr_tool,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
gimp_transform_tool_bounds (tr_tool, gdisp);

View File

@ -1174,35 +1174,27 @@ gimp_channel_combine_mask (GimpChannel *mask,
}
void
gimp_channel_feather (GimpChannel *input,
GimpChannel *output,
gimp_channel_feather (GimpChannel *mask,
gdouble radius_x,
gdouble radius_y,
ChannelOps op,
gint off_x,
gint off_y)
gboolean push_undo)
{
gint x1, y1, x2, y2;
PixelRegion srcPR;
g_return_if_fail (GIMP_IS_CHANNEL (input));
g_return_if_fail (GIMP_IS_CHANNEL (output));
g_return_if_fail (GIMP_IS_CHANNEL (mask));
g_return_if_fail (push_undo && gimp_drawable_gimage (GIMP_DRAWABLE (mask)));
x1 = CLAMP (off_x, 0, GIMP_DRAWABLE (output)->width);
y1 = CLAMP (off_y, 0, GIMP_DRAWABLE (output)->height);
x2 = CLAMP (off_x + GIMP_DRAWABLE (input)->width, 0,
GIMP_DRAWABLE (output)->width);
y2 = CLAMP (off_y + GIMP_DRAWABLE (input)->height, 0,
GIMP_DRAWABLE (output)->height);
if (push_undo)
gimp_channel_push_undo (mask);
pixel_region_init (&srcPR, GIMP_DRAWABLE (input)->tiles,
(x1 - off_x), (y1 - off_y), (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&srcPR, GIMP_DRAWABLE (mask)->tiles,
0, 0,
gimp_drawable_width (GIMP_DRAWABLE (mask)),
gimp_drawable_height (GIMP_DRAWABLE (mask)),
FALSE);
gaussian_blur_region (&srcPR, radius_x, radius_y);
if (input != output)
gimp_channel_combine_mask (output, input, op, 0, 0);
output->bounds_known = FALSE;
mask->bounds_known = FALSE;
}
void

View File

@ -32,6 +32,7 @@
#define GIMP_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CHANNEL, GimpChannelClass))
#define GIMP_IS_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CHANNEL))
#define GIMP_IS_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CHANNEL))
#define GIMP_CHANNEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CHANNEL, GimpChannelClass))
typedef struct _GimpChannelClass GimpChannelClass;
@ -162,13 +163,10 @@ void gimp_channel_combine_mask (GimpChannel *mask,
ChannelOps op,
gint off_x,
gint off_y);
void gimp_channel_feather (GimpChannel *input,
GimpChannel *output,
void gimp_channel_feather (GimpChannel *mask,
gdouble radius_x,
gdouble radius_y,
ChannelOps op,
gint off_x,
gint off_y);
gboolean push_undo);
void gimp_channel_push_undo (GimpChannel *mask);
void gimp_channel_clear (GimpChannel *mask);

View File

@ -0,0 +1,300 @@
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "core-types.h"
#include "gimpchannel.h"
#include "gimpimage.h"
#include "gimpimage-contiguous-region.h"
#include "gimpimage-mask.h"
#include "gimpimage-mask-select.h"
#include "gimpscanconvert.h"
void
gimp_image_mask_select_rectangle (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
ChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
GimpChannel *new_mask;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
/* if applicable, replace the current selection */
if (op == CHANNEL_OP_REPLACE)
gimage_mask_clear (gimage);
else
gimage_mask_undo (gimage);
/* if feathering for rect, make a new mask with the
* rectangle and feather that with the old mask
*/
if (feather)
{
new_mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_channel_combine_rect (new_mask, CHANNEL_OP_ADD, x, y, w, h);
gimp_channel_feather (new_mask,
feather_radius_x,
feather_radius_y,
FALSE /* no undo */);
gimp_channel_combine_mask (gimp_image_get_mask (gimage), new_mask,
op, 0, 0);
g_object_unref (G_OBJECT (new_mask));
}
else if (op == CHANNEL_OP_INTERSECT)
{
new_mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_channel_combine_rect (new_mask, CHANNEL_OP_ADD, x, y, w, h);
gimp_channel_combine_mask (gimp_image_get_mask (gimage), new_mask,
op, 0, 0);
g_object_unref (G_OBJECT (new_mask));
}
else
{
gimp_channel_combine_rect (gimp_image_get_mask (gimage), op, x, y, w, h);
}
}
void
gimp_image_mask_select_ellipse (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
GimpChannel *new_mask;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
/* if applicable, replace the current selection */
if (op == CHANNEL_OP_REPLACE)
gimage_mask_clear (gimage);
else
gimage_mask_undo (gimage);
/* if feathering for rect, make a new mask with the
* rectangle and feather that with the old mask
*/
if (feather)
{
new_mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_channel_combine_ellipse (new_mask, CHANNEL_OP_ADD,
x, y, w, h, antialias);
gimp_channel_feather (new_mask,
feather_radius_x,
feather_radius_y,
FALSE /* no undo */);
gimp_channel_combine_mask (gimp_image_get_mask (gimage), new_mask,
op, 0, 0);
g_object_unref (G_OBJECT (new_mask));
}
else if (op == CHANNEL_OP_INTERSECT)
{
new_mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_channel_combine_ellipse (new_mask, CHANNEL_OP_ADD,
x, y, w, h, antialias);
gimp_channel_combine_mask (gimp_image_get_mask (gimage), new_mask,
op, 0, 0);
g_object_unref (G_OBJECT (new_mask));
}
else
{
gimp_channel_combine_ellipse (gimp_image_get_mask (gimage), op,
x, y, w, h, antialias);
}
}
void
gimp_image_mask_select_polygon (GimpImage *gimage,
gint n_points,
GimpVector2 *points,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
GimpChannel *mask;
GimpScanConvert *scan_convert;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
/* if applicable, replace the current selection */
/* or insure that a floating selection is anchored down... */
if (op == CHANNEL_OP_REPLACE)
gimage_mask_clear (gimage);
else
gimage_mask_undo (gimage);
#define SUPERSAMPLE 3
scan_convert = gimp_scan_convert_new (gimage->width,
gimage->height,
antialias ? SUPERSAMPLE : 1);
gimp_scan_convert_add_points (scan_convert, n_points, points);
mask = gimp_scan_convert_to_channel (scan_convert, gimage);
gimp_scan_convert_free (scan_convert);
#undef SUPERSAMPLE
if (mask)
{
if (feather)
gimp_channel_feather (mask,
feather_radius_x,
feather_radius_y,
FALSE /* no undo */);
gimp_channel_combine_mask (gimp_image_get_mask (gimage),
mask, op, 0, 0);
g_object_unref (G_OBJECT (mask));
}
}
void
gimp_image_mask_select_channel (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
GimpChannel *channel,
ChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
gint off_x, off_y;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail ((! drawable && ! sample_merged) || GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_CHANNEL (channel));
/* if applicable, replace the current selection */
if (op == CHANNEL_OP_REPLACE)
gimage_mask_clear (gimage);
else
gimage_mask_undo (gimage);
if (sample_merged)
{
off_x = off_y = 0;
}
else
{
gimp_drawable_offsets (drawable, &off_x, &off_y);
}
if (feather)
gimp_channel_feather (channel,
feather_radius_x,
feather_radius_y,
FALSE /* no undo */);
gimp_channel_combine_mask (gimp_image_get_mask (gimage),
channel,
op,
off_x, off_y);
}
void
gimp_image_mask_select_fuzzy (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
gint x,
gint y,
gint threshold,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
GimpChannel *mask;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
mask = gimp_image_contiguous_region_by_seed (gimage, drawable,
sample_merged,
antialias,
threshold,
x, y);
gimp_image_mask_select_channel (gimage,
drawable,
sample_merged,
mask,
op,
feather,
feather_radius_x,
feather_radius_y);
g_object_unref (G_OBJECT (mask));
}
void
gimp_image_mask_select_by_color (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
const GimpRGB *color,
gint threshold,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
GimpChannel *mask;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (color != NULL);
mask = gimp_image_contiguous_region_by_color (gimage, drawable,
sample_merged,
antialias,
threshold,
color);
gimp_image_mask_select_channel (gimage,
drawable,
sample_merged,
mask,
op,
feather,
feather_radius_x,
feather_radius_y);
g_object_unref (G_OBJECT (mask));
}

View File

@ -0,0 +1,86 @@
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_IMAGE_MASK_SELECT_H__
#define __GIMP_IMAGE_MASK_SELECT_H__
void gimp_image_mask_select_rectangle (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
ChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_image_mask_select_ellipse (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_image_mask_select_polygon (GimpImage *gimage,
gint n_points,
GimpVector2 *points,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_image_mask_select_channel (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
GimpChannel *channel,
ChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_image_mask_select_fuzzy (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
gint x,
gint y,
gint threshold,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_image_mask_select_by_color (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
const GimpRGB *color,
gint threshold,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
#endif /* __GIMP_IMAGE_MASK_SELECT_H__ */

View File

@ -1174,35 +1174,27 @@ gimp_channel_combine_mask (GimpChannel *mask,
}
void
gimp_channel_feather (GimpChannel *input,
GimpChannel *output,
gimp_channel_feather (GimpChannel *mask,
gdouble radius_x,
gdouble radius_y,
ChannelOps op,
gint off_x,
gint off_y)
gboolean push_undo)
{
gint x1, y1, x2, y2;
PixelRegion srcPR;
g_return_if_fail (GIMP_IS_CHANNEL (input));
g_return_if_fail (GIMP_IS_CHANNEL (output));
g_return_if_fail (GIMP_IS_CHANNEL (mask));
g_return_if_fail (push_undo && gimp_drawable_gimage (GIMP_DRAWABLE (mask)));
x1 = CLAMP (off_x, 0, GIMP_DRAWABLE (output)->width);
y1 = CLAMP (off_y, 0, GIMP_DRAWABLE (output)->height);
x2 = CLAMP (off_x + GIMP_DRAWABLE (input)->width, 0,
GIMP_DRAWABLE (output)->width);
y2 = CLAMP (off_y + GIMP_DRAWABLE (input)->height, 0,
GIMP_DRAWABLE (output)->height);
if (push_undo)
gimp_channel_push_undo (mask);
pixel_region_init (&srcPR, GIMP_DRAWABLE (input)->tiles,
(x1 - off_x), (y1 - off_y), (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&srcPR, GIMP_DRAWABLE (mask)->tiles,
0, 0,
gimp_drawable_width (GIMP_DRAWABLE (mask)),
gimp_drawable_height (GIMP_DRAWABLE (mask)),
FALSE);
gaussian_blur_region (&srcPR, radius_x, radius_y);
if (input != output)
gimp_channel_combine_mask (output, input, op, 0, 0);
output->bounds_known = FALSE;
mask->bounds_known = FALSE;
}
void

View File

@ -32,6 +32,7 @@
#define GIMP_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CHANNEL, GimpChannelClass))
#define GIMP_IS_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CHANNEL))
#define GIMP_IS_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CHANNEL))
#define GIMP_CHANNEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CHANNEL, GimpChannelClass))
typedef struct _GimpChannelClass GimpChannelClass;
@ -162,13 +163,10 @@ void gimp_channel_combine_mask (GimpChannel *mask,
ChannelOps op,
gint off_x,
gint off_y);
void gimp_channel_feather (GimpChannel *input,
GimpChannel *output,
void gimp_channel_feather (GimpChannel *mask,
gdouble radius_x,
gdouble radius_y,
ChannelOps op,
gint off_x,
gint off_y);
gboolean push_undo);
void gimp_channel_push_undo (GimpChannel *mask);
void gimp_channel_clear (GimpChannel *mask);

View File

@ -95,11 +95,11 @@ enum
/* forward function declarations */
static void gimp_transform_tool_bounds (GimpTransformTool *tool,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_recalc (GimpTransformTool *tool,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_doit (GimpTransformTool *tool,
GDisplay *gdisp);
GimpDisplay *gdisp);
static gdouble gimp_transform_tool_cubic (gdouble dx,
gint jm1,
gint j,
@ -114,23 +114,23 @@ static void gimp_transform_tool_finalize (GObject *object);
static void gimp_transform_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_control (GimpTool *tool,
ToolAction action,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_draw (GimpDrawTool *draw_tool);
@ -234,7 +234,7 @@ gimp_transform_tool_init (GimpTransformTool *tr_tool)
TileManager *
gimp_transform_tool_transform (GimpTransformTool *tool,
GDisplay *gdisp,
GimpDisplay *gdisp,
TransformState state)
{
TileManager *retval;
@ -319,9 +319,9 @@ gimp_transform_tool_finalize (GObject *object)
}
static void
gimp_transform_tool_control (GimpTool *tool,
ToolAction action,
GDisplay *gdisp)
gimp_transform_tool_control (GimpTool *tool,
ToolAction action,
GimpDisplay *gdisp)
{
GimpDrawTool *dr_tool;
GimpTransformTool *tr_tool;
@ -351,9 +351,9 @@ gimp_transform_tool_control (GimpTool *tool,
}
static void
gimp_transform_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
gimp_transform_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GimpDisplay *gdisp)
{
GimpTransformTool *gt_tool;
GimpDrawable *drawable;
@ -529,9 +529,9 @@ gimp_transform_tool_button_press (GimpTool *tool,
}
static void
gimp_transform_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
gimp_transform_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GimpDisplay *gdisp)
{
GimpTransformTool *gt_tool;
gint i;
@ -590,7 +590,7 @@ gimp_transform_tool_button_release (GimpTool *tool,
static void
gimp_transform_tool_doit (GimpTransformTool *gt_tool,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpTool *tool;
TileManager *new_tiles;
@ -710,9 +710,9 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool,
}
static void
gimp_transform_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
gimp_transform_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GimpDisplay *gdisp)
{
GimpTransformTool *tr_tool;
@ -747,9 +747,9 @@ gimp_transform_tool_motion (GimpTool *tool,
}
static void
gimp_transform_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
gimp_transform_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GimpDisplay *gdisp)
{
GimpTransformTool *tr_tool;
GimpDrawable *drawable;
@ -790,7 +790,7 @@ gimp_transform_tool_cursor_update (GimpTool *tool,
static void
gimp_transform_tool_draw (GimpDrawTool *dr_tool)
{
GDisplay *gdisp;
GimpDisplay *gdisp;
GimpTransformTool *tr_tool;
GimpTool *tool;
gint x1, y1, x2, y2, x3, y3, x4, y4;
@ -942,7 +942,7 @@ gimp_transform_tool_transform_bounding_box (GimpTransformTool *tr_tool)
void
gimp_transform_tool_reset (GimpTransformTool *tr_tool,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpTool *tool;
@ -966,11 +966,11 @@ gimp_transform_tool_reset (GimpTransformTool *tr_tool,
static void
gimp_transform_tool_bounds (GimpTransformTool *tr_tool,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
TileManager *tiles;
GimpDrawable *drawable;
gint offset_x, offset_y;
TileManager *tiles;
GimpDrawable *drawable;
gint offset_x, offset_y;
tiles = tr_tool->original;
drawable = gimp_image_active_drawable (gdisp->gimage);
@ -1115,7 +1115,7 @@ gimp_transform_tool_setup_grid (GimpTransformTool *tr_tool)
static void
gimp_transform_tool_recalc (GimpTransformTool *tr_tool,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
gimp_transform_tool_bounds (tr_tool, gdisp);

View File

@ -0,0 +1,459 @@
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"
#include "core-types.h"
#include "base/pixel-region.h"
#include "base/tile.h"
#include "base/tile-manager.h"
#include "gimpchannel.h"
#include "gimpimage.h"
#include "gimpimage-contiguous-region.h"
/* local function prototypes */
static gint is_pixel_sufficiently_different (guchar *col1,
guchar *col2,
gboolean antialias,
gint threshold,
gint bytes,
gboolean has_alpha);
static void ref_tiles (TileManager *src,
TileManager *mask,
Tile **s_tile,
Tile **m_tile,
gint x,
gint y,
guchar **s,
guchar **m);
static gint find_contiguous_segment (guchar *col,
PixelRegion *src,
PixelRegion *mask,
gint width,
gint bytes,
gboolean has_alpha,
gboolean antialias,
gint threshold,
gint initial,
gint *start,
gint *end);
static void find_contiguous_region_helper (PixelRegion *mask,
PixelRegion *src,
gboolean has_alpha,
gboolean antialias,
gint threshold,
gboolean indexed,
gint x,
gint y,
guchar *col);
/* public functions */
GimpChannel *
gimp_image_contiguous_region_by_seed (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
gboolean antialias,
gint threshold,
gint x,
gint y)
{
PixelRegion srcPR, maskPR;
GimpChannel *mask;
guchar *start;
gboolean has_alpha;
gboolean indexed;
gint type;
gint bytes;
Tile *tile;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
if (sample_merged)
{
pixel_region_init (&srcPR, gimp_image_composite (gimage), 0, 0,
gimage->width, gimage->height, FALSE);
type = gimp_image_composite_type (gimage);
has_alpha = (type == RGBA_GIMAGE ||
type == GRAYA_GIMAGE ||
type == INDEXEDA_GIMAGE);
}
else
{
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
0, 0,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable),
FALSE);
has_alpha = gimp_drawable_has_alpha (drawable);
}
indexed = gimp_drawable_is_indexed (drawable);
bytes = gimp_drawable_bytes (drawable);
if (indexed)
{
bytes = has_alpha ? 4 : 3;
}
mask = gimp_channel_new_mask (gimage, srcPR.w, srcPR.h);
pixel_region_init (&maskPR, gimp_drawable_data (GIMP_DRAWABLE(mask)),
0, 0,
gimp_drawable_width (GIMP_DRAWABLE(mask)),
gimp_drawable_height (GIMP_DRAWABLE(mask)),
TRUE);
tile = tile_manager_get_tile (srcPR.tiles, x, y, TRUE, FALSE);
if (tile)
{
start = tile_data_pointer (tile, x%TILE_WIDTH, y%TILE_HEIGHT);
find_contiguous_region_helper (&maskPR, &srcPR, has_alpha, antialias,
threshold, bytes, x, y, start);
tile_release (tile, FALSE);
}
return mask;
}
GimpChannel *
gimp_image_contiguous_region_by_color (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
gboolean antialias,
gint threshold,
const GimpRGB *color)
{
/* Scan over the gimage's active layer, finding pixels within the specified
* threshold from the given R, G, & B values. If antialiasing is on,
* use the same antialiasing scheme as in fuzzy_select. Modify the gimage's
* mask to reflect the additional selection
*/
GimpChannel *mask;
PixelRegion imagePR, maskPR;
guchar *image_data;
guchar *mask_data;
guchar *idata, *mdata;
guchar rgb[MAX_CHANNELS];
gint has_alpha, indexed;
gint width, height;
gint bytes, color_bytes, alpha;
gint i, j;
gpointer pr;
gint d_type;
guchar col[MAX_CHANNELS];
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (color != NULL, NULL);
gimp_rgba_get_uchar (color, &col[0], &col[1], &col[2], &col[3]);
/* Get the image information */
if (sample_merged)
{
bytes = gimp_image_composite_bytes (gimage);
d_type = gimp_image_composite_type (gimage);
has_alpha = (d_type == RGBA_GIMAGE ||
d_type == GRAYA_GIMAGE ||
d_type == INDEXEDA_GIMAGE);
indexed = d_type == INDEXEDA_GIMAGE || d_type == INDEXED_GIMAGE;
width = gimage->width;
height = gimage->height;
pixel_region_init (&imagePR, gimp_image_composite (gimage),
0, 0, width, height, FALSE);
}
else
{
bytes = gimp_drawable_bytes (drawable);
d_type = gimp_drawable_type (drawable);
has_alpha = gimp_drawable_has_alpha (drawable);
indexed = gimp_drawable_is_indexed (drawable);
width = gimp_drawable_width (drawable);
height = gimp_drawable_height (drawable);
pixel_region_init (&imagePR, gimp_drawable_data (drawable),
0, 0, width, height, FALSE);
}
if (indexed)
{
/* indexed colors are always RGB or RGBA */
color_bytes = has_alpha ? 4 : 3;
}
else
{
/* RGB, RGBA, GRAY and GRAYA colors are shaped just like the image */
color_bytes = bytes;
}
alpha = bytes - 1;
mask = gimp_channel_new_mask (gimage, width, height);
pixel_region_init (&maskPR, gimp_drawable_data (GIMP_DRAWABLE (mask)),
0, 0, width, height, TRUE);
/* iterate over the entire image */
for (pr = pixel_regions_register (2, &imagePR, &maskPR);
pr != NULL;
pr = pixel_regions_process (pr))
{
image_data = imagePR.data;
mask_data = maskPR.data;
for (i = 0; i < imagePR.h; i++)
{
idata = image_data;
mdata = mask_data;
for (j = 0; j < imagePR.w; j++)
{
/* Get the rgb values for the color */
gimp_image_get_color (gimage, d_type, rgb, idata);
/* Plug the alpha channel in there */
if (has_alpha)
rgb[color_bytes - 1] = idata[alpha];
/* Find how closely the colors match */
*mdata++ = is_pixel_sufficiently_different (col,
rgb,
antialias,
threshold,
color_bytes,
has_alpha);
idata += bytes;
}
image_data += imagePR.rowstride;
mask_data += maskPR.rowstride;
}
}
return mask;
}
/* private functions */
static gint
is_pixel_sufficiently_different (guchar *col1,
guchar *col2,
gboolean antialias,
gint threshold,
gint bytes,
gboolean has_alpha)
{
gint diff;
gint max;
gint b;
gint alpha;
max = 0;
alpha = (has_alpha) ? bytes - 1 : bytes;
/* if there is an alpha channel, never select transparent regions */
if (has_alpha && col2[alpha] == 0)
return 0;
/* fuzzy_select had a "for (b = 0; b < _bytes_; b++)" loop. however
* i'm quite sure "b < alpha" is correct for both tools --Mitch
*/
for (b = 0; b < alpha; b++)
{
diff = col1[b] - col2[b];
diff = abs (diff);
if (diff > max)
max = diff;
}
if (antialias && threshold > 0)
{
gfloat aa;
aa = 1.5 - ((gfloat) max / threshold);
if (aa <= 0)
return 0;
else if (aa < 0.5)
return (guchar) (aa * 512);
else
return 255;
}
else
{
if (max > threshold)
return 0;
else
return 255;
}
}
static void
ref_tiles (TileManager *src,
TileManager *mask,
Tile **s_tile,
Tile **m_tile,
gint x,
gint y,
guchar **s,
guchar **m)
{
if (*s_tile != NULL)
tile_release (*s_tile, FALSE);
if (*m_tile != NULL)
tile_release (*m_tile, TRUE);
*s_tile = tile_manager_get_tile (src, x, y, TRUE, FALSE);
*m_tile = tile_manager_get_tile (mask, x, y, TRUE, TRUE);
*s = tile_data_pointer (*s_tile, x % TILE_WIDTH, y % TILE_HEIGHT);
*m = tile_data_pointer (*m_tile, x % TILE_WIDTH, y % TILE_HEIGHT);
}
static int
find_contiguous_segment (guchar *col,
PixelRegion *src,
PixelRegion *mask,
gint width,
gint bytes,
gboolean has_alpha,
gboolean antialias,
gint threshold,
gint initial,
gint *start,
gint *end)
{
guchar *s;
guchar *m;
guchar diff;
Tile *s_tile = NULL;
Tile *m_tile = NULL;
ref_tiles (src->tiles, mask->tiles, &s_tile, &m_tile, src->x, src->y, &s, &m);
/* check the starting pixel */
if (! (diff = is_pixel_sufficiently_different (col, s, antialias,
threshold, bytes, has_alpha)))
{
tile_release (s_tile, FALSE);
tile_release (m_tile, TRUE);
return FALSE;
}
*m-- = diff;
s -= bytes;
*start = initial - 1;
while (*start >= 0 && diff)
{
if (! ((*start + 1) % TILE_WIDTH))
ref_tiles (src->tiles, mask->tiles, &s_tile, &m_tile, *start, src->y, &s, &m);
diff = is_pixel_sufficiently_different (col, s, antialias,
threshold, bytes, has_alpha);
if ((*m-- = diff))
{
s -= bytes;
(*start)--;
}
}
diff = 1;
*end = initial + 1;
if (*end % TILE_WIDTH && *end < width)
ref_tiles (src->tiles, mask->tiles, &s_tile, &m_tile, *end, src->y, &s, &m);
while (*end < width && diff)
{
if (! (*end % TILE_WIDTH))
ref_tiles (src->tiles, mask->tiles, &s_tile, &m_tile, *end, src->y, &s, &m);
diff = is_pixel_sufficiently_different (col, s, antialias,
threshold, bytes, has_alpha);
if ((*m++ = diff))
{
s += bytes;
(*end)++;
}
}
tile_release (s_tile, FALSE);
tile_release (m_tile, TRUE);
return TRUE;
}
static void
find_contiguous_region_helper (PixelRegion *mask,
PixelRegion *src,
gboolean has_alpha,
gboolean antialias,
gint threshold,
gboolean indexed,
gint x,
gint y,
guchar *col)
{
gint start, end, i;
gint val;
gint bytes;
Tile *tile;
if (threshold == 0) threshold = 1;
if (x < 0 || x >= src->w) return;
if (y < 0 || y >= src->h) return;
tile = tile_manager_get_tile (mask->tiles, x, y, TRUE, FALSE);
val = *(guchar *)(tile_data_pointer (tile,
x % TILE_WIDTH, y % TILE_HEIGHT));
tile_release (tile, FALSE);
if (val != 0)
return;
src->x = x;
src->y = y;
bytes = src->bytes;
if(indexed)
{
bytes = has_alpha ? 4 : 3;
}
if (! find_contiguous_segment (col, src, mask, src->w,
src->bytes, has_alpha,
antialias, threshold, x, &start, &end))
return;
for (i = start + 1; i < end; i++)
{
find_contiguous_region_helper (mask, src, has_alpha, antialias,
threshold, indexed, i, y - 1, col);
find_contiguous_region_helper (mask, src, has_alpha, antialias,
threshold, indexed, i, y + 1, col);
}
}

View File

@ -0,0 +1,39 @@
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_IMAGE_CONTIGUOUS_REGION_H__
#define __GIMP_IMAGE_CONTIGUOUS_REGION_H__
GimpChannel * gimp_image_contiguous_region_by_seed (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
gboolean antialias,
gint threshold,
gint x,
gint y);
GimpChannel * gimp_image_contiguous_region_by_color (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
gboolean antialias,
gint threshold,
const GimpRGB *color);
#endif /* __GIMP_IMAGE_CONTIGUOUS_REGION_H__ */

View File

@ -0,0 +1,300 @@
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "core-types.h"
#include "gimpchannel.h"
#include "gimpimage.h"
#include "gimpimage-contiguous-region.h"
#include "gimpimage-mask.h"
#include "gimpimage-mask-select.h"
#include "gimpscanconvert.h"
void
gimp_image_mask_select_rectangle (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
ChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
GimpChannel *new_mask;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
/* if applicable, replace the current selection */
if (op == CHANNEL_OP_REPLACE)
gimage_mask_clear (gimage);
else
gimage_mask_undo (gimage);
/* if feathering for rect, make a new mask with the
* rectangle and feather that with the old mask
*/
if (feather)
{
new_mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_channel_combine_rect (new_mask, CHANNEL_OP_ADD, x, y, w, h);
gimp_channel_feather (new_mask,
feather_radius_x,
feather_radius_y,
FALSE /* no undo */);
gimp_channel_combine_mask (gimp_image_get_mask (gimage), new_mask,
op, 0, 0);
g_object_unref (G_OBJECT (new_mask));
}
else if (op == CHANNEL_OP_INTERSECT)
{
new_mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_channel_combine_rect (new_mask, CHANNEL_OP_ADD, x, y, w, h);
gimp_channel_combine_mask (gimp_image_get_mask (gimage), new_mask,
op, 0, 0);
g_object_unref (G_OBJECT (new_mask));
}
else
{
gimp_channel_combine_rect (gimp_image_get_mask (gimage), op, x, y, w, h);
}
}
void
gimp_image_mask_select_ellipse (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
GimpChannel *new_mask;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
/* if applicable, replace the current selection */
if (op == CHANNEL_OP_REPLACE)
gimage_mask_clear (gimage);
else
gimage_mask_undo (gimage);
/* if feathering for rect, make a new mask with the
* rectangle and feather that with the old mask
*/
if (feather)
{
new_mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_channel_combine_ellipse (new_mask, CHANNEL_OP_ADD,
x, y, w, h, antialias);
gimp_channel_feather (new_mask,
feather_radius_x,
feather_radius_y,
FALSE /* no undo */);
gimp_channel_combine_mask (gimp_image_get_mask (gimage), new_mask,
op, 0, 0);
g_object_unref (G_OBJECT (new_mask));
}
else if (op == CHANNEL_OP_INTERSECT)
{
new_mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_channel_combine_ellipse (new_mask, CHANNEL_OP_ADD,
x, y, w, h, antialias);
gimp_channel_combine_mask (gimp_image_get_mask (gimage), new_mask,
op, 0, 0);
g_object_unref (G_OBJECT (new_mask));
}
else
{
gimp_channel_combine_ellipse (gimp_image_get_mask (gimage), op,
x, y, w, h, antialias);
}
}
void
gimp_image_mask_select_polygon (GimpImage *gimage,
gint n_points,
GimpVector2 *points,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
GimpChannel *mask;
GimpScanConvert *scan_convert;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
/* if applicable, replace the current selection */
/* or insure that a floating selection is anchored down... */
if (op == CHANNEL_OP_REPLACE)
gimage_mask_clear (gimage);
else
gimage_mask_undo (gimage);
#define SUPERSAMPLE 3
scan_convert = gimp_scan_convert_new (gimage->width,
gimage->height,
antialias ? SUPERSAMPLE : 1);
gimp_scan_convert_add_points (scan_convert, n_points, points);
mask = gimp_scan_convert_to_channel (scan_convert, gimage);
gimp_scan_convert_free (scan_convert);
#undef SUPERSAMPLE
if (mask)
{
if (feather)
gimp_channel_feather (mask,
feather_radius_x,
feather_radius_y,
FALSE /* no undo */);
gimp_channel_combine_mask (gimp_image_get_mask (gimage),
mask, op, 0, 0);
g_object_unref (G_OBJECT (mask));
}
}
void
gimp_image_mask_select_channel (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
GimpChannel *channel,
ChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
gint off_x, off_y;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail ((! drawable && ! sample_merged) || GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_CHANNEL (channel));
/* if applicable, replace the current selection */
if (op == CHANNEL_OP_REPLACE)
gimage_mask_clear (gimage);
else
gimage_mask_undo (gimage);
if (sample_merged)
{
off_x = off_y = 0;
}
else
{
gimp_drawable_offsets (drawable, &off_x, &off_y);
}
if (feather)
gimp_channel_feather (channel,
feather_radius_x,
feather_radius_y,
FALSE /* no undo */);
gimp_channel_combine_mask (gimp_image_get_mask (gimage),
channel,
op,
off_x, off_y);
}
void
gimp_image_mask_select_fuzzy (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
gint x,
gint y,
gint threshold,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
GimpChannel *mask;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
mask = gimp_image_contiguous_region_by_seed (gimage, drawable,
sample_merged,
antialias,
threshold,
x, y);
gimp_image_mask_select_channel (gimage,
drawable,
sample_merged,
mask,
op,
feather,
feather_radius_x,
feather_radius_y);
g_object_unref (G_OBJECT (mask));
}
void
gimp_image_mask_select_by_color (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
const GimpRGB *color,
gint threshold,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
GimpChannel *mask;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (color != NULL);
mask = gimp_image_contiguous_region_by_color (gimage, drawable,
sample_merged,
antialias,
threshold,
color);
gimp_image_mask_select_channel (gimage,
drawable,
sample_merged,
mask,
op,
feather,
feather_radius_x,
feather_radius_y);
g_object_unref (G_OBJECT (mask));
}

View File

@ -0,0 +1,86 @@
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_IMAGE_MASK_SELECT_H__
#define __GIMP_IMAGE_MASK_SELECT_H__
void gimp_image_mask_select_rectangle (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
ChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_image_mask_select_ellipse (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_image_mask_select_polygon (GimpImage *gimage,
gint n_points,
GimpVector2 *points,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_image_mask_select_channel (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
GimpChannel *channel,
ChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_image_mask_select_fuzzy (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
gint x,
gint y,
gint threshold,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_image_mask_select_by_color (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
const GimpRGB *color,
gint threshold,
ChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
#endif /* __GIMP_IMAGE_MASK_SELECT_H__ */

View File

@ -64,6 +64,12 @@ gimage_mask_boundary (GimpImage *gimage,
gint x1, y1;
gint x2, y2;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (segs_in != NULL, FALSE);
g_return_val_if_fail (segs_out != NULL, FALSE);
g_return_val_if_fail (num_segs_in != NULL, FALSE);
g_return_val_if_fail (num_segs_out != NULL, FALSE);
if ((layer = gimp_image_floating_sel (gimage)))
{
/* If there is a floating selection, then
@ -458,17 +464,10 @@ gimage_mask_feather (GimpImage *gimage,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
/* push the current mask onto the undo stack--need to do this here because
* gimp_channel_feather doesn't do it
*/
gimp_channel_push_undo (gimp_image_get_mask (gimage));
/* feather the region */
gimp_channel_feather (gimp_image_get_mask (gimage),
gimp_image_get_mask (gimage),
feather_radius_x,
feather_radius_y,
CHANNEL_OP_REPLACE, 0, 0);
TRUE /* push undo */);
}
@ -477,7 +476,6 @@ gimage_mask_border (GimpImage *gimage,
gint border_radius_x,
gint border_radius_y)
{
/* feather the region */
gimp_channel_border (gimp_image_get_mask (gimage),
border_radius_x,
border_radius_y);
@ -489,7 +487,6 @@ gimage_mask_grow (GimpImage *gimage,
int grow_pixels_x,
int grow_pixels_y)
{
/* feather the region */
gimp_channel_grow (gimp_image_get_mask (gimage),
grow_pixels_x,
grow_pixels_y);
@ -502,7 +499,6 @@ gimage_mask_shrink (GimpImage *gimage,
gint shrink_pixels_y,
gboolean edge_lock)
{
/* feather the region */
gimp_channel_shrink (gimp_image_get_mask (gimage),
shrink_pixels_x,
shrink_pixels_y,

View File

@ -34,7 +34,6 @@
#include "gimpdisplay-render.h"
#include "gximage.h"
#include "appenv.h"
#include "gimprc.h"

View File

@ -34,7 +34,6 @@
#include "gimpdisplay-render.h"
#include "gximage.h"
#include "appenv.h"
#include "gimprc.h"

View File

@ -22,7 +22,6 @@
#include "core/core-types.h"
#include "appenv.h"
#include "colormaps.h"
#include "gximage.h"

View File

@ -326,7 +326,9 @@ gui_restore (Gimp *gimp)
color_select_init ();
devices_restore ();
session_restore ();
if (restore_session)
session_restore ();
}
void

View File

@ -52,7 +52,6 @@
#include "color-notebook.h"
#include "session.h"
#include "appenv.h"
#include "gimprc.h"
@ -79,8 +78,7 @@ session_init (void)
void
session_restore (void)
{
if (restore_session)
gimp_dialog_factories_session_restore ();
gimp_dialog_factories_session_restore ();
}
void

View File

@ -30,8 +30,6 @@
#include "splash.h"
#include "appenv.h"
#include "libgimp/gimpintl.h"
@ -74,7 +72,7 @@ static GtkWidget *progress = NULL;
/* public functions */
void
splash_create (void)
splash_create (gboolean show_image)
{
GtkWidget *vbox;
GtkWidget *logo_hbox;
@ -93,8 +91,7 @@ splash_create (void)
gimp_dialog_set_icon (GTK_WINDOW (win_initstatus));
if (no_splash_image == FALSE &&
splash_logo_load_size (win_initstatus))
if (show_image && splash_logo_load_size (win_initstatus))
{
splash_show_logo = SPLASH_SHOW_LOGO_LATER;
}

View File

@ -20,7 +20,7 @@
#define __SPLASH_H__
void splash_create (void);
void splash_create (gboolean show_image);
void splash_logo_load (void);
void splash_destroy (void);

View File

@ -301,14 +301,22 @@ gimp_paintbrush_tool_motion (GimpPaintTool *paint_tool,
if (gradient_length)
{
if (pressure_options->color)
gimp_gradient_get_color_at (gimp_context_get_gradient (context),
paint_tool->curpressure, &color);
else
gimp_paint_tool_get_color_from_gradient (paint_tool, gradient_length,
&color, mode);
GimpGradient *gradient;
temp_blend = (gint) ((color.a * local_blend));
gradient = gimp_context_get_gradient (context);
if (pressure_options->color)
gimp_gradient_get_color_at (gradient,
paint_tool->curpressure,
&color);
else
gimp_paint_tool_get_color_from_gradient (paint_tool,
gradient,
gradient_length,
&color,
mode);
temp_blend = (gint) ((color.a * local_blend));
gimp_rgb_get_uchar (&color,
&col[RED_PIX],

View File

@ -55,7 +55,6 @@
#include "gimpconvolvetool.h"
#include "gimppainttool.h"
#include "app_procs.h"
#include "devices.h"
#include "gimprc.h"
#include "undo.h"
@ -880,7 +879,7 @@ gimp_paint_tool_start (GimpPaintTool *paint_tool,
GimpContext *context;
context = gimp_get_current_context (the_gimp);
context = gimp_get_current_context (gimp_drawable_gimage (drawable)->gimp);
paint_tool->curx = x;
paint_tool->cury = y;
@ -1113,29 +1112,27 @@ gimp_paint_tool_cleanup (void)
void
gimp_paint_tool_get_color_from_gradient (GimpPaintTool *paint_tool,
GimpGradient *gradient,
gdouble gradient_length,
GimpRGB *color,
GradientPaintMode mode)
{
GimpContext *context;
gdouble y;
gdouble distance; /* distance in current brush stroke */
context = gimp_get_current_context (the_gimp);
gdouble distance; /* distance in current brush stroke */
gdouble y;
distance = paint_tool->pixel_dist;
y = ((double) distance / gradient_length);
y = (gdouble) distance / gradient_length;
/* for the once modes, set y close to 1.0 after the first chunk */
if ( (mode == ONCE_FORWARD || mode == ONCE_BACKWARDS) && y >= 1.0 )
if ((mode == ONCE_FORWARD || mode == ONCE_BACKWARDS) && y >= 1.0)
y = 0.9999999;
if ( (((int)y & 1) && mode != LOOP_SAWTOOTH) || mode == ONCE_BACKWARDS )
y = 1.0 - (y - (int)y);
if ((((gint) y & 1) && mode != LOOP_SAWTOOTH) || mode == ONCE_BACKWARDS )
y = 1.0 - (y - (gint) y);
else
y = y - (int)y;
y = y - (gint) y;
gimp_gradient_get_color_at (gimp_context_get_gradient (context), y, color);
gimp_gradient_get_color_at (gradient, y, color);
}

View File

@ -145,10 +145,11 @@ void gimp_paint_tool_finish (GimpPaintTool *tool,
GimpDrawable *drawable);
void gimp_paint_tool_cleanup (void);
void gimp_paint_tool_get_color_from_gradient (GimpPaintTool *tool,
gdouble gradient_length,
GimpRGB *color,
GradientPaintMode mode);
void gimp_paint_tool_get_color_from_gradient (GimpPaintTool *tool,
GimpGradient *gradient,
gdouble gradient_length,
GimpRGB *color,
GradientPaintMode mode);
/* paint tool painting functions */
TempBuf * gimp_paint_tool_get_paint_area (GimpPaintTool *tool,

View File

@ -36,6 +36,7 @@ libapppdb_a_SOURCES = @STRIP_BEGIN@ \
plug_in_cmds.c \
procedural_db_cmds.c \
selection_cmds.c \
selection_tools_cmds.c \
text_tool_cmds.c \
tools_cmds.c \
undo_cmds.c \

View File

@ -57,6 +57,7 @@ void register_patterns_procs (Gimp *gimp);
void register_plug_in_procs (Gimp *gimp);
void register_procedural_db_procs (Gimp *gimp);
void register_selection_procs (Gimp *gimp);
void register_selection_tools_procs (Gimp *gimp);
void register_text_tool_procs (Gimp *gimp);
void register_tools_procs (Gimp *gimp);
void register_undo_procs (Gimp *gimp);
@ -152,10 +153,13 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Image mask"), 0.801);
register_selection_procs (gimp);
(* status_callback) (NULL, _("Text procedures"), 0.856);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.856);
register_selection_tools_procs (gimp);
(* status_callback) (NULL, _("Text procedures"), 0.871);
register_text_tool_procs (gimp);
(* status_callback) (NULL, _("Tool procedures"), 0.868);
(* status_callback) (NULL, _("Tool procedures"), 0.883);
register_tools_procs (gimp);
(* status_callback) (NULL, _("Undo"), 0.957);

View File

@ -0,0 +1,623 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-2000 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* NOTE: This file is autogenerated by pdbgen.pl. */
#include "config.h"
#include <glib-object.h>
#include "libgimpbase/gimpbasetypes.h"
#include "pdb-types.h"
#include "procedural_db.h"
#include "core/core-types.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage-mask-select.h"
#include "core/gimpimage.h"
#include "libgimpcolor/gimpcolor.h"
static ProcRecord by_color_select_proc;
static ProcRecord ellipse_select_proc;
static ProcRecord free_select_proc;
static ProcRecord fuzzy_select_proc;
static ProcRecord rect_select_proc;
void
register_selection_tools_procs (Gimp *gimp)
{
procedural_db_register (gimp, &by_color_select_proc);
procedural_db_register (gimp, &ellipse_select_proc);
procedural_db_register (gimp, &free_select_proc);
procedural_db_register (gimp, &fuzzy_select_proc);
procedural_db_register (gimp, &rect_select_proc);
}
static Argument *
by_color_select_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
GimpDrawable *drawable;
GimpRGB color;
gint32 threshold;
gint32 operation;
gboolean antialias;
gboolean feather;
gdouble feather_radius;
gboolean sample_merged;
GimpImage *gimage;
drawable = gimp_drawable_get_by_ID (gimp, args[0].value.pdb_int);
if (drawable == NULL)
success = FALSE;
color = args[1].value.pdb_color;
threshold = args[2].value.pdb_int;
if (threshold < 0 || threshold > 255)
success = FALSE;
operation = args[3].value.pdb_int;
if (operation < CHANNEL_OP_ADD || operation > CHANNEL_OP_INTERSECT)
success = FALSE;
antialias = args[4].value.pdb_int ? TRUE : FALSE;
feather = args[5].value.pdb_int ? TRUE : FALSE;
feather_radius = args[6].value.pdb_float;
sample_merged = args[7].value.pdb_int ? TRUE : FALSE;
if (success)
{
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
gimp_image_mask_select_by_color (gimage, drawable,
sample_merged,
&color,
threshold,
operation, antialias,
feather,
feather_radius,
feather_radius);
}
return procedural_db_return_args (&by_color_select_proc, success);
}
static ProcArg by_color_select_inargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The affected drawable"
},
{
GIMP_PDB_COLOR,
"color",
"The color to select"
},
{
GIMP_PDB_INT32,
"threshold",
"Threshold in intensity levels 0 <= threshold <= 255"
},
{
GIMP_PDB_INT32,
"operation",
"The selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
},
{
GIMP_PDB_INT32,
"antialias",
"Antialiasing (TRUE or FALSE)"
},
{
GIMP_PDB_INT32,
"feather",
"Feather option for selections"
},
{
GIMP_PDB_FLOAT,
"feather_radius",
"Radius for feather operation"
},
{
GIMP_PDB_INT32,
"sample_merged",
"Use the composite image, not the drawable"
}
};
static ProcRecord by_color_select_proc =
{
"gimp_by_color_select",
"Create a selection by selecting all pixels (in the specified drawable) with the same (or similar) color to that specified.",
"This tool creates a selection over the specified image. A by-color selection is determined by the supplied color under the constraints of the specified threshold. Essentially, all pixels (in the drawable) that have color sufficiently close to the specified color (as determined by the threshold value) are included in the selection. The antialiasing parameter allows the final selection mask to contain intermediate values based on close misses to the threshold bar. Feathering can be enabled optionally and is controlled with the \"feather_radius\" parameter. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
8,
by_color_select_inargs,
0,
NULL,
{ { by_color_select_invoker } }
};
static Argument *
ellipse_select_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
GimpImage *gimage;
gdouble x;
gdouble y;
gdouble width;
gdouble height;
gint32 operation;
gboolean antialias;
gboolean feather;
gdouble feather_radius;
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (gimage == NULL)
success = FALSE;
x = args[1].value.pdb_float;
y = args[2].value.pdb_float;
width = args[3].value.pdb_float;
if (width <= 0.0)
success = FALSE;
height = args[4].value.pdb_float;
if (height <= 0.0)
success = FALSE;
operation = args[5].value.pdb_int;
if (operation < CHANNEL_OP_ADD || operation > CHANNEL_OP_INTERSECT)
success = FALSE;
antialias = args[6].value.pdb_int ? TRUE : FALSE;
feather = args[7].value.pdb_int ? TRUE : FALSE;
feather_radius = args[8].value.pdb_float;
if (success)
gimp_image_mask_select_ellipse (gimage,
(gint) x, (gint) y,
(gint) width, (gint) height,
operation,
antialias,
feather,
feather_radius,
feather_radius);
return procedural_db_return_args (&ellipse_select_proc, success);
}
static ProcArg ellipse_select_inargs[] =
{
{
GIMP_PDB_IMAGE,
"image",
"The image"
},
{
GIMP_PDB_FLOAT,
"x",
"x coordinate of upper-left corner of ellipse bounding box"
},
{
GIMP_PDB_FLOAT,
"y",
"y coordinate of upper-left corner of ellipse bounding box"
},
{
GIMP_PDB_FLOAT,
"width",
"The width of the ellipse: 0 < width"
},
{
GIMP_PDB_FLOAT,
"height",
"The height of the ellipse: 0 < height"
},
{
GIMP_PDB_INT32,
"operation",
"The selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
},
{
GIMP_PDB_INT32,
"antialias",
"Antialiasing (TRUE or FALSE)"
},
{
GIMP_PDB_INT32,
"feather",
"Feather option for selections"
},
{
GIMP_PDB_FLOAT,
"feather_radius",
"Radius for feather operation"
}
};
static ProcRecord ellipse_select_proc =
{
"gimp_ellipse_select",
"Create an elliptical selection over the specified image.",
"This tool creates an elliptical selection over the specified image. The elliptical region can be either added to, subtracted from, or replace the contents of the previous selection mask. If antialiasing is turned on, the edges of the elliptical region will contain intermediate values which give the appearance of a sharper, less pixelized edge. This should be set as TRUE most of the time. If the feather option is enabled, the resulting selection is blurred before combining. The blur is a gaussian blur with the specified feather radius.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
9,
ellipse_select_inargs,
0,
NULL,
{ { ellipse_select_invoker } }
};
static Argument *
free_select_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
GimpImage *gimage;
gint32 num_segs;
gdouble *segs;
gint32 operation;
gboolean antialias;
gboolean feather;
gdouble feather_radius;
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (gimage == NULL)
success = FALSE;
num_segs = args[1].value.pdb_int;
if (!(num_segs < 2))
num_segs /= 2;
else
success = FALSE;
segs = (gdouble *) args[2].value.pdb_pointer;
operation = args[3].value.pdb_int;
if (operation < CHANNEL_OP_ADD || operation > CHANNEL_OP_INTERSECT)
success = FALSE;
antialias = args[4].value.pdb_int ? TRUE : FALSE;
feather = args[5].value.pdb_int ? TRUE : FALSE;
feather_radius = args[6].value.pdb_float;
if (success)
gimp_image_mask_select_polygon (gimage,
num_segs,
(GimpVector2 *) segs,
operation,
antialias,
feather,
feather_radius,
feather_radius);
return procedural_db_return_args (&free_select_proc, success);
}
static ProcArg free_select_inargs[] =
{
{
GIMP_PDB_IMAGE,
"image",
"The image"
},
{
GIMP_PDB_INT32,
"num_segs",
"Number of points (count 1 coordinate as two points)"
},
{
GIMP_PDB_FLOATARRAY,
"segs",
"Array of points: { p1.x, p1.y, p2.x, p2.y, ..., pn.x, pn.y}"
},
{
GIMP_PDB_INT32,
"operation",
"The selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
},
{
GIMP_PDB_INT32,
"antialias",
"Antialiasing (TRUE or FALSE)"
},
{
GIMP_PDB_INT32,
"feather",
"Feather option for selections"
},
{
GIMP_PDB_FLOAT,
"feather_radius",
"Radius for feather operation"
}
};
static ProcRecord free_select_proc =
{
"gimp_free_select",
"Create a polygonal selection over the specified image.",
"This tool creates a polygonal selection over the specified image. The polygonal region can be either added to, subtracted from, or replace the contents of the previous selection mask. The polygon is specified through an array of floating point numbers and its length. The length of array must be 2n, where n is the number of points. Each point is defined by 2 floating point values which correspond to the x and y coordinates. If the final point does not connect to the starting point, a connecting segment is automatically added. If the feather option is enabled, the resulting selection is blurred before combining. The blur is a gaussian blur with the specified feather radius.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
7,
free_select_inargs,
0,
NULL,
{ { free_select_invoker } }
};
static Argument *
fuzzy_select_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gdouble x;
gdouble y;
gint32 threshold;
gint32 operation;
gboolean antialias;
gboolean feather;
gdouble feather_radius;
gboolean sample_merged;
GimpImage *gimage;
drawable = gimp_drawable_get_by_ID (gimp, args[0].value.pdb_int);
if (drawable == NULL)
success = FALSE;
x = args[1].value.pdb_float;
y = args[2].value.pdb_float;
threshold = args[3].value.pdb_int;
if (threshold < 0 || threshold > 255)
success = FALSE;
operation = args[4].value.pdb_int;
if (operation < CHANNEL_OP_ADD || operation > CHANNEL_OP_INTERSECT)
success = FALSE;
antialias = args[5].value.pdb_int ? TRUE : FALSE;
feather = args[6].value.pdb_int ? TRUE : FALSE;
feather_radius = args[7].value.pdb_float;
sample_merged = args[8].value.pdb_int ? TRUE : FALSE;
if (success)
{
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
gimp_image_mask_select_fuzzy (gimage,
drawable,
sample_merged,
x, y,
threshold,
operation,
antialias,
feather,
feather_radius,
feather_radius);
}
return procedural_db_return_args (&fuzzy_select_proc, success);
}
static ProcArg fuzzy_select_inargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The affected drawable"
},
{
GIMP_PDB_FLOAT,
"x",
"x coordinate of initial seed fill point: (image coordinates)"
},
{
GIMP_PDB_FLOAT,
"y",
"y coordinate of initial seed fill point: (image coordinates)"
},
{
GIMP_PDB_INT32,
"threshold",
"Threshold in intensity levels 0 <= threshold <= 255"
},
{
GIMP_PDB_INT32,
"operation",
"The selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
},
{
GIMP_PDB_INT32,
"antialias",
"Antialiasing (TRUE or FALSE)"
},
{
GIMP_PDB_INT32,
"feather",
"Feather option for selections"
},
{
GIMP_PDB_FLOAT,
"feather_radius",
"Radius for feather operation"
},
{
GIMP_PDB_INT32,
"sample_merged",
"Use the composite image, not the drawable"
}
};
static ProcRecord fuzzy_select_proc =
{
"gimp_fuzzy_select",
"Create a fuzzy selection starting at the specified coordinates on the specified drawable.",
"This tool creates a fuzzy selection over the specified image. A fuzzy selection is determined by a seed fill under the constraints of the specified threshold. Essentially, the color at the specified coordinates (in the drawable) is measured and the selection expands outwards from that point to any adjacent pixels which are not significantly different (as determined by the threshold value). This process continues until no more expansion is possible. The antialiasing parameter allows the final selection mask to contain intermediate values based on close misses to the threshold bar at pixels along the seed fill boundary. Feathering can be enabled optionally and is controlled with the \"feather_radius\" paramter. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored."
"If the sample is merged, the specified coordinates are relative to the image origin; otherwise, they are relative to the drawable's origin.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
9,
fuzzy_select_inargs,
0,
NULL,
{ { fuzzy_select_invoker } }
};
static Argument *
rect_select_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
GimpImage *gimage;
gdouble x;
gdouble y;
gdouble width;
gdouble height;
gint32 operation;
gboolean feather;
gdouble feather_radius;
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (gimage == NULL)
success = FALSE;
x = args[1].value.pdb_float;
y = args[2].value.pdb_float;
width = args[3].value.pdb_float;
if (width <= 0.0)
success = FALSE;
height = args[4].value.pdb_float;
if (height <= 0.0)
success = FALSE;
operation = args[5].value.pdb_int;
if (operation < CHANNEL_OP_ADD || operation > CHANNEL_OP_INTERSECT)
success = FALSE;
feather = args[6].value.pdb_int ? TRUE : FALSE;
feather_radius = args[7].value.pdb_float;
if (success)
gimp_image_mask_select_rectangle (gimage,
(gint) x, (gint) y,
(gint) width, (gint) height,
operation,
feather,
feather_radius,
feather_radius);
return procedural_db_return_args (&rect_select_proc, success);
}
static ProcArg rect_select_inargs[] =
{
{
GIMP_PDB_IMAGE,
"image",
"The image"
},
{
GIMP_PDB_FLOAT,
"x",
"x coordinate of upper-left corner of rectangle"
},
{
GIMP_PDB_FLOAT,
"y",
"y coordinate of upper-left corner of rectangle"
},
{
GIMP_PDB_FLOAT,
"width",
"The width of the rectangle: 0 < width"
},
{
GIMP_PDB_FLOAT,
"height",
"The height of the rectangle: 0 < height"
},
{
GIMP_PDB_INT32,
"operation",
"The selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
},
{
GIMP_PDB_INT32,
"feather",
"Feather option for selections"
},
{
GIMP_PDB_FLOAT,
"feather_radius",
"Radius for feather operation"
}
};
static ProcRecord rect_select_proc =
{
"gimp_rect_select",
"Create a rectangular selection over the specified image;",
"This tool creates a rectangular selection over the specified image. The rectangular region can be either added to, subtracted from, or replace the contents of the previous selection mask. If the feather option is enabled, the resulting selection is blurred before combining. The blur is a gaussian blur with the specified feather radius.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
8,
rect_select_inargs,
0,
NULL,
{ { rect_select_invoker } }
};

View File

@ -31,7 +31,6 @@
#include "tools/tools-types.h"
#include "procedural_db.h"
#include "appenv.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"

View File

@ -33,24 +33,20 @@
#include "base/tile-manager.h"
#include "core/core-types.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage-mask-select.h"
#include "core/gimpimage.h"
#include "tools/gimpairbrushtool.h"
#include "tools/gimpblendtool.h"
#include "tools/gimpbucketfilltool.h"
#include "tools/gimpbycolorselecttool.h"
#include "tools/gimpclonetool.h"
#include "tools/gimpcolorpickertool.h"
#include "tools/gimpconvolvetool.h"
#include "tools/gimpdodgeburntool.h"
#include "tools/gimpellipseselecttool.h"
#include "tools/gimperasertool.h"
#include "tools/gimpfliptool.h"
#include "tools/gimpfreeselecttool.h"
#include "tools/gimpfuzzyselecttool.h"
#include "tools/gimppaintbrushtool.h"
#include "tools/gimppenciltool.h"
#include "tools/gimpperspectivetool.h"
#include "tools/gimprectselecttool.h"
#include "tools/gimprotatetool.h"
#include "tools/gimpscaletool.h"
#include "tools/gimpsheartool.h"
@ -65,7 +61,6 @@ static ProcRecord airbrush_proc;
static ProcRecord airbrush_default_proc;
static ProcRecord blend_proc;
static ProcRecord bucket_fill_proc;
static ProcRecord by_color_select_proc;
static ProcRecord clone_proc;
static ProcRecord clone_default_proc;
static ProcRecord color_picker_proc;
@ -73,17 +68,13 @@ static ProcRecord convolve_proc;
static ProcRecord convolve_default_proc;
static ProcRecord dodgeburn_proc;
static ProcRecord dodgeburn_default_proc;
static ProcRecord ellipse_select_proc;
static ProcRecord eraser_proc;
static ProcRecord eraser_default_proc;
static ProcRecord flip_proc;
static ProcRecord free_select_proc;
static ProcRecord fuzzy_select_proc;
static ProcRecord paintbrush_proc;
static ProcRecord paintbrush_default_proc;
static ProcRecord pencil_proc;
static ProcRecord perspective_proc;
static ProcRecord rect_select_proc;
static ProcRecord rotate_proc;
static ProcRecord scale_proc;
static ProcRecord shear_proc;
@ -98,7 +89,6 @@ register_tools_procs (Gimp *gimp)
procedural_db_register (gimp, &airbrush_default_proc);
procedural_db_register (gimp, &blend_proc);
procedural_db_register (gimp, &bucket_fill_proc);
procedural_db_register (gimp, &by_color_select_proc);
procedural_db_register (gimp, &clone_proc);
procedural_db_register (gimp, &clone_default_proc);
procedural_db_register (gimp, &color_picker_proc);
@ -106,17 +96,13 @@ register_tools_procs (Gimp *gimp)
procedural_db_register (gimp, &convolve_default_proc);
procedural_db_register (gimp, &dodgeburn_proc);
procedural_db_register (gimp, &dodgeburn_default_proc);
procedural_db_register (gimp, &ellipse_select_proc);
procedural_db_register (gimp, &eraser_proc);
procedural_db_register (gimp, &eraser_default_proc);
procedural_db_register (gimp, &flip_proc);
procedural_db_register (gimp, &free_select_proc);
procedural_db_register (gimp, &fuzzy_select_proc);
procedural_db_register (gimp, &paintbrush_proc);
procedural_db_register (gimp, &paintbrush_default_proc);
procedural_db_register (gimp, &pencil_proc);
procedural_db_register (gimp, &perspective_proc);
procedural_db_register (gimp, &rect_select_proc);
procedural_db_register (gimp, &rotate_proc);
procedural_db_register (gimp, &scale_proc);
procedural_db_register (gimp, &shear_proc);
@ -538,117 +524,6 @@ static ProcRecord bucket_fill_proc =
{ { bucket_fill_invoker } }
};
static Argument *
by_color_select_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
GimpDrawable *drawable;
GimpRGB color;
gint32 threshold;
gint32 operation;
gboolean antialias;
gboolean feather;
gdouble feather_radius;
gboolean sample_merged;
GimpImage *gimage;
guchar fixme[3];
drawable = gimp_drawable_get_by_ID (gimp, args[0].value.pdb_int);
if (drawable == NULL)
success = FALSE;
color = args[1].value.pdb_color;
threshold = args[2].value.pdb_int;
if (threshold < 0 || threshold > 255)
success = FALSE;
operation = args[3].value.pdb_int;
if (operation < CHANNEL_OP_ADD || operation > CHANNEL_OP_INTERSECT)
success = FALSE;
antialias = args[4].value.pdb_int ? TRUE : FALSE;
feather = args[5].value.pdb_int ? TRUE : FALSE;
feather_radius = args[6].value.pdb_float;
sample_merged = args[7].value.pdb_int ? TRUE : FALSE;
if (success)
{
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
gimp_rgb_get_uchar (&color, fixme, fixme + 1, fixme + 2);
gimp_by_color_select_tool_select (gimage, drawable, fixme,
threshold, operation, antialias,
feather, feather_radius,
sample_merged);
}
return procedural_db_return_args (&by_color_select_proc, success);
}
static ProcArg by_color_select_inargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The affected drawable"
},
{
GIMP_PDB_COLOR,
"color",
"The color to select"
},
{
GIMP_PDB_INT32,
"threshold",
"Threshold in intensity levels 0 <= threshold <= 255"
},
{
GIMP_PDB_INT32,
"operation",
"The selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
},
{
GIMP_PDB_INT32,
"antialias",
"Antialiasing (TRUE or FALSE)"
},
{
GIMP_PDB_INT32,
"feather",
"Feather option for selections"
},
{
GIMP_PDB_FLOAT,
"feather_radius",
"Radius for feather operation"
},
{
GIMP_PDB_INT32,
"sample_merged",
"Use the composite image, not the drawable"
}
};
static ProcRecord by_color_select_proc =
{
"gimp_by_color_select",
"Create a selection by selecting all pixels (in the specified drawable) with the same (or similar) color to that specified.",
"This tool creates a selection over the specified image. A by-color selection is determined by the supplied color under the constraints of the specified threshold. Essentially, all pixels (in the drawable) that have color sufficiently close to the specified color (as determined by the threshold value) are included in the selection. The antialiasing parameter allows the final selection mask to contain intermediate values based on close misses to the threshold bar. Feathering can be enabled optionally and is controlled with the \"feather_radius\" parameter. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
8,
by_color_select_inargs,
0,
NULL,
{ { by_color_select_invoker } }
};
static Argument *
clone_invoker (Gimp *gimp,
Argument *args)
@ -1229,7 +1104,7 @@ static ProcRecord dodgeburn_default_proc =
{
"gimp_dodgeburn_default",
"Dodgeburn image with varying exposure. This is the same as the gimp_dodgeburn function except that the exposure, type and mode are taken from the tools option dialog. If the dialog has not been activated then the defaults as used by the dialog will be used.",
"Dodgebure. More details here later.",
"Dodgeburn. More details here later.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
@ -1241,119 +1116,6 @@ static ProcRecord dodgeburn_default_proc =
{ { dodgeburn_default_invoker } }
};
static Argument *
ellipse_select_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
GimpImage *gimage;
gdouble x;
gdouble y;
gdouble width;
gdouble height;
gint32 operation;
gboolean antialias;
gboolean feather;
gdouble feather_radius;
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (gimage == NULL)
success = FALSE;
x = args[1].value.pdb_float;
y = args[2].value.pdb_float;
width = args[3].value.pdb_float;
if (width <= 0.0)
success = FALSE;
height = args[4].value.pdb_float;
if (height <= 0.0)
success = FALSE;
operation = args[5].value.pdb_int;
if (operation < CHANNEL_OP_ADD || operation > CHANNEL_OP_INTERSECT)
success = FALSE;
antialias = args[6].value.pdb_int ? TRUE : FALSE;
feather = args[7].value.pdb_int ? TRUE : FALSE;
feather_radius = args[8].value.pdb_float;
if (success)
ellipse_select (gimage, (int) x, (int) y, (int) width, (int) height,
operation, antialias, feather, feather_radius);
return procedural_db_return_args (&ellipse_select_proc, success);
}
static ProcArg ellipse_select_inargs[] =
{
{
GIMP_PDB_IMAGE,
"image",
"The image"
},
{
GIMP_PDB_FLOAT,
"x",
"x coordinate of upper-left corner of ellipse bounding box"
},
{
GIMP_PDB_FLOAT,
"y",
"y coordinate of upper-left corner of ellipse bounding box"
},
{
GIMP_PDB_FLOAT,
"width",
"The width of the ellipse: 0 < width"
},
{
GIMP_PDB_FLOAT,
"height",
"The height of the ellipse: 0 < height"
},
{
GIMP_PDB_INT32,
"operation",
"The selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
},
{
GIMP_PDB_INT32,
"antialias",
"Antialiasing (TRUE or FALSE)"
},
{
GIMP_PDB_INT32,
"feather",
"Feather option for selections"
},
{
GIMP_PDB_FLOAT,
"feather_radius",
"Radius for feather operation"
}
};
static ProcRecord ellipse_select_proc =
{
"gimp_ellipse_select",
"Create an elliptical selection over the specified image.",
"This tool creates an elliptical selection over the specified image. The elliptical region can be either added to, subtracted from, or replace the contents of the previous selection mask. If antialiasing is turned on, the edges of the elliptical region will contain intermediate values which give the appearance of a sharper, less pixelized edge. This should be set as TRUE most of the time. If the feather option is enabled, the resulting selection is blurred before combining. The blur is a gaussian blur with the specified feather radius.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
9,
ellipse_select_inargs,
0,
NULL,
{ { ellipse_select_invoker } }
};
static Argument *
eraser_invoker (Gimp *gimp,
Argument *args)
@ -1603,228 +1365,6 @@ static ProcRecord flip_proc =
{ { flip_invoker } }
};
static Argument *
free_select_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
GimpImage *gimage;
gint32 num_segs;
gdouble *segs;
gint32 operation;
gboolean antialias;
gboolean feather;
gdouble feather_radius;
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (gimage == NULL)
success = FALSE;
num_segs = args[1].value.pdb_int;
if (!(num_segs < 2))
num_segs /= 2;
else
success = FALSE;
segs = (gdouble *) args[2].value.pdb_pointer;
operation = args[3].value.pdb_int;
if (operation < CHANNEL_OP_ADD || operation > CHANNEL_OP_INTERSECT)
success = FALSE;
antialias = args[4].value.pdb_int ? TRUE : FALSE;
feather = args[5].value.pdb_int ? TRUE : FALSE;
feather_radius = args[6].value.pdb_float;
if (success)
free_select (gimage, num_segs, (GimpVector2 *) segs, operation,
antialias, feather, feather_radius);
return procedural_db_return_args (&free_select_proc, success);
}
static ProcArg free_select_inargs[] =
{
{
GIMP_PDB_IMAGE,
"image",
"The image"
},
{
GIMP_PDB_INT32,
"num_segs",
"Number of points (count 1 coordinate as two points)"
},
{
GIMP_PDB_FLOATARRAY,
"segs",
"Array of points: { p1.x, p1.y, p2.x, p2.y, ..., pn.x, pn.y}"
},
{
GIMP_PDB_INT32,
"operation",
"The selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
},
{
GIMP_PDB_INT32,
"antialias",
"Antialiasing (TRUE or FALSE)"
},
{
GIMP_PDB_INT32,
"feather",
"Feather option for selections"
},
{
GIMP_PDB_FLOAT,
"feather_radius",
"Radius for feather operation"
}
};
static ProcRecord free_select_proc =
{
"gimp_free_select",
"Create a polygonal selection over the specified image.",
"This tool creates a polygonal selection over the specified image. The polygonal region can be either added to, subtracted from, or replace the contents of the previous selection mask. The polygon is specified through an array of floating point numbers and its length. The length of array must be 2n, where n is the number of points. Each point is defined by 2 floating point values which correspond to the x and y coordinates. If the final point does not connect to the starting point, a connecting segment is automatically added. If the feather option is enabled, the resulting selection is blurred before combining. The blur is a gaussian blur with the specified feather radius.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
7,
free_select_inargs,
0,
NULL,
{ { free_select_invoker } }
};
static Argument *
fuzzy_select_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gdouble x;
gdouble y;
gint32 threshold;
gint32 operation;
gboolean antialias;
gboolean feather;
gdouble feather_radius;
gboolean sample_merged;
GimpImage *gimage;
GimpChannel *new, *old_fuzzy_mask;
drawable = gimp_drawable_get_by_ID (gimp, args[0].value.pdb_int);
if (drawable == NULL)
success = FALSE;
x = args[1].value.pdb_float;
y = args[2].value.pdb_float;
threshold = args[3].value.pdb_int;
if (threshold < 0 || threshold > 255)
success = FALSE;
operation = args[4].value.pdb_int;
if (operation < CHANNEL_OP_ADD || operation > CHANNEL_OP_INTERSECT)
success = FALSE;
antialias = args[5].value.pdb_int ? TRUE : FALSE;
feather = args[6].value.pdb_int ? TRUE : FALSE;
feather_radius = args[7].value.pdb_float;
sample_merged = args[8].value.pdb_int ? TRUE : FALSE;
if (success)
{
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
new = find_contiguous_region (gimage, drawable, antialias, threshold,
x, y, sample_merged);
old_fuzzy_mask = fuzzy_mask;
fuzzy_mask = new;
drawable = sample_merged ? NULL : drawable;
fuzzy_select (gimage, drawable, operation, feather, feather_radius);
fuzzy_mask = old_fuzzy_mask;
}
return procedural_db_return_args (&fuzzy_select_proc, success);
}
static ProcArg fuzzy_select_inargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The affected drawable"
},
{
GIMP_PDB_FLOAT,
"x",
"x coordinate of initial seed fill point: (image coordinates)"
},
{
GIMP_PDB_FLOAT,
"y",
"y coordinate of initial seed fill point: (image coordinates)"
},
{
GIMP_PDB_INT32,
"threshold",
"Threshold in intensity levels 0 <= threshold <= 255"
},
{
GIMP_PDB_INT32,
"operation",
"The selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
},
{
GIMP_PDB_INT32,
"antialias",
"Antialiasing (TRUE or FALSE)"
},
{
GIMP_PDB_INT32,
"feather",
"Feather option for selections"
},
{
GIMP_PDB_FLOAT,
"feather_radius",
"Radius for feather operation"
},
{
GIMP_PDB_INT32,
"sample_merged",
"Use the composite image, not the drawable"
}
};
static ProcRecord fuzzy_select_proc =
{
"gimp_fuzzy_select",
"Create a fuzzy selection starting at the specified coordinates on the specified drawable.",
"This tool creates a fuzzy selection over the specified image. A fuzzy selection is determined by a seed fill under the constraints of the specified threshold. Essentially, the color at the specified coordinates (in the drawable) is measured and the selection expands outwards from that point to any adjacent pixels which are not significantly different (as determined by the threshold value). This process continues until no more expansion is possible. The antialiasing parameter allows the final selection mask to contain intermediate values based on close misses to the threshold bar at pixels along the seed fill boundary. Feathering can be enabled optionally and is controlled with the \"feather_radius\" paramter. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored."
"If the sample is merged, the specified coordinates are relative to the image origin; otherwise, they are relative to the drawable's origin.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
9,
fuzzy_select_inargs,
0,
NULL,
{ { fuzzy_select_invoker } }
};
static Argument *
paintbrush_invoker (Gimp *gimp,
Argument *args)
@ -2217,111 +1757,6 @@ static ProcRecord perspective_proc =
{ { perspective_invoker } }
};
static Argument *
rect_select_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
GimpImage *gimage;
gdouble x;
gdouble y;
gdouble width;
gdouble height;
gint32 operation;
gboolean feather;
gdouble feather_radius;
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (gimage == NULL)
success = FALSE;
x = args[1].value.pdb_float;
y = args[2].value.pdb_float;
width = args[3].value.pdb_float;
if (width <= 0.0)
success = FALSE;
height = args[4].value.pdb_float;
if (height <= 0.0)
success = FALSE;
operation = args[5].value.pdb_int;
if (operation < CHANNEL_OP_ADD || operation > CHANNEL_OP_INTERSECT)
success = FALSE;
feather = args[6].value.pdb_int ? TRUE : FALSE;
feather_radius = args[7].value.pdb_float;
if (success)
rect_select (gimage, (int) x, (int) y, (int) width, (int) height,
operation, feather, feather_radius);
return procedural_db_return_args (&rect_select_proc, success);
}
static ProcArg rect_select_inargs[] =
{
{
GIMP_PDB_IMAGE,
"image",
"The image"
},
{
GIMP_PDB_FLOAT,
"x",
"x coordinate of upper-left corner of rectangle"
},
{
GIMP_PDB_FLOAT,
"y",
"y coordinate of upper-left corner of rectangle"
},
{
GIMP_PDB_FLOAT,
"width",
"The width of the rectangle: 0 < width"
},
{
GIMP_PDB_FLOAT,
"height",
"The height of the rectangle: 0 < height"
},
{
GIMP_PDB_INT32,
"operation",
"The selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
},
{
GIMP_PDB_INT32,
"feather",
"Feather option for selections"
},
{
GIMP_PDB_FLOAT,
"feather_radius",
"Radius for feather operation"
}
};
static ProcRecord rect_select_proc =
{
"gimp_rect_select",
"Create a rectangular selection over the specified image;",
"This tool creates a rectangular selection over the specified image. The rectangular region can be either added to, subtracted from, or replace the contents of the previous selection mask. If the feather option is enabled, the resulting selection is blurred before combining. The blur is a gaussian blur with the specified feather radius.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
8,
rect_select_inargs,
0,
NULL,
{ { rect_select_invoker } }
};
static Argument *
rotate_invoker (Gimp *gimp,
Argument *args)
@ -2634,11 +2069,12 @@ shear_invoker (Gimp *gimp,
gimp_matrix3_xshear (matrix, magnitude / tile_manager_height (float_tiles));
else if (shear_type == ORIENTATION_VERTICAL)
gimp_matrix3_yshear (matrix, magnitude / tile_manager_width (float_tiles));
gimp_matrix3_translate (matrix, +cx, +cy);
/* Shear the buffer */
new_tiles = gimp_shear_tool_shear (gimage, drawable, NULL, float_tiles,
interpolation, matrix);
interpolation, matrix);
/* Free the cut/copied buffer */
tile_manager_destroy (float_tiles);

View File

@ -36,6 +36,7 @@
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-mask-select.h"
#include "core/gimptoolinfo.h"
#include "pdb/procedural_db.h"
@ -140,7 +141,7 @@ static BezierMatrix basis =
/* Global Static Variable to maintain informations about the "context" */
static GimpBezierSelectTool *curSel = NULL;
static GimpTool *curTool = NULL;
static GDisplay *curGdisp = NULL;
static GimpDisplay *curGdisp = NULL;
static GimpDrawTool *curCore = NULL;
static gint ModeEdit = EXTEND_NEW;
@ -158,21 +159,21 @@ static guint bezier_select_signals[LAST_SIGNAL] = { 0 };
static void gimp_bezier_select_tool_class_init (GimpBezierSelectToolClass *klass);
static void gimp_bezier_select_tool_init (GimpBezierSelectTool *bezier_select);
static void gimp_bezier_select_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
static void gimp_bezier_select_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GimpDisplay *gdisp);
static void gimp_bezier_select_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
static void gimp_bezier_select_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
static void gimp_bezier_select_tool_control (GimpTool *tool,
ToolAction action,
GDisplay *gdisp);
static void gimp_bezier_select_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_bezier_select_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GimpDisplay *gdisp);
static void gimp_bezier_select_tool_control (GimpTool *tool,
ToolAction action,
GimpDisplay *gdisp);
static void gimp_bezier_select_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GimpDisplay *gdisp);
static void bezier_select_draw (GimpDrawTool *draw_tool);
static void bezier_offset_point (GimpBezierSelectPoint *pt,
@ -206,7 +207,7 @@ static void bezier_compose (BezierMatrix a,
BezierMatrix ab);
static void bezier_convert (GimpBezierSelectTool *bezier_sel,
GDisplay *gdisp,
GimpDisplay *gdisp,
gint subdivisions,
gboolean antialias);
static void bezier_convert_points (GimpBezierSelectTool *bezier_sel,
@ -229,10 +230,9 @@ static gboolean test_add_point_on_segment (GimpBezierSelectTool *bezie
gint ypos,
gint halfwidth);
static void bezier_to_sel_internal (GimpBezierSelectTool *bezier_sel,
GimpTool *tool,
GDisplay *gdisp,
gint op,
gboolean replace);
GimpTool *tool,
GimpDisplay *gdisp,
ChannelOps op);
static void bezier_stack_points_aux (GdkPoint *points,
gint start,
gint end,
@ -251,14 +251,14 @@ static gint count_points_on_curve (GimpBezierSelectPoint *poi
static gboolean bezier_edit_point_on_curve (gint x,
gint y,
gint halfwidth,
GDisplay *gdisp,
GimpDisplay *gdisp,
GimpBezierSelectTool *bezier_sel,
GimpTool *tool,
GdkEventButton *bevent);
static gboolean bezier_add_point_on_segment (gint x,
gint y,
gint halfwidth,
GDisplay *gdisp,
GimpDisplay *gdisp,
GimpBezierSelectTool *bezier_sel,
GimpTool *tool);
static GimpBezierSelectPoint * find_start_open_curve (GimpBezierSelectTool *bsel);
@ -390,7 +390,7 @@ gimp_bezier_select_tool_init (GimpBezierSelectTool *bezier_select)
static void
gimp_bezier_select_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpBezierSelectTool *bezier_sel;
GimpBezierSelectPoint *points;
@ -422,7 +422,7 @@ gimp_bezier_select_tool_button_press (GimpTool *tool,
curTool = tool_manager_get_active (gdisp->gimage->gimp);
curSel = bezier_sel;
curGdisp = (GDisplay *) gdisp;
curGdisp = (GimpDisplay *) gdisp;
curCore = (GimpDrawTool *)bezier_sel;
switch (bezier_sel->state)
@ -654,8 +654,6 @@ gimp_bezier_select_tool_button_press (GimpTool *tool,
if (!grab_pointer && gimp_channel_value (bezier_sel->mask, x, y))
{
gboolean replace = FALSE;
if ((bevent->state & GDK_SHIFT_MASK) &&
!(bevent->state & GDK_CONTROL_MASK))
op = CHANNEL_OP_ADD;
@ -666,12 +664,9 @@ gimp_bezier_select_tool_button_press (GimpTool *tool,
(bevent->state & GDK_SHIFT_MASK))
op = CHANNEL_OP_INTERSECT;
else
{
op = CHANNEL_OP_ADD;
replace = TRUE;
}
op = CHANNEL_OP_REPLACE;
bezier_to_sel_internal (bezier_sel, tool, gdisp, op, replace);
bezier_to_sel_internal (bezier_sel, tool, gdisp, op);
gimp_draw_tool_resume ((GimpDrawTool *)bezier_sel);
}
else
@ -702,9 +697,9 @@ gimp_bezier_select_tool_button_press (GimpTool *tool,
}
static void
gimp_bezier_select_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
gimp_bezier_select_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GimpDisplay *gdisp)
{
GimpBezierSelectTool *bezier_sel;
@ -725,9 +720,9 @@ gimp_bezier_select_tool_button_release (GimpTool *tool,
static void
gimp_bezier_select_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
gimp_bezier_select_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GimpDisplay *gdisp)
{
static gint lastx, lasty;
@ -903,7 +898,7 @@ gimp_bezier_select_tool_motion (GimpTool *tool,
gint
bezier_select_load (GDisplay *gdisp,
bezier_select_load (GimpDisplay *gdisp,
GimpBezierSelectPoint *pts,
gint num_pts,
gint closed)
@ -1351,13 +1346,13 @@ delete_whole_curve (GimpBezierSelectTool *bezier_sel,
}
static gboolean
bezier_edit_point_on_curve (gint x,
gint y,
gint halfwidth,
GDisplay *gdisp,
GimpBezierSelectTool *bezier_sel,
GimpTool *tool,
GdkEventButton *bevent)
bezier_edit_point_on_curve (gint x,
gint y,
gint halfwidth,
GimpDisplay *gdisp,
GimpBezierSelectTool *bezier_sel,
GimpTool *tool,
GdkEventButton *bevent)
{
gboolean grab_pointer = FALSE;
GimpBezierSelectPoint *next_curve;
@ -1553,12 +1548,12 @@ bezier_edit_point_on_curve (gint x,
}
static gboolean
bezier_add_point_on_segment (gint x,
gint y,
gint halfwidth,
GDisplay *gdisp,
bezier_add_point_on_segment (gint x,
gint y,
gint halfwidth,
GimpDisplay *gdisp,
GimpBezierSelectTool *bezier_sel,
GimpTool *tool)
GimpTool *tool)
{
GimpBezierSelectPoint *points = bezier_sel->points;
GimpBezierSelectPoint *start_pt = bezier_sel->points;
@ -1619,9 +1614,9 @@ bezier_start_new_segment (GimpBezierSelectTool *bezier_sel,
}
static void
bezier_select_button_press (GimpTool *tool,
bezier_select_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpBezierSelectTool *bezier_sel;
GimpBezierSelectPoint *points;
@ -1653,7 +1648,7 @@ bezier_select_button_press (GimpTool *tool,
curTool = tool_manager_get_active (gdisp->gimage->gimp);
curSel = (GimpBezierSelectTool *) curTool;
curGdisp = (GDisplay *) gdisp;
curGdisp = (GimpDisplay *) gdisp;
curTool->gdisp = gdisp;
curCore = (GimpDrawTool *) bezier_sel;
@ -1899,8 +1894,6 @@ bezier_select_button_press (GimpTool *tool,
if (!grab_pointer && gimp_channel_value (bezier_sel->mask, x, y))
{
gboolean replace = FALSE;
if ((bevent->state & GDK_SHIFT_MASK) &&
!(bevent->state & GDK_CONTROL_MASK))
op = CHANNEL_OP_ADD;
@ -1911,12 +1904,9 @@ bezier_select_button_press (GimpTool *tool,
(bevent->state & GDK_SHIFT_MASK))
op = CHANNEL_OP_INTERSECT;
else
{
op = CHANNEL_OP_ADD;
replace = TRUE;
}
op = CHANNEL_OP_REPLACE;
bezier_to_sel_internal (bezier_sel, tool, gdisp, op, replace);
bezier_to_sel_internal (bezier_sel, tool, gdisp, op);
gimp_draw_tool_resume ( (GimpDrawTool *) bezier_sel);
}
else
@ -1949,14 +1939,14 @@ bezier_select_button_press (GimpTool *tool,
/* returns 0 if not on control point, else BEZIER_ANCHOR or BEZIER_CONTROL */
static gint
bezier_on_control_point (GDisplay *gdisp,
bezier_on_control_point (GimpDisplay *gdisp,
GimpBezierSelectTool *bezier_sel,
gint x,
gint y,
gint halfwidth)
gint x,
gint y,
gint halfwidth)
{
GimpBezierSelectPoint *points;
gint num_points;
gint num_points;
/* transform the points from image space to screen space */
points = bezier_sel->points;
@ -2053,11 +2043,11 @@ points_in_box (GimpBezierSelectPoint *points,
}
static gint
bezier_point_on_curve (GDisplay *gdisp,
bezier_point_on_curve (GimpDisplay *gdisp,
GimpBezierSelectTool *bezier_sel,
gint x,
gint y,
gint halfwidth)
gint x,
gint y,
gint halfwidth)
{
BezierCheckPnts chkpnts;
GimpBezierSelectPoint *points;
@ -2114,9 +2104,9 @@ bezier_point_on_curve (GDisplay *gdisp,
}
static void
gimp_bezier_select_tool_cursor_update (GimpTool *tool,
gimp_bezier_select_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpBezierSelectTool *bezier_sel;
GimpDrawTool *draw_tool;
@ -2316,9 +2306,9 @@ gimp_bezier_select_tool_cursor_update (GimpTool *tool,
}
static void
gimp_bezier_select_tool_control (GimpTool *tool,
ToolAction action,
GDisplay *gdisp)
gimp_bezier_select_tool_control (GimpTool *tool,
ToolAction action,
GimpDisplay *gdisp)
{
GimpBezierSelectTool * bezier_sel;
@ -2345,7 +2335,7 @@ gimp_bezier_select_tool_control (GimpTool *tool,
}
void
bezier_draw (GDisplay *gdisp,
bezier_draw (GimpDisplay *gdisp,
GimpBezierSelectTool *bezier_sel)
{
GimpBezierSelectPoint *points;
@ -2402,12 +2392,12 @@ bezier_draw (GDisplay *gdisp,
static void
bezier_select_draw (GimpDrawTool *draw_tool)
{
GDisplay *gdisp;
GimpTool *tool;
GimpDisplay *gdisp;
GimpTool *tool;
GimpBezierSelectTool *bezier_sel;
bezier_sel = (GimpBezierSelectTool *)draw_tool;
tool = GIMP_TOOL(bezier_sel);
bezier_sel = GIMP_BEZIER_SELECT_TOOL (draw_tool);
tool = GIMP_TOOL (draw_tool);
gdisp = tool->gdisp;
bezier_draw (gdisp, bezier_sel);
@ -2846,9 +2836,9 @@ static int lasty;
static void
bezier_convert (GimpBezierSelectTool *bezier_sel,
GDisplay *gdisp,
gint subdivisions,
gboolean antialias)
GimpDisplay *gdisp,
gint subdivisions,
gboolean antialias)
{
PixelRegion maskPR;
GimpBezierSelectPoint *points;
@ -3289,31 +3279,23 @@ bezier_paste_bezierselect_to_current (GDisplay *gdisp,
}
static void
bezier_to_sel_internal (GimpBezierSelectTool *bezier_sel,
GimpTool *tool,
GDisplay *gdisp,
gint op,
gint replace)
bezier_to_sel_internal (GimpBezierSelectTool *bezier_sel,
GimpTool *tool,
GDisplay *gdisp,
ChannelOps op)
{
/* If we're antialiased, then recompute the mask...
*/
if (bezier_options->antialias)
bezier_convert (bezier_sel, tool->gdisp, SUBDIVIDE, TRUE);
if (replace)
gimage_mask_clear (gdisp->gimage);
else
gimage_mask_undo (gdisp->gimage);
if (bezier_options->feather)
gimp_channel_feather (bezier_sel->mask,
gimp_image_get_mask (gdisp->gimage),
bezier_options->feather_radius,
bezier_options->feather_radius,
op, 0, 0);
else
gimp_channel_combine_mask (gimp_image_get_mask (gdisp->gimage),
bezier_sel->mask, op, 0, 0);
gimp_image_mask_select_channel (gdisp->gimage,
NULL, FALSE,
bezier_sel->mask,
op,
bezier_options->feather,
bezier_options->feather_radius,
bezier_options->feather_radius);
/* show selection on all views */
gdisplays_flush ();
@ -3570,7 +3552,7 @@ bezier_select_mode (gint mode)
void
bezier_to_selection (GimpBezierSelectTool *bezier_sel,
GDisplay *gdisp)
GDisplay *gdisp)
{
/* Call the internal function */
if (!bezier_sel->closed)
@ -3583,7 +3565,8 @@ bezier_to_selection (GimpBezierSelectTool *bezier_sel,
* This loads it into curSel for this image
*/
bezier_paste_bezierselect_to_current (gdisp, bezier_sel);
bezier_to_sel_internal (curSel, (GimpTool *) curTool, gdisp, CHANNEL_OP_ADD, TRUE);
bezier_to_sel_internal (curSel, (GimpTool *) curTool, gdisp,
CHANNEL_OP_REPLACE);
}
/* check whether vectors (offx, offy), (l_offx, l_offy) have the same angle. */

View File

@ -55,7 +55,6 @@
#include "gimpconvolvetool.h"
#include "gimppainttool.h"
#include "app_procs.h"
#include "devices.h"
#include "gimprc.h"
#include "undo.h"
@ -880,7 +879,7 @@ gimp_paint_tool_start (GimpPaintTool *paint_tool,
GimpContext *context;
context = gimp_get_current_context (the_gimp);
context = gimp_get_current_context (gimp_drawable_gimage (drawable)->gimp);
paint_tool->curx = x;
paint_tool->cury = y;
@ -1113,29 +1112,27 @@ gimp_paint_tool_cleanup (void)
void
gimp_paint_tool_get_color_from_gradient (GimpPaintTool *paint_tool,
GimpGradient *gradient,
gdouble gradient_length,
GimpRGB *color,
GradientPaintMode mode)
{
GimpContext *context;
gdouble y;
gdouble distance; /* distance in current brush stroke */
context = gimp_get_current_context (the_gimp);
gdouble distance; /* distance in current brush stroke */
gdouble y;
distance = paint_tool->pixel_dist;
y = ((double) distance / gradient_length);
y = (gdouble) distance / gradient_length;
/* for the once modes, set y close to 1.0 after the first chunk */
if ( (mode == ONCE_FORWARD || mode == ONCE_BACKWARDS) && y >= 1.0 )
if ((mode == ONCE_FORWARD || mode == ONCE_BACKWARDS) && y >= 1.0)
y = 0.9999999;
if ( (((int)y & 1) && mode != LOOP_SAWTOOTH) || mode == ONCE_BACKWARDS )
y = 1.0 - (y - (int)y);
if ((((gint) y & 1) && mode != LOOP_SAWTOOTH) || mode == ONCE_BACKWARDS )
y = 1.0 - (y - (gint) y);
else
y = y - (int)y;
y = y - (gint) y;
gimp_gradient_get_color_at (gimp_context_get_gradient (context), y, color);
gimp_gradient_get_color_at (gradient, y, color);
}

View File

@ -145,10 +145,11 @@ void gimp_paint_tool_finish (GimpPaintTool *tool,
GimpDrawable *drawable);
void gimp_paint_tool_cleanup (void);
void gimp_paint_tool_get_color_from_gradient (GimpPaintTool *tool,
gdouble gradient_length,
GimpRGB *color,
GradientPaintMode mode);
void gimp_paint_tool_get_color_from_gradient (GimpPaintTool *tool,
GimpGradient *gradient,
gdouble gradient_length,
GimpRGB *color,
GradientPaintMode mode);
/* paint tool painting functions */
TempBuf * gimp_paint_tool_get_paint_area (GimpPaintTool *tool,

View File

@ -36,6 +36,7 @@
#include "core/gimpcontext.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimage-contiguous-region.h"
#include "core/gimpimage-mask.h"
#include "core/gimppattern.h"
@ -45,8 +46,6 @@
#include "display/gimpdisplay-foreach.h"
#include "gimpbucketfilltool.h"
#include "gimpfuzzyselecttool.h"
#include "gimptool.h"
#include "paint_options.h"
#include "tool_manager.h"
@ -92,16 +91,16 @@ static void bucket_options_reset (GimpToolOptions *tool_optio
static void gimp_bucket_fill_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_bucket_fill_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_bucket_fill_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_bucket_fill_tool_modifier_key (GimpTool *tool,
GdkEventKey *kevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void bucket_fill_line_color (guchar *,
guchar *,
@ -301,7 +300,7 @@ bucket_options_new (void)
static void
gimp_bucket_fill_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpBucketFillTool *bucket_tool;
gboolean use_offsets;
@ -329,7 +328,7 @@ gimp_bucket_fill_tool_button_press (GimpTool *tool,
static void
gimp_bucket_fill_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpBucketFillTool *bucket_tool;
Argument *return_vals;
@ -375,7 +374,7 @@ gimp_bucket_fill_tool_button_release (GimpTool *tool,
static void
gimp_bucket_fill_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpLayer *layer;
GdkCursorType ctype = GDK_TOP_LEFT_ARROW;
@ -427,7 +426,7 @@ gimp_bucket_fill_tool_cursor_update (GimpTool *tool,
static void
gimp_bucket_fill_tool_modifier_key (GimpTool *tool,
GdkEventKey *kevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
switch (kevent->keyval)
{
@ -533,8 +532,12 @@ bucket_fill (GimpImage *gimage,
*/
if (! gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2))
{
mask = find_contiguous_region (gimage, drawable, TRUE, (int) threshold,
(int) x, (int) y, sample_merged);
mask = gimp_image_contiguous_region_by_seed (gimage, drawable,
sample_merged,
TRUE,
(gint) threshold,
(gint) x,
(gint) y);
gimp_channel_bounds (mask, &x1, &y1, &x2, &y2);

View File

@ -30,13 +30,13 @@
#include "base/pixel-region.h"
#include "base/temp-buf.h"
#include "base/tile.h"
#include "base/tile-manager.h"
#include "paint-funcs/paint-funcs.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage-contiguous-region.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-mask-select.h"
#include "core/gimpchannel.h"
#include "core/gimpcontainer.h"
#include "core/gimpimage.h"
@ -93,26 +93,26 @@ static void by_color_select_color_drop (GtkWidget *widget,
/* by_color select action functions */
static void by_color_select_initialize (GimpTool *tool,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void by_color_select_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void by_color_select_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void by_color_select_modifier_update (GimpTool *tool,
GdkEventKey *kevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void by_color_select_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void by_color_select_oper_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void by_color_select_control (GimpTool *tool,
ToolAction action,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void by_color_select_mask_changed (GimpImage *gimage);
static ByColorDialog * by_color_select_dialog_new (void);
@ -137,34 +137,20 @@ static void by_color_select_close_callback (GtkWidget *,
static void by_color_select_preview_button_press (ByColorDialog *,
GdkEventButton *);
static gint is_pixel_sufficiently_different (guchar *,
guchar *,
gint ,
gint ,
gint ,
gint );
static GimpChannel * by_color_select_color (GimpImage *,
GimpDrawable *,
guchar *,
gint ,
gint ,
gint );
/* The parent class (duh!) */
static GimpSelectionToolClass *parent_class = NULL;
/* the by color selection tool options */
static SelectionOptions * by_color_options = NULL;
static SelectionOptions *by_color_options = NULL;
/* the by color selection dialog */
static ByColorDialog * by_color_dialog = NULL;
static ByColorDialog *by_color_dialog = NULL;
/* dnd stuff */
static GtkTargetEntry by_color_select_targets[] =
{
GIMP_TARGET_COLOR
};
static guint n_by_color_select_targets = (sizeof (by_color_select_targets) /
sizeof (by_color_select_targets[0]));
/* public functions */
@ -211,57 +197,9 @@ gimp_by_color_select_tool_get_type (void)
return tool_type;
}
void
gimp_by_color_select_tool_select (GimpImage *gimage,
GimpDrawable *drawable,
guchar *color,
gint threshold,
SelectOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius,
gboolean sample_merged)
{
GimpChannel *new_mask;
gint off_x, off_y;
if (!drawable)
return;
new_mask = by_color_select_color (gimage, drawable, color,
antialias, threshold, sample_merged);
/* if applicable, replace the current selection */
if (op == SELECTION_REPLACE)
gimage_mask_clear (gimage);
else
gimage_mask_undo (gimage);
if (sample_merged)
{
off_x = 0; off_y = 0;
}
else
{
gimp_drawable_offsets (drawable, &off_x, &off_y);
}
if (feather)
gimp_channel_feather (new_mask, gimp_image_get_mask (gimage),
feather_radius,
feather_radius,
op, off_x, off_y);
else
gimp_channel_combine_mask (gimp_image_get_mask (gimage),
new_mask, op, off_x, off_y);
g_object_unref (G_OBJECT (new_mask));
}
void
gimp_by_color_select_tool_initialize_by_image (GimpImage *gimage)
{
/* update the preview window */
if (by_color_dialog)
{
@ -315,175 +253,13 @@ gimp_by_color_select_tool_init (GimpByColorSelectTool *by_color_select)
by_color_select->x = by_color_select->y = 0;
}
/* by_color selection machinery */
static gint
is_pixel_sufficiently_different (guchar *col1,
guchar *col2,
gint antialias,
gint threshold,
gint bytes,
gint has_alpha)
{
gint diff;
gint max;
gint b;
gint alpha;
max = 0;
alpha = (has_alpha) ? bytes - 1 : bytes;
/* if there is an alpha channel, never select transparent regions */
if (has_alpha && col2[alpha] == 0)
return 0;
for (b = 0; b < alpha; b++)
{
diff = col1[b] - col2[b];
diff = abs (diff);
if (diff > max)
max = diff;
}
if (antialias && threshold > 0)
{
gfloat aa;
aa = 1.5 - ((gfloat) max / threshold);
if (aa <= 0)
return 0;
else if (aa < 0.5)
return (guchar) (aa * 512);
else
return 255;
}
else
{
if (max > threshold)
return 0;
else
return 255;
}
}
static GimpChannel *
by_color_select_color (GimpImage *gimage,
GimpDrawable *drawable,
guchar *color,
gboolean antialias,
gint threshold,
gboolean sample_merged)
{
/* Scan over the gimage's active layer, finding pixels within the specified
* threshold from the given R, G, & B values. If antialiasing is on,
* use the same antialiasing scheme as in fuzzy_select. Modify the gimage's
* mask to reflect the additional selection
*/
GimpChannel *mask;
PixelRegion imagePR, maskPR;
guchar *image_data;
guchar *mask_data;
guchar *idata, *mdata;
guchar rgb[MAX_CHANNELS];
gint has_alpha, indexed;
gint width, height;
gint bytes, color_bytes, alpha;
gint i, j;
gpointer pr;
gint d_type;
/* Get the image information */
if (sample_merged)
{
bytes = gimp_image_composite_bytes (gimage);
d_type = gimp_image_composite_type (gimage);
has_alpha = (d_type == RGBA_GIMAGE ||
d_type == GRAYA_GIMAGE ||
d_type == INDEXEDA_GIMAGE);
indexed = d_type == INDEXEDA_GIMAGE || d_type == INDEXED_GIMAGE;
width = gimage->width;
height = gimage->height;
pixel_region_init (&imagePR, gimp_image_composite (gimage),
0, 0, width, height, FALSE);
}
else
{
bytes = gimp_drawable_bytes (drawable);
d_type = gimp_drawable_type (drawable);
has_alpha = gimp_drawable_has_alpha (drawable);
indexed = gimp_drawable_is_indexed (drawable);
width = gimp_drawable_width (drawable);
height = gimp_drawable_height (drawable);
pixel_region_init (&imagePR, gimp_drawable_data (drawable),
0, 0, width, height, FALSE);
}
if (indexed)
{
/* indexed colors are always RGB or RGBA */
color_bytes = has_alpha ? 4 : 3;
}
else
{
/* RGB, RGBA, GRAY and GRAYA colors are shaped just like the image */
color_bytes = bytes;
}
alpha = bytes - 1;
mask = gimp_channel_new_mask (gimage, width, height);
pixel_region_init (&maskPR, gimp_drawable_data (GIMP_DRAWABLE (mask)),
0, 0, width, height, TRUE);
/* iterate over the entire image */
for (pr = pixel_regions_register (2, &imagePR, &maskPR);
pr != NULL;
pr = pixel_regions_process (pr))
{
image_data = imagePR.data;
mask_data = maskPR.data;
for (i = 0; i < imagePR.h; i++)
{
idata = image_data;
mdata = mask_data;
for (j = 0; j < imagePR.w; j++)
{
/* Get the rgb values for the color */
gimp_image_get_color (gimage, d_type, rgb, idata);
/* Plug the alpha channel in there */
if (has_alpha)
rgb[color_bytes - 1] = idata[alpha];
/* Find how closely the colors match */
*mdata++ = is_pixel_sufficiently_different (color,
rgb,
antialias,
threshold,
color_bytes,
has_alpha);
idata += bytes;
}
image_data += imagePR.rowstride;
mask_data += maskPR.rowstride;
}
}
return mask;
}
/* by_color select action functions */
static void
by_color_select_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpByColorSelectTool *by_color_sel;
GimpDrawTool *draw_tool;
GimpDrawTool *draw_tool;
draw_tool = GIMP_DRAW_TOOL (tool);
by_color_sel = GIMP_BY_COLOR_SELECT_TOOL (tool);
@ -534,13 +310,14 @@ by_color_select_button_press (GimpTool *tool,
static void
by_color_select_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpByColorSelectTool *by_color_sel;
gint x, y;
GimpDrawable *drawable;
guchar *color;
gint use_offsets;
gint x, y;
GimpDrawable *drawable;
guchar *col;
GimpRGB color;
gint use_offsets;
by_color_sel = GIMP_BY_COLOR_SELECT_TOOL (tool);
drawable = gimp_image_active_drawable (gdisp->gimage);
@ -562,25 +339,29 @@ by_color_select_button_release (GimpTool *tool,
/* Get the start color */
if (by_color_options->sample_merged)
{
if (!(color = gimp_image_get_color_at (gdisp->gimage, x, y)))
if (!(col = gimp_image_get_color_at (gdisp->gimage, x, y)))
return;
}
else
{
if (!(color = gimp_drawable_get_color_at (drawable, x, y)))
if (!(col = gimp_drawable_get_color_at (drawable, x, y)))
return;
}
/* select the area */
gimp_by_color_select_tool_select (gdisp->gimage, drawable, color,
by_color_dialog->threshold,
by_color_sel->operation,
by_color_options->antialias,
by_color_options->feather,
by_color_options->feather_radius,
by_color_options->sample_merged);
gimp_rgba_set_uchar (&color, col[0], col[1], col[2], col[3]);
g_free (color);
g_free (col);
/* select the area */
gimp_image_mask_select_by_color (gdisp->gimage, drawable,
by_color_options->sample_merged,
&color,
by_color_dialog->threshold,
by_color_sel->operation,
by_color_options->antialias,
by_color_options->feather,
by_color_options->feather_radius,
by_color_options->feather_radius);
/* show selection on all views */
gdisplays_flush ();
@ -595,11 +376,11 @@ by_color_select_button_release (GimpTool *tool,
static void
by_color_select_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpByColorSelectTool *by_col_sel;
GimpLayer *layer;
gint x, y;
GimpLayer *layer;
gint x, y;
by_col_sel = GIMP_BY_COLOR_SELECT_TOOL (tool);
@ -667,7 +448,7 @@ by_color_select_cursor_update (GimpTool *tool,
static void
by_color_select_update_op_state (GimpByColorSelectTool *by_col_sel,
gint state,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
if (tool_manager_get_active (gdisp->gimage->gimp)->state == ACTIVE)
return;
@ -696,10 +477,10 @@ by_color_select_update_op_state (GimpByColorSelectTool *by_col_sel,
static void
by_color_select_modifier_update (GimpTool *tool,
GdkEventKey *kevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpByColorSelectTool *by_col_sel;
gint state;
gint state;
by_col_sel = GIMP_BY_COLOR_SELECT_TOOL (tool);
@ -735,7 +516,7 @@ by_color_select_modifier_update (GimpTool *tool,
static void
by_color_select_oper_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpByColorSelectTool *by_col_sel;
@ -745,9 +526,9 @@ by_color_select_oper_update (GimpTool *tool,
}
static void
by_color_select_control (GimpTool *tool,
ToolAction action,
GDisplay *gdisp)
by_color_select_control (GimpTool *tool,
ToolAction action,
GimpDisplay *gdisp)
{
switch (action)
{
@ -768,8 +549,8 @@ by_color_select_control (GimpTool *tool,
}
void
by_color_select_initialize (GimpTool *tool,
GDisplay *gdisp)
by_color_select_initialize (GimpTool *tool,
GimpDisplay *gdisp)
{
/* The "by color" dialog */
if (!by_color_dialog)
@ -790,10 +571,11 @@ by_color_select_initialize (GimpTool *tool,
gimp_by_color_select_tool_initialize_by_image (gdisp->gimage);
}
void by_color_select_mask_changed( GimpImage *gimage)
void
by_color_select_mask_changed (GimpImage *gimage)
{
if (by_color_dialog)
gimp_by_color_select_tool_initialize_by_image (gimage );
gimp_by_color_select_tool_initialize_by_image (gimage);
}
/****************************/
@ -859,7 +641,7 @@ by_color_select_dialog_new (void)
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
by_color_select_targets,
n_by_color_select_targets,
G_N_ELEMENTS (by_color_select_targets),
GDK_ACTION_COPY);
gimp_dnd_color_dest_set (bcd->preview, by_color_select_color_drop, bcd);
@ -1231,8 +1013,8 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
gboolean replace;
SelectOps operation;
GimpDrawable *drawable;
Tile *tile;
guchar *col;
GimpRGB color;
if (!bcd->gimage)
return;
@ -1265,39 +1047,46 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
/* Get the start color */
if (by_color_options->sample_merged)
{
x = bcd->gimage->width * bevent->x / bcd->preview->requisition.width;
x = bcd->gimage->width * bevent->x / bcd->preview->requisition.width;
y = bcd->gimage->height * bevent->y / bcd->preview->requisition.height;
if (x < 0 || y < 0 || x >= bcd->gimage->width || y >= bcd->gimage->height)
return;
tile = tile_manager_get_tile (gimp_image_composite (bcd->gimage),
x, y, TRUE, FALSE);
col = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT);
col = gimp_image_get_color_at (bcd->gimage, x, y);
}
else
{
gint offx, offy;
gimp_drawable_offsets (drawable, &offx, &offy);
x = gimp_drawable_width (drawable) * bevent->x / bcd->preview->requisition.width - offx;
y = gimp_drawable_height (drawable) * bevent->y / bcd->preview->requisition.height - offy;
x = (gimp_drawable_width (drawable) * bevent->x /
bcd->preview->requisition.width - offx);
y = (gimp_drawable_height (drawable) * bevent->y /
bcd->preview->requisition.height - offy);
if (x < 0 || y < 0 ||
x >= gimp_drawable_width (drawable) || y >= gimp_drawable_height (drawable))
return;
tile = tile_manager_get_tile (gimp_drawable_data (drawable),
x, y, TRUE, FALSE);
col = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT);
col = gimp_drawable_get_color_at (drawable, x, y);
}
gimp_by_color_select_tool_select (bcd->gimage, drawable, col,
bcd->threshold,
operation,
by_color_options->antialias,
by_color_options->feather,
by_color_options->feather_radius,
by_color_options->sample_merged);
tile_release (tile, FALSE);
gimp_rgba_set_uchar (&color, col[0], col[1], col[2], col[3]);
g_free (col);
gimp_image_mask_select_by_color (bcd->gimage, drawable,
by_color_options->sample_merged,
&color,
bcd->threshold,
operation,
by_color_options->antialias,
by_color_options->feather,
by_color_options->feather_radius,
by_color_options->feather_radius);
/* show selection on all views */
gdisplays_flush ();
@ -1314,22 +1103,19 @@ by_color_select_color_drop (GtkWidget *widget,
{
GimpDrawable *drawable;
ByColorDialog *bcd;
guchar col[3];
bcd = (ByColorDialog*) data;
drawable = gimp_image_active_drawable (bcd->gimage);
gimp_rgb_get_uchar (color, &col[0], &col[1], &col[2]);
gimp_by_color_select_tool_select (bcd->gimage,
drawable,
col,
bcd->threshold,
bcd->operation,
by_color_options->antialias,
by_color_options->feather,
by_color_options->feather_radius,
by_color_options->sample_merged);
gimp_image_mask_select_by_color (bcd->gimage, drawable,
by_color_options->sample_merged,
color,
bcd->threshold,
bcd->operation,
by_color_options->antialias,
by_color_options->feather,
by_color_options->feather_radius,
by_color_options->feather_radius);
/* show selection on all views */
gdisplays_flush ();

View File

@ -51,20 +51,9 @@ struct _GimpByColorSelectToolClass
};
void gimp_by_color_select_tool_register (Gimp *gimp);
void gimp_by_color_select_tool_register (Gimp *gimp);
GType gimp_by_color_select_tool_get_type (void);
void gimp_by_color_select_tool_select (GimpImage *gimage,
GimpDrawable *drawable,
guchar *color,
gint threshold,
SelectOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius,
gboolean sample_merged);
GType gimp_by_color_select_tool_get_type (void);
#endif /* __GIMP_BY_COLOR_SELECT_TOOL_H__ */

View File

@ -29,6 +29,7 @@
#include "core/gimpchannel.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-mask-select.h"
#include "core/gimptoolinfo.h"
#include "display/gimpdisplay.h"
@ -104,55 +105,6 @@ gimp_ellipse_select_tool_get_type (void)
return tool_type;
}
void
ellipse_select (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
SelectOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius)
{
GimpChannel *new_mask;
/* if applicable, replace the current selection */
if (op == SELECTION_REPLACE)
gimage_mask_clear (gimage);
else
gimage_mask_undo (gimage);
/* if feathering for rect, make a new mask with the
* rectangle and feather that with the old mask
*/
if (feather)
{
new_mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_channel_combine_ellipse (new_mask, CHANNEL_OP_ADD,
x, y, w, h, antialias);
gimp_channel_feather (new_mask, gimp_image_get_mask (gimage),
feather_radius,
feather_radius,
op, 0, 0);
g_object_unref (G_OBJECT (new_mask));
}
else if (op == SELECTION_INTERSECT)
{
new_mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_channel_combine_ellipse (new_mask, CHANNEL_OP_ADD,
x, y, w, h, antialias);
gimp_channel_combine_mask (gimp_image_get_mask (gimage), new_mask,
op, 0, 0);
g_object_unref (G_OBJECT (new_mask));
}
else
{
gimp_channel_combine_ellipse (gimp_image_get_mask (gimage), op,
x, y, w, h, antialias);
}
}
/* private functions */
@ -237,10 +189,11 @@ gimp_ellipse_select_tool_rect_select (GimpRectSelectTool *rect_tool,
sel_options = (SelectionOptions *)
tool_manager_get_info_by_tool (the_gimp, tool)->tool_options;
ellipse_select (tool->gdisp->gimage,
x, y, w, h,
sel_tool->op,
sel_options->antialias,
sel_options->feather,
sel_options->feather_radius);
gimp_image_mask_select_ellipse (tool->gdisp->gimage,
x, y, w, h,
sel_tool->op,
sel_options->antialias,
sel_options->feather,
sel_options->feather_radius,
sel_options->feather_radius);
}

View File

@ -45,20 +45,9 @@ struct _GimpEllipseSelectToolClass
};
void gimp_ellipse_select_tool_register (Gimp *gimp);
void gimp_ellipse_select_tool_register (Gimp *gimp);
GType gimp_ellipse_select_tool_get_type (void);
void ellipse_select (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
SelectOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius);
GType gimp_ellipse_select_tool_get_type (void);
#endif /* __GIMP_ELLIPSE_SELECT_TOOL_H__ */

View File

@ -32,7 +32,7 @@
#include "core/gimpchannel.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpscanconvert.h"
#include "core/gimpimage-mask-select.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
@ -49,9 +49,7 @@
#include "libgimp/gimpintl.h"
#define DEFAULT_MAX_INC 1024
#define SUPERSAMPLE 3
#define SUPERSAMPLE2 9
#define DEFAULT_MAX_INC 1024
static void gimp_free_select_tool_class_init (GimpFreeSelectToolClass *klass);
@ -60,13 +58,13 @@ static void gimp_free_select_tool_finalize (GObject *object);
static void gimp_free_select_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_free_select_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_free_select_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_free_select_tool_draw (GimpDrawTool *draw_tool);
@ -74,13 +72,6 @@ static void gimp_free_select_tool_add_point (GimpFreeSelectTool *free_sel
gint x,
gint y);
static GimpChannel * scan_convert (GimpImage *gimage,
gint n_points,
GimpVector2 *points,
gint width,
gint height,
gboolean antialias);
static GimpSelectionToolClass *parent_class = NULL;
@ -131,43 +122,6 @@ gimp_free_select_tool_get_type (void)
return tool_type;
}
void
free_select (GimpImage *gimage,
gint n_points,
GimpVector2 *points,
SelectOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius)
{
GimpChannel *mask;
/* if applicable, replace the current selection */
/* or insure that a floating selection is anchored down... */
if (op == SELECTION_REPLACE)
gimage_mask_clear (gimage);
else
gimage_mask_undo (gimage);
mask = scan_convert (gimage, n_points, points,
gimage->width, gimage->height, antialias);
if (mask)
{
if (feather)
gimp_channel_feather (mask, gimp_image_get_mask (gimage),
feather_radius,
feather_radius,
op, 0, 0);
else
gimp_channel_combine_mask (gimp_image_get_mask (gimage),
mask, op, 0, 0);
g_object_unref (G_OBJECT (mask));
}
}
/* private functions */
static void
@ -237,7 +191,7 @@ gimp_free_select_tool_finalize (GObject *object)
static void
gimp_free_select_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpFreeSelectTool *free_sel;
@ -275,7 +229,7 @@ gimp_free_select_tool_button_press (GimpTool *tool,
static void
gimp_free_select_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpFreeSelectTool *free_sel;
GimpVector2 *points;
@ -318,12 +272,13 @@ gimp_free_select_tool_button_release (GimpTool *tool,
FALSE);
}
free_select (gdisp->gimage,
free_sel->num_points, points,
GIMP_SELECTION_TOOL (tool)->op,
free_options->antialias,
free_options->feather,
free_options->feather_radius);
gimp_image_mask_select_polygon (gdisp->gimage,
free_sel->num_points, points,
GIMP_SELECTION_TOOL (tool)->op,
free_options->antialias,
free_options->feather,
free_options->feather_radius,
free_options->feather_radius);
g_free (points);
@ -334,7 +289,7 @@ gimp_free_select_tool_button_release (GimpTool *tool,
static void
gimp_free_select_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpFreeSelectTool *free_sel;
GimpSelectionTool *sel_tool;
@ -410,24 +365,3 @@ gimp_free_select_tool_add_point (GimpFreeSelectTool *free_sel,
free_sel->num_points++;
}
static GimpChannel *
scan_convert (GimpImage *gimage,
gint n_points,
GimpVector2 *points,
gint width,
gint height,
gboolean antialias)
{
GimpChannel *mask;
GimpScanConvert *sc;
sc = gimp_scan_convert_new (width, height, antialias ? SUPERSAMPLE : 1);
gimp_scan_convert_add_points (sc, n_points, points);
mask = gimp_scan_convert_to_channel (sc, gimage);
gimp_scan_convert_free (sc);
return mask;
}

View File

@ -49,18 +49,9 @@ struct _GimpFreeSelectToolClass
};
void gimp_free_select_tool_register (Gimp *gimp);
void gimp_free_select_tool_register (Gimp *gimp);
GType gimp_free_select_tool_get_type (void);
void free_select (GimpImage *gimage,
gint n_points,
GimpVector2 *points,
SelectOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius);
GType gimp_free_select_tool_get_type (void);
#endif /* __GIMP_FREE_SELECT_TOOL_H__ */

View File

@ -37,7 +37,9 @@
#include "core/gimpchannel.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimage-contiguous-region.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-mask-select.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
@ -57,20 +59,22 @@
static void gimp_fuzzy_select_tool_class_init (GimpFuzzySelectToolClass *klass);
static void gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select);
static void gimp_fuzzy_select_tool_finalize (GObject *object);
static void gimp_fuzzy_select_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_fuzzy_select_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_fuzzy_select_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_fuzzy_select_tool_draw (GimpDrawTool *draw_tool);
static GdkSegment * fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel,
GDisplay *gdisp,
GimpDisplay *gdisp,
gint *nsegs);
@ -83,8 +87,6 @@ static SelectionOptions *fuzzy_options = NULL;
static GdkSegment *segs = NULL;
static gint num_segs = 0;
GimpChannel * fuzzy_mask = NULL;
/* public functions */
@ -130,313 +132,24 @@ gimp_fuzzy_select_tool_get_type (void)
return tool_type;
}
/*******************************/
/* Fuzzy selection apparatus */
static gint
is_pixel_sufficiently_different (guchar *col1,
guchar *col2,
gboolean antialias,
gint threshold,
gint bytes,
gboolean has_alpha)
{
gint diff;
gint max;
gint b;
gint alpha;
max = 0;
alpha = (has_alpha) ? bytes - 1 : bytes;
/* if there is an alpha channel, never select transparent regions */
if (has_alpha && col2[alpha] == 0)
return 0;
for (b = 0; b < bytes; b++)
{
diff = col1[b] - col2[b];
diff = abs (diff);
if (diff > max)
max = diff;
}
if (antialias)
{
float aa;
aa = 1.5 - ((float) max / threshold);
if (aa <= 0)
return 0;
else if (aa < 0.5)
return (unsigned char) (aa * 512);
else
return 255;
}
else
{
if (max > threshold)
return 0;
else
return 255;
}
}
static void
ref_tiles (TileManager *src,
TileManager *mask,
Tile **s_tile,
Tile **m_tile,
gint x,
gint y,
guchar **s,
guchar **m)
{
if (*s_tile != NULL)
tile_release (*s_tile, FALSE);
if (*m_tile != NULL)
tile_release (*m_tile, TRUE);
*s_tile = tile_manager_get_tile (src, x, y, TRUE, FALSE);
*m_tile = tile_manager_get_tile (mask, x, y, TRUE, TRUE);
*s = tile_data_pointer (*s_tile, x % TILE_WIDTH, y % TILE_HEIGHT);
*m = tile_data_pointer (*m_tile, x % TILE_WIDTH, y % TILE_HEIGHT);
}
static int
find_contiguous_segment (guchar *col,
PixelRegion *src,
PixelRegion *mask,
gint width,
gint bytes,
gboolean has_alpha,
gboolean antialias,
gint threshold,
gint initial,
gint *start,
gint *end)
{
guchar *s;
guchar *m;
guchar diff;
Tile *s_tile = NULL;
Tile *m_tile = NULL;
ref_tiles (src->tiles, mask->tiles, &s_tile, &m_tile, src->x, src->y, &s, &m);
/* check the starting pixel */
if (! (diff = is_pixel_sufficiently_different (col, s, antialias,
threshold, bytes, has_alpha)))
{
tile_release (s_tile, FALSE);
tile_release (m_tile, TRUE);
return FALSE;
}
*m-- = diff;
s -= bytes;
*start = initial - 1;
while (*start >= 0 && diff)
{
if (! ((*start + 1) % TILE_WIDTH))
ref_tiles (src->tiles, mask->tiles, &s_tile, &m_tile, *start, src->y, &s, &m);
diff = is_pixel_sufficiently_different (col, s, antialias,
threshold, bytes, has_alpha);
if ((*m-- = diff))
{
s -= bytes;
(*start)--;
}
}
diff = 1;
*end = initial + 1;
if (*end % TILE_WIDTH && *end < width)
ref_tiles (src->tiles, mask->tiles, &s_tile, &m_tile, *end, src->y, &s, &m);
while (*end < width && diff)
{
if (! (*end % TILE_WIDTH))
ref_tiles (src->tiles, mask->tiles, &s_tile, &m_tile, *end, src->y, &s, &m);
diff = is_pixel_sufficiently_different (col, s, antialias,
threshold, bytes, has_alpha);
if ((*m++ = diff))
{
s += bytes;
(*end)++;
}
}
tile_release (s_tile, FALSE);
tile_release (m_tile, TRUE);
return TRUE;
}
static void
find_contiguous_region_helper (PixelRegion *mask,
PixelRegion *src,
gboolean has_alpha,
gboolean antialias,
gint threshold,
gboolean indexed,
gint x,
gint y,
guchar *col)
{
gint start, end, i;
gint val;
gint bytes;
Tile *tile;
if (threshold == 0) threshold = 1;
if (x < 0 || x >= src->w) return;
if (y < 0 || y >= src->h) return;
tile = tile_manager_get_tile (mask->tiles, x, y, TRUE, FALSE);
val = *(guchar *)(tile_data_pointer (tile,
x % TILE_WIDTH, y % TILE_HEIGHT));
tile_release (tile, FALSE);
if (val != 0)
return;
src->x = x;
src->y = y;
bytes = src->bytes;
if(indexed)
{
bytes = has_alpha ? 4 : 3;
}
if (! find_contiguous_segment (col, src, mask, src->w,
src->bytes, has_alpha,
antialias, threshold, x, &start, &end))
return;
for (i = start + 1; i < end; i++)
{
find_contiguous_region_helper (mask, src, has_alpha, antialias,
threshold, indexed, i, y - 1, col);
find_contiguous_region_helper (mask, src, has_alpha, antialias,
threshold, indexed, i, y + 1, col);
}
}
GimpChannel *
find_contiguous_region (GimpImage *gimage,
GimpDrawable *drawable,
gboolean antialias,
gint threshold,
gint x,
gint y,
gboolean sample_merged)
{
PixelRegion srcPR, maskPR;
GimpChannel *mask;
guchar *start;
gboolean has_alpha;
gboolean indexed;
gint type;
gint bytes;
Tile *tile;
if (sample_merged)
{
pixel_region_init (&srcPR, gimp_image_composite (gimage), 0, 0,
gimage->width, gimage->height, FALSE);
type = gimp_image_composite_type (gimage);
has_alpha = (type == RGBA_GIMAGE ||
type == GRAYA_GIMAGE ||
type == INDEXEDA_GIMAGE);
}
else
{
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
0, 0,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable),
FALSE);
has_alpha = gimp_drawable_has_alpha (drawable);
}
indexed = gimp_drawable_is_indexed (drawable);
bytes = gimp_drawable_bytes (drawable);
if (indexed)
{
bytes = has_alpha ? 4 : 3;
}
mask = gimp_channel_new_mask (gimage, srcPR.w, srcPR.h);
pixel_region_init (&maskPR, gimp_drawable_data (GIMP_DRAWABLE(mask)),
0, 0,
gimp_drawable_width (GIMP_DRAWABLE(mask)),
gimp_drawable_height (GIMP_DRAWABLE(mask)),
TRUE);
tile = tile_manager_get_tile (srcPR.tiles, x, y, TRUE, FALSE);
if (tile)
{
start = tile_data_pointer (tile, x%TILE_WIDTH, y%TILE_HEIGHT);
find_contiguous_region_helper (&maskPR, &srcPR, has_alpha, antialias,
threshold, bytes, x, y, start);
tile_release (tile, FALSE);
}
return mask;
}
void
fuzzy_select (GimpImage *gimage,
GimpDrawable *drawable,
gint op,
gboolean feather,
gdouble feather_radius)
{
gint off_x, off_y;
/* if applicable, replace the current selection */
if (op == CHANNEL_OP_REPLACE)
gimage_mask_clear (gimage);
else
gimage_mask_undo (gimage);
if (drawable) /* NULL if sample_merged is active */
gimp_drawable_offsets (drawable, &off_x, &off_y);
else
off_x = off_y = 0;
if (feather)
gimp_channel_feather (fuzzy_mask, gimp_image_get_mask (gimage),
feather_radius,
feather_radius,
op, off_x, off_y);
else
gimp_channel_combine_mask (gimp_image_get_mask (gimage),
fuzzy_mask, op, off_x, off_y);
g_object_unref (G_OBJECT (fuzzy_mask));
fuzzy_mask = NULL;
}
/* fuzzy select action functions */
/* private functions */
static void
gimp_fuzzy_select_tool_class_init (GimpFuzzySelectToolClass *klass)
{
GObjectClass *object_class;
GimpToolClass *tool_class;
GimpDrawToolClass *draw_tool_class;
object_class = G_OBJECT_CLASS (klass);
tool_class = GIMP_TOOL_CLASS (klass);
draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_fuzzy_select_tool_finalize;
tool_class->button_press = gimp_fuzzy_select_tool_button_press;
tool_class->button_release = gimp_fuzzy_select_tool_button_release;
tool_class->motion = gimp_fuzzy_select_tool_motion;
@ -465,6 +178,7 @@ gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select)
tool->tool_cursor = GIMP_FUZZY_SELECT_TOOL_CURSOR;
tool->scroll_lock = TRUE; /* Do not allow scrolling */
fuzzy_select->fuzzy_mask = NULL;
fuzzy_select->x = 0;
fuzzy_select->y = 0;
fuzzy_select->first_x = 0;
@ -472,10 +186,24 @@ gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select)
fuzzy_select->first_threshold = 0.0;
}
static void
gimp_fuzzy_select_tool_finalize (GObject *object)
{
GimpFuzzySelectTool *fuzzy_sel;
fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (object);
if (fuzzy_sel->fuzzy_mask)
{
g_object_unref (G_OBJECT (fuzzy_sel->fuzzy_mask));
fuzzy_sel->fuzzy_mask = NULL;
}
}
static void
gimp_fuzzy_select_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpFuzzySelectTool *fuzzy_sel;
@ -518,7 +246,7 @@ gimp_fuzzy_select_tool_button_press (GimpTool *tool,
static void
gimp_fuzzy_select_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpFuzzySelectTool *fuzzy_sel;
GimpDrawable *drawable;
@ -534,28 +262,35 @@ gimp_fuzzy_select_tool_button_release (GimpTool *tool,
/* First take care of the case where the user "cancels" the action */
if (! (bevent->state & GDK_BUTTON3_MASK))
{
drawable = (fuzzy_options->sample_merged ?
NULL : gimp_image_active_drawable (gdisp->gimage));
drawable = gimp_image_active_drawable (gdisp->gimage);
fuzzy_select (gdisp->gimage,
drawable,
GIMP_SELECTION_TOOL (tool)->op,
fuzzy_options->feather,
fuzzy_options->feather_radius);
gimp_image_mask_select_channel (gdisp->gimage,
drawable,
fuzzy_options->sample_merged,
fuzzy_sel->fuzzy_mask,
GIMP_SELECTION_TOOL (tool)->op,
fuzzy_options->feather,
fuzzy_options->feather_radius,
fuzzy_options->feather_radius);
g_object_unref (G_OBJECT (fuzzy_sel->fuzzy_mask));
fuzzy_sel->fuzzy_mask = NULL;
gdisplays_flush ();
}
/* If the segment array is allocated, free it */
if (segs)
g_free (segs);
segs = NULL;
{
g_free (segs);
segs = NULL;
}
}
static void
gimp_fuzzy_select_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpFuzzySelectTool *fuzzy_sel;
GimpSelectionTool *sel_tool;
@ -609,7 +344,7 @@ gimp_fuzzy_select_tool_motion (GimpTool *tool,
static GdkSegment *
fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel,
GDisplay *gdisp,
GimpDisplay *gdisp,
gint *nsegs)
{
PixelRegion maskPR;
@ -630,28 +365,30 @@ fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel,
gdisplay_untransform_coords (gdisp, fuzzy_sel->x,
fuzzy_sel->y, &x, &y, FALSE, use_offsets);
new = find_contiguous_region (gdisp->gimage, drawable,
fuzzy_options->antialias,
fuzzy_options->threshold, x, y,
fuzzy_options->sample_merged);
new = gimp_image_contiguous_region_by_seed (gdisp->gimage, drawable,
fuzzy_options->sample_merged,
fuzzy_options->antialias,
fuzzy_options->threshold,
x, y);
if (fuzzy_mask)
g_object_unref (G_OBJECT (fuzzy_mask));
if (fuzzy_sel->fuzzy_mask)
g_object_unref (G_OBJECT (fuzzy_sel->fuzzy_mask));
fuzzy_mask = new;
fuzzy_sel->fuzzy_mask = new;
/* calculate and allocate a new XSegment array which represents the boundary
* of the color-contiguous region
*/
pixel_region_init (&maskPR, gimp_drawable_data (GIMP_DRAWABLE (fuzzy_mask)),
pixel_region_init (&maskPR,
gimp_drawable_data (GIMP_DRAWABLE (fuzzy_sel->fuzzy_mask)),
0, 0,
gimp_drawable_width (GIMP_DRAWABLE (fuzzy_mask)),
gimp_drawable_height (GIMP_DRAWABLE (fuzzy_mask)),
gimp_drawable_width (GIMP_DRAWABLE (fuzzy_sel->fuzzy_mask)),
gimp_drawable_height (GIMP_DRAWABLE (fuzzy_sel->fuzzy_mask)),
FALSE);
bsegs = find_mask_boundary (&maskPR, nsegs, WithinBounds,
0, 0,
gimp_drawable_width (GIMP_DRAWABLE (fuzzy_mask)),
gimp_drawable_height (GIMP_DRAWABLE (fuzzy_mask)));
gimp_drawable_width (GIMP_DRAWABLE (fuzzy_sel->fuzzy_mask)),
gimp_drawable_height (GIMP_DRAWABLE (fuzzy_sel->fuzzy_mask)));
segs = g_new (GdkSegment, *nsegs);

View File

@ -38,10 +38,12 @@ struct _GimpFuzzySelectTool
{
GimpSelectionTool parent_instance;
gint x, y; /* Point from which to execute seed fill */
gint first_x; /* */
gint first_y; /* variables to keep track of sensitivity */
gdouble first_threshold; /* initial value of threshold slider */
gint x, y; /* Point from which to execute seed fill */
gint first_x; /* */
gint first_y; /* variables to keep track of sensitivity */
gdouble first_threshold; /* initial value of threshold slider */
GimpChannel *fuzzy_mask;
};
struct _GimpFuzzySelectToolClass
@ -50,26 +52,9 @@ struct _GimpFuzzySelectToolClass
};
void gimp_fuzzy_select_tool_register (Gimp *gimp);
void gimp_fuzzy_select_tool_register (Gimp *gimp);
GType gimp_fuzzy_select_tool_get_type (void);
GimpChannel * find_contiguous_region (GimpImage *gimage,
GimpDrawable *drawable,
gboolean antialias,
gint threshold,
gint x,
gint y,
gboolean sample_merged);
void fuzzy_select (GimpImage *gimage,
GimpDrawable *drawable,
gint op,
gboolean feather,
gdouble feather_radius);
extern GimpChannel *fuzzy_mask;
GType gimp_fuzzy_select_tool_get_type (void);
#endif /* __GIMP_FUZZY_SELECT_TOOL_H__ */

View File

@ -56,6 +56,7 @@
#include "core/gimpchannel.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-mask-select.h"
#include "core/gimpscanconvert.h"
#include "display/gimpdisplay.h"
@ -130,25 +131,25 @@ static void gimp_iscissors_tool_finalize (GObject *object);
static void gimp_iscissors_tool_control (GimpTool *tool,
ToolAction tool_action,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_iscissors_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_iscissors_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_iscissors_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_iscissors_tool_oper_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_iscissors_tool_modifier_key (GimpTool *tool,
GdkEventKey *kevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_iscissors_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_iscissors_tool_reset (GimpIscissorsTool *iscissors);
static void gimp_iscissors_tool_draw (GimpDrawTool *draw_tool);
@ -157,7 +158,7 @@ static void gimp_iscissors_tool_draw (GimpDrawTool *draw_tool);
static IScissorsOptions * iscissors_options_new (void);
static void iscissors_convert (GimpIscissorsTool *iscissors,
GDisplay *gdisp);
GimpDisplay *gdisp);
static TileManager * gradient_map_new (GimpImage *gimage);
static void find_optimal_path (TileManager *gradient_map,
@ -174,7 +175,7 @@ static void find_max_gradient (GimpIscissorsTool *iscissors,
gint *y);
static void calculate_curve (GimpTool *tool,
ICurve *curve);
static void iscissors_draw_curve (GDisplay *gdisp,
static void iscissors_draw_curve (GimpDisplay *gdisp,
GimpDrawTool *draw_tool,
ICurve *curve);
static void iscissors_free_icurves (GSList *list);
@ -395,9 +396,9 @@ iscissors_options_new (void)
}
static void
gimp_iscissors_tool_control (GimpTool *tool,
ToolAction action,
GDisplay *gdisp)
gimp_iscissors_tool_control (GimpTool *tool,
ToolAction action,
GimpDisplay *gdisp)
{
GimpIscissorsTool *iscissors;
Iscissors_draw draw;
@ -444,7 +445,7 @@ gimp_iscissors_tool_control (GimpTool *tool,
static void
gimp_iscissors_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpIscissorsTool *iscissors;
GimpDrawable *drawable;
@ -515,20 +516,13 @@ gimp_iscissors_tool_button_press (GimpTool *tool,
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
if (iscissors->op == SELECTION_REPLACE)
gimage_mask_clear (gdisp->gimage);
else
gimage_mask_undo (gdisp->gimage);
if (((SelectionOptions *) iscissors_options)->feather)
gimp_channel_feather (iscissors->mask,
gimp_image_get_mask (gdisp->gimage),
((SelectionOptions *) iscissors_options)->feather_radius,
((SelectionOptions *) iscissors_options)->feather_radius,
iscissors->op, 0, 0);
else
gimp_channel_combine_mask (gimp_image_get_mask (gdisp->gimage),
iscissors->mask, iscissors->op, 0, 0);
gimp_image_mask_select_channel (gdisp->gimage,
NULL, FALSE,
iscissors->mask,
iscissors->op,
((SelectionOptions *) iscissors_options)->feather,
((SelectionOptions *) iscissors_options)->feather_radius,
((SelectionOptions *) iscissors_options)->feather_radius);
gimp_iscissors_tool_reset (iscissors);
@ -561,7 +555,7 @@ gimp_iscissors_tool_button_press (GimpTool *tool,
static void
iscissors_convert (GimpIscissorsTool *iscissors,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpScanConvert *sc;
GimpVector2 *points;
@ -608,7 +602,7 @@ iscissors_convert (GimpIscissorsTool *iscissors,
static void
gimp_iscissors_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpIscissorsTool *iscissors;
ICurve *curve;
@ -722,7 +716,7 @@ gimp_iscissors_tool_button_release (GimpTool *tool,
static void
gimp_iscissors_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpIscissorsTool *iscissors;
@ -791,7 +785,7 @@ gimp_iscissors_tool_draw (GimpDrawTool *draw_tool)
{
GimpTool *tool;
GimpIscissorsTool *iscissors;
GDisplay *gdisp;
GimpDisplay *gdisp;
ICurve *curve;
GSList *list;
gint tx1, ty1, tx2, ty2;
@ -931,7 +925,7 @@ gimp_iscissors_tool_draw (GimpDrawTool *draw_tool)
static void
iscissors_draw_curve (GDisplay *gdisp,
iscissors_draw_curve (GimpDisplay *gdisp,
GimpDrawTool *draw_tool,
ICurve *curve)
{
@ -976,7 +970,7 @@ iscissors_draw_curve (GDisplay *gdisp,
static void
gimp_iscissors_tool_oper_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpIscissorsTool *iscissors;
gint x, y;
@ -1028,7 +1022,7 @@ gimp_iscissors_tool_oper_update (GimpTool *tool,
static void
gimp_iscissors_tool_modifier_key (GimpTool *tool,
GdkEventKey *kevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpIscissorsTool *iscissors;
SelectOps op;
@ -1071,7 +1065,7 @@ gimp_iscissors_tool_modifier_key (GimpTool *tool,
static void
gimp_iscissors_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpIscissorsTool *iscissors;
@ -1421,7 +1415,7 @@ calculate_curve (GimpTool *tool,
ICurve *curve)
{
GimpIscissorsTool *iscissors;
GDisplay *gdisp;
GimpDisplay *gdisp;
gint x, y, dir;
gint xs, ys, xe, ye;
gint x1, y1, x2, y2;

View File

@ -301,14 +301,22 @@ gimp_paintbrush_tool_motion (GimpPaintTool *paint_tool,
if (gradient_length)
{
if (pressure_options->color)
gimp_gradient_get_color_at (gimp_context_get_gradient (context),
paint_tool->curpressure, &color);
else
gimp_paint_tool_get_color_from_gradient (paint_tool, gradient_length,
&color, mode);
GimpGradient *gradient;
temp_blend = (gint) ((color.a * local_blend));
gradient = gimp_context_get_gradient (context);
if (pressure_options->color)
gimp_gradient_get_color_at (gradient,
paint_tool->curpressure,
&color);
else
gimp_paint_tool_get_color_from_gradient (paint_tool,
gradient,
gradient_length,
&color,
mode);
temp_blend = (gint) ((color.a * local_blend));
gimp_rgb_get_uchar (&color,
&col[RED_PIX],

View File

@ -55,7 +55,6 @@
#include "gimpconvolvetool.h"
#include "gimppainttool.h"
#include "app_procs.h"
#include "devices.h"
#include "gimprc.h"
#include "undo.h"
@ -880,7 +879,7 @@ gimp_paint_tool_start (GimpPaintTool *paint_tool,
GimpContext *context;
context = gimp_get_current_context (the_gimp);
context = gimp_get_current_context (gimp_drawable_gimage (drawable)->gimp);
paint_tool->curx = x;
paint_tool->cury = y;
@ -1113,29 +1112,27 @@ gimp_paint_tool_cleanup (void)
void
gimp_paint_tool_get_color_from_gradient (GimpPaintTool *paint_tool,
GimpGradient *gradient,
gdouble gradient_length,
GimpRGB *color,
GradientPaintMode mode)
{
GimpContext *context;
gdouble y;
gdouble distance; /* distance in current brush stroke */
context = gimp_get_current_context (the_gimp);
gdouble distance; /* distance in current brush stroke */
gdouble y;
distance = paint_tool->pixel_dist;
y = ((double) distance / gradient_length);
y = (gdouble) distance / gradient_length;
/* for the once modes, set y close to 1.0 after the first chunk */
if ( (mode == ONCE_FORWARD || mode == ONCE_BACKWARDS) && y >= 1.0 )
if ((mode == ONCE_FORWARD || mode == ONCE_BACKWARDS) && y >= 1.0)
y = 0.9999999;
if ( (((int)y & 1) && mode != LOOP_SAWTOOTH) || mode == ONCE_BACKWARDS )
y = 1.0 - (y - (int)y);
if ((((gint) y & 1) && mode != LOOP_SAWTOOTH) || mode == ONCE_BACKWARDS )
y = 1.0 - (y - (gint) y);
else
y = y - (int)y;
y = y - (gint) y;
gimp_gradient_get_color_at (gimp_context_get_gradient (context), y, color);
gimp_gradient_get_color_at (gradient, y, color);
}

View File

@ -145,10 +145,11 @@ void gimp_paint_tool_finish (GimpPaintTool *tool,
GimpDrawable *drawable);
void gimp_paint_tool_cleanup (void);
void gimp_paint_tool_get_color_from_gradient (GimpPaintTool *tool,
gdouble gradient_length,
GimpRGB *color,
GradientPaintMode mode);
void gimp_paint_tool_get_color_from_gradient (GimpPaintTool *tool,
GimpGradient *gradient,
gdouble gradient_length,
GimpRGB *color,
GradientPaintMode mode);
/* paint tool painting functions */
TempBuf * gimp_paint_tool_get_paint_area (GimpPaintTool *tool,

View File

@ -31,6 +31,7 @@
#include "core/gimpchannel.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-mask-select.h"
#include "core/gimpmarshal.h"
#include "core/gimptoolinfo.h"
@ -132,51 +133,6 @@ gimp_rect_select_tool_get_type (void)
return tool_type;
}
void
rect_select (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
SelectOps op,
gboolean feather,
gdouble feather_radius)
{
GimpChannel *new_mask;
/* if applicable, replace the current selection */
if (op == SELECTION_REPLACE)
gimage_mask_clear (gimage);
else
gimage_mask_undo (gimage);
/* if feathering for rect, make a new mask with the
* rectangle and feather that with the old mask
*/
if (feather)
{
new_mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_channel_combine_rect (new_mask, CHANNEL_OP_ADD, x, y, w, h);
gimp_channel_feather (new_mask, gimp_image_get_mask (gimage),
feather_radius,
feather_radius,
op, 0, 0);
g_object_unref (G_OBJECT (new_mask));
}
else if (op == SELECTION_INTERSECT)
{
new_mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
gimp_channel_combine_rect (new_mask, CHANNEL_OP_ADD, x, y, w, h);
gimp_channel_combine_mask (gimp_image_get_mask (gimage), new_mask,
op, 0, 0);
g_object_unref (G_OBJECT (new_mask));
}
else
{
gimp_channel_combine_rect (gimp_image_get_mask (gimage), op, x, y, w, h);
}
}
/* private funuctions */
@ -616,11 +572,12 @@ gimp_rect_select_tool_real_rect_select (GimpRectSelectTool *rect_tool,
sel_options = (SelectionOptions *)
tool_manager_get_info_by_tool (the_gimp, tool)->tool_options;
rect_select (tool->gdisp->gimage,
x, y, w, h,
sel_tool->op,
sel_options->feather,
sel_options->feather_radius);
gimp_image_mask_select_rectangle (tool->gdisp->gimage,
x, y, w, h,
sel_tool->op,
sel_options->feather,
sel_options->feather_radius,
sel_options->feather_radius);
}
void

View File

@ -73,14 +73,4 @@ void gimp_rect_select_tool_rect_select (GimpRectSelectTool *rect_tool,
gint h);
void rect_select (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
SelectOps op,
gboolean feather,
gdouble feather_radius);
#endif /* __GIMP_RECT_SELECT_TOOL_H__ */

View File

@ -37,7 +37,9 @@
#include "core/gimpchannel.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimage-contiguous-region.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-mask-select.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
@ -57,20 +59,22 @@
static void gimp_fuzzy_select_tool_class_init (GimpFuzzySelectToolClass *klass);
static void gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select);
static void gimp_fuzzy_select_tool_finalize (GObject *object);
static void gimp_fuzzy_select_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_fuzzy_select_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_fuzzy_select_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_fuzzy_select_tool_draw (GimpDrawTool *draw_tool);
static GdkSegment * fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel,
GDisplay *gdisp,
GimpDisplay *gdisp,
gint *nsegs);
@ -83,8 +87,6 @@ static SelectionOptions *fuzzy_options = NULL;
static GdkSegment *segs = NULL;
static gint num_segs = 0;
GimpChannel * fuzzy_mask = NULL;
/* public functions */
@ -130,313 +132,24 @@ gimp_fuzzy_select_tool_get_type (void)
return tool_type;
}
/*******************************/
/* Fuzzy selection apparatus */
static gint
is_pixel_sufficiently_different (guchar *col1,
guchar *col2,
gboolean antialias,
gint threshold,
gint bytes,
gboolean has_alpha)
{
gint diff;
gint max;
gint b;
gint alpha;
max = 0;
alpha = (has_alpha) ? bytes - 1 : bytes;
/* if there is an alpha channel, never select transparent regions */
if (has_alpha && col2[alpha] == 0)
return 0;
for (b = 0; b < bytes; b++)
{
diff = col1[b] - col2[b];
diff = abs (diff);
if (diff > max)
max = diff;
}
if (antialias)
{
float aa;
aa = 1.5 - ((float) max / threshold);
if (aa <= 0)
return 0;
else if (aa < 0.5)
return (unsigned char) (aa * 512);
else
return 255;
}
else
{
if (max > threshold)
return 0;
else
return 255;
}
}
static void
ref_tiles (TileManager *src,
TileManager *mask,
Tile **s_tile,
Tile **m_tile,
gint x,
gint y,
guchar **s,
guchar **m)
{
if (*s_tile != NULL)
tile_release (*s_tile, FALSE);
if (*m_tile != NULL)
tile_release (*m_tile, TRUE);
*s_tile = tile_manager_get_tile (src, x, y, TRUE, FALSE);
*m_tile = tile_manager_get_tile (mask, x, y, TRUE, TRUE);
*s = tile_data_pointer (*s_tile, x % TILE_WIDTH, y % TILE_HEIGHT);
*m = tile_data_pointer (*m_tile, x % TILE_WIDTH, y % TILE_HEIGHT);
}
static int
find_contiguous_segment (guchar *col,
PixelRegion *src,
PixelRegion *mask,
gint width,
gint bytes,
gboolean has_alpha,
gboolean antialias,
gint threshold,
gint initial,
gint *start,
gint *end)
{
guchar *s;
guchar *m;
guchar diff;
Tile *s_tile = NULL;
Tile *m_tile = NULL;
ref_tiles (src->tiles, mask->tiles, &s_tile, &m_tile, src->x, src->y, &s, &m);
/* check the starting pixel */
if (! (diff = is_pixel_sufficiently_different (col, s, antialias,
threshold, bytes, has_alpha)))
{
tile_release (s_tile, FALSE);
tile_release (m_tile, TRUE);
return FALSE;
}
*m-- = diff;
s -= bytes;
*start = initial - 1;
while (*start >= 0 && diff)
{
if (! ((*start + 1) % TILE_WIDTH))
ref_tiles (src->tiles, mask->tiles, &s_tile, &m_tile, *start, src->y, &s, &m);
diff = is_pixel_sufficiently_different (col, s, antialias,
threshold, bytes, has_alpha);
if ((*m-- = diff))
{
s -= bytes;
(*start)--;
}
}
diff = 1;
*end = initial + 1;
if (*end % TILE_WIDTH && *end < width)
ref_tiles (src->tiles, mask->tiles, &s_tile, &m_tile, *end, src->y, &s, &m);
while (*end < width && diff)
{
if (! (*end % TILE_WIDTH))
ref_tiles (src->tiles, mask->tiles, &s_tile, &m_tile, *end, src->y, &s, &m);
diff = is_pixel_sufficiently_different (col, s, antialias,
threshold, bytes, has_alpha);
if ((*m++ = diff))
{
s += bytes;
(*end)++;
}
}
tile_release (s_tile, FALSE);
tile_release (m_tile, TRUE);
return TRUE;
}
static void
find_contiguous_region_helper (PixelRegion *mask,
PixelRegion *src,
gboolean has_alpha,
gboolean antialias,
gint threshold,
gboolean indexed,
gint x,
gint y,
guchar *col)
{
gint start, end, i;
gint val;
gint bytes;
Tile *tile;
if (threshold == 0) threshold = 1;
if (x < 0 || x >= src->w) return;
if (y < 0 || y >= src->h) return;
tile = tile_manager_get_tile (mask->tiles, x, y, TRUE, FALSE);
val = *(guchar *)(tile_data_pointer (tile,
x % TILE_WIDTH, y % TILE_HEIGHT));
tile_release (tile, FALSE);
if (val != 0)
return;
src->x = x;
src->y = y;
bytes = src->bytes;
if(indexed)
{
bytes = has_alpha ? 4 : 3;
}
if (! find_contiguous_segment (col, src, mask, src->w,
src->bytes, has_alpha,
antialias, threshold, x, &start, &end))
return;
for (i = start + 1; i < end; i++)
{
find_contiguous_region_helper (mask, src, has_alpha, antialias,
threshold, indexed, i, y - 1, col);
find_contiguous_region_helper (mask, src, has_alpha, antialias,
threshold, indexed, i, y + 1, col);
}
}
GimpChannel *
find_contiguous_region (GimpImage *gimage,
GimpDrawable *drawable,
gboolean antialias,
gint threshold,
gint x,
gint y,
gboolean sample_merged)
{
PixelRegion srcPR, maskPR;
GimpChannel *mask;
guchar *start;
gboolean has_alpha;
gboolean indexed;
gint type;
gint bytes;
Tile *tile;
if (sample_merged)
{
pixel_region_init (&srcPR, gimp_image_composite (gimage), 0, 0,
gimage->width, gimage->height, FALSE);
type = gimp_image_composite_type (gimage);
has_alpha = (type == RGBA_GIMAGE ||
type == GRAYA_GIMAGE ||
type == INDEXEDA_GIMAGE);
}
else
{
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
0, 0,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable),
FALSE);
has_alpha = gimp_drawable_has_alpha (drawable);
}
indexed = gimp_drawable_is_indexed (drawable);
bytes = gimp_drawable_bytes (drawable);
if (indexed)
{
bytes = has_alpha ? 4 : 3;
}
mask = gimp_channel_new_mask (gimage, srcPR.w, srcPR.h);
pixel_region_init (&maskPR, gimp_drawable_data (GIMP_DRAWABLE(mask)),
0, 0,
gimp_drawable_width (GIMP_DRAWABLE(mask)),
gimp_drawable_height (GIMP_DRAWABLE(mask)),
TRUE);
tile = tile_manager_get_tile (srcPR.tiles, x, y, TRUE, FALSE);
if (tile)
{
start = tile_data_pointer (tile, x%TILE_WIDTH, y%TILE_HEIGHT);
find_contiguous_region_helper (&maskPR, &srcPR, has_alpha, antialias,
threshold, bytes, x, y, start);
tile_release (tile, FALSE);
}
return mask;
}
void
fuzzy_select (GimpImage *gimage,
GimpDrawable *drawable,
gint op,
gboolean feather,
gdouble feather_radius)
{
gint off_x, off_y;
/* if applicable, replace the current selection */
if (op == CHANNEL_OP_REPLACE)
gimage_mask_clear (gimage);
else
gimage_mask_undo (gimage);
if (drawable) /* NULL if sample_merged is active */
gimp_drawable_offsets (drawable, &off_x, &off_y);
else
off_x = off_y = 0;
if (feather)
gimp_channel_feather (fuzzy_mask, gimp_image_get_mask (gimage),
feather_radius,
feather_radius,
op, off_x, off_y);
else
gimp_channel_combine_mask (gimp_image_get_mask (gimage),
fuzzy_mask, op, off_x, off_y);
g_object_unref (G_OBJECT (fuzzy_mask));
fuzzy_mask = NULL;
}
/* fuzzy select action functions */
/* private functions */
static void
gimp_fuzzy_select_tool_class_init (GimpFuzzySelectToolClass *klass)
{
GObjectClass *object_class;
GimpToolClass *tool_class;
GimpDrawToolClass *draw_tool_class;
object_class = G_OBJECT_CLASS (klass);
tool_class = GIMP_TOOL_CLASS (klass);
draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_fuzzy_select_tool_finalize;
tool_class->button_press = gimp_fuzzy_select_tool_button_press;
tool_class->button_release = gimp_fuzzy_select_tool_button_release;
tool_class->motion = gimp_fuzzy_select_tool_motion;
@ -465,6 +178,7 @@ gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select)
tool->tool_cursor = GIMP_FUZZY_SELECT_TOOL_CURSOR;
tool->scroll_lock = TRUE; /* Do not allow scrolling */
fuzzy_select->fuzzy_mask = NULL;
fuzzy_select->x = 0;
fuzzy_select->y = 0;
fuzzy_select->first_x = 0;
@ -472,10 +186,24 @@ gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select)
fuzzy_select->first_threshold = 0.0;
}
static void
gimp_fuzzy_select_tool_finalize (GObject *object)
{
GimpFuzzySelectTool *fuzzy_sel;
fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (object);
if (fuzzy_sel->fuzzy_mask)
{
g_object_unref (G_OBJECT (fuzzy_sel->fuzzy_mask));
fuzzy_sel->fuzzy_mask = NULL;
}
}
static void
gimp_fuzzy_select_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpFuzzySelectTool *fuzzy_sel;
@ -518,7 +246,7 @@ gimp_fuzzy_select_tool_button_press (GimpTool *tool,
static void
gimp_fuzzy_select_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpFuzzySelectTool *fuzzy_sel;
GimpDrawable *drawable;
@ -534,28 +262,35 @@ gimp_fuzzy_select_tool_button_release (GimpTool *tool,
/* First take care of the case where the user "cancels" the action */
if (! (bevent->state & GDK_BUTTON3_MASK))
{
drawable = (fuzzy_options->sample_merged ?
NULL : gimp_image_active_drawable (gdisp->gimage));
drawable = gimp_image_active_drawable (gdisp->gimage);
fuzzy_select (gdisp->gimage,
drawable,
GIMP_SELECTION_TOOL (tool)->op,
fuzzy_options->feather,
fuzzy_options->feather_radius);
gimp_image_mask_select_channel (gdisp->gimage,
drawable,
fuzzy_options->sample_merged,
fuzzy_sel->fuzzy_mask,
GIMP_SELECTION_TOOL (tool)->op,
fuzzy_options->feather,
fuzzy_options->feather_radius,
fuzzy_options->feather_radius);
g_object_unref (G_OBJECT (fuzzy_sel->fuzzy_mask));
fuzzy_sel->fuzzy_mask = NULL;
gdisplays_flush ();
}
/* If the segment array is allocated, free it */
if (segs)
g_free (segs);
segs = NULL;
{
g_free (segs);
segs = NULL;
}
}
static void
gimp_fuzzy_select_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpFuzzySelectTool *fuzzy_sel;
GimpSelectionTool *sel_tool;
@ -609,7 +344,7 @@ gimp_fuzzy_select_tool_motion (GimpTool *tool,
static GdkSegment *
fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel,
GDisplay *gdisp,
GimpDisplay *gdisp,
gint *nsegs)
{
PixelRegion maskPR;
@ -630,28 +365,30 @@ fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel,
gdisplay_untransform_coords (gdisp, fuzzy_sel->x,
fuzzy_sel->y, &x, &y, FALSE, use_offsets);
new = find_contiguous_region (gdisp->gimage, drawable,
fuzzy_options->antialias,
fuzzy_options->threshold, x, y,
fuzzy_options->sample_merged);
new = gimp_image_contiguous_region_by_seed (gdisp->gimage, drawable,
fuzzy_options->sample_merged,
fuzzy_options->antialias,
fuzzy_options->threshold,
x, y);
if (fuzzy_mask)
g_object_unref (G_OBJECT (fuzzy_mask));
if (fuzzy_sel->fuzzy_mask)
g_object_unref (G_OBJECT (fuzzy_sel->fuzzy_mask));
fuzzy_mask = new;
fuzzy_sel->fuzzy_mask = new;
/* calculate and allocate a new XSegment array which represents the boundary
* of the color-contiguous region
*/
pixel_region_init (&maskPR, gimp_drawable_data (GIMP_DRAWABLE (fuzzy_mask)),
pixel_region_init (&maskPR,
gimp_drawable_data (GIMP_DRAWABLE (fuzzy_sel->fuzzy_mask)),
0, 0,
gimp_drawable_width (GIMP_DRAWABLE (fuzzy_mask)),
gimp_drawable_height (GIMP_DRAWABLE (fuzzy_mask)),
gimp_drawable_width (GIMP_DRAWABLE (fuzzy_sel->fuzzy_mask)),
gimp_drawable_height (GIMP_DRAWABLE (fuzzy_sel->fuzzy_mask)),
FALSE);
bsegs = find_mask_boundary (&maskPR, nsegs, WithinBounds,
0, 0,
gimp_drawable_width (GIMP_DRAWABLE (fuzzy_mask)),
gimp_drawable_height (GIMP_DRAWABLE (fuzzy_mask)));
gimp_drawable_width (GIMP_DRAWABLE (fuzzy_sel->fuzzy_mask)),
gimp_drawable_height (GIMP_DRAWABLE (fuzzy_sel->fuzzy_mask)));
segs = g_new (GdkSegment, *nsegs);

View File

@ -38,10 +38,12 @@ struct _GimpFuzzySelectTool
{
GimpSelectionTool parent_instance;
gint x, y; /* Point from which to execute seed fill */
gint first_x; /* */
gint first_y; /* variables to keep track of sensitivity */
gdouble first_threshold; /* initial value of threshold slider */
gint x, y; /* Point from which to execute seed fill */
gint first_x; /* */
gint first_y; /* variables to keep track of sensitivity */
gdouble first_threshold; /* initial value of threshold slider */
GimpChannel *fuzzy_mask;
};
struct _GimpFuzzySelectToolClass
@ -50,26 +52,9 @@ struct _GimpFuzzySelectToolClass
};
void gimp_fuzzy_select_tool_register (Gimp *gimp);
void gimp_fuzzy_select_tool_register (Gimp *gimp);
GType gimp_fuzzy_select_tool_get_type (void);
GimpChannel * find_contiguous_region (GimpImage *gimage,
GimpDrawable *drawable,
gboolean antialias,
gint threshold,
gint x,
gint y,
gboolean sample_merged);
void fuzzy_select (GimpImage *gimage,
GimpDrawable *drawable,
gint op,
gboolean feather,
gdouble feather_radius);
extern GimpChannel *fuzzy_mask;
GType gimp_fuzzy_select_tool_get_type (void);
#endif /* __GIMP_FUZZY_SELECT_TOOL_H__ */

View File

@ -37,19 +37,19 @@ static void gimp_selection_tool_init (GimpSelectionTool *selecti
static void gimp_selection_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_selection_tool_oper_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_selection_tool_modifier_key (GimpTool *tool,
GdkEventKey *kevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_selection_tool_update_op_state (GimpSelectionTool *selection_tool,
gint x,
gint y,
gint state,
GDisplay *gdisp);
GimpDisplay *gdisp);
static GimpDrawToolClass *parent_class = NULL;
@ -112,9 +112,9 @@ gimp_selection_tool_init (GimpSelectionTool *selection_tool)
}
static void
gimp_selection_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
gimp_selection_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GimpDisplay *gdisp)
{
GimpSelectionTool *selection_tool;
@ -170,7 +170,7 @@ gimp_selection_tool_cursor_update (GimpTool *tool,
static void
gimp_selection_tool_oper_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpSelectionTool *selection_tool;
@ -189,7 +189,7 @@ gimp_selection_tool_oper_update (GimpTool *tool,
static void
gimp_selection_tool_modifier_key (GimpTool *tool,
GdkEventKey *kevent,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpSelectionTool *selection_tool;
gint state;
@ -233,7 +233,7 @@ gimp_selection_tool_update_op_state (GimpSelectionTool *selection_tool,
gint x,
gint y,
gint state,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpLayer *layer;
GimpLayer *floating_sel;

View File

@ -95,11 +95,11 @@ enum
/* forward function declarations */
static void gimp_transform_tool_bounds (GimpTransformTool *tool,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_recalc (GimpTransformTool *tool,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_doit (GimpTransformTool *tool,
GDisplay *gdisp);
GimpDisplay *gdisp);
static gdouble gimp_transform_tool_cubic (gdouble dx,
gint jm1,
gint j,
@ -114,23 +114,23 @@ static void gimp_transform_tool_finalize (GObject *object);
static void gimp_transform_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_control (GimpTool *tool,
ToolAction action,
GDisplay *gdisp);
GimpDisplay *gdisp);
static void gimp_transform_tool_draw (GimpDrawTool *draw_tool);
@ -234,7 +234,7 @@ gimp_transform_tool_init (GimpTransformTool *tr_tool)
TileManager *
gimp_transform_tool_transform (GimpTransformTool *tool,
GDisplay *gdisp,
GimpDisplay *gdisp,
TransformState state)
{
TileManager *retval;
@ -319,9 +319,9 @@ gimp_transform_tool_finalize (GObject *object)
}
static void
gimp_transform_tool_control (GimpTool *tool,
ToolAction action,
GDisplay *gdisp)
gimp_transform_tool_control (GimpTool *tool,
ToolAction action,
GimpDisplay *gdisp)
{
GimpDrawTool *dr_tool;
GimpTransformTool *tr_tool;
@ -351,9 +351,9 @@ gimp_transform_tool_control (GimpTool *tool,
}
static void
gimp_transform_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
gimp_transform_tool_button_press (GimpTool *tool,
GdkEventButton *bevent,
GimpDisplay *gdisp)
{
GimpTransformTool *gt_tool;
GimpDrawable *drawable;
@ -529,9 +529,9 @@ gimp_transform_tool_button_press (GimpTool *tool,
}
static void
gimp_transform_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
gimp_transform_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GimpDisplay *gdisp)
{
GimpTransformTool *gt_tool;
gint i;
@ -590,7 +590,7 @@ gimp_transform_tool_button_release (GimpTool *tool,
static void
gimp_transform_tool_doit (GimpTransformTool *gt_tool,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpTool *tool;
TileManager *new_tiles;
@ -710,9 +710,9 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool,
}
static void
gimp_transform_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
gimp_transform_tool_motion (GimpTool *tool,
GdkEventMotion *mevent,
GimpDisplay *gdisp)
{
GimpTransformTool *tr_tool;
@ -747,9 +747,9 @@ gimp_transform_tool_motion (GimpTool *tool,
}
static void
gimp_transform_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
gimp_transform_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GimpDisplay *gdisp)
{
GimpTransformTool *tr_tool;
GimpDrawable *drawable;
@ -790,7 +790,7 @@ gimp_transform_tool_cursor_update (GimpTool *tool,
static void
gimp_transform_tool_draw (GimpDrawTool *dr_tool)
{
GDisplay *gdisp;
GimpDisplay *gdisp;
GimpTransformTool *tr_tool;
GimpTool *tool;
gint x1, y1, x2, y2, x3, y3, x4, y4;
@ -942,7 +942,7 @@ gimp_transform_tool_transform_bounding_box (GimpTransformTool *tr_tool)
void
gimp_transform_tool_reset (GimpTransformTool *tr_tool,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
GimpTool *tool;
@ -966,11 +966,11 @@ gimp_transform_tool_reset (GimpTransformTool *tr_tool,
static void
gimp_transform_tool_bounds (GimpTransformTool *tr_tool,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
TileManager *tiles;
GimpDrawable *drawable;
gint offset_x, offset_y;
TileManager *tiles;
GimpDrawable *drawable;
gint offset_x, offset_y;
tiles = tr_tool->original;
drawable = gimp_image_active_drawable (gdisp->gimage);
@ -1115,7 +1115,7 @@ gimp_transform_tool_setup_grid (GimpTransformTool *tr_tool)
static void
gimp_transform_tool_recalc (GimpTransformTool *tr_tool,
GDisplay *gdisp)
GimpDisplay *gdisp)
{
gimp_transform_tool_bounds (tr_tool, gdisp);

View File

@ -282,9 +282,9 @@ tool_manager_pop_tool (Gimp *gimp)
void
tool_manager_initialize_tool (Gimp *gimp,
GimpTool *tool, /* FIXME: remove tool param */
GDisplay *gdisp)
tool_manager_initialize_tool (Gimp *gimp,
GimpTool *tool, /* FIXME: remove tool param */
GimpDisplay *gdisp)
{
GimpToolManager *tool_manager;
GimpToolInfo *tool_info;
@ -328,9 +328,9 @@ tool_manager_initialize_tool (Gimp *gimp,
}
void
tool_manager_control_active (Gimp *gimp,
ToolAction action,
GDisplay *gdisp)
tool_manager_control_active (Gimp *gimp,
ToolAction action,
GimpDisplay *gdisp)
{
GimpToolManager *tool_manager;
@ -665,7 +665,7 @@ tool_manager_image_dirty (GimpImage *gimage,
if (tool_manager->active_tool && ! tool_manager->active_tool->preserve)
{
GDisplay *gdisp = tool_manager->active_tool->gdisp;
GimpDisplay *gdisp = tool_manager->active_tool->gdisp;
if (gdisp)
{

View File

@ -36,8 +36,6 @@
#include "gimppreview.h"
#include "gimpconstrainedhwrapbox.h"
#include "colormaps.h"
#include "libgimp/gimpintl.h"
@ -120,12 +118,6 @@ gimp_container_grid_view_class_init (GimpContainerGridViewClass *klass)
container_view_class->clear_items = gimp_container_grid_view_clear_items;
container_view_class->set_preview_size = gimp_container_grid_view_set_preview_size;
klass->white_style = gtk_style_copy (gtk_widget_get_default_style ());
klass->white_style->bg[GTK_STATE_NORMAL].red = 0xffff;
klass->white_style->bg[GTK_STATE_NORMAL].green = 0xffff;
klass->white_style->bg[GTK_STATE_NORMAL].blue = 0xffff;
klass->white_style->bg[GTK_STATE_NORMAL].pixel = g_white_pixel;
gimp_rgba_set (&white_color, 1.0, 1.0, 1.0, 1.0);
gimp_rgba_set (&black_color, 0.0, 0.0, 0.0, 1.0);
}
@ -159,10 +151,6 @@ gimp_container_grid_view_init (GimpContainerGridView *grid_view)
grid_view->wrap_box);
gtk_widget_show (grid_view->wrap_box);
gtk_widget_set_style
(grid_view->wrap_box->parent,
GIMP_CONTAINER_GRID_VIEW_GET_CLASS (grid_view)->white_style);
gtk_container_set_focus_vadjustment
(GTK_CONTAINER (grid_view->wrap_box->parent),
gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW

View File

@ -49,8 +49,6 @@ struct _GimpContainerGridView
struct _GimpContainerGridViewClass
{
GimpContainerViewClass parent_class;
GtkStyle *white_style;
};

View File

@ -53,6 +53,7 @@ PDB_WRAPPERS_C = \
gimpplugin_pdb.c \
gimpproceduraldb_pdb.c \
gimpselection_pdb.c \
gimpselectiontools_pdb.c \
gimptexttool_pdb.c \
gimptools_pdb.c \
gimpundo_pdb.c \
@ -87,6 +88,7 @@ PDB_WRAPPERS_H = \
gimpplugin_pdb.h \
gimpproceduraldb_pdb.h \
gimpselection_pdb.h \
gimpselectiontools_pdb.h \
gimptexttool_pdb.h \
gimptools_pdb.h \
gimpundo_pdb.h \

View File

@ -49,6 +49,7 @@
#include <libgimp/gimpproceduraldb_pdb.h>
#include <libgimp/gimpplugin_pdb.h>
#include <libgimp/gimpselection_pdb.h>
#include <libgimp/gimpselectiontools_pdb.h>
#include <libgimp/gimptexttool_pdb.h>
#include <libgimp/gimptools_pdb.h>
#include <libgimp/gimpundo_pdb.h>

View File

@ -0,0 +1,331 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* gimpselectiontools_pdb.c
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* NOTE: This file is autogenerated by pdbgen.pl */
#include "gimp.h"
/**
* gimp_by_color_select:
* @drawable_ID: The affected drawable.
* @color: The color to select.
* @threshold: Threshold in intensity levels %%desc%%.
* @operation: The selection operation.
* @antialias: Antialiasing.
* @feather: Feather option for selections.
* @feather_radius: Radius for feather operation.
* @sample_merged: Use the composite image, not the drawable.
*
* Create a selection by selecting all pixels (in the specified
* drawable) with the same (or similar) color to that specified.
*
* This tool creates a selection over the specified image. A by-color
* selection is determined by the supplied color under the constraints
* of the specified threshold. Essentially, all pixels (in the
* drawable) that have color sufficiently close to the specified color
* (as determined by the threshold value) are included in the
* selection. The antialiasing parameter allows the final selection
* mask to contain intermediate values based on close misses to the
* threshold bar. Feathering can be enabled optionally and is
* controlled with the \"feather_radius\" parameter. If the
* sample_merged parameter is non-zero, the data of the composite image
* will be used instead of that for the specified drawable. This is
* equivalent to sampling for colors after merging all visible layers.
* In the case of a merged sampling, the supplied drawable is ignored.
*
* Returns: TRUE on success.
*/
gboolean
gimp_by_color_select (gint32 drawable_ID,
GimpRGB *color,
gint threshold,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius,
gboolean sample_merged)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_by_color_select",
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_COLOR, color,
GIMP_PDB_INT32, threshold,
GIMP_PDB_INT32, operation,
GIMP_PDB_INT32, antialias,
GIMP_PDB_INT32, feather,
GIMP_PDB_FLOAT, feather_radius,
GIMP_PDB_INT32, sample_merged,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_ellipse_select:
* @image_ID: The image.
* @x: x coordinate of upper-left corner of ellipse bounding box.
* @y: y coordinate of upper-left corner of ellipse bounding box.
* @width: The width of the ellipse.
* @height: The height of the ellipse.
* @operation: The selection operation.
* @antialias: Antialiasing.
* @feather: Feather option for selections.
* @feather_radius: Radius for feather operation.
*
* Create an elliptical selection over the specified image.
*
* This tool creates an elliptical selection over the specified image.
* The elliptical region can be either added to, subtracted from, or
* replace the contents of the previous selection mask. If antialiasing
* is turned on, the edges of the elliptical region will contain
* intermediate values which give the appearance of a sharper, less
* pixelized edge. This should be set as TRUE most of the time. If the
* feather option is enabled, the resulting selection is blurred before
* combining. The blur is a gaussian blur with the specified feather
* radius.
*
* Returns: TRUE on success.
*/
gboolean
gimp_ellipse_select (gint32 image_ID,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_ellipse_select",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_FLOAT, x,
GIMP_PDB_FLOAT, y,
GIMP_PDB_FLOAT, width,
GIMP_PDB_FLOAT, height,
GIMP_PDB_INT32, operation,
GIMP_PDB_INT32, antialias,
GIMP_PDB_INT32, feather,
GIMP_PDB_FLOAT, feather_radius,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_free_select:
* @image_ID: The image.
* @num_segs: Number of points (count 1 coordinate as two points).
* @segs: Array of points: { p1.x, p1.y, p2.x, p2.y, ..., pn.x, pn.y}.
* @operation: The selection operation.
* @antialias: Antialiasing.
* @feather: Feather option for selections.
* @feather_radius: Radius for feather operation.
*
* Create a polygonal selection over the specified image.
*
* This tool creates a polygonal selection over the specified image.
* The polygonal region can be either added to, subtracted from, or
* replace the contents of the previous selection mask. The polygon is
* specified through an array of floating point numbers and its length.
* The length of array must be 2n, where n is the number of points.
* Each point is defined by 2 floating point values which correspond to
* the x and y coordinates. If the final point does not connect to the
* starting point, a connecting segment is automatically added. If the
* feather option is enabled, the resulting selection is blurred before
* combining. The blur is a gaussian blur with the specified feather
* radius.
*
* Returns: TRUE on success.
*/
gboolean
gimp_free_select (gint32 image_ID,
gint num_segs,
gdouble *segs,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_free_select",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_INT32, num_segs,
GIMP_PDB_FLOATARRAY, segs,
GIMP_PDB_INT32, operation,
GIMP_PDB_INT32, antialias,
GIMP_PDB_INT32, feather,
GIMP_PDB_FLOAT, feather_radius,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_fuzzy_select:
* @drawable_ID: The affected drawable.
* @x: x coordinate of initial seed fill point: (image coordinates).
* @y: y coordinate of initial seed fill point: (image coordinates).
* @threshold: Threshold in intensity levels %%desc%%.
* @operation: The selection operation.
* @antialias: Antialiasing.
* @feather: Feather option for selections.
* @feather_radius: Radius for feather operation.
* @sample_merged: Use the composite image, not the drawable.
*
* Create a fuzzy selection starting at the specified coordinates on
* the specified drawable.
*
* This tool creates a fuzzy selection over the specified image. A
* fuzzy selection is determined by a seed fill under the constraints
* of the specified threshold. Essentially, the color at the specified
* coordinates (in the drawable) is measured and the selection expands
* outwards from that point to any adjacent pixels which are not
* significantly different (as determined by the threshold value). This
* process continues until no more expansion is possible. The
* antialiasing parameter allows the final selection mask to contain
* intermediate values based on close misses to the threshold bar at
* pixels along the seed fill boundary. Feathering can be enabled
* optionally and is controlled with the \"feather_radius\" paramter.
* If the sample_merged parameter is non-zero, the data of the
* composite image will be used instead of that for the specified
* drawable. This is equivalent to sampling for colors after merging
* all visible layers. In the case of a merged sampling, the supplied
* drawable is ignored. If the sample is merged, the specified
* coordinates are relative to the image origin; otherwise, they are
* relative to the drawable's origin.
*
* Returns: TRUE on success.
*/
gboolean
gimp_fuzzy_select (gint32 drawable_ID,
gdouble x,
gdouble y,
gint threshold,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius,
gboolean sample_merged)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_fuzzy_select",
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_FLOAT, x,
GIMP_PDB_FLOAT, y,
GIMP_PDB_INT32, threshold,
GIMP_PDB_INT32, operation,
GIMP_PDB_INT32, antialias,
GIMP_PDB_INT32, feather,
GIMP_PDB_FLOAT, feather_radius,
GIMP_PDB_INT32, sample_merged,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_rect_select:
* @image_ID: The image.
* @x: x coordinate of upper-left corner of rectangle.
* @y: y coordinate of upper-left corner of rectangle.
* @width: The width of the rectangle.
* @height: The height of the rectangle.
* @operation: The selection operation.
* @feather: Feather option for selections.
* @feather_radius: Radius for feather operation.
*
* Create a rectangular selection over the specified image;
*
* This tool creates a rectangular selection over the specified image.
* The rectangular region can be either added to, subtracted from, or
* replace the contents of the previous selection mask. If the feather
* option is enabled, the resulting selection is blurred before
* combining. The blur is a gaussian blur with the specified feather
* radius.
*
* Returns: TRUE on success.
*/
gboolean
gimp_rect_select (gint32 image_ID,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GimpChannelOps operation,
gboolean feather,
gdouble feather_radius)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_rect_select",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_FLOAT, x,
GIMP_PDB_FLOAT, y,
GIMP_PDB_FLOAT, width,
GIMP_PDB_FLOAT, height,
GIMP_PDB_INT32, operation,
GIMP_PDB_INT32, feather,
GIMP_PDB_FLOAT, feather_radius,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}

View File

@ -0,0 +1,81 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* gimpselectiontools_pdb.h
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* NOTE: This file is autogenerated by pdbgen.pl */
#ifndef __GIMP_SELECTION_TOOLS_PDB_H__
#define __GIMP_SELECTION_TOOLS_PDB_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* For information look into the C source or the html documentation */
gboolean gimp_by_color_select (gint32 drawable_ID,
GimpRGB *color,
gint threshold,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius,
gboolean sample_merged);
gboolean gimp_ellipse_select (gint32 image_ID,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius);
gboolean gimp_free_select (gint32 image_ID,
gint num_segs,
gdouble *segs,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius);
gboolean gimp_fuzzy_select (gint32 drawable_ID,
gdouble x,
gdouble y,
gint threshold,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius,
gboolean sample_merged);
gboolean gimp_rect_select (gint32 image_ID,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GimpChannelOps operation,
gboolean feather,
gdouble feather_radius);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GIMP_SELECTION_TOOLS_PDB_H__ */

View File

@ -238,69 +238,6 @@ gimp_bucket_fill (gint32 drawable_ID,
return success;
}
/**
* gimp_by_color_select:
* @drawable_ID: The affected drawable.
* @color: The color to select.
* @threshold: Threshold in intensity levels %%desc%%.
* @operation: The selection operation.
* @antialias: Antialiasing.
* @feather: Feather option for selections.
* @feather_radius: Radius for feather operation.
* @sample_merged: Use the composite image, not the drawable.
*
* Create a selection by selecting all pixels (in the specified
* drawable) with the same (or similar) color to that specified.
*
* This tool creates a selection over the specified image. A by-color
* selection is determined by the supplied color under the constraints
* of the specified threshold. Essentially, all pixels (in the
* drawable) that have color sufficiently close to the specified color
* (as determined by the threshold value) are included in the
* selection. The antialiasing parameter allows the final selection
* mask to contain intermediate values based on close misses to the
* threshold bar. Feathering can be enabled optionally and is
* controlled with the \"feather_radius\" parameter. If the
* sample_merged parameter is non-zero, the data of the composite image
* will be used instead of that for the specified drawable. This is
* equivalent to sampling for colors after merging all visible layers.
* In the case of a merged sampling, the supplied drawable is ignored.
*
* Returns: TRUE on success.
*/
gboolean
gimp_by_color_select (gint32 drawable_ID,
GimpRGB *color,
gint threshold,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius,
gboolean sample_merged)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_by_color_select",
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_COLOR, color,
GIMP_PDB_INT32, threshold,
GIMP_PDB_INT32, operation,
GIMP_PDB_INT32, antialias,
GIMP_PDB_INT32, feather,
GIMP_PDB_FLOAT, feather_radius,
GIMP_PDB_INT32, sample_merged,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_clone:
* @drawable_ID: The affected drawable.
@ -602,7 +539,7 @@ gimp_dodgeburn (gint32 drawable_ID,
* taken from the tools option dialog. If the dialog has not been
* activated then the defaults as used by the dialog will be used.
*
* Dodgebure. More details here later.
* Dodgeburn. More details here later.
*
* Returns: TRUE on success.
*/
@ -629,67 +566,6 @@ gimp_dodgeburn_default (gint32 drawable_ID,
return success;
}
/**
* gimp_ellipse_select:
* @image_ID: The image.
* @x: x coordinate of upper-left corner of ellipse bounding box.
* @y: y coordinate of upper-left corner of ellipse bounding box.
* @width: The width of the ellipse.
* @height: The height of the ellipse.
* @operation: The selection operation.
* @antialias: Antialiasing.
* @feather: Feather option for selections.
* @feather_radius: Radius for feather operation.
*
* Create an elliptical selection over the specified image.
*
* This tool creates an elliptical selection over the specified image.
* The elliptical region can be either added to, subtracted from, or
* replace the contents of the previous selection mask. If antialiasing
* is turned on, the edges of the elliptical region will contain
* intermediate values which give the appearance of a sharper, less
* pixelized edge. This should be set as TRUE most of the time. If the
* feather option is enabled, the resulting selection is blurred before
* combining. The blur is a gaussian blur with the specified feather
* radius.
*
* Returns: TRUE on success.
*/
gboolean
gimp_ellipse_select (gint32 image_ID,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_ellipse_select",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_FLOAT, x,
GIMP_PDB_FLOAT, y,
GIMP_PDB_FLOAT, width,
GIMP_PDB_FLOAT, height,
GIMP_PDB_INT32, operation,
GIMP_PDB_INT32, antialias,
GIMP_PDB_INT32, feather,
GIMP_PDB_FLOAT, feather_radius,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_eraser:
* @drawable_ID: The affected drawable.
@ -816,134 +692,6 @@ gimp_flip (gint32 drawable_ID,
return ret_drawable_ID;
}
/**
* gimp_free_select:
* @image_ID: The image.
* @num_segs: Number of points (count 1 coordinate as two points).
* @segs: Array of points: { p1.x, p1.y, p2.x, p2.y, ..., pn.x, pn.y}.
* @operation: The selection operation.
* @antialias: Antialiasing.
* @feather: Feather option for selections.
* @feather_radius: Radius for feather operation.
*
* Create a polygonal selection over the specified image.
*
* This tool creates a polygonal selection over the specified image.
* The polygonal region can be either added to, subtracted from, or
* replace the contents of the previous selection mask. The polygon is
* specified through an array of floating point numbers and its length.
* The length of array must be 2n, where n is the number of points.
* Each point is defined by 2 floating point values which correspond to
* the x and y coordinates. If the final point does not connect to the
* starting point, a connecting segment is automatically added. If the
* feather option is enabled, the resulting selection is blurred before
* combining. The blur is a gaussian blur with the specified feather
* radius.
*
* Returns: TRUE on success.
*/
gboolean
gimp_free_select (gint32 image_ID,
gint num_segs,
gdouble *segs,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_free_select",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_INT32, num_segs,
GIMP_PDB_FLOATARRAY, segs,
GIMP_PDB_INT32, operation,
GIMP_PDB_INT32, antialias,
GIMP_PDB_INT32, feather,
GIMP_PDB_FLOAT, feather_radius,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_fuzzy_select:
* @drawable_ID: The affected drawable.
* @x: x coordinate of initial seed fill point: (image coordinates).
* @y: y coordinate of initial seed fill point: (image coordinates).
* @threshold: Threshold in intensity levels %%desc%%.
* @operation: The selection operation.
* @antialias: Antialiasing.
* @feather: Feather option for selections.
* @feather_radius: Radius for feather operation.
* @sample_merged: Use the composite image, not the drawable.
*
* Create a fuzzy selection starting at the specified coordinates on
* the specified drawable.
*
* This tool creates a fuzzy selection over the specified image. A
* fuzzy selection is determined by a seed fill under the constraints
* of the specified threshold. Essentially, the color at the specified
* coordinates (in the drawable) is measured and the selection expands
* outwards from that point to any adjacent pixels which are not
* significantly different (as determined by the threshold value). This
* process continues until no more expansion is possible. The
* antialiasing parameter allows the final selection mask to contain
* intermediate values based on close misses to the threshold bar at
* pixels along the seed fill boundary. Feathering can be enabled
* optionally and is controlled with the \"feather_radius\" paramter.
* If the sample_merged parameter is non-zero, the data of the
* composite image will be used instead of that for the specified
* drawable. This is equivalent to sampling for colors after merging
* all visible layers. In the case of a merged sampling, the supplied
* drawable is ignored. If the sample is merged, the specified
* coordinates are relative to the image origin; otherwise, they are
* relative to the drawable's origin.
*
* Returns: TRUE on success.
*/
gboolean
gimp_fuzzy_select (gint32 drawable_ID,
gdouble x,
gdouble y,
gint threshold,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius,
gboolean sample_merged)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_fuzzy_select",
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_FLOAT, x,
GIMP_PDB_FLOAT, y,
GIMP_PDB_INT32, threshold,
GIMP_PDB_INT32, operation,
GIMP_PDB_INT32, antialias,
GIMP_PDB_INT32, feather,
GIMP_PDB_FLOAT, feather_radius,
GIMP_PDB_INT32, sample_merged,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_paintbrush:
* @drawable_ID: The affected drawable.
@ -1161,61 +909,6 @@ gimp_perspective (gint32 drawable_ID,
return ret_drawable_ID;
}
/**
* gimp_rect_select:
* @image_ID: The image.
* @x: x coordinate of upper-left corner of rectangle.
* @y: y coordinate of upper-left corner of rectangle.
* @width: The width of the rectangle.
* @height: The height of the rectangle.
* @operation: The selection operation.
* @feather: Feather option for selections.
* @feather_radius: Radius for feather operation.
*
* Create a rectangular selection over the specified image;
*
* This tool creates a rectangular selection over the specified image.
* The rectangular region can be either added to, subtracted from, or
* replace the contents of the previous selection mask. If the feather
* option is enabled, the resulting selection is blurred before
* combining. The blur is a gaussian blur with the specified feather
* radius.
*
* Returns: TRUE on success.
*/
gboolean
gimp_rect_select (gint32 image_ID,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GimpChannelOps operation,
gboolean feather,
gdouble feather_radius)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_rect_select",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_FLOAT, x,
GIMP_PDB_FLOAT, y,
GIMP_PDB_FLOAT, width,
GIMP_PDB_FLOAT, height,
GIMP_PDB_INT32, operation,
GIMP_PDB_INT32, feather,
GIMP_PDB_FLOAT, feather_radius,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_rotate:
* @drawable_ID: The affected drawable.

View File

@ -60,14 +60,6 @@ gboolean gimp_bucket_fill (gint32 drawable_ID,
gboolean sample_merged,
gdouble x,
gdouble y);
gboolean gimp_by_color_select (gint32 drawable_ID,
GimpRGB *color,
gint threshold,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius,
gboolean sample_merged);
gboolean gimp_clone (gint32 drawable_ID,
gint32 src_drawable_ID,
GimpCloneType clone_type,
@ -104,15 +96,6 @@ gboolean gimp_dodgeburn (gint32 drawable_ID,
gboolean gimp_dodgeburn_default (gint32 drawable_ID,
gint num_strokes,
gdouble *strokes);
gboolean gimp_ellipse_select (gint32 image_ID,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius);
gboolean gimp_eraser (gint32 drawable_ID,
gint num_strokes,
gdouble *strokes,
@ -123,22 +106,6 @@ gboolean gimp_eraser_default (gint32 drawable_ID,
gdouble *strokes);
gint32 gimp_flip (gint32 drawable_ID,
GimpOrientationType flip_type);
gboolean gimp_free_select (gint32 image_ID,
gint num_segs,
gdouble *segs,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius);
gboolean gimp_fuzzy_select (gint32 drawable_ID,
gdouble x,
gdouble y,
gint threshold,
GimpChannelOps operation,
gboolean antialias,
gboolean feather,
gdouble feather_radius,
gboolean sample_merged);
gboolean gimp_paintbrush (gint32 drawable_ID,
gdouble fade_out,
gint num_strokes,
@ -161,14 +128,6 @@ gint32 gimp_perspective (gint32 drawable_ID,
gdouble y2,
gdouble x3,
gdouble y3);
gboolean gimp_rect_select (gint32 image_ID,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GimpChannelOps operation,
gboolean feather,
gdouble feather_radius);
gint32 gimp_rotate (gint32 drawable_ID,
gboolean interpolation,
gdouble angle);

View File

@ -67,6 +67,14 @@ style "gimp-dock-style" = "gimp-small-font-style"
widget "*Gimp*Dock*" style "gimp-dock-style"
style "gimp-grid-view-style" = "gimp-dock-style"
{
bg[NORMAL] = { 1.0, 1.0, 1.0 }
}
widget "*GimpContainerGridView*GtkViewport*" style "gimp-grid-view-style"
style "gimp-tooltips"
{
fg[NORMAL] = { 0.0, 0.0, 0.0 }

View File

@ -29,6 +29,7 @@ pdb_sources = \
pdb/plug_in.pdb \
pdb/procedural_db.pdb \
pdb/selection.pdb \
pdb/selection_tools.pdb \
pdb/text_tool.pdb \
pdb/tools.pdb \
pdb/undo.pdb \

View File

@ -27,6 +27,7 @@
plug_in
procedural_db
selection
selection_tools
text_tool
tools
undo

View File

@ -41,12 +41,6 @@ sub sample_merged_arg () {{
desc => 'Use the composite image, not the drawable'
}}
sub operation_arg () {{
name => 'operation',
type => 'enum ChannelOps',
desc => 'The selection operation: { %%desc%% }'
}}
sub threshold_arg () {{
name => 'threshold',
type => '0 <= int32 <= 255',
@ -249,55 +243,6 @@ CODE
);
}
sub by_color_select {
$blurb = <<'BLURB';
Create a selection by selecting all pixels (in the specified drawable) with the
same (or similar) color to that specified.
BLURB
$help = <<'HELP';
This tool creates a selection over the specified image. A by-color selection is
determined by the supplied color under the constraints of the specified
threshold. Essentially, all pixels (in the drawable) that have color
sufficiently close to the specified color (as determined by the threshold
value) are included in the selection. The antialiasing parameter allows the
final selection mask to contain intermediate values based on close misses to
the threshold bar. Feathering can be enabled optionally and is controlled with
the "feather_radius" parameter. If the sample_merged parameter is non-zero,
the data of the composite image will be used instead of that for the specified
drawable. This is equivalent to sampling for colors after merging all visible
layers. In the case of a merged sampling, the supplied drawable is ignored.
HELP
&std_pdb_misc;
@inargs = (
&drawable_arg,
{ name => 'color', type => 'color',
desc => 'The color to select' },
&threshold_arg,
&operation_arg,
&std_antialias_arg,
&feather_select_args,
&sample_merged_arg
);
%invoke = (
headers => [ qw("tools/gimpbycolorselecttool.h") ],
vars => [ 'GimpImage *gimage', 'guchar fixme[3]' ],
code => <<'CODE'
{
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
gimp_rgb_get_uchar (&color, fixme, fixme + 1, fixme + 2);
gimp_by_color_select_tool_select (gimage, drawable, fixme,
threshold, operation, antialias,
feather, feather_radius,
sample_merged);
}
CODE
);
}
sub clone {
$blurb = <<'BLURB';
Clone from the source to the dest drawable using the current brush
@ -495,46 +440,6 @@ CODE
);
}
sub ellipse_select {
$blurb = 'Create an elliptical selection over the specified image.';
$help = <<'HELP';
This tool creates an elliptical selection over the specified image. The
elliptical region can be either added to, subtracted from, or replace the
contents of the previous selection mask. If antialiasing is turned on, the
edges of the elliptical region will contain intermediate values which give the
appearance of a sharper, less pixelized edge. This should be set as TRUE most
of the time. If the feather option is enabled, the resulting selection is
blurred before combining. The blur is a gaussian blur with the specified
feather radius.
HELP
&std_pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'x', type => 'float',
desc => 'x coordinate of upper-left corner of ellipse bounding box' },
{ name => 'y', type => 'float',
desc => 'y coordinate of upper-left corner of ellipse bounding box' },
{ name => 'width', type => '0 < float',
desc => 'The width of the ellipse: %%desc%%' },
{ name => 'height', type => '0 < float',
desc => 'The height of the ellipse: %%desc%%' },
&operation_arg,
&std_antialias_arg,
&feather_select_args
);
%invoke = (
headers => [ qw("tools/gimpellipseselecttool.h") ],
code => <<'CODE'
ellipse_select (gimage, (int) x, (int) y, (int) width, (int) height,
operation, antialias, feather, feather_radius);
CODE
);
}
sub eraser_default {
$blurb = 'Erase using the current brush.';
@ -694,107 +599,6 @@ CODE
);
}
sub free_select {
$blurb = 'Create a polygonal selection over the specified image.';
$help = <<'HELP';
This tool creates a polygonal selection over the specified image. The polygonal
region can be either added to, subtracted from, or replace the contents of the
previous selection mask. The polygon is specified through an array of floating
point numbers and its length. The length of array must be 2n, where n is the
number of points. Each point is defined by 2 floating point values which
correspond to the x and y coordinates. If the final point does not connect to
the starting point, a connecting segment is automatically added. If the feather
option is enabled, the resulting selection is blurred before combining. The
blur is a gaussian blur with the specified feather radius.
HELP
&std_pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'segs', type => 'floatarray',
desc => 'Array of points: { p1.x, p1.y, p2.x, p2.y, ...,
pn.x, pn.y}',
array => { type => '2 <= int32', on_success => 'num_segs /= 2;',
desc => 'Number of points (count 1 coordinate as two
points)' } },
&operation_arg,
&std_antialias_arg,
&feather_select_args
);
%invoke = (
headers => [ qw("tools/gimpfreeselecttool.h") ],
code => <<'CODE'
free_select (gimage, num_segs, (GimpVector2 *) segs, operation,
antialias, feather, feather_radius);
CODE
);
}
sub fuzzy_select {
$blurb = <<'BLURB';
Create a fuzzy selection starting at the specified coordinates on the specified
drawable.
BLURB
$help = <<'HELP';
This tool creates a fuzzy selection over the specified image. A fuzzy selection
is determined by a seed fill under the constraints of the specified threshold.
Essentially, the color at the specified coordinates (in the drawable) is
measured and the selection expands outwards from that point to any adjacent
pixels which are not significantly different (as determined by the threshold
value). This process continues until no more expansion is possible. The
antialiasing parameter allows the final selection mask to contain intermediate
values based on close misses to the threshold bar at pixels along the seed fill
boundary. Feathering can be enabled optionally and is controlled with the
"feather_radius" paramter. If the sample_merged parameter is non-zero, the data
of the composite image will be used instead of that for the specified drawable.
This is equivalent to sampling for colors after merging all visible layers. In
the case of a merged sampling, the supplied drawable is ignored. If the sample
is merged, the specified coordinates are relative to the image origin;
otherwise, they are relative to the drawable's origin.
HELP
&std_pdb_misc;
@inargs = (
&drawable_arg,
{ name => 'x', type => 'float',
desc => 'x coordinate of initial seed fill point: (image
coordinates)' },
{ name => 'y', type => 'float',
desc => 'y coordinate of initial seed fill point: (image
coordinates)' },
&threshold_arg,
&operation_arg,
&std_antialias_arg,
&feather_select_args,
&sample_merged_arg
);
%invoke = (
headers => [ qw("tools/gimpfuzzyselecttool.h") ],
vars => [ 'GimpImage *gimage', 'GimpChannel *new, *old_fuzzy_mask' ],
code => <<'CODE'
{
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
new = find_contiguous_region (gimage, drawable, antialias, threshold,
x, y, sample_merged);
old_fuzzy_mask = fuzzy_mask;
fuzzy_mask = new;
drawable = sample_merged ? NULL : drawable;
fuzzy_select (gimage, drawable, operation, feather, feather_radius);
fuzzy_mask = old_fuzzy_mask;
}
CODE
);
}
sub paintbrush {
$blurb = <<'BLURB';
Paint in the current brush with optional fade out parameter and pull colors
@ -996,42 +800,6 @@ CODE
);
}
sub rect_select {
$blurb = 'Create a rectangular selection over the specified image;';
$help = <<'HELP';
This tool creates a rectangular selection over the specified image. The
rectangular region can be either added to, subtracted from, or replace the
contents of the previous selection mask. If the feather option is enabled, the
resulting selection is blurred before combining. The blur is a gaussian blur
with the specified feather radius.
HELP
&std_pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'x', type => 'float',
desc => 'x coordinate of upper-left corner of rectangle' },
{ name => 'y', type => 'float',
desc => 'y coordinate of upper-left corner of rectangle' },
{ name => 'width', type => '0 < float',
desc => 'The width of the rectangle: %%desc%%' },
{ name => 'height', type => '0 < float',
desc => 'The height of the rectangle: %%desc%%' },
&operation_arg,
&feather_select_args,
);
%invoke = (
headers => [ qw("tools/gimprectselecttool.h") ],
code => <<'CODE'
rect_select (gimage, (int) x, (int) y, (int) width, (int) height,
operation, feather, feather_radius);
CODE
);
}
sub rotate {
$blurb = <<'BLURB';
Rotate the specified drawable about its center through the specified angle.
@ -1261,11 +1029,12 @@ HELP
gimp_matrix3_xshear (matrix, magnitude / tile_manager_height (float_tiles));
else if (shear_type == ORIENTATION_VERTICAL)
gimp_matrix3_yshear (matrix, magnitude / tile_manager_width (float_tiles));
gimp_matrix3_translate (matrix, +cx, +cy);
/* Shear the buffer */
new_tiles = gimp_shear_tool_shear (gimage, drawable, NULL, float_tiles,
interpolation, matrix);
interpolation, matrix);
/* Free the cut/copied buffer */
tile_manager_destroy (float_tiles);
@ -1365,7 +1134,6 @@ CODE
);
}
sub smudge {
$blurb = <<'BLURB';
Smudge image with varying pressure.
@ -1462,7 +1230,7 @@ as used by the dialog will be used.
BLURB
$help = <<'HELP';
Dodgebure. More details here later.
Dodgeburn. More details here later.
HELP
&std_pdb_misc;
@ -1496,17 +1264,15 @@ sub ink {
);
}
@headers = qw("libgimpmath/gimpmath.h" "tools/tools-types.h"
"core/gimpdrawable.h" "base/tile-manager.h");
@headers = qw("libgimpmath/gimpmath.h" "core/gimpimage-mask-select.h"
"tools/tools-types.h" "core/gimpdrawable.h"
"base/tile-manager.h");
@procs = qw(airbrush airbrush_default blend bucket_fill by_color_select
clone clone_default color_picker
convolve convolve_default dodgeburn dodgeburn_default
ellipse_select eraser eraser_default
flip free_select fuzzy_select
paintbrush paintbrush_default
pencil perspective rect_select rotate scale shear
smudge smudge_default transform_2d);
@procs = qw(airbrush airbrush_default blend bucket_fill clone clone_default
color_picker convolve convolve_default dodgeburn dodgeburn_default
eraser eraser_default flip paintbrush paintbrush_default
pencil perspective rotate scale shear smudge smudge_default
transform_2d);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Tool procedures';

View File

@ -41,12 +41,6 @@ sub sample_merged_arg () {{
desc => 'Use the composite image, not the drawable'
}}
sub operation_arg () {{
name => 'operation',
type => 'enum ChannelOps',
desc => 'The selection operation: { %%desc%% }'
}}
sub threshold_arg () {{
name => 'threshold',
type => '0 <= int32 <= 255',
@ -249,55 +243,6 @@ CODE
);
}
sub by_color_select {
$blurb = <<'BLURB';
Create a selection by selecting all pixels (in the specified drawable) with the
same (or similar) color to that specified.
BLURB
$help = <<'HELP';
This tool creates a selection over the specified image. A by-color selection is
determined by the supplied color under the constraints of the specified
threshold. Essentially, all pixels (in the drawable) that have color
sufficiently close to the specified color (as determined by the threshold
value) are included in the selection. The antialiasing parameter allows the
final selection mask to contain intermediate values based on close misses to
the threshold bar. Feathering can be enabled optionally and is controlled with
the "feather_radius" parameter. If the sample_merged parameter is non-zero,
the data of the composite image will be used instead of that for the specified
drawable. This is equivalent to sampling for colors after merging all visible
layers. In the case of a merged sampling, the supplied drawable is ignored.
HELP
&std_pdb_misc;
@inargs = (
&drawable_arg,
{ name => 'color', type => 'color',
desc => 'The color to select' },
&threshold_arg,
&operation_arg,
&std_antialias_arg,
&feather_select_args,
&sample_merged_arg
);
%invoke = (
headers => [ qw("tools/gimpbycolorselecttool.h") ],
vars => [ 'GimpImage *gimage', 'guchar fixme[3]' ],
code => <<'CODE'
{
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
gimp_rgb_get_uchar (&color, fixme, fixme + 1, fixme + 2);
gimp_by_color_select_tool_select (gimage, drawable, fixme,
threshold, operation, antialias,
feather, feather_radius,
sample_merged);
}
CODE
);
}
sub clone {
$blurb = <<'BLURB';
Clone from the source to the dest drawable using the current brush
@ -495,46 +440,6 @@ CODE
);
}
sub ellipse_select {
$blurb = 'Create an elliptical selection over the specified image.';
$help = <<'HELP';
This tool creates an elliptical selection over the specified image. The
elliptical region can be either added to, subtracted from, or replace the
contents of the previous selection mask. If antialiasing is turned on, the
edges of the elliptical region will contain intermediate values which give the
appearance of a sharper, less pixelized edge. This should be set as TRUE most
of the time. If the feather option is enabled, the resulting selection is
blurred before combining. The blur is a gaussian blur with the specified
feather radius.
HELP
&std_pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'x', type => 'float',
desc => 'x coordinate of upper-left corner of ellipse bounding box' },
{ name => 'y', type => 'float',
desc => 'y coordinate of upper-left corner of ellipse bounding box' },
{ name => 'width', type => '0 < float',
desc => 'The width of the ellipse: %%desc%%' },
{ name => 'height', type => '0 < float',
desc => 'The height of the ellipse: %%desc%%' },
&operation_arg,
&std_antialias_arg,
&feather_select_args
);
%invoke = (
headers => [ qw("tools/gimpellipseselecttool.h") ],
code => <<'CODE'
ellipse_select (gimage, (int) x, (int) y, (int) width, (int) height,
operation, antialias, feather, feather_radius);
CODE
);
}
sub eraser_default {
$blurb = 'Erase using the current brush.';
@ -694,107 +599,6 @@ CODE
);
}
sub free_select {
$blurb = 'Create a polygonal selection over the specified image.';
$help = <<'HELP';
This tool creates a polygonal selection over the specified image. The polygonal
region can be either added to, subtracted from, or replace the contents of the
previous selection mask. The polygon is specified through an array of floating
point numbers and its length. The length of array must be 2n, where n is the
number of points. Each point is defined by 2 floating point values which
correspond to the x and y coordinates. If the final point does not connect to
the starting point, a connecting segment is automatically added. If the feather
option is enabled, the resulting selection is blurred before combining. The
blur is a gaussian blur with the specified feather radius.
HELP
&std_pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'segs', type => 'floatarray',
desc => 'Array of points: { p1.x, p1.y, p2.x, p2.y, ...,
pn.x, pn.y}',
array => { type => '2 <= int32', on_success => 'num_segs /= 2;',
desc => 'Number of points (count 1 coordinate as two
points)' } },
&operation_arg,
&std_antialias_arg,
&feather_select_args
);
%invoke = (
headers => [ qw("tools/gimpfreeselecttool.h") ],
code => <<'CODE'
free_select (gimage, num_segs, (GimpVector2 *) segs, operation,
antialias, feather, feather_radius);
CODE
);
}
sub fuzzy_select {
$blurb = <<'BLURB';
Create a fuzzy selection starting at the specified coordinates on the specified
drawable.
BLURB
$help = <<'HELP';
This tool creates a fuzzy selection over the specified image. A fuzzy selection
is determined by a seed fill under the constraints of the specified threshold.
Essentially, the color at the specified coordinates (in the drawable) is
measured and the selection expands outwards from that point to any adjacent
pixels which are not significantly different (as determined by the threshold
value). This process continues until no more expansion is possible. The
antialiasing parameter allows the final selection mask to contain intermediate
values based on close misses to the threshold bar at pixels along the seed fill
boundary. Feathering can be enabled optionally and is controlled with the
"feather_radius" paramter. If the sample_merged parameter is non-zero, the data
of the composite image will be used instead of that for the specified drawable.
This is equivalent to sampling for colors after merging all visible layers. In
the case of a merged sampling, the supplied drawable is ignored. If the sample
is merged, the specified coordinates are relative to the image origin;
otherwise, they are relative to the drawable's origin.
HELP
&std_pdb_misc;
@inargs = (
&drawable_arg,
{ name => 'x', type => 'float',
desc => 'x coordinate of initial seed fill point: (image
coordinates)' },
{ name => 'y', type => 'float',
desc => 'y coordinate of initial seed fill point: (image
coordinates)' },
&threshold_arg,
&operation_arg,
&std_antialias_arg,
&feather_select_args,
&sample_merged_arg
);
%invoke = (
headers => [ qw("tools/gimpfuzzyselecttool.h") ],
vars => [ 'GimpImage *gimage', 'GimpChannel *new, *old_fuzzy_mask' ],
code => <<'CODE'
{
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
new = find_contiguous_region (gimage, drawable, antialias, threshold,
x, y, sample_merged);
old_fuzzy_mask = fuzzy_mask;
fuzzy_mask = new;
drawable = sample_merged ? NULL : drawable;
fuzzy_select (gimage, drawable, operation, feather, feather_radius);
fuzzy_mask = old_fuzzy_mask;
}
CODE
);
}
sub paintbrush {
$blurb = <<'BLURB';
Paint in the current brush with optional fade out parameter and pull colors
@ -996,42 +800,6 @@ CODE
);
}
sub rect_select {
$blurb = 'Create a rectangular selection over the specified image;';
$help = <<'HELP';
This tool creates a rectangular selection over the specified image. The
rectangular region can be either added to, subtracted from, or replace the
contents of the previous selection mask. If the feather option is enabled, the
resulting selection is blurred before combining. The blur is a gaussian blur
with the specified feather radius.
HELP
&std_pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'x', type => 'float',
desc => 'x coordinate of upper-left corner of rectangle' },
{ name => 'y', type => 'float',
desc => 'y coordinate of upper-left corner of rectangle' },
{ name => 'width', type => '0 < float',
desc => 'The width of the rectangle: %%desc%%' },
{ name => 'height', type => '0 < float',
desc => 'The height of the rectangle: %%desc%%' },
&operation_arg,
&feather_select_args,
);
%invoke = (
headers => [ qw("tools/gimprectselecttool.h") ],
code => <<'CODE'
rect_select (gimage, (int) x, (int) y, (int) width, (int) height,
operation, feather, feather_radius);
CODE
);
}
sub rotate {
$blurb = <<'BLURB';
Rotate the specified drawable about its center through the specified angle.
@ -1261,11 +1029,12 @@ HELP
gimp_matrix3_xshear (matrix, magnitude / tile_manager_height (float_tiles));
else if (shear_type == ORIENTATION_VERTICAL)
gimp_matrix3_yshear (matrix, magnitude / tile_manager_width (float_tiles));
gimp_matrix3_translate (matrix, +cx, +cy);
/* Shear the buffer */
new_tiles = gimp_shear_tool_shear (gimage, drawable, NULL, float_tiles,
interpolation, matrix);
interpolation, matrix);
/* Free the cut/copied buffer */
tile_manager_destroy (float_tiles);
@ -1365,7 +1134,6 @@ CODE
);
}
sub smudge {
$blurb = <<'BLURB';
Smudge image with varying pressure.
@ -1462,7 +1230,7 @@ as used by the dialog will be used.
BLURB
$help = <<'HELP';
Dodgebure. More details here later.
Dodgeburn. More details here later.
HELP
&std_pdb_misc;
@ -1496,17 +1264,15 @@ sub ink {
);
}
@headers = qw("libgimpmath/gimpmath.h" "tools/tools-types.h"
"core/gimpdrawable.h" "base/tile-manager.h");
@headers = qw("libgimpmath/gimpmath.h" "core/gimpimage-mask-select.h"
"tools/tools-types.h" "core/gimpdrawable.h"
"base/tile-manager.h");
@procs = qw(airbrush airbrush_default blend bucket_fill by_color_select
clone clone_default color_picker
convolve convolve_default dodgeburn dodgeburn_default
ellipse_select eraser eraser_default
flip free_select fuzzy_select
paintbrush paintbrush_default
pencil perspective rect_select rotate scale shear
smudge smudge_default transform_2d);
@procs = qw(airbrush airbrush_default blend bucket_fill clone clone_default
color_picker convolve convolve_default dodgeburn dodgeburn_default
eraser eraser_default flip paintbrush paintbrush_default
pencil perspective rotate scale shear smudge smudge_default
transform_2d);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Tool procedures';

View File

@ -0,0 +1,316 @@
# 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
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
# Tools
# shortcuts
sub drawable_arg () {{
name => 'drawable',
type => 'drawable',
desc => 'The affected drawable',
}}
sub drawable_out_arg {
my $type = shift;
my $arg = &drawable_arg;
$arg->{desc} = "The $type drawable";
$arg->{no_declare} = 1;
$arg;
}
sub sample_merged_arg () {{
name => 'sample_merged',
type => 'boolean',
desc => 'Use the composite image, not the drawable'
}}
sub operation_arg () {{
name => 'operation',
type => 'enum ChannelOps',
desc => 'The selection operation: { %%desc%% }'
}}
sub threshold_arg () {{
name => 'threshold',
type => '0 <= int32 <= 255',
desc => 'Threshold in intensity levels %%desc%%'
}}
sub feather_select_args () {(
{ name => 'feather', type => 'boolean',
desc => 'Feather option for selections' },
{ name => 'feather_radius', type => 'float',
desc => 'Radius for feather operation' }
)}
# The defs
sub by_color_select {
$blurb = <<'BLURB';
Create a selection by selecting all pixels (in the specified drawable) with the
same (or similar) color to that specified.
BLURB
$help = <<'HELP';
This tool creates a selection over the specified image. A by-color selection is
determined by the supplied color under the constraints of the specified
threshold. Essentially, all pixels (in the drawable) that have color
sufficiently close to the specified color (as determined by the threshold
value) are included in the selection. The antialiasing parameter allows the
final selection mask to contain intermediate values based on close misses to
the threshold bar. Feathering can be enabled optionally and is controlled with
the "feather_radius" parameter. If the sample_merged parameter is non-zero,
the data of the composite image will be used instead of that for the specified
drawable. This is equivalent to sampling for colors after merging all visible
layers. In the case of a merged sampling, the supplied drawable is ignored.
HELP
&std_pdb_misc;
@inargs = (
&drawable_arg,
{ name => 'color', type => 'color',
desc => 'The color to select' },
&threshold_arg,
&operation_arg,
&std_antialias_arg,
&feather_select_args,
&sample_merged_arg
);
%invoke = (
vars => [ 'GimpImage *gimage' ],
code => <<'CODE'
{
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
gimp_image_mask_select_by_color (gimage, drawable,
sample_merged,
&color,
threshold,
operation, antialias,
feather,
feather_radius,
feather_radius);
}
CODE
);
}
sub ellipse_select {
$blurb = 'Create an elliptical selection over the specified image.';
$help = <<'HELP';
This tool creates an elliptical selection over the specified image. The
elliptical region can be either added to, subtracted from, or replace the
contents of the previous selection mask. If antialiasing is turned on, the
edges of the elliptical region will contain intermediate values which give the
appearance of a sharper, less pixelized edge. This should be set as TRUE most
of the time. If the feather option is enabled, the resulting selection is
blurred before combining. The blur is a gaussian blur with the specified
feather radius.
HELP
&std_pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'x', type => 'float',
desc => 'x coordinate of upper-left corner of ellipse bounding box' },
{ name => 'y', type => 'float',
desc => 'y coordinate of upper-left corner of ellipse bounding box' },
{ name => 'width', type => '0 < float',
desc => 'The width of the ellipse: %%desc%%' },
{ name => 'height', type => '0 < float',
desc => 'The height of the ellipse: %%desc%%' },
&operation_arg,
&std_antialias_arg,
&feather_select_args
);
%invoke = (
code => <<'CODE'
gimp_image_mask_select_ellipse (gimage,
(gint) x, (gint) y,
(gint) width, (gint) height,
operation,
antialias,
feather,
feather_radius,
feather_radius);
CODE
);
}
sub free_select {
$blurb = 'Create a polygonal selection over the specified image.';
$help = <<'HELP';
This tool creates a polygonal selection over the specified image. The polygonal
region can be either added to, subtracted from, or replace the contents of the
previous selection mask. The polygon is specified through an array of floating
point numbers and its length. The length of array must be 2n, where n is the
number of points. Each point is defined by 2 floating point values which
correspond to the x and y coordinates. If the final point does not connect to
the starting point, a connecting segment is automatically added. If the feather
option is enabled, the resulting selection is blurred before combining. The
blur is a gaussian blur with the specified feather radius.
HELP
&std_pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'segs', type => 'floatarray',
desc => 'Array of points: { p1.x, p1.y, p2.x, p2.y, ...,
pn.x, pn.y}',
array => { type => '2 <= int32', on_success => 'num_segs /= 2;',
desc => 'Number of points (count 1 coordinate as two
points)' } },
&operation_arg,
&std_antialias_arg,
&feather_select_args
);
%invoke = (
code => <<'CODE'
gimp_image_mask_select_polygon (gimage,
num_segs,
(GimpVector2 *) segs,
operation,
antialias,
feather,
feather_radius,
feather_radius);
CODE
);
}
sub fuzzy_select {
$blurb = <<'BLURB';
Create a fuzzy selection starting at the specified coordinates on the specified
drawable.
BLURB
$help = <<'HELP';
This tool creates a fuzzy selection over the specified image. A fuzzy selection
is determined by a seed fill under the constraints of the specified threshold.
Essentially, the color at the specified coordinates (in the drawable) is
measured and the selection expands outwards from that point to any adjacent
pixels which are not significantly different (as determined by the threshold
value). This process continues until no more expansion is possible. The
antialiasing parameter allows the final selection mask to contain intermediate
values based on close misses to the threshold bar at pixels along the seed fill
boundary. Feathering can be enabled optionally and is controlled with the
"feather_radius" paramter. If the sample_merged parameter is non-zero, the data
of the composite image will be used instead of that for the specified drawable.
This is equivalent to sampling for colors after merging all visible layers. In
the case of a merged sampling, the supplied drawable is ignored. If the sample
is merged, the specified coordinates are relative to the image origin;
otherwise, they are relative to the drawable's origin.
HELP
&std_pdb_misc;
@inargs = (
&drawable_arg,
{ name => 'x', type => 'float',
desc => 'x coordinate of initial seed fill point: (image
coordinates)' },
{ name => 'y', type => 'float',
desc => 'y coordinate of initial seed fill point: (image
coordinates)' },
&threshold_arg,
&operation_arg,
&std_antialias_arg,
&feather_select_args,
&sample_merged_arg
);
%invoke = (
vars => [ 'GimpImage *gimage' ],
code => <<'CODE'
{
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
gimp_image_mask_select_fuzzy (gimage,
drawable,
sample_merged,
x, y,
threshold,
operation,
antialias,
feather,
feather_radius,
feather_radius);
}
CODE
);
}
sub rect_select {
$blurb = 'Create a rectangular selection over the specified image;';
$help = <<'HELP';
This tool creates a rectangular selection over the specified image. The
rectangular region can be either added to, subtracted from, or replace the
contents of the previous selection mask. If the feather option is enabled, the
resulting selection is blurred before combining. The blur is a gaussian blur
with the specified feather radius.
HELP
&std_pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'x', type => 'float',
desc => 'x coordinate of upper-left corner of rectangle' },
{ name => 'y', type => 'float',
desc => 'y coordinate of upper-left corner of rectangle' },
{ name => 'width', type => '0 < float',
desc => 'The width of the rectangle: %%desc%%' },
{ name => 'height', type => '0 < float',
desc => 'The height of the rectangle: %%desc%%' },
&operation_arg,
&feather_select_args,
);
%invoke = (
code => <<'CODE'
gimp_image_mask_select_rectangle (gimage,
(gint) x, (gint) y,
(gint) width, (gint) height,
operation,
feather,
feather_radius,
feather_radius);
CODE
);
}
@headers = qw("core/gimpimage-mask-select.h");
@procs = qw(by_color_select ellipse_select free_select fuzzy_select
rect_select);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Selection Tool procedures';
1;

View File

@ -245,7 +245,7 @@ HELP
);
}
@headers = qw("appenv.h" "tools/tools-types.h" "tools/gimptexttool.h"
@headers = qw("tools/tools-types.h" "tools/gimptexttool.h"
"libgimpbase/gimpbase.h" <stdio.h> <string.h>);
$extra{app}->{code} = <<'CODE';

View File

@ -41,12 +41,6 @@ sub sample_merged_arg () {{
desc => 'Use the composite image, not the drawable'
}}
sub operation_arg () {{
name => 'operation',
type => 'enum ChannelOps',
desc => 'The selection operation: { %%desc%% }'
}}
sub threshold_arg () {{
name => 'threshold',
type => '0 <= int32 <= 255',
@ -249,55 +243,6 @@ CODE
);
}
sub by_color_select {
$blurb = <<'BLURB';
Create a selection by selecting all pixels (in the specified drawable) with the
same (or similar) color to that specified.
BLURB
$help = <<'HELP';
This tool creates a selection over the specified image. A by-color selection is
determined by the supplied color under the constraints of the specified
threshold. Essentially, all pixels (in the drawable) that have color
sufficiently close to the specified color (as determined by the threshold
value) are included in the selection. The antialiasing parameter allows the
final selection mask to contain intermediate values based on close misses to
the threshold bar. Feathering can be enabled optionally and is controlled with
the "feather_radius" parameter. If the sample_merged parameter is non-zero,
the data of the composite image will be used instead of that for the specified
drawable. This is equivalent to sampling for colors after merging all visible
layers. In the case of a merged sampling, the supplied drawable is ignored.
HELP
&std_pdb_misc;
@inargs = (
&drawable_arg,
{ name => 'color', type => 'color',
desc => 'The color to select' },
&threshold_arg,
&operation_arg,
&std_antialias_arg,
&feather_select_args,
&sample_merged_arg
);
%invoke = (
headers => [ qw("tools/gimpbycolorselecttool.h") ],
vars => [ 'GimpImage *gimage', 'guchar fixme[3]' ],
code => <<'CODE'
{
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
gimp_rgb_get_uchar (&color, fixme, fixme + 1, fixme + 2);
gimp_by_color_select_tool_select (gimage, drawable, fixme,
threshold, operation, antialias,
feather, feather_radius,
sample_merged);
}
CODE
);
}
sub clone {
$blurb = <<'BLURB';
Clone from the source to the dest drawable using the current brush
@ -495,46 +440,6 @@ CODE
);
}
sub ellipse_select {
$blurb = 'Create an elliptical selection over the specified image.';
$help = <<'HELP';
This tool creates an elliptical selection over the specified image. The
elliptical region can be either added to, subtracted from, or replace the
contents of the previous selection mask. If antialiasing is turned on, the
edges of the elliptical region will contain intermediate values which give the
appearance of a sharper, less pixelized edge. This should be set as TRUE most
of the time. If the feather option is enabled, the resulting selection is
blurred before combining. The blur is a gaussian blur with the specified
feather radius.
HELP
&std_pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'x', type => 'float',
desc => 'x coordinate of upper-left corner of ellipse bounding box' },
{ name => 'y', type => 'float',
desc => 'y coordinate of upper-left corner of ellipse bounding box' },
{ name => 'width', type => '0 < float',
desc => 'The width of the ellipse: %%desc%%' },
{ name => 'height', type => '0 < float',
desc => 'The height of the ellipse: %%desc%%' },
&operation_arg,
&std_antialias_arg,
&feather_select_args
);
%invoke = (
headers => [ qw("tools/gimpellipseselecttool.h") ],
code => <<'CODE'
ellipse_select (gimage, (int) x, (int) y, (int) width, (int) height,
operation, antialias, feather, feather_radius);
CODE
);
}
sub eraser_default {
$blurb = 'Erase using the current brush.';
@ -694,107 +599,6 @@ CODE
);
}
sub free_select {
$blurb = 'Create a polygonal selection over the specified image.';
$help = <<'HELP';
This tool creates a polygonal selection over the specified image. The polygonal
region can be either added to, subtracted from, or replace the contents of the
previous selection mask. The polygon is specified through an array of floating
point numbers and its length. The length of array must be 2n, where n is the
number of points. Each point is defined by 2 floating point values which
correspond to the x and y coordinates. If the final point does not connect to
the starting point, a connecting segment is automatically added. If the feather
option is enabled, the resulting selection is blurred before combining. The
blur is a gaussian blur with the specified feather radius.
HELP
&std_pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'segs', type => 'floatarray',
desc => 'Array of points: { p1.x, p1.y, p2.x, p2.y, ...,
pn.x, pn.y}',
array => { type => '2 <= int32', on_success => 'num_segs /= 2;',
desc => 'Number of points (count 1 coordinate as two
points)' } },
&operation_arg,
&std_antialias_arg,
&feather_select_args
);
%invoke = (
headers => [ qw("tools/gimpfreeselecttool.h") ],
code => <<'CODE'
free_select (gimage, num_segs, (GimpVector2 *) segs, operation,
antialias, feather, feather_radius);
CODE
);
}
sub fuzzy_select {
$blurb = <<'BLURB';
Create a fuzzy selection starting at the specified coordinates on the specified
drawable.
BLURB
$help = <<'HELP';
This tool creates a fuzzy selection over the specified image. A fuzzy selection
is determined by a seed fill under the constraints of the specified threshold.
Essentially, the color at the specified coordinates (in the drawable) is
measured and the selection expands outwards from that point to any adjacent
pixels which are not significantly different (as determined by the threshold
value). This process continues until no more expansion is possible. The
antialiasing parameter allows the final selection mask to contain intermediate
values based on close misses to the threshold bar at pixels along the seed fill
boundary. Feathering can be enabled optionally and is controlled with the
"feather_radius" paramter. If the sample_merged parameter is non-zero, the data
of the composite image will be used instead of that for the specified drawable.
This is equivalent to sampling for colors after merging all visible layers. In
the case of a merged sampling, the supplied drawable is ignored. If the sample
is merged, the specified coordinates are relative to the image origin;
otherwise, they are relative to the drawable's origin.
HELP
&std_pdb_misc;
@inargs = (
&drawable_arg,
{ name => 'x', type => 'float',
desc => 'x coordinate of initial seed fill point: (image
coordinates)' },
{ name => 'y', type => 'float',
desc => 'y coordinate of initial seed fill point: (image
coordinates)' },
&threshold_arg,
&operation_arg,
&std_antialias_arg,
&feather_select_args,
&sample_merged_arg
);
%invoke = (
headers => [ qw("tools/gimpfuzzyselecttool.h") ],
vars => [ 'GimpImage *gimage', 'GimpChannel *new, *old_fuzzy_mask' ],
code => <<'CODE'
{
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
new = find_contiguous_region (gimage, drawable, antialias, threshold,
x, y, sample_merged);
old_fuzzy_mask = fuzzy_mask;
fuzzy_mask = new;
drawable = sample_merged ? NULL : drawable;
fuzzy_select (gimage, drawable, operation, feather, feather_radius);
fuzzy_mask = old_fuzzy_mask;
}
CODE
);
}
sub paintbrush {
$blurb = <<'BLURB';
Paint in the current brush with optional fade out parameter and pull colors
@ -996,42 +800,6 @@ CODE
);
}
sub rect_select {
$blurb = 'Create a rectangular selection over the specified image;';
$help = <<'HELP';
This tool creates a rectangular selection over the specified image. The
rectangular region can be either added to, subtracted from, or replace the
contents of the previous selection mask. If the feather option is enabled, the
resulting selection is blurred before combining. The blur is a gaussian blur
with the specified feather radius.
HELP
&std_pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'x', type => 'float',
desc => 'x coordinate of upper-left corner of rectangle' },
{ name => 'y', type => 'float',
desc => 'y coordinate of upper-left corner of rectangle' },
{ name => 'width', type => '0 < float',
desc => 'The width of the rectangle: %%desc%%' },
{ name => 'height', type => '0 < float',
desc => 'The height of the rectangle: %%desc%%' },
&operation_arg,
&feather_select_args,
);
%invoke = (
headers => [ qw("tools/gimprectselecttool.h") ],
code => <<'CODE'
rect_select (gimage, (int) x, (int) y, (int) width, (int) height,
operation, feather, feather_radius);
CODE
);
}
sub rotate {
$blurb = <<'BLURB';
Rotate the specified drawable about its center through the specified angle.
@ -1261,11 +1029,12 @@ HELP
gimp_matrix3_xshear (matrix, magnitude / tile_manager_height (float_tiles));
else if (shear_type == ORIENTATION_VERTICAL)
gimp_matrix3_yshear (matrix, magnitude / tile_manager_width (float_tiles));
gimp_matrix3_translate (matrix, +cx, +cy);
/* Shear the buffer */
new_tiles = gimp_shear_tool_shear (gimage, drawable, NULL, float_tiles,
interpolation, matrix);
interpolation, matrix);
/* Free the cut/copied buffer */
tile_manager_destroy (float_tiles);
@ -1365,7 +1134,6 @@ CODE
);
}
sub smudge {
$blurb = <<'BLURB';
Smudge image with varying pressure.
@ -1462,7 +1230,7 @@ as used by the dialog will be used.
BLURB
$help = <<'HELP';
Dodgebure. More details here later.
Dodgeburn. More details here later.
HELP
&std_pdb_misc;
@ -1496,17 +1264,15 @@ sub ink {
);
}
@headers = qw("libgimpmath/gimpmath.h" "tools/tools-types.h"
"core/gimpdrawable.h" "base/tile-manager.h");
@headers = qw("libgimpmath/gimpmath.h" "core/gimpimage-mask-select.h"
"tools/tools-types.h" "core/gimpdrawable.h"
"base/tile-manager.h");
@procs = qw(airbrush airbrush_default blend bucket_fill by_color_select
clone clone_default color_picker
convolve convolve_default dodgeburn dodgeburn_default
ellipse_select eraser eraser_default
flip free_select fuzzy_select
paintbrush paintbrush_default
pencil perspective rect_select rotate scale shear
smudge smudge_default transform_2d);
@procs = qw(airbrush airbrush_default blend bucket_fill clone clone_default
color_picker convolve convolve_default dodgeburn dodgeburn_default
eraser eraser_default flip paintbrush paintbrush_default
pencil perspective rotate scale shear smudge smudge_default
transform_2d);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Tool procedures';

View File

@ -41,12 +41,6 @@ sub sample_merged_arg () {{
desc => 'Use the composite image, not the drawable'
}}
sub operation_arg () {{
name => 'operation',
type => 'enum ChannelOps',
desc => 'The selection operation: { %%desc%% }'
}}
sub threshold_arg () {{
name => 'threshold',
type => '0 <= int32 <= 255',
@ -249,55 +243,6 @@ CODE
);
}
sub by_color_select {
$blurb = <<'BLURB';
Create a selection by selecting all pixels (in the specified drawable) with the
same (or similar) color to that specified.
BLURB
$help = <<'HELP';
This tool creates a selection over the specified image. A by-color selection is
determined by the supplied color under the constraints of the specified
threshold. Essentially, all pixels (in the drawable) that have color
sufficiently close to the specified color (as determined by the threshold
value) are included in the selection. The antialiasing parameter allows the
final selection mask to contain intermediate values based on close misses to
the threshold bar. Feathering can be enabled optionally and is controlled with
the "feather_radius" parameter. If the sample_merged parameter is non-zero,
the data of the composite image will be used instead of that for the specified
drawable. This is equivalent to sampling for colors after merging all visible
layers. In the case of a merged sampling, the supplied drawable is ignored.
HELP
&std_pdb_misc;
@inargs = (
&drawable_arg,
{ name => 'color', type => 'color',
desc => 'The color to select' },
&threshold_arg,
&operation_arg,
&std_antialias_arg,
&feather_select_args,
&sample_merged_arg
);
%invoke = (
headers => [ qw("tools/gimpbycolorselecttool.h") ],
vars => [ 'GimpImage *gimage', 'guchar fixme[3]' ],
code => <<'CODE'
{
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
gimp_rgb_get_uchar (&color, fixme, fixme + 1, fixme + 2);
gimp_by_color_select_tool_select (gimage, drawable, fixme,
threshold, operation, antialias,
feather, feather_radius,
sample_merged);
}
CODE
);
}
sub clone {
$blurb = <<'BLURB';
Clone from the source to the dest drawable using the current brush
@ -495,46 +440,6 @@ CODE
);
}
sub ellipse_select {
$blurb = 'Create an elliptical selection over the specified image.';
$help = <<'HELP';
This tool creates an elliptical selection over the specified image. The
elliptical region can be either added to, subtracted from, or replace the
contents of the previous selection mask. If antialiasing is turned on, the
edges of the elliptical region will contain intermediate values which give the
appearance of a sharper, less pixelized edge. This should be set as TRUE most
of the time. If the feather option is enabled, the resulting selection is
blurred before combining. The blur is a gaussian blur with the specified
feather radius.
HELP
&std_pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'x', type => 'float',
desc => 'x coordinate of upper-left corner of ellipse bounding box' },
{ name => 'y', type => 'float',
desc => 'y coordinate of upper-left corner of ellipse bounding box' },
{ name => 'width', type => '0 < float',
desc => 'The width of the ellipse: %%desc%%' },
{ name => 'height', type => '0 < float',
desc => 'The height of the ellipse: %%desc%%' },
&operation_arg,
&std_antialias_arg,
&feather_select_args
);
%invoke = (
headers => [ qw("tools/gimpellipseselecttool.h") ],
code => <<'CODE'
ellipse_select (gimage, (int) x, (int) y, (int) width, (int) height,
operation, antialias, feather, feather_radius);
CODE
);
}
sub eraser_default {
$blurb = 'Erase using the current brush.';
@ -694,107 +599,6 @@ CODE
);
}
sub free_select {
$blurb = 'Create a polygonal selection over the specified image.';
$help = <<'HELP';
This tool creates a polygonal selection over the specified image. The polygonal
region can be either added to, subtracted from, or replace the contents of the
previous selection mask. The polygon is specified through an array of floating
point numbers and its length. The length of array must be 2n, where n is the
number of points. Each point is defined by 2 floating point values which
correspond to the x and y coordinates. If the final point does not connect to
the starting point, a connecting segment is automatically added. If the feather
option is enabled, the resulting selection is blurred before combining. The
blur is a gaussian blur with the specified feather radius.
HELP
&std_pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'segs', type => 'floatarray',
desc => 'Array of points: { p1.x, p1.y, p2.x, p2.y, ...,
pn.x, pn.y}',
array => { type => '2 <= int32', on_success => 'num_segs /= 2;',
desc => 'Number of points (count 1 coordinate as two
points)' } },
&operation_arg,
&std_antialias_arg,
&feather_select_args
);
%invoke = (
headers => [ qw("tools/gimpfreeselecttool.h") ],
code => <<'CODE'
free_select (gimage, num_segs, (GimpVector2 *) segs, operation,
antialias, feather, feather_radius);
CODE
);
}
sub fuzzy_select {
$blurb = <<'BLURB';
Create a fuzzy selection starting at the specified coordinates on the specified
drawable.
BLURB
$help = <<'HELP';
This tool creates a fuzzy selection over the specified image. A fuzzy selection
is determined by a seed fill under the constraints of the specified threshold.
Essentially, the color at the specified coordinates (in the drawable) is
measured and the selection expands outwards from that point to any adjacent
pixels which are not significantly different (as determined by the threshold
value). This process continues until no more expansion is possible. The
antialiasing parameter allows the final selection mask to contain intermediate
values based on close misses to the threshold bar at pixels along the seed fill
boundary. Feathering can be enabled optionally and is controlled with the
"feather_radius" paramter. If the sample_merged parameter is non-zero, the data
of the composite image will be used instead of that for the specified drawable.
This is equivalent to sampling for colors after merging all visible layers. In
the case of a merged sampling, the supplied drawable is ignored. If the sample
is merged, the specified coordinates are relative to the image origin;
otherwise, they are relative to the drawable's origin.
HELP
&std_pdb_misc;
@inargs = (
&drawable_arg,
{ name => 'x', type => 'float',
desc => 'x coordinate of initial seed fill point: (image
coordinates)' },
{ name => 'y', type => 'float',
desc => 'y coordinate of initial seed fill point: (image
coordinates)' },
&threshold_arg,
&operation_arg,
&std_antialias_arg,
&feather_select_args,
&sample_merged_arg
);
%invoke = (
headers => [ qw("tools/gimpfuzzyselecttool.h") ],
vars => [ 'GimpImage *gimage', 'GimpChannel *new, *old_fuzzy_mask' ],
code => <<'CODE'
{
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
new = find_contiguous_region (gimage, drawable, antialias, threshold,
x, y, sample_merged);
old_fuzzy_mask = fuzzy_mask;
fuzzy_mask = new;
drawable = sample_merged ? NULL : drawable;
fuzzy_select (gimage, drawable, operation, feather, feather_radius);
fuzzy_mask = old_fuzzy_mask;
}
CODE
);
}
sub paintbrush {
$blurb = <<'BLURB';
Paint in the current brush with optional fade out parameter and pull colors
@ -996,42 +800,6 @@ CODE
);
}
sub rect_select {
$blurb = 'Create a rectangular selection over the specified image;';
$help = <<'HELP';
This tool creates a rectangular selection over the specified image. The
rectangular region can be either added to, subtracted from, or replace the
contents of the previous selection mask. If the feather option is enabled, the
resulting selection is blurred before combining. The blur is a gaussian blur
with the specified feather radius.
HELP
&std_pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'x', type => 'float',
desc => 'x coordinate of upper-left corner of rectangle' },
{ name => 'y', type => 'float',
desc => 'y coordinate of upper-left corner of rectangle' },
{ name => 'width', type => '0 < float',
desc => 'The width of the rectangle: %%desc%%' },
{ name => 'height', type => '0 < float',
desc => 'The height of the rectangle: %%desc%%' },
&operation_arg,
&feather_select_args,
);
%invoke = (
headers => [ qw("tools/gimprectselecttool.h") ],
code => <<'CODE'
rect_select (gimage, (int) x, (int) y, (int) width, (int) height,
operation, feather, feather_radius);
CODE
);
}
sub rotate {
$blurb = <<'BLURB';
Rotate the specified drawable about its center through the specified angle.
@ -1261,11 +1029,12 @@ HELP
gimp_matrix3_xshear (matrix, magnitude / tile_manager_height (float_tiles));
else if (shear_type == ORIENTATION_VERTICAL)
gimp_matrix3_yshear (matrix, magnitude / tile_manager_width (float_tiles));
gimp_matrix3_translate (matrix, +cx, +cy);
/* Shear the buffer */
new_tiles = gimp_shear_tool_shear (gimage, drawable, NULL, float_tiles,
interpolation, matrix);
interpolation, matrix);
/* Free the cut/copied buffer */
tile_manager_destroy (float_tiles);
@ -1365,7 +1134,6 @@ CODE
);
}
sub smudge {
$blurb = <<'BLURB';
Smudge image with varying pressure.
@ -1462,7 +1230,7 @@ as used by the dialog will be used.
BLURB
$help = <<'HELP';
Dodgebure. More details here later.
Dodgeburn. More details here later.
HELP
&std_pdb_misc;
@ -1496,17 +1264,15 @@ sub ink {
);
}
@headers = qw("libgimpmath/gimpmath.h" "tools/tools-types.h"
"core/gimpdrawable.h" "base/tile-manager.h");
@headers = qw("libgimpmath/gimpmath.h" "core/gimpimage-mask-select.h"
"tools/tools-types.h" "core/gimpdrawable.h"
"base/tile-manager.h");
@procs = qw(airbrush airbrush_default blend bucket_fill by_color_select
clone clone_default color_picker
convolve convolve_default dodgeburn dodgeburn_default
ellipse_select eraser eraser_default
flip free_select fuzzy_select
paintbrush paintbrush_default
pencil perspective rect_select rotate scale shear
smudge smudge_default transform_2d);
@procs = qw(airbrush airbrush_default blend bucket_fill clone clone_default
color_picker convolve convolve_default dodgeburn dodgeburn_default
eraser eraser_default flip paintbrush paintbrush_default
pencil perspective rotate scale shear smudge smudge_default
transform_2d);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Tool procedures';