potracelib.h
Go to the documentation of this file.
00001 /* Copyright (C) 2001-2007 Peter Selinger.
00002    This file is part of Potrace. It is free software and it is covered
00003    by the GNU General Public License. See the file COPYING for details. */
00004 
00005 #ifndef POTRACELIB_H
00006 #define POTRACELIB_H
00007 
00008 /* this file defines the API for the core Potrace library. For a more
00009    detailed description of the API, see doc/potracelib.txt */
00010 
00011 /* ---------------------------------------------------------------------- */
00012 /* tracing parameters */
00013 
00014 /* turn policies */
00015 #define POTRACE_TURNPOLICY_BLACK 0
00016 #define POTRACE_TURNPOLICY_WHITE 1
00017 #define POTRACE_TURNPOLICY_LEFT 2
00018 #define POTRACE_TURNPOLICY_RIGHT 3
00019 #define POTRACE_TURNPOLICY_MINORITY 4
00020 #define POTRACE_TURNPOLICY_MAJORITY 5
00021 #define POTRACE_TURNPOLICY_RANDOM 6
00022 
00023 /* structure to hold progress bar callback data */
00024 struct potrace_progress_s {
00025   void (*callback)(double progress, void *privdata); /* callback fn */
00026   void *data;          /* callback function's private data */
00027   double min, max;     /* desired range of progress, e.g. 0.0 to 1.0 */
00028   double epsilon;      /* granularity: can skip smaller increments */
00029 };
00030 typedef struct potrace_progress_s potrace_progress_t;
00031 
00032 /* structure to hold tracing parameters */
00033 struct potrace_param_s {
00034   int turdsize;        /* area of largest path to be ignored */
00035   int turnpolicy;      /* resolves ambiguous turns in path decomposition */
00036   double alphamax;     /* corner threshold */
00037   int opticurve;       /* use curve optimization? */
00038   double opttolerance; /* curve optimization tolerance */
00039   potrace_progress_t progress; /* progress callback function */
00040 };
00041 typedef struct potrace_param_s potrace_param_t;
00042 
00043 /* ---------------------------------------------------------------------- */
00044 /* bitmaps */
00045 
00046 /* native word size */
00047 typedef unsigned long potrace_word;
00048 
00049 /* Internal bitmap format. The n-th scanline starts at scanline(n) =
00050    (map + n*dy). Raster data is stored as a sequence of potrace_words
00051    (NOT bytes). The leftmost bit of scanline n is the most significant
00052    bit of scanline(n)[0]. */
00053 struct potrace_bitmap_s {
00054   int w, h;              /* width and height, in pixels */
00055   int dy;                /* words per scanline (not bytes) */
00056   potrace_word *map;     /* raw data, dy*h words */
00057 };
00058 typedef struct potrace_bitmap_s potrace_bitmap_t;
00059 
00060 /* ---------------------------------------------------------------------- */
00061 /* curves */
00062 
00063 /* point */
00064 struct potrace_dpoint_s {
00065   double x, y;
00066 };
00067 typedef struct potrace_dpoint_s potrace_dpoint_t;
00068 
00069 /* segment tags */
00070 #define POTRACE_CURVETO 1
00071 #define POTRACE_CORNER 2
00072 
00073 /* closed curve segment */
00074 struct potrace_curve_s {
00075   int n;                    /* number of segments */
00076   int *tag;                 /* tag[n]: POTRACE_CURVETO or POTRACE_CORNER */
00077   potrace_dpoint_t (*c)[3]; /* c[n][3]: control points. 
00078                                c[n][0] is unused for tag[n]=POTRACE_CORNER */
00079 };
00080 typedef struct potrace_curve_s potrace_curve_t;
00081 
00082 /* Linked list of signed curve segments. Also carries a tree structure. */
00083 struct potrace_path_s {
00084   int area;                         /* area of the bitmap path */
00085   int sign;                         /* '+' or '-', depending on orientation */
00086   potrace_curve_t curve;            /* this path's vector data */
00087 
00088   struct potrace_path_s *next;      /* linked list structure */
00089 
00090   struct potrace_path_s *childlist; /* tree structure */
00091   struct potrace_path_s *sibling;   /* tree structure */
00092 
00093   struct potrace_privpath_s *priv;  /* private state */
00094 };
00095 typedef struct potrace_path_s potrace_path_t;  
00096 
00097 /* ---------------------------------------------------------------------- */
00098 /* Potrace state */
00099 
00100 #define POTRACE_STATUS_OK         0
00101 #define POTRACE_STATUS_INCOMPLETE 1
00102 
00103 struct potrace_state_s {
00104   int status;                       
00105   potrace_path_t *plist;            /* vector data */
00106 
00107   struct potrace_privstate_s *priv; /* private state */
00108 };
00109 typedef struct potrace_state_s potrace_state_t;
00110 
00111 /* ---------------------------------------------------------------------- */
00112 /* API functions */
00113 
00114 /* get default parameters */
00115 potrace_param_t *potrace_param_default(void);
00116 
00117 /* free parameter set */
00118 void potrace_param_free(potrace_param_t *p);
00119 
00120 /* trace a bitmap*/
00121 potrace_state_t *potrace_trace(const potrace_param_t *param, 
00122                                const potrace_bitmap_t *bm);
00123 
00124 /* free a Potrace state */
00125 void potrace_state_free(potrace_state_t *st);
00126 
00127 /* return a static plain text version string identifying this version
00128    of potracelib */
00129 char *potrace_version(void);
00130 
00131 #endif /* POTRACELIB_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


portrait_painter
Author(s): Niklas Meinzer, Ina Baumgarten
autogenerated on Wed Dec 26 2012 16:00:43