1 /* Copyright (C) 2001-2019 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 
6 #ifndef MAIN_H
7 #define MAIN_H
8 
9 #ifdef HAVE_CONFIG_H
10 #include <config.h>
11 #endif
12 
13 #include "potracelib.h"
14 #include "progress_bar.h"
15 #include "auxiliary.h"
16 #include "trans.h"
17 
18 /* structure to hold a dimensioned value */
19 struct dim_s {
20   double x; /* value */
21   double d; /* dimension (in pt), or 0 if not given */
22 };
23 typedef struct dim_s dim_t;
24 
25 #define DIM_IN (72)
26 #define DIM_CM (72 / 2.54)
27 #define DIM_MM (72 / 25.4)
28 #define DIM_PT (1)
29 
30 /* set some configurable defaults */
31 
32 #ifdef USE_METRIC
33 #define DEFAULT_DIM DIM_CM
34 #define DEFAULT_DIM_NAME "centimeters"
35 #else
36 #define DEFAULT_DIM DIM_IN
37 #define DEFAULT_DIM_NAME "inches"
38 #endif
39 
40 #ifdef USE_A4
41 #define DEFAULT_PAPERWIDTH 595
42 #define DEFAULT_PAPERHEIGHT 842
43 #define DEFAULT_PAPERFORMAT "a4"
44 #else
45 #define DEFAULT_PAPERWIDTH 612
46 #define DEFAULT_PAPERHEIGHT 792
47 #define DEFAULT_PAPERFORMAT "letter"
48 #endif
49 
50 #ifdef DUMB_TTY
51 #define DEFAULT_PROGRESS_BAR progress_bar_simplified
52 #else
53 #define DEFAULT_PROGRESS_BAR progress_bar_vt100
54 #endif
55 
56 
57 
58 struct backend_s;
59 
60 /* structure to hold command line options */
61 struct info_s {
62   struct backend_s *backend;  /* type of backend (eps,ps,pgm etc) */
63   potrace_param_t *param;  /* tracing parameters, see potracelib.h */
64   int debug;         /* type of output (0-2) (for BACKEND_PS/EPS only) */
65   dim_t width_d;     /* desired width of image */
66   dim_t height_d;    /* desired height of image */
67   double rx;         /* desired x resolution (in dpi) */
68   double ry;         /* desired y resolution (in dpi) */
69   double sx;         /* desired x scaling factor */
70   double sy;         /* desired y scaling factor */
71   double stretch;    /* ry/rx, if not otherwise determined */
72   dim_t lmar_d, rmar_d, tmar_d, bmar_d;   /* margins */
73   double angle;      /* rotate by this many degrees */
74   int paperwidth, paperheight;  /* paper size for ps backend (in pt) */
75   int tight;         /* should bounding box follow actual vector outline? */
76   double unit;       /* granularity of output grid */
77   int compress;      /* apply compression? */
78   int pslevel;       /* postscript level to use: affects only compression */
79   int color;         /* rgb color code 0xrrggbb: line color */
80   int fillcolor;     /* rgb color code 0xrrggbb: fill color */
81   double gamma;      /* gamma value for pgm backend */
82   int longcoding;    /* do not optimize for file size? */
83   char *outfile;     /* output filename, if given */
84   char **infiles;    /* array of input filenames */
85   int infilecount;   /* number of input filenames */
86   int some_infiles;  /* do we process a list of input filenames? */
87   double blacklevel; /* 0 to 1: black/white cutoff in input file */
88   int invert;        /* invert bitmap? */
89   int opaque;        /* paint white shapes opaquely? */
90   int grouping;      /* 0=flat; 1=connected components; 2=hierarchical */
91   int progress;      /* should we display a progress bar? */
92   progress_bar_t *progress_bar;  /* which progress bar to use */
93 };
94 typedef struct info_s info_t;
95 
96 extern info_t info;
97 
98 /* structure to hold per-image information, set e.g. by calc_dimensions */
99 struct imginfo_s {
100   int pixwidth;        /* width of input pixmap */
101   int pixheight;       /* height of input pixmap */
102   double width;        /* desired width of image (in pt or pixels) */
103   double height;       /* desired height of image (in pt or pixels) */
104   double lmar, rmar, tmar, bmar;   /* requested margins (in pt) */
105   trans_t trans;        /* specify relative position of a tilted rectangle */
106 };
107 typedef struct imginfo_s imginfo_t;
108 
109 #endif /* MAIN_H */
110