2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-10-22 12:13:44 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-10-22 12:13:44 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-10-22 12:13:44 +00: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
|
2018-07-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2001-10-22 12:13:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-05-23 14:09:55 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2011-04-10 22:42:39 +02:00
|
|
|
#include <cairo.h>
|
2013-10-15 01:58:39 +02:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2008-10-09 20:24:04 +00:00
|
|
|
#include <gegl.h>
|
2001-10-22 12:13:44 +00:00
|
|
|
|
2004-10-26 14:45:25 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2007-03-09 13:00:01 +00:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2003-08-21 15:54:47 +00:00
|
|
|
|
2001-10-22 12:13:44 +00:00
|
|
|
#include "core-types.h"
|
|
|
|
|
2013-04-08 22:52:26 +02:00
|
|
|
#include "gegl/gimp-gegl-apply-operation.h"
|
2015-08-26 01:06:34 +02:00
|
|
|
#include "gegl/gimp-gegl-loops.h"
|
2013-04-08 22:52:26 +02:00
|
|
|
#include "gegl/gimp-gegl-mask-combine.h"
|
|
|
|
|
2020-08-17 18:22:19 +02:00
|
|
|
#include "gimp.h"
|
2001-10-22 12:13:44 +00:00
|
|
|
#include "gimpchannel.h"
|
2003-10-06 12:17:11 +00:00
|
|
|
#include "gimpchannel-select.h"
|
2003-09-04 12:18:40 +00:00
|
|
|
#include "gimpchannel-combine.h"
|
2020-08-17 18:22:19 +02:00
|
|
|
#include "gimpcontainer.h"
|
|
|
|
#include "gimpimage.h"
|
|
|
|
#include "gimpimage-new.h"
|
2014-05-31 09:52:44 +02:00
|
|
|
#include "gimppickable.h"
|
|
|
|
#include "gimppickable-contiguous-region.h"
|
2001-10-22 12:13:44 +00:00
|
|
|
#include "gimpscanconvert.h"
|
|
|
|
|
2002-02-26 05:42:14 +00:00
|
|
|
#include "vectors/gimpstroke.h"
|
|
|
|
#include "vectors/gimpvectors.h"
|
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2003-02-14 14:14:29 +00:00
|
|
|
|
2001-10-22 12:13:44 +00:00
|
|
|
|
2003-10-09 11:30:49 +00:00
|
|
|
/* basic selection functions */
|
|
|
|
|
2001-10-22 12:13:44 +00:00
|
|
|
void
|
2003-10-06 12:17:11 +00:00
|
|
|
gimp_channel_select_rectangle (GimpChannel *channel,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h,
|
|
|
|
GimpChannelOps op,
|
|
|
|
gboolean feather,
|
|
|
|
gdouble feather_radius_x,
|
2006-08-25 17:19:36 +00:00
|
|
|
gdouble feather_radius_y,
|
|
|
|
gboolean push_undo)
|
2001-10-22 12:13:44 +00:00
|
|
|
{
|
2003-10-06 12:17:11 +00:00
|
|
|
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
2004-11-16 13:41:55 +00:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
|
2001-10-22 12:13:44 +00:00
|
|
|
|
2006-08-25 17:19:36 +00:00
|
|
|
if (push_undo)
|
2010-06-08 14:24:11 +03:00
|
|
|
gimp_channel_push_undo (channel, C_("undo-type", "Rectangle Select"));
|
2003-09-03 14:22:38 +00:00
|
|
|
|
2001-10-22 12:13:44 +00:00
|
|
|
/* if feathering for rect, make a new mask with the
|
|
|
|
* rectangle and feather that with the old mask
|
|
|
|
*/
|
app: improve gimpchannel-{combine,select}
In gimpchannel-select, move some of the common functionality of the
various gimp_channel_select_foo() functions to gimpchannel-combine.
Furthermore, don't special-case CHANNEL_OP_INTERSECT, but rather
pass it over to gimpchannel-combine, which is now prepared to
handle it in all functions, as per the previous commits.
In gimpchannel-combine, factor out the common functionality of the
various gimp_channel_combine_foo() functions into a pair of
gimp_channel_combine_{start,end}() functions, which are called
before/after the actual gimp_gegl_mask_combine_foo() function,
respectively. In particular, these functions deal with calculating
the new channel bounds. Previously, the various
gimp_gegl_mask_combine_foo() functions would implicitly invalidate
the channel bounds (since commit
d0ae244fe85a502446fe9c7b82afdf1b89498966), rendering the bounds-
recalculation code ineffective. This avoids manually recalculating
the bounds in many cases, speeding up selection operations.
2019-03-20 15:30:35 -04:00
|
|
|
if (feather)
|
2001-10-22 12:13:44 +00:00
|
|
|
{
|
2013-04-08 22:52:26 +02:00
|
|
|
GimpItem *item = GIMP_ITEM (channel);
|
|
|
|
GeglBuffer *add_on;
|
|
|
|
|
|
|
|
add_on = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
|
|
|
gimp_item_get_width (item),
|
|
|
|
gimp_item_get_height (item)),
|
|
|
|
babl_format ("Y float"));
|
2001-11-08 19:14:51 +00:00
|
|
|
|
app: improve gimpchannel-{combine,select}
In gimpchannel-select, move some of the common functionality of the
various gimp_channel_select_foo() functions to gimpchannel-combine.
Furthermore, don't special-case CHANNEL_OP_INTERSECT, but rather
pass it over to gimpchannel-combine, which is now prepared to
handle it in all functions, as per the previous commits.
In gimpchannel-combine, factor out the common functionality of the
various gimp_channel_combine_foo() functions into a pair of
gimp_channel_combine_{start,end}() functions, which are called
before/after the actual gimp_gegl_mask_combine_foo() function,
respectively. In particular, these functions deal with calculating
the new channel bounds. Previously, the various
gimp_gegl_mask_combine_foo() functions would implicitly invalidate
the channel bounds (since commit
d0ae244fe85a502446fe9c7b82afdf1b89498966), rendering the bounds-
recalculation code ineffective. This avoids manually recalculating
the bounds in many cases, speeding up selection operations.
2019-03-20 15:30:35 -04:00
|
|
|
gimp_gegl_mask_combine_rect (add_on, GIMP_CHANNEL_OP_REPLACE, x, y, w, h);
|
2001-11-08 19:14:51 +00:00
|
|
|
|
app: improve gimpchannel-{combine,select}
In gimpchannel-select, move some of the common functionality of the
various gimp_channel_select_foo() functions to gimpchannel-combine.
Furthermore, don't special-case CHANNEL_OP_INTERSECT, but rather
pass it over to gimpchannel-combine, which is now prepared to
handle it in all functions, as per the previous commits.
In gimpchannel-combine, factor out the common functionality of the
various gimp_channel_combine_foo() functions into a pair of
gimp_channel_combine_{start,end}() functions, which are called
before/after the actual gimp_gegl_mask_combine_foo() function,
respectively. In particular, these functions deal with calculating
the new channel bounds. Previously, the various
gimp_gegl_mask_combine_foo() functions would implicitly invalidate
the channel bounds (since commit
d0ae244fe85a502446fe9c7b82afdf1b89498966), rendering the bounds-
recalculation code ineffective. This avoids manually recalculating
the bounds in many cases, speeding up selection operations.
2019-03-20 15:30:35 -04:00
|
|
|
gimp_gegl_apply_feather (add_on, NULL, NULL, add_on, NULL,
|
|
|
|
feather_radius_x,
|
2019-06-16 17:06:08 +02:00
|
|
|
feather_radius_y,
|
|
|
|
TRUE);
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2013-04-08 22:52:26 +02:00
|
|
|
gimp_channel_combine_buffer (channel, add_on, op, 0, 0);
|
2003-10-06 12:17:11 +00:00
|
|
|
g_object_unref (add_on);
|
2001-10-22 12:13:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-10-06 12:17:11 +00:00
|
|
|
gimp_channel_combine_rect (channel, op, x, y, w, h);
|
2001-10-22 12:13:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-10-06 12:17:11 +00:00
|
|
|
gimp_channel_select_ellipse (GimpChannel *channel,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h,
|
|
|
|
GimpChannelOps op,
|
|
|
|
gboolean antialias,
|
|
|
|
gboolean feather,
|
|
|
|
gdouble feather_radius_x,
|
2006-08-25 17:19:36 +00:00
|
|
|
gdouble feather_radius_y,
|
|
|
|
gboolean push_undo)
|
2001-10-22 12:13:44 +00:00
|
|
|
{
|
2003-10-06 12:17:11 +00:00
|
|
|
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
2004-11-16 13:41:55 +00:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
|
2001-10-22 12:13:44 +00:00
|
|
|
|
2006-08-25 17:19:36 +00:00
|
|
|
if (push_undo)
|
2010-06-08 14:24:11 +03:00
|
|
|
gimp_channel_push_undo (channel, C_("undo-type", "Ellipse Select"));
|
2003-09-03 14:22:38 +00:00
|
|
|
|
2001-10-22 12:13:44 +00:00
|
|
|
/* if feathering for rect, make a new mask with the
|
|
|
|
* rectangle and feather that with the old mask
|
|
|
|
*/
|
app: improve gimpchannel-{combine,select}
In gimpchannel-select, move some of the common functionality of the
various gimp_channel_select_foo() functions to gimpchannel-combine.
Furthermore, don't special-case CHANNEL_OP_INTERSECT, but rather
pass it over to gimpchannel-combine, which is now prepared to
handle it in all functions, as per the previous commits.
In gimpchannel-combine, factor out the common functionality of the
various gimp_channel_combine_foo() functions into a pair of
gimp_channel_combine_{start,end}() functions, which are called
before/after the actual gimp_gegl_mask_combine_foo() function,
respectively. In particular, these functions deal with calculating
the new channel bounds. Previously, the various
gimp_gegl_mask_combine_foo() functions would implicitly invalidate
the channel bounds (since commit
d0ae244fe85a502446fe9c7b82afdf1b89498966), rendering the bounds-
recalculation code ineffective. This avoids manually recalculating
the bounds in many cases, speeding up selection operations.
2019-03-20 15:30:35 -04:00
|
|
|
if (feather)
|
2001-10-22 12:13:44 +00:00
|
|
|
{
|
2013-04-08 22:52:26 +02:00
|
|
|
GimpItem *item = GIMP_ITEM (channel);
|
|
|
|
GeglBuffer *add_on;
|
|
|
|
|
|
|
|
add_on = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
|
|
|
gimp_item_get_width (item),
|
|
|
|
gimp_item_get_height (item)),
|
|
|
|
babl_format ("Y float"));
|
2003-10-06 12:17:11 +00:00
|
|
|
|
app: improve gimpchannel-{combine,select}
In gimpchannel-select, move some of the common functionality of the
various gimp_channel_select_foo() functions to gimpchannel-combine.
Furthermore, don't special-case CHANNEL_OP_INTERSECT, but rather
pass it over to gimpchannel-combine, which is now prepared to
handle it in all functions, as per the previous commits.
In gimpchannel-combine, factor out the common functionality of the
various gimp_channel_combine_foo() functions into a pair of
gimp_channel_combine_{start,end}() functions, which are called
before/after the actual gimp_gegl_mask_combine_foo() function,
respectively. In particular, these functions deal with calculating
the new channel bounds. Previously, the various
gimp_gegl_mask_combine_foo() functions would implicitly invalidate
the channel bounds (since commit
d0ae244fe85a502446fe9c7b82afdf1b89498966), rendering the bounds-
recalculation code ineffective. This avoids manually recalculating
the bounds in many cases, speeding up selection operations.
2019-03-20 15:30:35 -04:00
|
|
|
gimp_gegl_mask_combine_ellipse (add_on, GIMP_CHANNEL_OP_REPLACE,
|
2013-04-08 22:52:26 +02:00
|
|
|
x, y, w, h, antialias);
|
2001-11-08 19:14:51 +00:00
|
|
|
|
app: improve gimpchannel-{combine,select}
In gimpchannel-select, move some of the common functionality of the
various gimp_channel_select_foo() functions to gimpchannel-combine.
Furthermore, don't special-case CHANNEL_OP_INTERSECT, but rather
pass it over to gimpchannel-combine, which is now prepared to
handle it in all functions, as per the previous commits.
In gimpchannel-combine, factor out the common functionality of the
various gimp_channel_combine_foo() functions into a pair of
gimp_channel_combine_{start,end}() functions, which are called
before/after the actual gimp_gegl_mask_combine_foo() function,
respectively. In particular, these functions deal with calculating
the new channel bounds. Previously, the various
gimp_gegl_mask_combine_foo() functions would implicitly invalidate
the channel bounds (since commit
d0ae244fe85a502446fe9c7b82afdf1b89498966), rendering the bounds-
recalculation code ineffective. This avoids manually recalculating
the bounds in many cases, speeding up selection operations.
2019-03-20 15:30:35 -04:00
|
|
|
gimp_gegl_apply_feather (add_on, NULL, NULL, add_on, NULL,
|
|
|
|
feather_radius_x,
|
2019-06-16 17:06:08 +02:00
|
|
|
feather_radius_y,
|
|
|
|
TRUE);
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2013-04-08 22:52:26 +02:00
|
|
|
gimp_channel_combine_buffer (channel, add_on, op, 0, 0);
|
2003-10-06 12:17:11 +00:00
|
|
|
g_object_unref (add_on);
|
2001-10-22 12:13:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-10-06 12:17:11 +00:00
|
|
|
gimp_channel_combine_ellipse (channel, op, x, y, w, h, antialias);
|
2001-10-22 12:13:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-18 18:54:28 +00:00
|
|
|
void
|
|
|
|
gimp_channel_select_round_rect (GimpChannel *channel,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h,
|
|
|
|
gdouble corner_radius_x,
|
|
|
|
gdouble corner_radius_y,
|
|
|
|
GimpChannelOps op,
|
|
|
|
gboolean antialias,
|
|
|
|
gboolean feather,
|
|
|
|
gdouble feather_radius_x,
|
|
|
|
gdouble feather_radius_y,
|
|
|
|
gboolean push_undo)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
|
|
|
|
|
|
|
|
if (push_undo)
|
2010-06-08 14:24:11 +03:00
|
|
|
gimp_channel_push_undo (channel, C_("undo-type", "Rounded Rectangle Select"));
|
2006-10-18 18:54:28 +00:00
|
|
|
|
|
|
|
/* if feathering for rect, make a new mask with the
|
|
|
|
* rectangle and feather that with the old mask
|
|
|
|
*/
|
app: improve gimpchannel-{combine,select}
In gimpchannel-select, move some of the common functionality of the
various gimp_channel_select_foo() functions to gimpchannel-combine.
Furthermore, don't special-case CHANNEL_OP_INTERSECT, but rather
pass it over to gimpchannel-combine, which is now prepared to
handle it in all functions, as per the previous commits.
In gimpchannel-combine, factor out the common functionality of the
various gimp_channel_combine_foo() functions into a pair of
gimp_channel_combine_{start,end}() functions, which are called
before/after the actual gimp_gegl_mask_combine_foo() function,
respectively. In particular, these functions deal with calculating
the new channel bounds. Previously, the various
gimp_gegl_mask_combine_foo() functions would implicitly invalidate
the channel bounds (since commit
d0ae244fe85a502446fe9c7b82afdf1b89498966), rendering the bounds-
recalculation code ineffective. This avoids manually recalculating
the bounds in many cases, speeding up selection operations.
2019-03-20 15:30:35 -04:00
|
|
|
if (feather)
|
2006-10-18 18:54:28 +00:00
|
|
|
{
|
2013-04-08 22:52:26 +02:00
|
|
|
GimpItem *item = GIMP_ITEM (channel);
|
|
|
|
GeglBuffer *add_on;
|
|
|
|
|
|
|
|
add_on = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
|
|
|
gimp_item_get_width (item),
|
|
|
|
gimp_item_get_height (item)),
|
|
|
|
babl_format ("Y float"));
|
|
|
|
|
app: improve gimpchannel-{combine,select}
In gimpchannel-select, move some of the common functionality of the
various gimp_channel_select_foo() functions to gimpchannel-combine.
Furthermore, don't special-case CHANNEL_OP_INTERSECT, but rather
pass it over to gimpchannel-combine, which is now prepared to
handle it in all functions, as per the previous commits.
In gimpchannel-combine, factor out the common functionality of the
various gimp_channel_combine_foo() functions into a pair of
gimp_channel_combine_{start,end}() functions, which are called
before/after the actual gimp_gegl_mask_combine_foo() function,
respectively. In particular, these functions deal with calculating
the new channel bounds. Previously, the various
gimp_gegl_mask_combine_foo() functions would implicitly invalidate
the channel bounds (since commit
d0ae244fe85a502446fe9c7b82afdf1b89498966), rendering the bounds-
recalculation code ineffective. This avoids manually recalculating
the bounds in many cases, speeding up selection operations.
2019-03-20 15:30:35 -04:00
|
|
|
gimp_gegl_mask_combine_ellipse_rect (add_on, GIMP_CHANNEL_OP_REPLACE,
|
2013-04-08 22:52:26 +02:00
|
|
|
x, y, w, h,
|
|
|
|
corner_radius_x, corner_radius_y,
|
|
|
|
antialias);
|
2006-10-18 18:54:28 +00:00
|
|
|
|
app: improve gimpchannel-{combine,select}
In gimpchannel-select, move some of the common functionality of the
various gimp_channel_select_foo() functions to gimpchannel-combine.
Furthermore, don't special-case CHANNEL_OP_INTERSECT, but rather
pass it over to gimpchannel-combine, which is now prepared to
handle it in all functions, as per the previous commits.
In gimpchannel-combine, factor out the common functionality of the
various gimp_channel_combine_foo() functions into a pair of
gimp_channel_combine_{start,end}() functions, which are called
before/after the actual gimp_gegl_mask_combine_foo() function,
respectively. In particular, these functions deal with calculating
the new channel bounds. Previously, the various
gimp_gegl_mask_combine_foo() functions would implicitly invalidate
the channel bounds (since commit
d0ae244fe85a502446fe9c7b82afdf1b89498966), rendering the bounds-
recalculation code ineffective. This avoids manually recalculating
the bounds in many cases, speeding up selection operations.
2019-03-20 15:30:35 -04:00
|
|
|
gimp_gegl_apply_feather (add_on, NULL, NULL, add_on, NULL,
|
|
|
|
feather_radius_x,
|
2019-06-16 17:06:08 +02:00
|
|
|
feather_radius_y,
|
|
|
|
TRUE);
|
2006-10-18 18:54:28 +00:00
|
|
|
|
2013-04-08 22:52:26 +02:00
|
|
|
gimp_channel_combine_buffer (channel, add_on, op, 0, 0);
|
2006-10-18 18:54:28 +00:00
|
|
|
g_object_unref (add_on);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_channel_combine_ellipse_rect (channel, op, x, y, w, h,
|
|
|
|
corner_radius_x, corner_radius_y,
|
|
|
|
antialias);
|
|
|
|
}
|
|
|
|
}
|
2003-10-09 11:30:49 +00:00
|
|
|
|
|
|
|
/* select by GimpScanConvert functions */
|
|
|
|
|
2001-10-22 12:13:44 +00:00
|
|
|
void
|
2003-10-09 11:30:49 +00:00
|
|
|
gimp_channel_select_scan_convert (GimpChannel *channel,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpScanConvert *scan_convert,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
|
|
|
GimpChannelOps op,
|
|
|
|
gboolean antialias,
|
|
|
|
gboolean feather,
|
|
|
|
gdouble feather_radius_x,
|
2006-08-25 17:19:36 +00:00
|
|
|
gdouble feather_radius_y,
|
|
|
|
gboolean push_undo)
|
2001-10-22 12:13:44 +00:00
|
|
|
{
|
2013-04-08 22:52:26 +02:00
|
|
|
GimpItem *item;
|
|
|
|
GeglBuffer *add_on;
|
2001-10-22 12:13:44 +00:00
|
|
|
|
2003-10-06 12:17:11 +00:00
|
|
|
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
2004-11-16 13:41:55 +00:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
|
2003-10-09 11:30:49 +00:00
|
|
|
g_return_if_fail (undo_desc != NULL);
|
|
|
|
g_return_if_fail (scan_convert != NULL);
|
2001-10-22 12:13:44 +00:00
|
|
|
|
2006-08-25 17:19:36 +00:00
|
|
|
if (push_undo)
|
|
|
|
gimp_channel_push_undo (channel, undo_desc);
|
2003-09-03 14:22:38 +00:00
|
|
|
|
2003-10-06 12:17:11 +00:00
|
|
|
item = GIMP_ITEM (channel);
|
|
|
|
|
2013-04-08 22:52:26 +02:00
|
|
|
add_on = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
|
|
|
gimp_item_get_width (item),
|
|
|
|
gimp_item_get_height (item)),
|
|
|
|
babl_format ("Y float"));
|
2012-03-20 23:34:11 +01:00
|
|
|
|
2013-04-08 22:52:26 +02:00
|
|
|
gimp_scan_convert_render (scan_convert, add_on,
|
2003-10-09 11:30:49 +00:00
|
|
|
offset_x, offset_y, antialias);
|
2001-10-22 12:13:44 +00:00
|
|
|
|
2003-10-06 12:17:11 +00:00
|
|
|
if (feather)
|
2014-03-04 22:09:11 +01:00
|
|
|
gimp_gegl_apply_feather (add_on, NULL, NULL, add_on, NULL,
|
2013-04-08 22:52:26 +02:00
|
|
|
feather_radius_x,
|
2019-06-16 17:06:08 +02:00
|
|
|
feather_radius_y,
|
|
|
|
TRUE);
|
2002-08-21 10:59:26 +00:00
|
|
|
|
2013-04-08 22:52:26 +02:00
|
|
|
gimp_channel_combine_buffer (channel, add_on, op, 0, 0);
|
2003-10-06 12:17:11 +00:00
|
|
|
g_object_unref (add_on);
|
2001-10-22 12:13:44 +00:00
|
|
|
}
|
|
|
|
|
2003-10-09 11:30:49 +00:00
|
|
|
void
|
2017-06-23 01:38:30 +02:00
|
|
|
gimp_channel_select_polygon (GimpChannel *channel,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
gint n_points,
|
|
|
|
const GimpVector2 *points,
|
|
|
|
GimpChannelOps op,
|
|
|
|
gboolean antialias,
|
|
|
|
gboolean feather,
|
|
|
|
gdouble feather_radius_x,
|
|
|
|
gdouble feather_radius_y,
|
|
|
|
gboolean push_undo)
|
2003-10-09 11:30:49 +00:00
|
|
|
{
|
|
|
|
GimpScanConvert *scan_convert;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
2004-11-16 13:41:55 +00:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
|
2003-10-09 11:30:49 +00:00
|
|
|
g_return_if_fail (undo_desc != NULL);
|
|
|
|
|
|
|
|
scan_convert = gimp_scan_convert_new ();
|
|
|
|
|
|
|
|
gimp_scan_convert_add_polyline (scan_convert, n_points, points, TRUE);
|
|
|
|
|
|
|
|
gimp_channel_select_scan_convert (channel, undo_desc, scan_convert, 0, 0,
|
|
|
|
op, antialias, feather,
|
2006-08-25 17:19:36 +00:00
|
|
|
feather_radius_x, feather_radius_y,
|
|
|
|
push_undo);
|
2003-10-09 11:30:49 +00:00
|
|
|
|
|
|
|
gimp_scan_convert_free (scan_convert);
|
|
|
|
}
|
|
|
|
|
2002-02-26 05:42:14 +00:00
|
|
|
void
|
2003-10-06 12:17:11 +00:00
|
|
|
gimp_channel_select_vectors (GimpChannel *channel,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
GimpChannelOps op,
|
|
|
|
gboolean antialias,
|
|
|
|
gboolean feather,
|
|
|
|
gdouble feather_radius_x,
|
2006-08-25 17:19:36 +00:00
|
|
|
gdouble feather_radius_y,
|
|
|
|
gboolean push_undo)
|
2002-02-26 05:42:14 +00:00
|
|
|
{
|
2011-04-10 22:42:39 +02:00
|
|
|
const GimpBezierDesc *bezier;
|
2002-02-26 05:42:14 +00:00
|
|
|
|
2003-10-06 12:17:11 +00:00
|
|
|
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
2004-11-16 13:41:55 +00:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
|
2003-10-09 11:30:49 +00:00
|
|
|
g_return_if_fail (undo_desc != NULL);
|
2003-09-03 14:22:38 +00:00
|
|
|
g_return_if_fail (GIMP_IS_VECTORS (vectors));
|
|
|
|
|
2011-04-10 22:42:39 +02:00
|
|
|
bezier = gimp_vectors_get_bezier (vectors);
|
2003-05-21 01:01:09 +00:00
|
|
|
|
2011-04-10 22:42:39 +02:00
|
|
|
if (bezier && bezier->num_data > 4)
|
2002-02-26 05:42:14 +00:00
|
|
|
{
|
2011-04-10 22:42:39 +02:00
|
|
|
GimpScanConvert *scan_convert;
|
2002-02-26 05:42:14 +00:00
|
|
|
|
2011-04-10 22:42:39 +02:00
|
|
|
scan_convert = gimp_scan_convert_new ();
|
|
|
|
gimp_scan_convert_add_bezier (scan_convert, bezier);
|
2002-02-26 05:42:14 +00:00
|
|
|
|
2011-04-10 22:42:39 +02:00
|
|
|
gimp_channel_select_scan_convert (channel, undo_desc, scan_convert, 0, 0,
|
|
|
|
op, antialias, feather,
|
|
|
|
feather_radius_x, feather_radius_y,
|
|
|
|
push_undo);
|
2003-05-21 01:01:09 +00:00
|
|
|
|
2011-04-10 22:42:39 +02:00
|
|
|
gimp_scan_convert_free (scan_convert);
|
2003-05-21 01:01:09 +00:00
|
|
|
}
|
2002-02-26 05:42:14 +00:00
|
|
|
}
|
|
|
|
|
2003-10-09 11:30:49 +00:00
|
|
|
|
|
|
|
/* select by GimpChannel functions */
|
|
|
|
|
2001-10-22 12:13:44 +00:00
|
|
|
void
|
2013-04-08 23:31:26 +02:00
|
|
|
gimp_channel_select_buffer (GimpChannel *channel,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GeglBuffer *add_on,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
|
|
|
GimpChannelOps op,
|
|
|
|
gboolean feather,
|
|
|
|
gdouble feather_radius_x,
|
|
|
|
gdouble feather_radius_y)
|
2001-10-22 12:13:44 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
2004-11-16 13:41:55 +00:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
|
2003-10-09 11:30:49 +00:00
|
|
|
g_return_if_fail (undo_desc != NULL);
|
2013-04-08 23:31:26 +02:00
|
|
|
g_return_if_fail (GEGL_IS_BUFFER (add_on));
|
2001-10-22 12:13:44 +00:00
|
|
|
|
2003-10-06 12:17:11 +00:00
|
|
|
gimp_channel_push_undo (channel, undo_desc);
|
2003-09-03 14:22:38 +00:00
|
|
|
|
app: improve gimpchannel-{combine,select}
In gimpchannel-select, move some of the common functionality of the
various gimp_channel_select_foo() functions to gimpchannel-combine.
Furthermore, don't special-case CHANNEL_OP_INTERSECT, but rather
pass it over to gimpchannel-combine, which is now prepared to
handle it in all functions, as per the previous commits.
In gimpchannel-combine, factor out the common functionality of the
various gimp_channel_combine_foo() functions into a pair of
gimp_channel_combine_{start,end}() functions, which are called
before/after the actual gimp_gegl_mask_combine_foo() function,
respectively. In particular, these functions deal with calculating
the new channel bounds. Previously, the various
gimp_gegl_mask_combine_foo() functions would implicitly invalidate
the channel bounds (since commit
d0ae244fe85a502446fe9c7b82afdf1b89498966), rendering the bounds-
recalculation code ineffective. This avoids manually recalculating
the bounds in many cases, speeding up selection operations.
2019-03-20 15:30:35 -04:00
|
|
|
if (feather)
|
2003-08-20 17:14:57 +00:00
|
|
|
{
|
2013-04-08 22:52:26 +02:00
|
|
|
GimpItem *item = GIMP_ITEM (channel);
|
|
|
|
GeglBuffer *add_on2;
|
|
|
|
|
|
|
|
add_on2 = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
|
|
|
gimp_item_get_width (item),
|
|
|
|
gimp_item_get_height (item)),
|
|
|
|
babl_format ("Y float"));
|
2003-10-06 12:17:11 +00:00
|
|
|
|
2013-04-08 23:31:26 +02:00
|
|
|
gimp_gegl_mask_combine_buffer (add_on2, add_on,
|
app: improve gimpchannel-{combine,select}
In gimpchannel-select, move some of the common functionality of the
various gimp_channel_select_foo() functions to gimpchannel-combine.
Furthermore, don't special-case CHANNEL_OP_INTERSECT, but rather
pass it over to gimpchannel-combine, which is now prepared to
handle it in all functions, as per the previous commits.
In gimpchannel-combine, factor out the common functionality of the
various gimp_channel_combine_foo() functions into a pair of
gimp_channel_combine_{start,end}() functions, which are called
before/after the actual gimp_gegl_mask_combine_foo() function,
respectively. In particular, these functions deal with calculating
the new channel bounds. Previously, the various
gimp_gegl_mask_combine_foo() functions would implicitly invalidate
the channel bounds (since commit
d0ae244fe85a502446fe9c7b82afdf1b89498966), rendering the bounds-
recalculation code ineffective. This avoids manually recalculating
the bounds in many cases, speeding up selection operations.
2019-03-20 15:30:35 -04:00
|
|
|
GIMP_CHANNEL_OP_REPLACE,
|
2013-04-08 22:52:26 +02:00
|
|
|
offset_x, offset_y);
|
2003-08-20 17:14:57 +00:00
|
|
|
|
app: improve gimpchannel-{combine,select}
In gimpchannel-select, move some of the common functionality of the
various gimp_channel_select_foo() functions to gimpchannel-combine.
Furthermore, don't special-case CHANNEL_OP_INTERSECT, but rather
pass it over to gimpchannel-combine, which is now prepared to
handle it in all functions, as per the previous commits.
In gimpchannel-combine, factor out the common functionality of the
various gimp_channel_combine_foo() functions into a pair of
gimp_channel_combine_{start,end}() functions, which are called
before/after the actual gimp_gegl_mask_combine_foo() function,
respectively. In particular, these functions deal with calculating
the new channel bounds. Previously, the various
gimp_gegl_mask_combine_foo() functions would implicitly invalidate
the channel bounds (since commit
d0ae244fe85a502446fe9c7b82afdf1b89498966), rendering the bounds-
recalculation code ineffective. This avoids manually recalculating
the bounds in many cases, speeding up selection operations.
2019-03-20 15:30:35 -04:00
|
|
|
gimp_gegl_apply_feather (add_on2, NULL, NULL, add_on2, NULL,
|
|
|
|
feather_radius_x,
|
2019-06-16 17:06:08 +02:00
|
|
|
feather_radius_y,
|
|
|
|
TRUE);
|
2003-08-20 17:14:57 +00:00
|
|
|
|
2013-04-08 22:52:26 +02:00
|
|
|
gimp_channel_combine_buffer (channel, add_on2, op, 0, 0);
|
2003-10-06 12:17:11 +00:00
|
|
|
g_object_unref (add_on2);
|
2003-08-20 17:14:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-08 23:31:26 +02:00
|
|
|
gimp_channel_combine_buffer (channel, add_on, op, offset_x, offset_y);
|
2003-08-20 17:14:57 +00:00
|
|
|
}
|
2001-10-22 12:13:44 +00:00
|
|
|
}
|
|
|
|
|
2013-04-08 23:31:26 +02:00
|
|
|
void
|
|
|
|
gimp_channel_select_channel (GimpChannel *channel,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpChannel *add_on,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
|
|
|
GimpChannelOps op,
|
|
|
|
gboolean feather,
|
|
|
|
gdouble feather_radius_x,
|
|
|
|
gdouble feather_radius_y)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
|
|
|
|
g_return_if_fail (undo_desc != NULL);
|
|
|
|
g_return_if_fail (GIMP_IS_CHANNEL (add_on));
|
|
|
|
|
|
|
|
gimp_channel_select_buffer (channel, undo_desc,
|
|
|
|
gimp_drawable_get_buffer (GIMP_DRAWABLE (add_on)),
|
|
|
|
offset_x, offset_y, op,
|
|
|
|
feather,
|
|
|
|
feather_radius_x, feather_radius_y);
|
|
|
|
}
|
|
|
|
|
2003-08-21 15:54:47 +00:00
|
|
|
void
|
2003-10-06 12:17:11 +00:00
|
|
|
gimp_channel_select_alpha (GimpChannel *channel,
|
2004-03-16 16:23:06 +00:00
|
|
|
GimpDrawable *drawable,
|
2003-10-06 12:17:11 +00:00
|
|
|
GimpChannelOps op,
|
|
|
|
gboolean feather,
|
|
|
|
gdouble feather_radius_x,
|
|
|
|
gdouble feather_radius_y)
|
2003-08-21 15:54:47 +00:00
|
|
|
{
|
2003-10-06 12:17:11 +00:00
|
|
|
GimpItem *item;
|
|
|
|
GimpChannel *add_on;
|
2003-10-06 16:43:05 +00:00
|
|
|
gint off_x, off_y;
|
2003-08-21 15:54:47 +00:00
|
|
|
|
2003-10-06 12:17:11 +00:00
|
|
|
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
2004-11-16 13:41:55 +00:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
|
2004-03-16 16:23:06 +00:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2003-08-21 15:54:47 +00:00
|
|
|
|
2003-10-06 12:17:11 +00:00
|
|
|
item = GIMP_ITEM (channel);
|
|
|
|
|
2004-03-16 16:23:06 +00:00
|
|
|
if (gimp_drawable_has_alpha (drawable))
|
2003-10-09 11:30:49 +00:00
|
|
|
{
|
|
|
|
add_on = gimp_channel_new_from_alpha (gimp_item_get_image (item),
|
2005-01-15 16:59:34 +00:00
|
|
|
drawable, NULL, NULL);
|
2003-10-09 11:30:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* no alpha is equivalent to completely opaque alpha,
|
|
|
|
* so simply select the whole layer's extents. --mitch
|
|
|
|
*/
|
|
|
|
add_on = gimp_channel_new_mask (gimp_item_get_image (item),
|
2008-11-03 00:09:01 +00:00
|
|
|
gimp_item_get_width (GIMP_ITEM (drawable)),
|
|
|
|
gimp_item_get_height (GIMP_ITEM (drawable)));
|
2003-10-09 11:30:49 +00:00
|
|
|
gimp_channel_all (add_on, FALSE);
|
|
|
|
}
|
2003-08-21 15:54:47 +00:00
|
|
|
|
2008-11-02 23:03:29 +00:00
|
|
|
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
|
2003-10-06 16:43:05 +00:00
|
|
|
|
2010-06-08 14:24:11 +03:00
|
|
|
gimp_channel_select_channel (channel, C_("undo-type", "Alpha to Selection"), add_on,
|
2003-10-09 11:30:49 +00:00
|
|
|
off_x, off_y,
|
|
|
|
op, feather,
|
|
|
|
feather_radius_x,
|
|
|
|
feather_radius_y);
|
2003-10-06 12:17:11 +00:00
|
|
|
g_object_unref (add_on);
|
2003-08-21 15:54:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-10-06 12:17:11 +00:00
|
|
|
gimp_channel_select_component (GimpChannel *channel,
|
|
|
|
GimpChannelType component,
|
|
|
|
GimpChannelOps op,
|
|
|
|
gboolean feather,
|
|
|
|
gdouble feather_radius_x,
|
|
|
|
gdouble feather_radius_y)
|
2003-08-21 15:54:47 +00:00
|
|
|
{
|
2003-10-06 12:17:11 +00:00
|
|
|
GimpItem *item;
|
|
|
|
GimpChannel *add_on;
|
2004-10-26 14:45:25 +00:00
|
|
|
const gchar *desc;
|
2003-10-09 11:30:49 +00:00
|
|
|
gchar *undo_desc;
|
2003-08-21 15:54:47 +00:00
|
|
|
|
2003-10-06 12:17:11 +00:00
|
|
|
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
2004-11-16 13:41:55 +00:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
|
2003-08-21 15:54:47 +00:00
|
|
|
|
2003-10-06 12:17:11 +00:00
|
|
|
item = GIMP_ITEM (channel);
|
|
|
|
|
|
|
|
add_on = gimp_channel_new_from_component (gimp_item_get_image (item),
|
2005-01-15 16:59:34 +00:00
|
|
|
component, NULL, NULL);
|
2003-08-21 15:54:47 +00:00
|
|
|
|
|
|
|
if (feather)
|
2003-10-06 12:17:11 +00:00
|
|
|
gimp_channel_feather (add_on,
|
2003-08-21 15:54:47 +00:00
|
|
|
feather_radius_x,
|
|
|
|
feather_radius_y,
|
2019-06-16 17:06:08 +02:00
|
|
|
TRUE,
|
2003-08-21 15:54:47 +00:00
|
|
|
FALSE /* no undo */);
|
|
|
|
|
2004-10-26 14:45:25 +00:00
|
|
|
gimp_enum_get_value (GIMP_TYPE_CHANNEL_TYPE, component,
|
|
|
|
NULL, NULL, &desc, NULL);
|
2003-08-21 15:54:47 +00:00
|
|
|
|
2010-06-08 14:24:11 +03:00
|
|
|
undo_desc = g_strdup_printf (C_("undo-type", "%s Channel to Selection"), desc);
|
2003-08-21 15:54:47 +00:00
|
|
|
|
2003-10-09 11:30:49 +00:00
|
|
|
gimp_channel_select_channel (channel, undo_desc, add_on,
|
2003-10-06 12:17:11 +00:00
|
|
|
0, 0, op,
|
|
|
|
FALSE, 0.0, 0.0);
|
2003-08-21 15:54:47 +00:00
|
|
|
|
2003-10-09 11:30:49 +00:00
|
|
|
g_free (undo_desc);
|
2003-10-06 12:17:11 +00:00
|
|
|
g_object_unref (add_on);
|
2003-08-21 15:54:47 +00:00
|
|
|
}
|
|
|
|
|
2001-10-22 12:13:44 +00:00
|
|
|
void
|
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 13:02:47 +00:00
|
|
|
gimp_channel_select_fuzzy (GimpChannel *channel,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
gboolean sample_merged,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
2012-04-27 14:23:19 +02: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 13:02:47 +00:00
|
|
|
gboolean select_transparent,
|
|
|
|
GimpSelectCriterion select_criterion,
|
2016-01-11 11:02:27 +00:00
|
|
|
gboolean diagonal_neighbors,
|
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 13:02:47 +00:00
|
|
|
GimpChannelOps op,
|
|
|
|
gboolean antialias,
|
|
|
|
gboolean feather,
|
|
|
|
gdouble feather_radius_x,
|
|
|
|
gdouble feather_radius_y)
|
2003-10-06 12:17:11 +00:00
|
|
|
{
|
2014-05-31 09:52:44 +02:00
|
|
|
GimpPickable *pickable;
|
|
|
|
GeglBuffer *add_on;
|
|
|
|
gint add_on_x = 0;
|
|
|
|
gint add_on_y = 0;
|
2003-10-06 12:17:11 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
2004-11-16 13:41:55 +00:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
|
2003-10-06 12:17:11 +00:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
2014-05-31 09:52:44 +02:00
|
|
|
if (sample_merged)
|
|
|
|
pickable = GIMP_PICKABLE (gimp_item_get_image (GIMP_ITEM (drawable)));
|
|
|
|
else
|
|
|
|
pickable = GIMP_PICKABLE (drawable);
|
2003-10-06 12:17:11 +00:00
|
|
|
|
2014-05-31 09:52:44 +02:00
|
|
|
add_on = gimp_pickable_contiguous_region_by_seed (pickable,
|
|
|
|
antialias,
|
|
|
|
threshold,
|
|
|
|
select_transparent,
|
|
|
|
select_criterion,
|
2016-01-11 11:02:27 +00:00
|
|
|
diagonal_neighbors,
|
2014-05-31 09:52:44 +02:00
|
|
|
x, y);
|
2003-10-06 12:17:11 +00:00
|
|
|
|
|
|
|
if (! sample_merged)
|
2008-11-02 23:03:29 +00:00
|
|
|
gimp_item_get_offset (GIMP_ITEM (drawable), &add_on_x, &add_on_y);
|
2003-10-06 12:17:11 +00:00
|
|
|
|
2013-04-09 01:38:24 +02:00
|
|
|
gimp_channel_select_buffer (channel, C_("undo-type", "Fuzzy Select"),
|
|
|
|
add_on, add_on_x, add_on_y,
|
|
|
|
op,
|
|
|
|
feather,
|
|
|
|
feather_radius_x,
|
|
|
|
feather_radius_y);
|
2003-10-06 12:17:11 +00:00
|
|
|
g_object_unref (add_on);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
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 13:02:47 +00:00
|
|
|
gimp_channel_select_by_color (GimpChannel *channel,
|
2020-08-17 18:22:19 +02:00
|
|
|
GList *drawables,
|
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 13:02:47 +00:00
|
|
|
gboolean sample_merged,
|
|
|
|
const GimpRGB *color,
|
2012-04-27 14:23:19 +02: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 13:02:47 +00:00
|
|
|
gboolean select_transparent,
|
|
|
|
GimpSelectCriterion select_criterion,
|
|
|
|
GimpChannelOps op,
|
|
|
|
gboolean antialias,
|
|
|
|
gboolean feather,
|
|
|
|
gdouble feather_radius_x,
|
|
|
|
gdouble feather_radius_y)
|
2001-10-22 12:13:44 +00:00
|
|
|
{
|
2014-05-31 09:52:44 +02:00
|
|
|
GimpPickable *pickable;
|
|
|
|
GeglBuffer *add_on;
|
2020-08-17 18:22:19 +02:00
|
|
|
GimpImage *image;
|
|
|
|
GimpImage *sel_image = NULL;
|
|
|
|
gint add_on_x = 0;
|
|
|
|
gint add_on_y = 0;
|
2001-10-22 12:13:44 +00:00
|
|
|
|
2003-10-06 12:17:11 +00:00
|
|
|
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
2004-11-16 13:41:55 +00:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
|
2020-08-17 18:22:19 +02:00
|
|
|
g_return_if_fail (drawables != NULL);
|
2001-10-22 12:13:44 +00:00
|
|
|
g_return_if_fail (color != NULL);
|
|
|
|
|
2020-08-17 18:22:19 +02:00
|
|
|
image = gimp_item_get_image (drawables->data);
|
2014-05-31 09:52:44 +02:00
|
|
|
if (sample_merged)
|
2020-08-17 18:22:19 +02:00
|
|
|
{
|
|
|
|
pickable = GIMP_PICKABLE (image);
|
|
|
|
}
|
2014-05-31 09:52:44 +02:00
|
|
|
else
|
2020-08-17 18:22:19 +02:00
|
|
|
{
|
|
|
|
if (g_list_length (drawables) == 1)
|
|
|
|
{
|
|
|
|
pickable = GIMP_PICKABLE (drawables->data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sel_image = gimp_image_new_from_drawables (image->gimp, drawables, FALSE);
|
|
|
|
gimp_container_remove (image->gimp->images, GIMP_OBJECT (sel_image));
|
|
|
|
|
|
|
|
pickable = GIMP_PICKABLE (sel_image);
|
|
|
|
gimp_pickable_flush (pickable);
|
|
|
|
}
|
|
|
|
}
|
2014-05-31 09:52:44 +02:00
|
|
|
|
|
|
|
add_on = gimp_pickable_contiguous_region_by_color (pickable,
|
|
|
|
antialias,
|
|
|
|
threshold,
|
|
|
|
select_transparent,
|
|
|
|
select_criterion,
|
|
|
|
color);
|
2003-10-06 12:17:11 +00:00
|
|
|
|
2020-08-17 18:22:19 +02:00
|
|
|
if (! sample_merged && ! sel_image)
|
|
|
|
gimp_item_get_offset (GIMP_ITEM (drawables->data), &add_on_x, &add_on_y);
|
2003-10-06 12:17:11 +00:00
|
|
|
|
2013-04-09 01:38:24 +02:00
|
|
|
gimp_channel_select_buffer (channel, C_("undo-type", "Select by Color"),
|
|
|
|
add_on, add_on_x, add_on_y,
|
|
|
|
op,
|
|
|
|
feather,
|
|
|
|
feather_radius_x,
|
|
|
|
feather_radius_y);
|
2020-08-17 18:22:19 +02:00
|
|
|
|
2003-10-06 12:17:11 +00:00
|
|
|
g_object_unref (add_on);
|
2020-08-17 18:22:19 +02:00
|
|
|
if (sel_image)
|
|
|
|
g_object_unref (sel_image);
|
|
|
|
|
2001-10-22 12:13:44 +00:00
|
|
|
}
|
2015-08-26 01:06:34 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
gimp_channel_select_by_index (GimpChannel *channel,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
gint index,
|
|
|
|
GimpChannelOps op,
|
|
|
|
gboolean feather,
|
|
|
|
gdouble feather_radius_x,
|
|
|
|
gdouble feather_radius_y)
|
|
|
|
{
|
|
|
|
GeglBuffer *add_on;
|
|
|
|
gint add_on_x = 0;
|
|
|
|
gint add_on_y = 0;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_CHANNEL (channel));
|
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
g_return_if_fail (gimp_drawable_is_indexed (drawable));
|
|
|
|
|
|
|
|
add_on = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
|
|
|
gimp_item_get_width (GIMP_ITEM (drawable)),
|
|
|
|
gimp_item_get_height (GIMP_ITEM (drawable))),
|
|
|
|
babl_format ("Y float"));
|
|
|
|
|
|
|
|
gimp_gegl_index_to_mask (gimp_drawable_get_buffer (drawable), NULL,
|
|
|
|
gimp_drawable_get_format_without_alpha (drawable),
|
|
|
|
add_on, NULL,
|
|
|
|
index);
|
|
|
|
|
|
|
|
gimp_item_get_offset (GIMP_ITEM (drawable), &add_on_x, &add_on_y);
|
|
|
|
|
|
|
|
gimp_channel_select_buffer (channel, C_("undo-type", "Select by Indexed Color"),
|
|
|
|
add_on, add_on_x, add_on_y,
|
|
|
|
op,
|
|
|
|
feather,
|
|
|
|
feather_radius_x,
|
|
|
|
feather_radius_y);
|
|
|
|
g_object_unref (add_on);
|
|
|
|
}
|