OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
potracelib.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2015 Peter Selinger.
2  This file is part of Potrace. It is free software and it is covered
3  by the GNU General Public License. See the file COPYING for details. */
4 
5 #ifndef POTRACELIB_H
6 #define POTRACELIB_H
7 
8 #include <stdio.h>
9 
10 /* this file defines the API for the core Potrace library. For a more
11  detailed description of the API, see potracelib.pdf */
12 
13 /* ---------------------------------------------------------------------- */
14 /* tracing parameters */
15 
16 /* turn policies */
17 #define POTRACE_TURNPOLICY_BLACK 0
18 #define POTRACE_TURNPOLICY_WHITE 1
19 #define POTRACE_TURNPOLICY_LEFT 2
20 #define POTRACE_TURNPOLICY_RIGHT 3
21 #define POTRACE_TURNPOLICY_MINORITY 4
22 #define POTRACE_TURNPOLICY_MAJORITY 5
23 #define POTRACE_TURNPOLICY_RANDOM 6
24 
25 /* structure to hold progress bar callback data */
27  void (*callback)(double progress, void *privdata); /* callback fn */
28  void *data; /* callback function's private data */
29  double min, max; /* desired range of progress, e.g. 0.0 to 1.0 */
30  double epsilon; /* granularity: can skip smaller increments */
31 };
33 
34 /* structure to hold tracing parameters */
36  int turdsize; /* area of largest path to be ignored */
37  int turnpolicy; /* resolves ambiguous turns in path decomposition */
38  double alphamax; /* corner threshold */
39  int opticurve; /* use curve optimization? */
40  double opttolerance; /* curve optimization tolerance */
41  potrace_progress_t progress; /* progress callback function */
42 };
44 
45 /* ---------------------------------------------------------------------- */
46 /* bitmaps */
47 
48 /* native word size */
49 typedef unsigned long potrace_word;
50 
51 /* Internal bitmap format. The n-th scanline starts at scanline(n) =
52  (map + n*dy). Raster data is stored as a sequence of potrace_words
53  (NOT bytes). The leftmost bit of scanline n is the most significant
54  bit of scanline(n)[0]. */
56  int w, h; /* width and height, in pixels */
57  int dy; /* words per scanline (not bytes) */
58  potrace_word *map; /* raw data, dy*h words */
59 };
61 
62 /* ---------------------------------------------------------------------- */
63 /* curves */
64 
65 /* point */
67  double x, y;
68 };
70 
71 /* segment tags */
72 #define POTRACE_CURVETO 1
73 #define POTRACE_CORNER 2
74 #define POTRACE_ENDPOINT 3
75 
76 /* closed curve segment */
78  int n; /* number of segments */
79  int *tag; /* tag[n]: POTRACE_CURVETO or POTRACE_CORNER */
80  potrace_dpoint_t (*c)[3]; /* c[n][3]: control points.
81  c[n][0] is unused for tag[n]=POTRACE_CORNER */
82 };
84 
85 /* Linked list of signed curve segments. Also carries a tree structure. */
87  int area; /* area of the bitmap path */
88  int sign; /* '+' or '-', depending on orientation */
89  potrace_curve_t curve; /* this path's vector data */
90 
91  struct potrace_path_s *next; /* linked list structure */
92 
93  struct potrace_path_s *childlist; /* tree structure */
94  struct potrace_path_s *sibling; /* tree structure */
95 
96  struct potrace_privpath_s *priv; /* private state */
97 };
99 
100 /* ---------------------------------------------------------------------- */
101 /* Potrace state */
102 
103 #define POTRACE_STATUS_OK 0
104 #define POTRACE_STATUS_INCOMPLETE 1
105 
107  int status;
108  potrace_path_t *plist; /* vector data */
109 
110  struct potrace_privstate_s *priv; /* private state */
111 };
113 
114 /* ---------------------------------------------------------------------- */
115 
116 /* API functions */
117 
118 /* get default parameters */
120 
121 /* free parameter set */
123 
124 /* trace a bitmap*/
126  const potrace_bitmap_t *bm);
127 
128 /* free a Potrace state */
130 
131 /* return a static plain text version string identifying this version
132  of potracelib */
133 char *potrace_version(void);
134 
135 /* Stub for GeoJSON output */
136 int potrace_geojson(FILE *fout, potrace_path_t *plist, int as_polygons);
137 
138 /* Stub for debug utility for outputting intermediate bitmap file */
139 void potrace_writepbm(FILE *fout, potrace_bitmap_t *bm);
140 
141 #endif /* POTRACELIB_H */
int potrace_geojson(FILE *fout, potrace_path_t *plist, int as_polygons)
void(* callback)(double progress, void *privdata)
Definition: potracelib.h:27
struct potrace_dpoint_s potrace_dpoint_t
Definition: potracelib.h:69
struct potrace_path_s * childlist
Definition: potracelib.h:93
double alphamax
Definition: potracelib.h:38
void potrace_param_free(potrace_param_t *p)
void potrace_writepbm(FILE *fout, potrace_bitmap_t *bm)
potrace_state_t * potrace_trace(const potrace_param_t *param, const potrace_bitmap_t *bm)
potrace_word * map
Definition: potracelib.h:58
unsigned long potrace_word
Definition: potracelib.h:49
char * potrace_version(void)
struct potrace_path_s * next
Definition: potracelib.h:91
struct potrace_privpath_s * priv
Definition: potracelib.h:96
potrace_progress_t progress
Definition: potracelib.h:41
struct potrace_privstate_s * priv
Definition: potracelib.h:110
void potrace_state_free(potrace_state_t *st)
double opttolerance
Definition: potracelib.h:40
struct potrace_path_s * sibling
Definition: potracelib.h:94
potrace_param_t * potrace_param_default(void)
potrace_path_t * plist
Definition: potracelib.h:108
potrace_dpoint_t(* c)[3]
Definition: potracelib.h:80
potrace_curve_t curve
Definition: potracelib.h:89