1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef  __GIMP_BOUNDARY_H__
19 #define  __GIMP_BOUNDARY_H__
20 
21 
22 /* half intensity for mask */
23 #define GIMP_BOUNDARY_HALF_WAY 0.5
24 
25 
26 typedef enum
27 {
28   GIMP_BOUNDARY_WITHIN_BOUNDS,
29   GIMP_BOUNDARY_IGNORE_BOUNDS
30 } GimpBoundaryType;
31 
32 
33 struct _GimpBoundSeg
34 {
35   gint   x1;
36   gint   y1;
37   gint   x2;
38   gint   y2;
39   guint  open    : 1;
40   guint  visited : 1;
41 };
42 
43 
44 GimpBoundSeg * gimp_boundary_find      (GeglBuffer          *buffer,
45                                         const GeglRectangle *region,
46                                         const Babl          *format,
47                                         GimpBoundaryType     type,
48                                         gint                 x1,
49                                         gint                 y1,
50                                         gint                 x2,
51                                         gint                 y2,
52                                         gfloat               threshold,
53                                         gint                *num_segs);
54 GimpBoundSeg * gimp_boundary_sort      (const GimpBoundSeg  *segs,
55                                         gint                 num_segs,
56                                         gint                *num_groups);
57 GimpBoundSeg * gimp_boundary_simplify  (GimpBoundSeg        *sorted_segs,
58                                         gint                 num_groups,
59                                         gint                *num_segs);
60 
61 /* offsets in-place */
62 void       gimp_boundary_offset        (GimpBoundSeg        *segs,
63                                         gint                 num_segs,
64                                         gint                 off_x,
65                                         gint                 off_y);
66 
67 
68 #endif  /*  __GIMP_BOUNDARY_H__  */
69