app: add boundary_offset() which offsets BoundSegs in place
and use it in gimp_region_select_tool_calculate(). Also fix boundary_transform() indentation.
This commit is contained in:
@ -363,19 +363,17 @@ boundary_simplify (BoundSeg *sorted_segs,
|
|||||||
|
|
||||||
/*Transform boundary based on a matrix*/
|
/*Transform boundary based on a matrix*/
|
||||||
|
|
||||||
BoundSeg * boundary_transform (const BoundSeg *segs,
|
BoundSeg *
|
||||||
|
boundary_transform (const BoundSeg *segs,
|
||||||
gint *num_segs,
|
gint *num_segs,
|
||||||
GimpMatrix3 *matrix)
|
GimpMatrix3 *matrix)
|
||||||
{
|
{
|
||||||
|
Boundary *boundary = boundary_new (NULL);
|
||||||
Boundary *boundary = boundary_new(NULL);
|
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
for (i = 0; i < *num_segs; i++)
|
for (i = 0; i < *num_segs; i++)
|
||||||
{
|
{
|
||||||
|
/* dont transform sorting sentinels */
|
||||||
|
|
||||||
/*dont transform sorting sentinels*/
|
|
||||||
if (!(segs[i].x1 == -1 &&
|
if (!(segs[i].x1 == -1 &&
|
||||||
segs[i].y1 == -1 &&
|
segs[i].y1 == -1 &&
|
||||||
segs[i].x2 == -1 &&
|
segs[i].x2 == -1 &&
|
||||||
@ -393,15 +391,41 @@ BoundSeg * boundary_transform (const BoundSeg *segs,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*Keep the sorting sentinel*/
|
/* Keep the sorting sentinel */
|
||||||
boundary_add_seg (boundary,
|
boundary_add_seg (boundary,
|
||||||
-1, -1,
|
-1, -1,
|
||||||
-1, -1,
|
-1, -1,
|
||||||
segs[i].open);
|
segs[i].open);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*num_segs = boundary->num_segs;
|
*num_segs = boundary->num_segs;
|
||||||
return boundary_free(boundary, FALSE);
|
|
||||||
|
return boundary_free (boundary, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
boundary_offset (BoundSeg *segs,
|
||||||
|
gint num_segs,
|
||||||
|
gint off_x,
|
||||||
|
gint off_y)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
for (i = 0; i < num_segs; i++)
|
||||||
|
{
|
||||||
|
/* dont offset sorting sentinels */
|
||||||
|
if (!(segs[i].x1 == -1 &&
|
||||||
|
segs[i].y1 == -1 &&
|
||||||
|
segs[i].x2 == -1 &&
|
||||||
|
segs[i].y2 == -1))
|
||||||
|
{
|
||||||
|
segs[i].x1 += off_x;
|
||||||
|
segs[i].y1 += off_y;
|
||||||
|
segs[i].x2 += off_x;
|
||||||
|
segs[i].y2 += off_y;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,5 +60,11 @@ BoundSeg * boundary_transform (const BoundSeg *segs,
|
|||||||
gint *num_segs,
|
gint *num_segs,
|
||||||
GimpMatrix3 *matrix);
|
GimpMatrix3 *matrix);
|
||||||
|
|
||||||
|
/* offsets in-place */
|
||||||
|
void boundary_offset (BoundSeg *segs,
|
||||||
|
gint num_segs,
|
||||||
|
gint off_x,
|
||||||
|
gint off_y);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __BOUNDARY_H__ */
|
#endif /* __BOUNDARY_H__ */
|
||||||
|
@ -381,10 +381,20 @@ gimp_region_select_tool_calculate (GimpRegionSelectTool *region_sel,
|
|||||||
BOUNDARY_HALF_WAY,
|
BOUNDARY_HALF_WAY,
|
||||||
num_segs);
|
num_segs);
|
||||||
|
|
||||||
|
if (! options->sample_merged)
|
||||||
|
{
|
||||||
|
GimpImage *image = gimp_display_get_image (display);
|
||||||
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
||||||
|
gint off_x, off_y;
|
||||||
|
|
||||||
|
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
|
||||||
|
|
||||||
|
boundary_offset (bsegs, *num_segs, off_x, off_y);
|
||||||
|
}
|
||||||
|
|
||||||
segs = g_new (GdkSegment, *num_segs);
|
segs = g_new (GdkSegment, *num_segs);
|
||||||
|
|
||||||
gimp_display_shell_transform_segments (shell, bsegs, segs, *num_segs,
|
gimp_display_shell_transform_segments (shell, bsegs, segs, *num_segs, FALSE);
|
||||||
! options->sample_merged);
|
|
||||||
g_free (bsegs);
|
g_free (bsegs);
|
||||||
|
|
||||||
gimp_display_shell_unset_override_cursor (shell);
|
gimp_display_shell_unset_override_cursor (shell);
|
||||||
|
Reference in New Issue
Block a user