2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-10-22 20:13:44 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-10-22 20:13:44 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-10-22 20:13:44 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2001-10-22 20:13:44 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2001-10-29 20:51:21 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2011-04-28 21:50:39 +08:00
|
|
|
#include <cairo.h>
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2012-05-03 09:36:22 +08:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2001-10-22 20:13:44 +08:00
|
|
|
|
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2012-04-27 20:23:19 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-10-22 20:13:44 +08:00
|
|
|
|
|
|
|
#include "core-types.h"
|
|
|
|
|
2012-04-27 20:23:19 +08:00
|
|
|
#include "gegl/gimp-babl.h"
|
|
|
|
|
2001-10-22 20:13:44 +08:00
|
|
|
#include "gimpchannel.h"
|
|
|
|
#include "gimpimage.h"
|
|
|
|
#include "gimpimage-contiguous-region.h"
|
2004-07-14 07:04:05 +08:00
|
|
|
#include "gimppickable.h"
|
2001-10-22 20:13:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
|
2012-04-27 20:23:19 +08:00
|
|
|
static gfloat pixel_difference (const gfloat *col1,
|
|
|
|
const gfloat *col2,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gboolean antialias,
|
2012-04-27 20:23:19 +08:00
|
|
|
gfloat threshold,
|
|
|
|
gint n_components,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gboolean has_alpha,
|
|
|
|
gboolean select_transparent,
|
|
|
|
GimpSelectCriterion select_criterion);
|
2012-04-27 20:23:19 +08:00
|
|
|
static gboolean find_contiguous_segment (const gfloat *col,
|
2012-04-18 01:56:13 +08:00
|
|
|
GeglBuffer *src_buffer,
|
|
|
|
GeglBuffer *mask_buffer,
|
|
|
|
const Babl *src_format,
|
2012-04-27 20:23:19 +08:00
|
|
|
gint n_components,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gboolean has_alpha,
|
2012-04-18 01:56:13 +08:00
|
|
|
gint width,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gboolean select_transparent,
|
|
|
|
GimpSelectCriterion select_criterion,
|
|
|
|
gboolean antialias,
|
2012-04-27 20:23:19 +08:00
|
|
|
gfloat threshold,
|
2012-04-18 01:56:13 +08:00
|
|
|
gint initial_x,
|
|
|
|
gint initial_y,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gint *start,
|
|
|
|
gint *end);
|
2012-04-18 01:56:13 +08:00
|
|
|
static void find_contiguous_region_helper (GeglBuffer *src_buffer,
|
|
|
|
GeglBuffer *mask_buffer,
|
|
|
|
const Babl *format,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gboolean select_transparent,
|
|
|
|
GimpSelectCriterion select_criterion,
|
|
|
|
gboolean antialias,
|
2012-04-27 20:23:19 +08:00
|
|
|
gfloat threshold,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2012-04-27 20:23:19 +08:00
|
|
|
const gfloat *col);
|
2001-10-22 20:13:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
GimpChannel *
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gimp_image_contiguous_region_by_seed (GimpImage *image,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
gboolean sample_merged,
|
|
|
|
gboolean antialias,
|
2012-04-27 20:23:19 +08:00
|
|
|
gfloat threshold,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gboolean select_transparent,
|
|
|
|
GimpSelectCriterion select_criterion,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
2001-10-22 20:13:44 +08:00
|
|
|
{
|
2012-04-18 01:56:13 +08:00
|
|
|
GimpPickable *pickable;
|
|
|
|
GeglBuffer *src_buffer;
|
|
|
|
GimpChannel *mask;
|
|
|
|
GeglBuffer *mask_buffer;
|
|
|
|
const Babl *src_format;
|
2012-04-27 20:23:19 +08:00
|
|
|
gfloat start_col[MAX_CHANNELS];
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
2001-10-22 20:13:44 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
|
|
|
if (sample_merged)
|
2010-02-04 04:46:09 +08:00
|
|
|
pickable = GIMP_PICKABLE (gimp_image_get_projection (image));
|
2004-07-14 07:04:05 +08:00
|
|
|
else
|
|
|
|
pickable = GIMP_PICKABLE (drawable);
|
2001-12-14 23:30:31 +08:00
|
|
|
|
2006-03-03 03:30:59 +08:00
|
|
|
gimp_pickable_flush (pickable);
|
|
|
|
|
2012-03-29 07:51:59 +08:00
|
|
|
src_format = gimp_pickable_get_format (pickable);
|
2012-04-18 01:56:13 +08:00
|
|
|
if (babl_format_is_palette (src_format))
|
2012-04-27 20:23:19 +08:00
|
|
|
src_format = babl_format ("RGBA float");
|
|
|
|
else
|
|
|
|
src_format = gimp_babl_format (gimp_babl_format_get_base_type (src_format),
|
|
|
|
GIMP_PRECISION_FLOAT,
|
|
|
|
babl_format_has_alpha (src_format));
|
2004-01-05 01:00:59 +08:00
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
src_buffer = gimp_pickable_get_buffer (pickable);
|
2002-02-10 23:18:08 +08:00
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
mask = gimp_channel_new_mask (image,
|
|
|
|
gegl_buffer_get_width (src_buffer),
|
|
|
|
gegl_buffer_get_height (src_buffer));
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
mask_buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (mask));
|
2012-03-29 07:51:59 +08:00
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
gegl_buffer_sample (src_buffer, x, y, NULL, start_col, src_format,
|
|
|
|
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
|
|
|
|
|
|
|
|
if (babl_format_has_alpha (src_format))
|
|
|
|
{
|
|
|
|
if (select_transparent)
|
2004-01-05 01:00:59 +08:00
|
|
|
{
|
2012-04-27 20:23:19 +08:00
|
|
|
gint n_components = babl_format_get_n_components (src_format);
|
2004-01-05 01:00:59 +08:00
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
/* don't select transparent regions if the start pixel isn't
|
|
|
|
* fully transparent
|
|
|
|
*/
|
2012-04-27 20:23:19 +08:00
|
|
|
if (start_col[n_components - 1] > 0)
|
2012-04-18 01:56:13 +08:00
|
|
|
select_transparent = FALSE;
|
2004-01-05 01:00:59 +08:00
|
|
|
}
|
2001-10-22 20:13:44 +08:00
|
|
|
}
|
2012-04-18 01:56:13 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
select_transparent = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
find_contiguous_region_helper (src_buffer, mask_buffer, src_format,
|
|
|
|
select_transparent, select_criterion,
|
|
|
|
antialias, threshold,
|
|
|
|
x, y, start_col);
|
2001-10-22 20:13:44 +08:00
|
|
|
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpChannel *
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gimp_image_contiguous_region_by_color (GimpImage *image,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
gboolean sample_merged,
|
|
|
|
gboolean antialias,
|
2012-04-27 20:23:19 +08:00
|
|
|
gfloat threshold,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gboolean select_transparent,
|
|
|
|
GimpSelectCriterion select_criterion,
|
|
|
|
const GimpRGB *color)
|
2001-10-22 20:13:44 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
/* Scan over the image's active layer, finding pixels within the
|
2005-02-16 08:38:20 +08:00
|
|
|
* specified threshold from the given R, G, & B values. If
|
|
|
|
* antialiasing is on, use the same antialiasing scheme as in
|
2006-03-29 01:08:36 +08:00
|
|
|
* fuzzy_select. Modify the image's mask to reflect the
|
2005-02-16 08:38:20 +08:00
|
|
|
* additional selection
|
2001-10-22 20:13:44 +08:00
|
|
|
*/
|
2012-03-29 07:17:42 +08:00
|
|
|
GeglBufferIterator *iter;
|
|
|
|
GimpPickable *pickable;
|
|
|
|
GimpChannel *mask;
|
|
|
|
GeglBuffer *src_buffer;
|
|
|
|
GeglBuffer *mask_buffer;
|
|
|
|
gint width, height;
|
|
|
|
gboolean has_alpha;
|
2012-04-27 20:23:19 +08:00
|
|
|
gfloat col[MAX_CHANNELS];
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
2001-10-22 20:13:44 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
g_return_val_if_fail (color != NULL, NULL);
|
|
|
|
|
2012-04-27 20:23:19 +08:00
|
|
|
gimp_rgba_get_pixel (color, babl_format ("RGBA float"), col);
|
2001-10-22 20:13:44 +08:00
|
|
|
|
|
|
|
if (sample_merged)
|
2010-02-04 04:46:09 +08:00
|
|
|
pickable = GIMP_PICKABLE (gimp_image_get_projection (image));
|
2001-10-22 20:13:44 +08:00
|
|
|
else
|
2004-07-14 07:04:05 +08:00
|
|
|
pickable = GIMP_PICKABLE (drawable);
|
|
|
|
|
2006-03-03 03:30:59 +08:00
|
|
|
gimp_pickable_flush (pickable);
|
|
|
|
|
2012-03-29 07:17:42 +08:00
|
|
|
has_alpha = babl_format_has_alpha (gimp_pickable_get_format (pickable));
|
2004-07-14 07:04:05 +08:00
|
|
|
|
2012-03-29 07:17:42 +08:00
|
|
|
src_buffer = gimp_pickable_get_buffer (pickable);
|
|
|
|
width = gegl_buffer_get_width (src_buffer);
|
|
|
|
height = gegl_buffer_get_height (src_buffer);
|
2004-07-14 07:04:05 +08:00
|
|
|
|
2012-03-29 07:17:42 +08:00
|
|
|
iter = gegl_buffer_iterator_new (src_buffer,
|
2012-04-27 20:23:19 +08:00
|
|
|
NULL, 0, babl_format ("RGBA float"),
|
2012-03-29 07:17:42 +08:00
|
|
|
GEGL_BUFFER_READ, GEGL_ABYSS_NONE);
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2012-03-29 07:17:42 +08:00
|
|
|
if (has_alpha)
|
2002-02-10 23:18:08 +08:00
|
|
|
{
|
|
|
|
if (select_transparent)
|
|
|
|
{
|
|
|
|
/* don't select transparancy if "color" isn't fully transparent
|
|
|
|
*/
|
2012-04-27 20:23:19 +08:00
|
|
|
if (col[3] > 0.0)
|
2002-02-10 23:18:08 +08:00
|
|
|
select_transparent = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
select_transparent = FALSE;
|
|
|
|
}
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
mask = gimp_channel_new_mask (image, width, height);
|
2001-12-14 23:30:31 +08:00
|
|
|
|
2012-03-29 07:17:42 +08:00
|
|
|
mask_buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (mask));
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2012-03-29 07:17:42 +08:00
|
|
|
gegl_buffer_iterator_add (iter, mask_buffer,
|
2012-04-27 20:23:19 +08:00
|
|
|
NULL, 0, babl_format ("Y float"),
|
2012-03-29 07:17:42 +08:00
|
|
|
GEGL_BUFFER_WRITE, GEGL_ABYSS_NONE);
|
2005-02-16 08:38:20 +08:00
|
|
|
|
2012-03-29 07:17:42 +08:00
|
|
|
while (gegl_buffer_iterator_next (iter))
|
2005-02-16 08:38:20 +08:00
|
|
|
{
|
2012-04-27 20:23:19 +08:00
|
|
|
const gfloat *src = iter->data[0];
|
|
|
|
gfloat *dest = iter->data[1];
|
2005-02-16 08:38:20 +08:00
|
|
|
|
2012-03-29 07:17:42 +08:00
|
|
|
while (iter->length--)
|
2005-02-16 08:38:20 +08:00
|
|
|
{
|
|
|
|
/* Find how closely the colors match */
|
2012-03-29 07:17:42 +08:00
|
|
|
*dest = pixel_difference (col, src,
|
|
|
|
antialias,
|
|
|
|
threshold,
|
|
|
|
has_alpha ? 4 : 3,
|
|
|
|
has_alpha,
|
|
|
|
select_transparent,
|
|
|
|
select_criterion);
|
|
|
|
|
|
|
|
src += 4;
|
|
|
|
dest += 1;
|
2005-02-16 08:38:20 +08:00
|
|
|
}
|
|
|
|
}
|
2012-03-29 07:17:42 +08:00
|
|
|
|
|
|
|
return mask;
|
2005-02-16 08:38:20 +08:00
|
|
|
}
|
|
|
|
|
2012-03-29 07:17:42 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2012-04-27 20:23:19 +08:00
|
|
|
static gfloat
|
|
|
|
pixel_difference (const gfloat *col1,
|
|
|
|
const gfloat *col2,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gboolean antialias,
|
2012-04-27 20:23:19 +08:00
|
|
|
gfloat threshold,
|
|
|
|
gint n_components,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gboolean has_alpha,
|
|
|
|
gboolean select_transparent,
|
|
|
|
GimpSelectCriterion select_criterion)
|
2001-10-22 20:13:44 +08:00
|
|
|
{
|
2012-04-27 20:23:19 +08:00
|
|
|
gfloat max = 0.0;
|
2001-10-22 20:13:44 +08:00
|
|
|
|
|
|
|
/* if there is an alpha channel, never select transparent regions */
|
2012-04-27 20:23:19 +08:00
|
|
|
if (! select_transparent && has_alpha && col2[n_components - 1] == 0.0)
|
|
|
|
return 0.0;
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2002-02-10 23:18:08 +08:00
|
|
|
if (select_transparent && has_alpha)
|
2001-10-22 20:13:44 +08:00
|
|
|
{
|
2012-04-27 20:23:19 +08:00
|
|
|
max = fabs (col1[n_components - 1] - col2[n_components - 1]);
|
2002-02-10 23:18:08 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-27 20:23:19 +08:00
|
|
|
gfloat diff;
|
|
|
|
gint b;
|
2002-03-04 03:31:18 +08:00
|
|
|
|
|
|
|
if (has_alpha)
|
2012-04-27 20:23:19 +08:00
|
|
|
n_components--;
|
2002-03-04 03:31:18 +08:00
|
|
|
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
switch (select_criterion)
|
2002-02-10 23:18:08 +08:00
|
|
|
{
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
case GIMP_SELECT_CRITERION_COMPOSITE:
|
2012-04-27 20:23:19 +08:00
|
|
|
for (b = 0; b < n_components; b++)
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
{
|
2012-04-27 20:23:19 +08:00
|
|
|
diff = fabs (col1[b] - col2[b]);
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
if (diff > max)
|
|
|
|
max = diff;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_SELECT_CRITERION_R:
|
2012-04-27 20:23:19 +08:00
|
|
|
max = fabs (col1[0] - col2[0]);
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_SELECT_CRITERION_G:
|
2012-04-27 20:23:19 +08:00
|
|
|
max = fabs (col1[1] - col2[1]);
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_SELECT_CRITERION_B:
|
2012-04-27 20:23:19 +08:00
|
|
|
max = fabs (col1[2] - col2[2]);
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
break;
|
|
|
|
|
2012-04-27 20:23:19 +08:00
|
|
|
#if 0
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
case GIMP_SELECT_CRITERION_H:
|
2008-12-05 04:58:50 +08:00
|
|
|
av0 = (gint) col1[0];
|
|
|
|
av1 = (gint) col1[1];
|
|
|
|
av2 = (gint) col1[2];
|
|
|
|
bv0 = (gint) col2[0];
|
|
|
|
bv1 = (gint) col2[1];
|
|
|
|
bv2 = (gint) col2[2];
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gimp_rgb_to_hsv_int (&av0, &av1, &av2);
|
|
|
|
gimp_rgb_to_hsv_int (&bv0, &bv1, &bv2);
|
2008-12-05 04:58:50 +08:00
|
|
|
/* wrap around candidates for the actual distance */
|
|
|
|
{
|
|
|
|
gint dist1 = abs (av0 - bv0);
|
|
|
|
gint dist2 = abs (av0 - 360 - bv0);
|
|
|
|
gint dist3 = abs (av0 - bv0 + 360);
|
|
|
|
max = MIN (dist1, dist2);
|
|
|
|
if (max > dist3)
|
|
|
|
max = dist3;
|
|
|
|
}
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_SELECT_CRITERION_S:
|
2008-12-05 04:58:50 +08:00
|
|
|
av0 = (gint) col1[0];
|
|
|
|
av1 = (gint) col1[1];
|
|
|
|
av2 = (gint) col1[2];
|
|
|
|
bv0 = (gint) col2[0];
|
|
|
|
bv1 = (gint) col2[1];
|
|
|
|
bv2 = (gint) col2[2];
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gimp_rgb_to_hsv_int (&av0, &av1, &av2);
|
|
|
|
gimp_rgb_to_hsv_int (&bv0, &bv1, &bv2);
|
|
|
|
max = abs (av1 - bv1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_SELECT_CRITERION_V:
|
2008-12-05 04:58:50 +08:00
|
|
|
av0 = (gint) col1[0];
|
|
|
|
av1 = (gint) col1[1];
|
|
|
|
av2 = (gint) col1[2];
|
|
|
|
bv0 = (gint) col2[0];
|
|
|
|
bv1 = (gint) col2[1];
|
|
|
|
bv2 = (gint) col2[2];
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gimp_rgb_to_hsv_int (&av0, &av1, &av2);
|
|
|
|
gimp_rgb_to_hsv_int (&bv0, &bv1, &bv2);
|
|
|
|
max = abs (av2 - bv2);
|
|
|
|
break;
|
2012-04-27 20:23:19 +08:00
|
|
|
#endif
|
2002-02-10 23:18:08 +08:00
|
|
|
}
|
2001-10-22 20:13:44 +08:00
|
|
|
}
|
|
|
|
|
2012-04-27 20:23:19 +08:00
|
|
|
if (antialias && threshold > 0.0)
|
2001-10-22 20:13:44 +08:00
|
|
|
{
|
2012-04-27 20:23:19 +08:00
|
|
|
gfloat aa = 1.5 - (max / threshold);
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2002-03-04 03:31:18 +08:00
|
|
|
if (aa <= 0.0)
|
2012-04-27 20:23:19 +08:00
|
|
|
return 0.0;
|
2001-10-22 20:13:44 +08:00
|
|
|
else if (aa < 0.5)
|
2012-04-27 20:23:19 +08:00
|
|
|
return aa * 2.0;
|
2001-10-22 20:13:44 +08:00
|
|
|
else
|
2012-04-27 20:23:19 +08:00
|
|
|
return 1.0;
|
2001-10-22 20:13:44 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (max > threshold)
|
2012-04-27 20:23:19 +08:00
|
|
|
return 0.0;
|
2001-10-22 20:13:44 +08:00
|
|
|
else
|
2012-04-27 20:23:19 +08:00
|
|
|
return 1.0;
|
2001-10-22 20:13:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-05 21:54:36 +08:00
|
|
|
static gboolean
|
2012-04-27 20:23:19 +08:00
|
|
|
find_contiguous_segment (const gfloat *col,
|
2012-04-18 01:56:13 +08:00
|
|
|
GeglBuffer *src_buffer,
|
|
|
|
GeglBuffer *mask_buffer,
|
|
|
|
const Babl *src_format,
|
2012-04-27 20:23:19 +08:00
|
|
|
gint n_components,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gboolean has_alpha,
|
2012-04-18 01:56:13 +08:00
|
|
|
gint width,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gboolean select_transparent,
|
|
|
|
GimpSelectCriterion select_criterion,
|
|
|
|
gboolean antialias,
|
2012-04-27 20:23:19 +08:00
|
|
|
gfloat threshold,
|
2012-04-18 01:56:13 +08:00
|
|
|
gint initial_x,
|
|
|
|
gint initial_y,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gint *start,
|
|
|
|
gint *end)
|
2001-10-22 20:13:44 +08:00
|
|
|
{
|
2012-04-27 20:23:19 +08:00
|
|
|
gfloat s[MAX_CHANNELS];
|
|
|
|
gfloat mask_row[width];
|
|
|
|
gfloat diff;
|
2004-01-05 01:00:59 +08:00
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
gegl_buffer_sample (src_buffer, initial_x, initial_y, NULL, s, src_format,
|
|
|
|
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
|
2004-01-05 01:00:59 +08:00
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
diff = pixel_difference (col, s, antialias, threshold,
|
2012-04-27 20:23:19 +08:00
|
|
|
n_components, has_alpha, select_transparent,
|
2012-04-18 01:56:13 +08:00
|
|
|
select_criterion);
|
2004-01-05 01:00:59 +08:00
|
|
|
|
2001-10-22 20:13:44 +08:00
|
|
|
/* check the starting pixel */
|
2004-01-05 01:00:59 +08:00
|
|
|
if (! diff)
|
2012-04-18 01:56:13 +08:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
mask_row[initial_x] = diff;
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
*start = initial_x - 1;
|
2001-10-22 20:13:44 +08:00
|
|
|
|
|
|
|
while (*start >= 0 && diff)
|
|
|
|
{
|
2012-04-18 01:56:13 +08:00
|
|
|
gegl_buffer_sample (src_buffer, *start, initial_y, NULL, s, src_format,
|
|
|
|
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
|
2002-03-04 03:31:18 +08:00
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
diff = pixel_difference (col, s, antialias, threshold,
|
2012-04-27 20:23:19 +08:00
|
|
|
n_components, has_alpha, select_transparent,
|
2012-04-18 01:56:13 +08:00
|
|
|
select_criterion);
|
2004-01-05 01:00:59 +08:00
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
mask_row[*start] = diff;
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
if (diff)
|
|
|
|
(*start)--;
|
2001-10-22 20:13:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
diff = 1;
|
2012-04-18 01:56:13 +08:00
|
|
|
*end = initial_x + 1;
|
2001-10-22 20:13:44 +08:00
|
|
|
|
|
|
|
while (*end < width && diff)
|
|
|
|
{
|
2012-04-18 01:56:13 +08:00
|
|
|
gegl_buffer_sample (src_buffer, *end, initial_y, NULL, s, src_format,
|
|
|
|
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
|
2002-03-04 03:31:18 +08:00
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
diff = pixel_difference (col, s, antialias, threshold,
|
2012-04-27 20:23:19 +08:00
|
|
|
n_components, has_alpha, select_transparent,
|
2012-04-18 01:56:13 +08:00
|
|
|
select_criterion);
|
2004-01-05 01:00:59 +08:00
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
mask_row[*end] = diff;
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
if (diff)
|
|
|
|
(*end)++;
|
2001-10-22 20:13:44 +08:00
|
|
|
}
|
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
gegl_buffer_set (mask_buffer, GEGL_RECTANGLE (*start, initial_y,
|
|
|
|
*end - *start, 1),
|
2012-04-27 20:23:19 +08:00
|
|
|
0, babl_format ("Y float"), &mask_row[*start],
|
2012-04-18 01:56:13 +08:00
|
|
|
GEGL_AUTO_ROWSTRIDE);
|
|
|
|
|
|
|
|
/* XXX this should now be needed and is a performance killer */
|
|
|
|
gegl_buffer_sample_cleanup (mask_buffer);
|
2001-10-22 20:13:44 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-18 01:56:13 +08:00
|
|
|
find_contiguous_region_helper (GeglBuffer *src_buffer,
|
|
|
|
GeglBuffer *mask_buffer,
|
|
|
|
const Babl *format,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gboolean select_transparent,
|
|
|
|
GimpSelectCriterion select_criterion,
|
|
|
|
gboolean antialias,
|
2012-04-27 20:23:19 +08:00
|
|
|
gfloat threshold,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2012-04-27 20:23:19 +08:00
|
|
|
const gfloat *col)
|
2001-10-22 20:13:44 +08:00
|
|
|
{
|
2007-09-13 02:29:11 +08:00
|
|
|
gint start, end;
|
|
|
|
gint new_start, new_end;
|
2004-08-28 19:48:00 +08:00
|
|
|
GQueue *coord_stack;
|
|
|
|
|
2008-10-05 21:54:36 +08:00
|
|
|
coord_stack = g_queue_new ();
|
2004-08-28 19:48:00 +08:00
|
|
|
|
|
|
|
/* To avoid excessive memory allocation (y, start, end) tuples are
|
|
|
|
* stored in interleaved format:
|
|
|
|
*
|
|
|
|
* [y1] [start1] [end1] [y2] [start2] [end2]
|
|
|
|
*/
|
|
|
|
g_queue_push_tail (coord_stack, GINT_TO_POINTER (y));
|
|
|
|
g_queue_push_tail (coord_stack, GINT_TO_POINTER (x - 1));
|
|
|
|
g_queue_push_tail (coord_stack, GINT_TO_POINTER (x + 1));
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2004-08-28 19:48:00 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
y = GPOINTER_TO_INT (g_queue_pop_head (coord_stack));
|
|
|
|
start = GPOINTER_TO_INT (g_queue_pop_head (coord_stack));
|
|
|
|
end = GPOINTER_TO_INT (g_queue_pop_head (coord_stack));
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2004-08-28 19:48:00 +08:00
|
|
|
for (x = start + 1; x < end; x++)
|
|
|
|
{
|
2012-04-27 20:23:19 +08:00
|
|
|
gfloat val;
|
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
gegl_buffer_sample (mask_buffer, x, y, NULL, &val,
|
2012-04-27 20:23:19 +08:00
|
|
|
babl_format ("Y float"),
|
2012-04-18 01:56:13 +08:00
|
|
|
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
|
2012-04-27 20:23:19 +08:00
|
|
|
if (val != 0.0)
|
2004-08-28 19:48:00 +08:00
|
|
|
continue;
|
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
if (! find_contiguous_segment (col, src_buffer, mask_buffer,
|
|
|
|
format,
|
2012-04-27 20:23:19 +08:00
|
|
|
babl_format_get_n_components (format),
|
2012-04-18 01:56:13 +08:00
|
|
|
babl_format_has_alpha (format),
|
|
|
|
gegl_buffer_get_width (src_buffer),
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
select_transparent, select_criterion,
|
2012-04-18 01:56:13 +08:00
|
|
|
antialias, threshold, x, y,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
&new_start, &new_end))
|
2006-04-12 20:49:29 +08:00
|
|
|
continue;
|
2004-08-28 19:48:00 +08:00
|
|
|
|
2012-04-18 01:56:13 +08:00
|
|
|
if (y + 1 < gegl_buffer_get_height (src_buffer))
|
2004-08-28 19:48:00 +08:00
|
|
|
{
|
|
|
|
g_queue_push_tail (coord_stack, GINT_TO_POINTER (y + 1));
|
|
|
|
g_queue_push_tail (coord_stack, GINT_TO_POINTER (new_start));
|
|
|
|
g_queue_push_tail (coord_stack, GINT_TO_POINTER (new_end));
|
|
|
|
}
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
if (y - 1 >= 0)
|
2004-08-28 19:48:00 +08:00
|
|
|
{
|
|
|
|
g_queue_push_tail (coord_stack, GINT_TO_POINTER (y - 1));
|
|
|
|
g_queue_push_tail (coord_stack, GINT_TO_POINTER (new_start));
|
|
|
|
g_queue_push_tail (coord_stack, GINT_TO_POINTER (new_end));
|
|
|
|
}
|
|
|
|
}
|
2001-10-22 20:13:44 +08:00
|
|
|
}
|
2008-10-05 21:54:36 +08:00
|
|
|
while (! g_queue_is_empty (coord_stack));
|
2004-08-28 19:48:00 +08:00
|
|
|
|
|
|
|
g_queue_free (coord_stack);
|
2001-10-22 20:13:44 +08:00
|
|
|
}
|