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.
This commit is contained in:
Michael Natterer 2006-08-05 13:02:47 +00:00 committed by Michael Natterer
parent 5ce64ce234
commit 9dabd23e2d
23 changed files with 531 additions and 293 deletions

View File

@ -1,3 +1,39 @@
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 Raphaël Quinet <raphael@gimp.org>
* app/core/gimpgradient-load.c (gimp_gradient_load): Do not crash

View File

@ -1138,6 +1138,44 @@ gimp_merge_type_get_type (void)
return type;
}
GType
gimp_select_criterion_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_SELECT_CRITERION_COMPOSITE, "GIMP_SELECT_CRITERION_COMPOSITE", "composite" },
{ GIMP_SELECT_CRITERION_R, "GIMP_SELECT_CRITERION_R", "r" },
{ GIMP_SELECT_CRITERION_G, "GIMP_SELECT_CRITERION_G", "g" },
{ GIMP_SELECT_CRITERION_B, "GIMP_SELECT_CRITERION_B", "b" },
{ GIMP_SELECT_CRITERION_H, "GIMP_SELECT_CRITERION_H", "h" },
{ GIMP_SELECT_CRITERION_S, "GIMP_SELECT_CRITERION_S", "s" },
{ GIMP_SELECT_CRITERION_V, "GIMP_SELECT_CRITERION_V", "v" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_SELECT_CRITERION_COMPOSITE, N_("Composite"), NULL },
{ GIMP_SELECT_CRITERION_R, N_("Red"), NULL },
{ GIMP_SELECT_CRITERION_G, N_("Green"), NULL },
{ GIMP_SELECT_CRITERION_B, N_("Blue"), NULL },
{ GIMP_SELECT_CRITERION_H, N_("Hue"), NULL },
{ GIMP_SELECT_CRITERION_S, N_("Saturation"), NULL },
{ GIMP_SELECT_CRITERION_V, N_("Value"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (! type)
{
type = g_enum_register_static ("GimpSelectCriterion", values);
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
/* Generated data ends here */

View File

@ -531,6 +531,22 @@ typedef enum
} GimpMergeType;
#define GIMP_TYPE_SELECT_CRITERION (gimp_select_criterion_get_type ())
GType gimp_select_criterion_get_type (void) G_GNUC_CONST;
typedef enum /*< pdb-skip >*/
{
GIMP_SELECT_CRITERION_COMPOSITE, /*< desc="Composite" >*/
GIMP_SELECT_CRITERION_R, /*< desc="Red" >*/
GIMP_SELECT_CRITERION_G, /*< desc="Green" >*/
GIMP_SELECT_CRITERION_B, /*< desc="Blue" >*/
GIMP_SELECT_CRITERION_H, /*< desc="Hue" >*/
GIMP_SELECT_CRITERION_S, /*< desc="Saturation" >*/
GIMP_SELECT_CRITERION_V /*< desc="Value" >*/
} GimpSelectCriterion;
/*
* non-registered enums; register them if needed
*/

View File

@ -410,18 +410,19 @@ gimp_channel_select_component (GimpChannel *channel,
}
void
gimp_channel_select_fuzzy (GimpChannel *channel,
GimpDrawable *drawable,
gboolean sample_merged,
gint x,
gint y,
gint threshold,
gboolean select_transparent,
GimpChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
gimp_channel_select_fuzzy (GimpChannel *channel,
GimpDrawable *drawable,
gboolean sample_merged,
gint x,
gint y,
gint threshold,
gboolean select_transparent,
GimpSelectCriterion select_criterion,
GimpChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
GimpItem *item;
GimpChannel *add_on;
@ -440,6 +441,7 @@ gimp_channel_select_fuzzy (GimpChannel *channel,
antialias,
threshold,
select_transparent,
select_criterion,
x, y);
if (! sample_merged)
@ -455,17 +457,18 @@ gimp_channel_select_fuzzy (GimpChannel *channel,
}
void
gimp_channel_select_by_color (GimpChannel *channel,
GimpDrawable *drawable,
gboolean sample_merged,
const GimpRGB *color,
gint threshold,
gboolean select_transparent,
GimpChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
gimp_channel_select_by_color (GimpChannel *channel,
GimpDrawable *drawable,
gboolean sample_merged,
const GimpRGB *color,
gint threshold,
gboolean select_transparent,
GimpSelectCriterion select_criterion,
GimpChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
GimpItem *item;
GimpChannel *add_on;
@ -485,6 +488,7 @@ gimp_channel_select_by_color (GimpChannel *channel,
antialias,
threshold,
select_transparent,
select_criterion,
color);
if (! sample_merged)

View File

@ -22,104 +22,106 @@
/* basic selection functions */
void gimp_channel_select_rectangle (GimpChannel *channel,
gint x,
gint y,
gint w,
gint h,
GimpChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_channel_select_ellipse (GimpChannel *channel,
gint x,
gint y,
gint w,
gint h,
GimpChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_channel_select_rectangle (GimpChannel *channel,
gint x,
gint y,
gint w,
gint h,
GimpChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_channel_select_ellipse (GimpChannel *channel,
gint x,
gint y,
gint w,
gint h,
GimpChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
/* select by GimpScanConvert functions */
void 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,
gdouble feather_radius_y);
void gimp_channel_select_polygon (GimpChannel *channel,
const gchar *undo_desc,
gint n_points,
GimpVector2 *points,
GimpChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_channel_select_vectors (GimpChannel *channel,
const gchar *undo_desc,
GimpVectors *vectors,
GimpChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void 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,
gdouble feather_radius_y);
void gimp_channel_select_polygon (GimpChannel *channel,
const gchar *undo_desc,
gint n_points,
GimpVector2 *points,
GimpChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_channel_select_vectors (GimpChannel *channel,
const gchar *undo_desc,
GimpVectors *vectors,
GimpChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
/* select by GimpChannel functions */
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);
void gimp_channel_select_alpha (GimpChannel *channel,
GimpDrawable *drawable,
GimpChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_channel_select_component (GimpChannel *channel,
GimpChannelType component,
GimpChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_channel_select_fuzzy (GimpChannel *channel,
GimpDrawable *drawable,
gboolean sample_merged,
gint x,
gint y,
gint threshold,
gboolean select_transparent,
GimpChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_channel_select_by_color (GimpChannel *channel,
GimpDrawable *drawable,
gboolean sample_merged,
const GimpRGB *color,
gint threshold,
gboolean select_transparent,
GimpChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
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);
void gimp_channel_select_alpha (GimpChannel *channel,
GimpDrawable *drawable,
GimpChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_channel_select_component (GimpChannel *channel,
GimpChannelType component,
GimpChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_channel_select_fuzzy (GimpChannel *channel,
GimpDrawable *drawable,
gboolean sample_merged,
gint x,
gint y,
gint threshold,
gboolean select_transparent,
GimpSelectCriterion select_criterion,
GimpChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_channel_select_by_color (GimpChannel *channel,
GimpDrawable *drawable,
gboolean sample_merged,
const GimpRGB *color,
gint threshold,
gboolean select_transparent,
GimpSelectCriterion select_criterion,
GimpChannelOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y);
#endif /* __GIMP_CHANNEL_SELECT_H__ */

View File

@ -46,17 +46,18 @@
/* public functions */
void
gimp_drawable_bucket_fill (GimpDrawable *drawable,
GimpContext *context,
GimpBucketFillMode fill_mode,
gint paint_mode,
gdouble opacity,
gboolean do_seed_fill,
gboolean fill_transparent,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y)
gimp_drawable_bucket_fill (GimpDrawable *drawable,
GimpContext *context,
GimpBucketFillMode fill_mode,
gint paint_mode,
gdouble opacity,
gboolean do_seed_fill,
gboolean fill_transparent,
GimpSelectCriterion fill_criterion,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y)
{
GimpImage *image;
GimpRGB color;
@ -96,25 +97,26 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
fill_mode,
paint_mode, opacity,
do_seed_fill,
fill_transparent,
fill_transparent, fill_criterion,
threshold, sample_merged,
x, y,
&color, pattern);
}
void
gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
GimpBucketFillMode fill_mode,
gint paint_mode,
gdouble opacity,
gboolean do_seed_fill,
gboolean fill_transparent,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y,
const GimpRGB *color,
GimpPattern *pattern)
gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
GimpBucketFillMode fill_mode,
gint paint_mode,
gdouble opacity,
gboolean do_seed_fill,
gboolean fill_transparent,
GimpSelectCriterion fill_criterion,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y,
const GimpRGB *color,
GimpPattern *pattern)
{
GimpImage *image;
TileManager *buf_tiles;
@ -179,6 +181,7 @@ gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
TRUE,
(gint) threshold,
fill_transparent,
fill_criterion,
(gint) x,
(gint) y);

View File

@ -20,30 +20,32 @@
#define __GIMP_DRAWABLE_BUCKET_FILL_H__
void gimp_drawable_bucket_fill (GimpDrawable *drawable,
GimpContext *context,
GimpBucketFillMode fill_mode,
gint paint_mode,
gdouble opacity,
gboolean do_seed_fill,
gboolean fill_transparent,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y);
void gimp_drawable_bucket_fill (GimpDrawable *drawable,
GimpContext *context,
GimpBucketFillMode fill_mode,
gint paint_mode,
gdouble opacity,
gboolean do_seed_fill,
gboolean fill_transparent,
GimpSelectCriterion fill_criterion,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y);
void gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
GimpBucketFillMode fill_mode,
gint paint_mode,
gdouble opacity,
gboolean do_seed_fill,
gboolean fill_transparent,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y,
const GimpRGB *color,
GimpPattern *pattern);
void gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
GimpBucketFillMode fill_mode,
gint paint_mode,
gdouble opacity,
gboolean do_seed_fill,
gboolean fill_transparent,
GimpSelectCriterion fill_criterion,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y,
const GimpRGB *color,
GimpPattern *pattern);
#endif /* __GIMP_DRAWABLE_BUCKET_FILL_H__ */

View File

@ -39,14 +39,15 @@
typedef struct
{
GimpImage *image;
GimpImageType type;
gboolean sample_merged;
gboolean antialias;
gint threshold;
gboolean select_transparent;
gboolean has_alpha;
guchar color[MAX_CHANNELS];
GimpImage *image;
GimpImageType type;
gboolean sample_merged;
gboolean antialias;
gint threshold;
gboolean select_transparent;
GimpSelectCriterion select_criterion;
gboolean has_alpha;
guchar color[MAX_CHANNELS];
} ContinuousRegionData;
@ -56,59 +57,63 @@ static void contiguous_region_by_color (ContinuousRegionData *cont,
PixelRegion *imagePR,
PixelRegion *maskPR);
static gint pixel_difference (const guchar *col1,
const guchar *col2,
gboolean antialias,
gint threshold,
gint bytes,
gboolean has_alpha,
gboolean select_transparent);
static void ref_tiles (TileManager *src,
TileManager *mask,
Tile **s_tile,
Tile **m_tile,
gint x,
gint y,
guchar **s,
guchar **m);
static gint find_contiguous_segment (GimpImage *image,
const guchar *col,
PixelRegion *src,
PixelRegion *mask,
gint width,
gint bytes,
GimpImageType src_type,
gboolean has_alpha,
gboolean select_transparent,
gboolean antialias,
gint threshold,
gint initial,
gint *start,
gint *end);
static void find_contiguous_region_helper (GimpImage *image,
PixelRegion *mask,
PixelRegion *src,
GimpImageType src_type,
gboolean has_alpha,
gboolean select_transparent,
gboolean antialias,
gint threshold,
gint x,
gint y,
const guchar *col);
static gint pixel_difference (const guchar *col1,
const guchar *col2,
gboolean antialias,
gint threshold,
gint bytes,
gboolean has_alpha,
gboolean select_transparent,
GimpSelectCriterion select_criterion);
static void ref_tiles (TileManager *src,
TileManager *mask,
Tile **s_tile,
Tile **m_tile,
gint x,
gint y,
guchar **s,
guchar **m);
static gint find_contiguous_segment (GimpImage *image,
const guchar *col,
PixelRegion *src,
PixelRegion *mask,
gint width,
gint bytes,
GimpImageType src_type,
gboolean has_alpha,
gboolean select_transparent,
GimpSelectCriterion select_criterion,
gboolean antialias,
gint threshold,
gint initial,
gint *start,
gint *end);
static void find_contiguous_region_helper (GimpImage *image,
PixelRegion *mask,
PixelRegion *src,
GimpImageType src_type,
gboolean has_alpha,
gboolean select_transparent,
GimpSelectCriterion select_criterion,
gboolean antialias,
gint threshold,
gint x,
gint y,
const guchar *col);
/* public functions */
GimpChannel *
gimp_image_contiguous_region_by_seed (GimpImage *image,
GimpDrawable *drawable,
gboolean sample_merged,
gboolean antialias,
gint threshold,
gboolean select_transparent,
gint x,
gint y)
gimp_image_contiguous_region_by_seed (GimpImage *image,
GimpDrawable *drawable,
gboolean sample_merged,
gboolean antialias,
gint threshold,
gboolean select_transparent,
GimpSelectCriterion select_criterion,
gint x,
gint y)
{
PixelRegion srcPR, maskPR;
GimpPickable *pickable;
@ -185,7 +190,8 @@ gimp_image_contiguous_region_by_seed (GimpImage *image,
find_contiguous_region_helper (image, &maskPR, &srcPR,
src_type, has_alpha,
select_transparent, antialias, threshold,
select_transparent, select_criterion,
antialias, threshold,
x, y, start_col);
tile_release (tile, FALSE);
@ -195,13 +201,14 @@ gimp_image_contiguous_region_by_seed (GimpImage *image,
}
GimpChannel *
gimp_image_contiguous_region_by_color (GimpImage *image,
GimpDrawable *drawable,
gboolean sample_merged,
gboolean antialias,
gint threshold,
gboolean select_transparent,
const GimpRGB *color)
gimp_image_contiguous_region_by_color (GimpImage *image,
GimpDrawable *drawable,
gboolean sample_merged,
gboolean antialias,
gint threshold,
gboolean select_transparent,
GimpSelectCriterion select_criterion,
const GimpRGB *color)
{
/* Scan over the image's active layer, finding pixels within the
* specified threshold from the given R, G, & B values. If
@ -258,10 +265,11 @@ gimp_image_contiguous_region_by_color (GimpImage *image,
select_transparent = FALSE;
}
cont.image = image;
cont.image = image;
cont.antialias = antialias;
cont.threshold = threshold;
cont.select_transparent = select_transparent;
cont.select_criterion = select_criterion;
mask = gimp_channel_new_mask (image, width, height);
@ -306,7 +314,8 @@ contiguous_region_by_color (ContinuousRegionData *cont,
cont->threshold,
cont->has_alpha ? 4 : 3,
cont->has_alpha,
cont->select_transparent);
cont->select_transparent,
cont->select_criterion);
i += imagePR->bytes;
}
@ -317,13 +326,14 @@ contiguous_region_by_color (ContinuousRegionData *cont,
}
static gint
pixel_difference (const guchar *col1,
const guchar *col2,
gboolean antialias,
gint threshold,
gint bytes,
gboolean has_alpha,
gboolean select_transparent)
pixel_difference (const guchar *col1,
const guchar *col2,
gboolean antialias,
gint threshold,
gint bytes,
gboolean has_alpha,
gboolean select_transparent,
GimpSelectCriterion select_criterion)
{
gint max = 0;
@ -339,15 +349,70 @@ pixel_difference (const guchar *col1,
{
gint diff;
gint b;
gint av0, av1, av2;
gint bv0, bv1, bv2;
if (has_alpha)
bytes--;
for (b = 0; b < bytes; b++)
switch (select_criterion)
{
diff = abs (col1[b] - col2[b]);
if (diff > max)
max = diff;
case GIMP_SELECT_CRITERION_COMPOSITE:
for (b = 0; b < bytes; b++)
{
diff = abs (col1[b] - col2[b]);
if (diff > max)
max = diff;
}
break;
case GIMP_SELECT_CRITERION_R:
max = abs (col1[0] - col2[0]);
break;
case GIMP_SELECT_CRITERION_G:
max = abs (col1[1] - col2[1]);
break;
case GIMP_SELECT_CRITERION_B:
max = abs (col1[2] - col2[2]);
break;
case GIMP_SELECT_CRITERION_H:
av0 = (gint)col1[0];
av1 = (gint)col1[1];
av2 = (gint)col1[2];
bv0 = (gint)col2[0];
bv1 = (gint)col2[1];
bv2 = (gint)col2[2];
gimp_rgb_to_hsv_int (&av0, &av1, &av2);
gimp_rgb_to_hsv_int (&bv0, &bv1, &bv2);
max = abs (av0 - bv0);
break;
case GIMP_SELECT_CRITERION_S:
av0 = (gint)col1[0];
av1 = (gint)col1[1];
av2 = (gint)col1[2];
bv0 = (gint)col2[0];
bv1 = (gint)col2[1];
bv2 = (gint)col2[2];
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:
av0 = (gint)col1[0];
av1 = (gint)col1[1];
av2 = (gint)col1[2];
bv0 = (gint)col2[0];
bv1 = (gint)col2[1];
bv2 = (gint)col2[2];
gimp_rgb_to_hsv_int (&av0, &av1, &av2);
gimp_rgb_to_hsv_int (&bv0, &bv1, &bv2);
max = abs (av2 - bv2);
break;
}
}
@ -394,20 +459,21 @@ ref_tiles (TileManager *src,
}
static int
find_contiguous_segment (GimpImage *image,
const guchar *col,
PixelRegion *src,
PixelRegion *mask,
gint width,
gint bytes,
GimpImageType src_type,
gboolean has_alpha,
gboolean select_transparent,
gboolean antialias,
gint threshold,
gint initial,
gint *start,
gint *end)
find_contiguous_segment (GimpImage *image,
const guchar *col,
PixelRegion *src,
PixelRegion *mask,
gint width,
gint bytes,
GimpImageType src_type,
gboolean has_alpha,
gboolean select_transparent,
GimpSelectCriterion select_criterion,
gboolean antialias,
gint threshold,
gint initial,
gint *start,
gint *end)
{
guchar *s;
guchar *m;
@ -427,12 +493,14 @@ find_contiguous_segment (GimpImage *image,
gimp_image_get_color (image, src_type, s, s_color);
diff = pixel_difference (col, s_color, antialias, threshold,
col_bytes, has_alpha, select_transparent);
col_bytes, has_alpha, select_transparent,
select_criterion);
}
else
{
diff = pixel_difference (col, s, antialias, threshold,
col_bytes, has_alpha, select_transparent);
col_bytes, has_alpha, select_transparent,
select_criterion);
}
/* check the starting pixel */
@ -458,12 +526,14 @@ find_contiguous_segment (GimpImage *image,
gimp_image_get_color (image, src_type, s, s_color);
diff = pixel_difference (col, s_color, antialias, threshold,
col_bytes, has_alpha, select_transparent);
col_bytes, has_alpha, select_transparent,
select_criterion);
}
else
{
diff = pixel_difference (col, s, antialias, threshold,
col_bytes, has_alpha, select_transparent);
col_bytes, has_alpha, select_transparent,
select_criterion);
}
if ((*m-- = diff))
@ -491,12 +561,14 @@ find_contiguous_segment (GimpImage *image,
gimp_image_get_color (image, src_type, s, s_color);
diff = pixel_difference (col, s_color, antialias, threshold,
col_bytes, has_alpha, select_transparent);
col_bytes, has_alpha, select_transparent,
select_criterion);
}
else
{
diff = pixel_difference (col, s, antialias, threshold,
col_bytes, has_alpha, select_transparent);
col_bytes, has_alpha, select_transparent,
select_criterion);
}
if ((*m++ = diff))
@ -513,17 +585,18 @@ find_contiguous_segment (GimpImage *image,
}
static void
find_contiguous_region_helper (GimpImage *image,
PixelRegion *mask,
PixelRegion *src,
GimpImageType src_type,
gboolean has_alpha,
gboolean select_transparent,
gboolean antialias,
gint threshold,
gint x,
gint y,
const guchar *col)
find_contiguous_region_helper (GimpImage *image,
PixelRegion *mask,
PixelRegion *src,
GimpImageType src_type,
gboolean has_alpha,
gboolean select_transparent,
GimpSelectCriterion select_criterion,
gboolean antialias,
gint threshold,
gint x,
gint y,
const guchar *col)
{
gint start, end;
gint new_start, new_end;
@ -563,8 +636,9 @@ find_contiguous_region_helper (GimpImage *image,
if (! find_contiguous_segment (image, col, src, mask, src->w,
src->bytes, src_type, has_alpha,
select_transparent, antialias,
threshold, x, &new_start, &new_end))
select_transparent, select_criterion,
antialias, threshold, x,
&new_start, &new_end))
continue;
if (y + 1 < src->h)

View File

@ -20,22 +20,24 @@
#define __GIMP_IMAGE_CONTIGUOUS_REGION_H__
GimpChannel * gimp_image_contiguous_region_by_seed (GimpImage *image,
GimpDrawable *drawable,
gboolean sample_merged,
gboolean antialias,
gint threshold,
gboolean select_transparent,
gint x,
gint y);
GimpChannel * gimp_image_contiguous_region_by_seed (GimpImage *image,
GimpDrawable *drawable,
gboolean sample_merged,
gboolean antialias,
gint threshold,
gboolean select_transparent,
GimpSelectCriterion select_criterion,
gint x,
gint y);
GimpChannel * gimp_image_contiguous_region_by_color (GimpImage *image,
GimpDrawable *drawable,
gboolean sample_merged,
gboolean antialias,
gint threshold,
gboolean select_transparent,
const GimpRGB *color);
GimpChannel * gimp_image_contiguous_region_by_color (GimpImage *image,
GimpDrawable *drawable,
gboolean sample_merged,
gboolean antialias,
gint threshold,
gboolean select_transparent,
GimpSelectCriterion select_criterion,
const GimpRGB *color);
#endif /* __GIMP_IMAGE_CONTIGUOUS_REGION_H__ */

View File

@ -321,7 +321,9 @@ gimp_display_shell_bucket_fill (GimpDisplayShell *shell,
fill_mode,
GIMP_NORMAL_MODE, GIMP_OPACITY_OPAQUE,
FALSE, /* no seed fill */
FALSE, 0.0, FALSE, /* fill params */
FALSE, /* don't fill transp */
GIMP_SELECT_CRITERION_COMPOSITE,
0.0, FALSE, /* fill params */
0.0, 0.0, /* ignored */
color, pattern);
}

View File

@ -507,6 +507,7 @@ edit_bucket_fill_invoker (GimpProcedure *procedure,
paint_mode, opacity / 100.0,
do_seed_fill,
FALSE /* don't fill transparent */,
GIMP_SELECT_CRITERION_COMPOSITE,
threshold, sample_merged, x, y);
}
else

View File

@ -71,6 +71,7 @@ by_color_select_invoker (GimpProcedure *procedure,
&color,
threshold,
FALSE /* don't select transparent */,
GIMP_SELECT_CRITERION_COMPOSITE,
operation,
antialias,
feather,
@ -202,6 +203,7 @@ fuzzy_select_invoker (GimpProcedure *procedure,
x, y,
threshold,
FALSE /* don't select transparent */,
GIMP_SELECT_CRITERION_COMPOSITE,
operation,
antialias,
feather,

View File

@ -49,7 +49,8 @@ enum
PROP_FILL_SELECTION,
PROP_FILL_TRANSPARENT,
PROP_SAMPLE_MERGED,
PROP_THRESHOLD
PROP_THRESHOLD,
PROP_FILL_CRITERION
};
@ -111,6 +112,11 @@ gimp_bucket_fill_options_class_init (GimpBucketFillOptionsClass *klass)
N_("Maximum color difference"),
0.0, 255.0, 15.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_FILL_CRITERION,
"fill-criterion", NULL,
GIMP_TYPE_SELECT_CRITERION,
GIMP_SELECT_CRITERION_COMPOSITE,
GIMP_PARAM_STATIC_STRINGS);
}
static void
@ -143,6 +149,10 @@ gimp_bucket_fill_options_set_property (GObject *object,
case PROP_THRESHOLD:
options->threshold = g_value_get_double (value);
break;
case PROP_FILL_CRITERION:
options->fill_criterion = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -174,6 +184,10 @@ gimp_bucket_fill_options_get_property (GObject *object,
case PROP_THRESHOLD:
g_value_set_double (value, options->threshold);
break;
case PROP_FILL_CRITERION:
g_value_set_enum (value, options->fill_criterion);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -205,6 +219,7 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *button;
GtkWidget *combo;
gchar *str;
vbox = gimp_paint_options_gui (tool_options);
@ -264,7 +279,7 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
gtk_widget_show (button);
/* the threshold scale */
table = gtk_table_new (1, 3, FALSE);
table = gtk_table_new (2, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (vbox2), table, FALSE, FALSE, 0);
gtk_widget_show (table);
@ -275,6 +290,12 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
1.0, 16.0, 1,
FALSE, 0.0, 0.0);
/* the fill criterion combo */
combo = gimp_prop_enum_combo_box_new (config, "fill-criterion", 0, 0);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Fill by:"), 0.0, 0.5,
combo, 2, FALSE);
return vbox;
}

View File

@ -43,6 +43,7 @@ struct _GimpBucketFillOptions
gboolean fill_transparent;
gboolean sample_merged;
gdouble threshold;
GimpSelectCriterion fill_criterion;
};

View File

@ -173,6 +173,7 @@ gimp_bucket_fill_tool_button_release (GimpTool *tool,
gimp_context_get_opacity (context),
! options->fill_selection,
options->fill_transparent,
options->fill_criterion,
options->threshold,
options->sample_merged,
bucket_tool->target_x,

View File

@ -140,6 +140,7 @@ gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
options->antialias,
options->threshold,
options->select_transparent,
options->select_criterion,
&color);
}

View File

@ -120,5 +120,6 @@ gimp_fuzzy_select_tool_get_mask (GimpRegionSelectTool *region_select,
options->antialias,
options->threshold,
options->select_transparent,
options->select_criterion,
x, y);
}

View File

@ -53,6 +53,7 @@ enum
PROP_SELECT_TRANSPARENT,
PROP_SAMPLE_MERGED,
PROP_THRESHOLD,
PROP_SELECT_CRITERION,
PROP_AUTO_SHRINK,
PROP_SHRINK_MERGED,
PROP_FIXED_MODE,
@ -127,6 +128,11 @@ gimp_selection_options_class_init (GimpSelectionOptionsClass *klass)
N_("Maximum color difference"),
0.0, 255.0, 15.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_SELECT_CRITERION,
"select-criterion", NULL,
GIMP_TYPE_SELECT_CRITERION,
GIMP_SELECT_CRITERION_COMPOSITE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_AUTO_SHRINK,
"auto-shrink", NULL,
@ -200,6 +206,9 @@ gimp_selection_options_set_property (GObject *object,
case PROP_THRESHOLD:
options->threshold = g_value_get_double (value);
break;
case PROP_SELECT_CRITERION:
options->select_criterion = g_value_get_enum (value);
break;
case PROP_AUTO_SHRINK:
options->auto_shrink = g_value_get_boolean (value);
@ -263,6 +272,9 @@ gimp_selection_options_get_property (GObject *object,
case PROP_THRESHOLD:
g_value_set_double (value, options->threshold);
break;
case PROP_SELECT_CRITERION:
g_value_set_enum (value, options->select_criterion);
break;
case PROP_AUTO_SHRINK:
g_value_set_boolean (value, options->auto_shrink);
@ -461,6 +473,7 @@ gimp_selection_options_gui (GimpToolOptions *tool_options)
GtkWidget *frame;
GtkWidget *vbox2;
GtkWidget *table;
GtkWidget *combo;
frame = gimp_frame_new (_("Finding Similar Colors"));
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
@ -483,7 +496,7 @@ gimp_selection_options_gui (GimpToolOptions *tool_options)
gtk_widget_show (button);
/* the threshold scale */
table = gtk_table_new (1, 3, FALSE);
table = gtk_table_new (2, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (vbox2), table, FALSE, FALSE, 0);
gtk_widget_show (table);
@ -493,6 +506,12 @@ gimp_selection_options_gui (GimpToolOptions *tool_options)
_("Threshold:"),
1.0, 16.0, 1,
FALSE, 0.0, 0.0);
/* the select criterion combo */
combo = gimp_prop_enum_combo_box_new (config, "select-criterion", 0, 0);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Select by:"), 0.0, 0.5,
combo, 2, FALSE);
}
/* widgets for fixed size select */

View File

@ -48,6 +48,7 @@ struct _GimpSelectionOptions
gboolean select_transparent;
gboolean sample_merged;
gdouble threshold;
GimpSelectCriterion select_criterion;
/* used by rect., ellipse selection */
gboolean auto_shrink;

View File

@ -241,7 +241,9 @@ gimp_drawable_tree_view_drop_viewable (GimpContainerTreeView *view,
GIMP_PATTERN_BUCKET_FILL,
GIMP_NORMAL_MODE, GIMP_OPACITY_OPAQUE,
FALSE, /* no seed fill */
FALSE, 0.0, FALSE, /* fill params */
FALSE, /* don't fill transp */
GIMP_SELECT_CRITERION_COMPOSITE,
0.0, FALSE, /* fill params */
0.0, 0.0, /* ignored */
NULL, GIMP_PATTERN (src_viewable));
gimp_image_flush (GIMP_ITEM_TREE_VIEW (view)->image);
@ -266,7 +268,9 @@ gimp_drawable_tree_view_drop_color (GimpContainerTreeView *view,
GIMP_FG_BUCKET_FILL,
GIMP_NORMAL_MODE, GIMP_OPACITY_OPAQUE,
FALSE, /* no seed fill */
FALSE, 0.0, FALSE, /* fill params */
FALSE, /* don't fill transp */
GIMP_SELECT_CRITERION_COMPOSITE,
0.0, FALSE, /* fill params */
0.0, 0.0, /* ignored */
color, NULL);
gimp_image_flush (GIMP_ITEM_TREE_VIEW (view)->image);
@ -345,8 +349,10 @@ gimp_drawable_tree_view_new_dropped (GimpItemTreeView *view,
fill_mode,
gimp_context_get_paint_mode (context),
gimp_context_get_opacity (context),
FALSE /* no seed fill */,
FALSE, 0.0, FALSE, 0.0, 0.0 /* fill params */,
FALSE, /* no seed fill */
FALSE, /* don't fill transp */
GIMP_SELECT_CRITERION_COMPOSITE,
0.0, FALSE, 0.0, 0.0 /* fill params */,
color, pattern);
}

View File

@ -276,6 +276,7 @@ gimp_selection_view_button_press (GtkWidget *widget,
&color,
options->threshold,
options->select_transparent,
options->select_criterion,
operation,
options->antialias,
options->feather,
@ -322,6 +323,7 @@ gimp_selection_editor_drop_color (GtkWidget *widget,
color,
options->threshold,
options->select_transparent,
options->select_criterion,
options->operation,
options->antialias,
options->feather,

View File

@ -577,6 +577,7 @@ HELP
paint_mode, opacity / 100.0,
do_seed_fill,
FALSE /* don't fill transparent */,
GIMP_SELECT_CRITERION_COMPOSITE,
threshold, sample_merged, x, y);
}
else

View File

@ -68,6 +68,7 @@ HELP
&color,
threshold,
FALSE /* don't select transparent */,
GIMP_SELECT_CRITERION_COMPOSITE,
operation,
antialias,
feather,
@ -244,6 +245,7 @@ HELP
x, y,
threshold,
FALSE /* don't select transparent */,
GIMP_SELECT_CRITERION_COMPOSITE,
operation,
antialias,
feather,