app: in gimp_pickable_contiguous_region_by_seed(), add support for arbitrary buffer extents
This commit is contained in:
@ -85,12 +85,12 @@ static void pop_segment (GQueue *segment_queue,
|
|||||||
static gboolean find_contiguous_segment (const gfloat *col,
|
static gboolean find_contiguous_segment (const gfloat *col,
|
||||||
GeglBuffer *src_buffer,
|
GeglBuffer *src_buffer,
|
||||||
GeglSampler *src_sampler,
|
GeglSampler *src_sampler,
|
||||||
|
const GeglRectangle *src_extent,
|
||||||
GeglBuffer *mask_buffer,
|
GeglBuffer *mask_buffer,
|
||||||
const Babl *src_format,
|
const Babl *src_format,
|
||||||
const Babl *mask_format,
|
const Babl *mask_format,
|
||||||
gint n_components,
|
gint n_components,
|
||||||
gboolean has_alpha,
|
gboolean has_alpha,
|
||||||
gint width,
|
|
||||||
gboolean select_transparent,
|
gboolean select_transparent,
|
||||||
GimpSelectCriterion select_criterion,
|
GimpSelectCriterion select_criterion,
|
||||||
gboolean antialias,
|
gboolean antialias,
|
||||||
@ -885,12 +885,12 @@ static gboolean
|
|||||||
find_contiguous_segment (const gfloat *col,
|
find_contiguous_segment (const gfloat *col,
|
||||||
GeglBuffer *src_buffer,
|
GeglBuffer *src_buffer,
|
||||||
GeglSampler *src_sampler,
|
GeglSampler *src_sampler,
|
||||||
|
const GeglRectangle *src_extent,
|
||||||
GeglBuffer *mask_buffer,
|
GeglBuffer *mask_buffer,
|
||||||
const Babl *src_format,
|
const Babl *src_format,
|
||||||
const Babl *mask_format,
|
const Babl *mask_format,
|
||||||
gint n_components,
|
gint n_components,
|
||||||
gboolean has_alpha,
|
gboolean has_alpha,
|
||||||
gint width,
|
|
||||||
gboolean select_transparent,
|
gboolean select_transparent,
|
||||||
GimpSelectCriterion select_criterion,
|
GimpSelectCriterion select_criterion,
|
||||||
gboolean antialias,
|
gboolean antialias,
|
||||||
@ -902,7 +902,8 @@ find_contiguous_segment (const gfloat *col,
|
|||||||
gfloat *row)
|
gfloat *row)
|
||||||
{
|
{
|
||||||
gfloat *s;
|
gfloat *s;
|
||||||
gfloat mask_row[width];
|
gfloat mask_row_buf[src_extent->width];
|
||||||
|
gfloat *mask_row = mask_row_buf - src_extent->x;
|
||||||
gfloat diff;
|
gfloat diff;
|
||||||
|
|
||||||
#ifdef FETCH_ROW
|
#ifdef FETCH_ROW
|
||||||
@ -932,7 +933,7 @@ find_contiguous_segment (const gfloat *col,
|
|||||||
s = row + *start * n_components;
|
s = row + *start * n_components;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (*start >= 0)
|
while (*start >= src_extent->x)
|
||||||
{
|
{
|
||||||
#ifndef FETCH_ROW
|
#ifndef FETCH_ROW
|
||||||
gegl_sampler_get (src_sampler,
|
gegl_sampler_get (src_sampler,
|
||||||
@ -958,7 +959,7 @@ find_contiguous_segment (const gfloat *col,
|
|||||||
s = row + *end * n_components;
|
s = row + *end * n_components;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (*end < width)
|
while (*end < src_extent->x + src_extent->width)
|
||||||
{
|
{
|
||||||
#ifndef FETCH_ROW
|
#ifndef FETCH_ROW
|
||||||
gegl_sampler_get (src_sampler,
|
gegl_sampler_get (src_sampler,
|
||||||
@ -1004,14 +1005,18 @@ find_contiguous_region (GeglBuffer *src_buffer,
|
|||||||
{
|
{
|
||||||
const Babl *mask_format = babl_format ("Y float");
|
const Babl *mask_format = babl_format ("Y float");
|
||||||
GeglSampler *src_sampler;
|
GeglSampler *src_sampler;
|
||||||
|
const GeglRectangle *src_extent;
|
||||||
|
gint x1, x2;
|
||||||
gint old_y;
|
gint old_y;
|
||||||
gint start, end;
|
gint start, end;
|
||||||
gint new_start, new_end;
|
gint new_start, new_end;
|
||||||
GQueue *segment_queue;
|
GQueue *segment_queue;
|
||||||
gfloat *row = NULL;
|
gfloat *row = NULL;
|
||||||
|
|
||||||
|
src_extent = gegl_buffer_get_extent (src_buffer);
|
||||||
|
|
||||||
#ifdef FETCH_ROW
|
#ifdef FETCH_ROW
|
||||||
row = g_new (gfloat, gegl_buffer_get_width (src_buffer) * n_components);
|
row = g_new (gfloat, src_extent->width * n_components);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
src_sampler = gegl_buffer_sampler_new (src_buffer,
|
src_sampler = gegl_buffer_sampler_new (src_buffer,
|
||||||
@ -1047,11 +1052,11 @@ find_contiguous_region (GeglBuffer *src_buffer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! find_contiguous_segment (col,
|
if (! find_contiguous_segment (col,
|
||||||
src_buffer, src_sampler, mask_buffer,
|
src_buffer, src_sampler, src_extent,
|
||||||
|
mask_buffer,
|
||||||
format, mask_format,
|
format, mask_format,
|
||||||
n_components,
|
n_components,
|
||||||
has_alpha,
|
has_alpha,
|
||||||
gegl_buffer_get_width (src_buffer),
|
|
||||||
select_transparent, select_criterion,
|
select_transparent, select_criterion,
|
||||||
antialias, threshold, x, y,
|
antialias, threshold, x, y,
|
||||||
&new_start, &new_end,
|
&new_start, &new_end,
|
||||||
@ -1068,21 +1073,21 @@ find_contiguous_region (GeglBuffer *src_buffer,
|
|||||||
|
|
||||||
if (diagonal_neighbors)
|
if (diagonal_neighbors)
|
||||||
{
|
{
|
||||||
if (new_start >= 0)
|
if (new_start >= src_extent->x)
|
||||||
new_start--;
|
new_start--;
|
||||||
|
|
||||||
if (new_end < gegl_buffer_get_width (src_buffer))
|
if (new_end < src_extent->x + src_extent->width)
|
||||||
new_end++;
|
new_end++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y + 1 < gegl_buffer_get_height (src_buffer))
|
if (y + 1 < src_extent->y + src_extent->height)
|
||||||
{
|
{
|
||||||
push_segment (segment_queue,
|
push_segment (segment_queue,
|
||||||
y, old_y, start, end,
|
y, old_y, start, end,
|
||||||
y + 1, new_start, new_end);
|
y + 1, new_start, new_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y - 1 >= 0)
|
if (y - 1 >= src_extent->y)
|
||||||
{
|
{
|
||||||
push_segment (segment_queue,
|
push_segment (segment_queue,
|
||||||
y, old_y, start, end,
|
y, old_y, start, end,
|
||||||
|
Reference in New Issue
Block a user