Statistics
| Revision:

gvsig-raster / libjni-potrace / trunk / libjni-potrace / src / main / native / jpotrace / potracelib.h @ 1780

History | View | Annotate | Download (4.37 KB)

1
/* Copyright (C) 2001-2007 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
/* this file defines the API for the core Potrace library. For a more
9
   detailed description of the API, see doc/potracelib.txt */
10

    
11
/* ---------------------------------------------------------------------- */
12
/* tracing parameters */
13

    
14
/* turn policies */
15
#define POTRACE_TURNPOLICY_BLACK 0
16
#define POTRACE_TURNPOLICY_WHITE 1
17
#define POTRACE_TURNPOLICY_LEFT 2
18
#define POTRACE_TURNPOLICY_RIGHT 3
19
#define POTRACE_TURNPOLICY_MINORITY 4
20
#define POTRACE_TURNPOLICY_MAJORITY 5
21
#define POTRACE_TURNPOLICY_RANDOM 6
22

    
23
/* structure to hold progress bar callback data */
24
struct potrace_progress_s {
25
  void (*callback)(double progress, void *privdata); /* callback fn */
26
  void *data;          /* callback function's private data */
27
  double min, max;     /* desired range of progress, e.g. 0.0 to 1.0 */
28
  double epsilon;      /* granularity: can skip smaller increments */
29
};
30
typedef struct potrace_progress_s potrace_progress_t;
31

    
32
/* structure to hold tracing parameters */
33
struct potrace_param_s {
34
  int turdsize;        /* area of largest path to be ignored */
35
  int turnpolicy;      /* resolves ambiguous turns in path decomposition */
36
  double alphamax;     /* corner threshold */
37
  int opticurve;       /* use curve optimization? */
38
  double opttolerance; /* curve optimization tolerance */
39
  potrace_progress_t progress; /* progress callback function */
40
};
41
typedef struct potrace_param_s potrace_param_t;
42

    
43
/* ---------------------------------------------------------------------- */
44
/* bitmaps */
45

    
46
/* native word size */
47
typedef unsigned long potrace_word;
48

    
49
/* Internal bitmap format. The n-th scanline starts at scanline(n) =
50
   (map + n*dy). Raster data is stored as a sequence of potrace_words
51
   (NOT bytes). The leftmost bit of scanline n is the most significant
52
   bit of scanline(n)[0]. */
53
struct potrace_bitmap_s {
54
  int w, h;              /* width and height, in pixels */
55
  int dy;                /* words per scanline (not bytes) */
56
  potrace_word *map;     /* raw data, dy*h words */
57
};
58
typedef struct potrace_bitmap_s potrace_bitmap_t;
59

    
60
/* ---------------------------------------------------------------------- */
61
/* curves */
62

    
63
/* point */
64
struct potrace_dpoint_s {
65
  double x, y;
66
};
67
typedef struct potrace_dpoint_s potrace_dpoint_t;
68

    
69
/* segment tags */
70
#define POTRACE_CURVETO 1
71
#define POTRACE_CORNER 2
72

    
73
/* closed curve segment */
74
struct potrace_curve_s {
75
  int n;                    /* number of segments */
76
  int *tag;                 /* tag[n]: POTRACE_CURVETO or POTRACE_CORNER */
77
  potrace_dpoint_t (*c)[3]; /* c[n][3]: control points. 
78
                               c[n][0] is unused for tag[n]=POTRACE_CORNER */
79
};
80
typedef struct potrace_curve_s potrace_curve_t;
81

    
82
/* Linked list of signed curve segments. Also carries a tree structure. */
83
struct potrace_path_s {
84
  int area;                         /* area of the bitmap path */
85
  int sign;                         /* '+' or '-', depending on orientation */
86
  potrace_curve_t curve;            /* this path's vector data */
87

    
88
  struct potrace_path_s *next;      /* linked list structure */
89

    
90
  struct potrace_path_s *childlist; /* tree structure */
91
  struct potrace_path_s *sibling;   /* tree structure */
92

    
93
  struct potrace_privpath_s *priv;  /* private state */
94
};
95
typedef struct potrace_path_s potrace_path_t;  
96

    
97
/* ---------------------------------------------------------------------- */
98
/* Potrace state */
99

    
100
#define POTRACE_STATUS_OK         0
101
#define POTRACE_STATUS_INCOMPLETE 1
102

    
103
struct potrace_state_s {
104
  int status;                       
105
  potrace_path_t *plist;            /* vector data */
106

    
107
  struct potrace_privstate_s *priv; /* private state */
108
};
109
typedef struct potrace_state_s potrace_state_t;
110

    
111
/* ---------------------------------------------------------------------- */
112
/* API functions */
113

    
114
/* get default parameters */
115
potrace_param_t *potrace_param_default(void);
116

    
117
/* free parameter set */
118
void potrace_param_free(potrace_param_t *p);
119

    
120
/* trace a bitmap*/
121
potrace_state_t *potrace_trace(const potrace_param_t *param, 
122
                               const potrace_bitmap_t *bm);
123

    
124
/* free a Potrace state */
125
void potrace_state_free(potrace_state_t *st);
126

    
127
/* return a static plain text version string identifying this version
128
   of potracelib */
129
char *potrace_version(void);
130

    
131
#endif /* POTRACELIB_H */