File indexing completed on 2024-12-22 04:04:13
0001 /* Copyright (C) 2001-2019 Peter Selinger. 0002 This file is part of Potrace. It is free software and it is covered 0003 by the GNU General Public License. See the file COPYING for details. */ 0004 0005 0006 #ifndef MAIN_H 0007 #define MAIN_H 0008 0009 #ifdef HAVE_CONFIG_H 0010 #include <config.h> 0011 #endif 0012 0013 #include "potracelib.h" 0014 #include "progress_bar.h" 0015 #include "auxiliary.h" 0016 #include "trans.h" 0017 0018 /* structure to hold a dimensioned value */ 0019 struct dim_s { 0020 double x; /* value */ 0021 double d; /* dimension (in pt), or 0 if not given */ 0022 }; 0023 typedef struct dim_s dim_t; 0024 0025 #define DIM_IN (72) 0026 #define DIM_CM (72 / 2.54) 0027 #define DIM_MM (72 / 25.4) 0028 #define DIM_PT (1) 0029 0030 /* set some configurable defaults */ 0031 0032 #ifdef USE_METRIC 0033 #define DEFAULT_DIM DIM_CM 0034 #define DEFAULT_DIM_NAME "centimeters" 0035 #else 0036 #define DEFAULT_DIM DIM_IN 0037 #define DEFAULT_DIM_NAME "inches" 0038 #endif 0039 0040 #ifdef USE_A4 0041 #define DEFAULT_PAPERWIDTH 595 0042 #define DEFAULT_PAPERHEIGHT 842 0043 #define DEFAULT_PAPERFORMAT "a4" 0044 #else 0045 #define DEFAULT_PAPERWIDTH 612 0046 #define DEFAULT_PAPERHEIGHT 792 0047 #define DEFAULT_PAPERFORMAT "letter" 0048 #endif 0049 0050 #ifdef DUMB_TTY 0051 #define DEFAULT_PROGRESS_BAR progress_bar_simplified 0052 #else 0053 #define DEFAULT_PROGRESS_BAR progress_bar_vt100 0054 #endif 0055 0056 0057 0058 struct backend_s; 0059 0060 /* structure to hold command line options */ 0061 struct info_s { 0062 struct backend_s *backend; /* type of backend (eps,ps,pgm etc) */ 0063 potrace_param_t *param; /* tracing parameters, see potracelib.h */ 0064 int debug; /* type of output (0-2) (for BACKEND_PS/EPS only) */ 0065 dim_t width_d; /* desired width of image */ 0066 dim_t height_d; /* desired height of image */ 0067 double rx; /* desired x resolution (in dpi) */ 0068 double ry; /* desired y resolution (in dpi) */ 0069 double sx; /* desired x scaling factor */ 0070 double sy; /* desired y scaling factor */ 0071 double stretch; /* ry/rx, if not otherwise determined */ 0072 dim_t lmar_d, rmar_d, tmar_d, bmar_d; /* margins */ 0073 double angle; /* rotate by this many degrees */ 0074 int paperwidth, paperheight; /* paper size for ps backend (in pt) */ 0075 int tight; /* should bounding box follow actual vector outline? */ 0076 double unit; /* granularity of output grid */ 0077 int compress; /* apply compression? */ 0078 int pslevel; /* postscript level to use: affects only compression */ 0079 int color; /* rgb color code 0xrrggbb: line color */ 0080 int fillcolor; /* rgb color code 0xrrggbb: fill color */ 0081 double gamma; /* gamma value for pgm backend */ 0082 int longcoding; /* do not optimize for file size? */ 0083 char *outfile; /* output filename, if given */ 0084 char **infiles; /* array of input filenames */ 0085 int infilecount; /* number of input filenames */ 0086 int some_infiles; /* do we process a list of input filenames? */ 0087 double blacklevel; /* 0 to 1: black/white cutoff in input file */ 0088 int invert; /* invert bitmap? */ 0089 int opaque; /* paint white shapes opaquely? */ 0090 int grouping; /* 0=flat; 1=connected components; 2=hierarchical */ 0091 int progress; /* should we display a progress bar? */ 0092 progress_bar_t *progress_bar; /* which progress bar to use */ 0093 }; 0094 typedef struct info_s info_t; 0095 0096 extern info_t info; 0097 0098 /* structure to hold per-image information, set e.g. by calc_dimensions */ 0099 struct imginfo_s { 0100 int pixwidth; /* width of input pixmap */ 0101 int pixheight; /* height of input pixmap */ 0102 double width; /* desired width of image (in pt or pixels) */ 0103 double height; /* desired height of image (in pt or pixels) */ 0104 double lmar, rmar, tmar, bmar; /* requested margins (in pt) */ 0105 trans_t trans; /* specify relative position of a tilted rectangle */ 0106 }; 0107 typedef struct imginfo_s imginfo_t; 0108 0109 #endif /* MAIN_H */