Revision 255
1.10/tags/gvSIG_3D_Animation_1_10_build_21_FINAL/libraries/libjni-potrace/src/main/java/org/gvsig/jpotrace/PotraceException.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.jpotrace; |
|
20 |
/** |
|
21 |
* La clase <code>PotraceException</code> es una forma de expresar que un |
|
22 |
* parametro ha sido mal usado en la libreria de jpotrace |
|
23 |
|
|
24 |
* @version 31/07/2008 |
|
25 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
26 |
*/ |
|
27 |
public class PotraceException extends Exception { |
|
28 |
private static final long serialVersionUID = -5761750440639572006L; |
|
29 |
|
|
30 |
public PotraceException(String msg) { |
|
31 |
super(msg); |
|
32 |
} |
|
33 |
} |
1.10/tags/gvSIG_3D_Animation_1_10_build_21_FINAL/libraries/libjni-potrace/src/main/java/org/gvsig/jpotrace/Potrace.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.jpotrace; |
|
20 |
/** |
|
21 |
* La clase <code>Potrace</code> contiene los metodos que comunican la libreria |
|
22 |
* nativa con Java |
|
23 |
* |
|
24 |
* @version 31/07/2008 |
|
25 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
26 |
*/ |
|
27 |
public class Potrace extends JNIBase { |
|
28 |
private static native double[] vectorizeBufferRasterNat(int[] bufferIn, int width, int height, String[] params); |
|
29 |
|
|
30 |
/** |
|
31 |
* Vectoriza un buffer pasado por parametro y es devuelto en forma de array |
|
32 |
* de doubles. Hay que especificar el ancho y alto del buffer y el buffer ha |
|
33 |
* de ser pasado en el formato que soporta potrace, que es en forma de bits. |
|
34 |
* |
|
35 |
* El parametro params es un array de Strings como se usaria en el tipico |
|
36 |
* main(char[]) para expresar los parametros de potrace, es una forma de poder |
|
37 |
* aprovechar todos los parametros del comando potrace desde Java. Algunos |
|
38 |
* no funcionan, como especificar el fichero origen o destino |
|
39 |
* |
|
40 |
* @param bufferIn |
|
41 |
* @param width |
|
42 |
* @param height |
|
43 |
* @param params |
|
44 |
* @return |
|
45 |
* @throws PotraceException |
|
46 |
*/ |
|
47 |
public static double[] vectorizeBufferRaster(int[] bufferIn, int width, int height, String[] params) throws PotraceException { |
|
48 |
if (bufferIn == null) |
|
49 |
throw new PotraceException("El parametro Buffer no puede estar vacio"); |
|
50 |
|
|
51 |
if (width <= 0) |
|
52 |
throw new PotraceException("El ancho del buffer ha de ser mayor a 0"); |
|
53 |
|
|
54 |
if (height <= 0) |
|
55 |
throw new PotraceException("El alto del buffer ha de ser mayor a 0"); |
|
56 |
|
|
57 |
return vectorizeBufferRasterNat(bufferIn, width, height, params); |
|
58 |
} |
|
59 |
} |
1.10/tags/gvSIG_3D_Animation_1_10_build_21_FINAL/libraries/libjni-potrace/src/main/java/org/gvsig/jpotrace/JNIBase.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.jpotrace; |
|
20 |
/** |
|
21 |
* La clase <code>JNIBase</code> sirve para cargar la libreria de jpotrace |
|
22 |
* |
|
23 |
* @version 31/07/2008 |
|
24 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
25 |
*/ |
|
26 |
public class JNIBase { |
|
27 |
static { |
|
28 |
String os = System.getProperty("os.name"); |
|
29 |
if (os.toLowerCase().startsWith("windows")) |
|
30 |
System.loadLibrary("jpotrace001"); |
|
31 |
else |
|
32 |
System.loadLibrary("jpotrace"); |
|
33 |
} |
|
34 |
} |
1.10/tags/gvSIG_3D_Animation_1_10_build_21_FINAL/libraries/libjni-potrace/src/main/native/jpotrace/bitmap.h | ||
---|---|---|
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 BITMAP_H |
|
6 |
#define BITMAP_H |
|
7 |
|
|
8 |
#ifdef HAVE_CONFIG_H |
|
9 |
#include "config.h" |
|
10 |
#endif |
|
11 |
|
|
12 |
#include <string.h> |
|
13 |
#include <stdlib.h> |
|
14 |
|
|
15 |
/* The bitmap type is defined in potracelib.h */ |
|
16 |
#include "potracelib.h" |
|
17 |
|
|
18 |
/* The present file defines some convenient macros and static inline |
|
19 |
functions for accessing bitmaps. Since they only produce inline |
|
20 |
code, they can be conveniently shared by the library and frontends, |
|
21 |
if desired */ |
|
22 |
|
|
23 |
/* ---------------------------------------------------------------------- */ |
|
24 |
/* some measurements */ |
|
25 |
|
|
26 |
#define BM_WORDSIZE ((int)sizeof(potrace_word)) |
|
27 |
#define BM_WORDBITS (8*BM_WORDSIZE) |
|
28 |
#define BM_HIBIT (((potrace_word)1)<<(BM_WORDBITS-1)) |
|
29 |
#define BM_ALLBITS (~(potrace_word)0) |
|
30 |
|
|
31 |
/* macros for accessing pixel at index (x,y). U* macros omit the |
|
32 |
bounds check. */ |
|
33 |
|
|
34 |
#define bm_scanline(bm, y) ((bm)->map + (y)*(bm)->dy) |
|
35 |
#define bm_index(bm, x, y) (&bm_scanline(bm, y)[(x)/BM_WORDBITS]) |
|
36 |
#define bm_mask(x) (BM_HIBIT >> ((x) & (BM_WORDBITS-1))) |
|
37 |
#define bm_range(x, a) ((int)(x) >= 0 && (int)(x) < (a)) |
|
38 |
#define bm_safe(bm, x, y) (bm_range(x, (bm)->w) && bm_range(y, (bm)->h)) |
|
39 |
#define BM_UGET(bm, x, y) ((*bm_index(bm, x, y) & bm_mask(x)) != 0) |
|
40 |
#define BM_USET(bm, x, y) (*bm_index(bm, x, y) |= bm_mask(x)) |
|
41 |
#define BM_UCLR(bm, x, y) (*bm_index(bm, x, y) &= ~bm_mask(x)) |
|
42 |
#define BM_UINV(bm, x, y) (*bm_index(bm, x, y) ^= bm_mask(x)) |
|
43 |
#define BM_UPUT(bm, x, y, b) ((b) ? BM_USET(bm, x, y) : BM_UCLR(bm, x, y)) |
|
44 |
#define BM_GET(bm, x, y) (bm_safe(bm, x, y) ? BM_UGET(bm, x, y) : 0) |
|
45 |
#define BM_SET(bm, x, y) (bm_safe(bm, x, y) ? BM_USET(bm, x, y) : 0) |
|
46 |
#define BM_CLR(bm, x, y) (bm_safe(bm, x, y) ? BM_UCLR(bm, x, y) : 0) |
|
47 |
#define BM_INV(bm, x, y) (bm_safe(bm, x, y) ? BM_UINV(bm, x, y) : 0) |
|
48 |
#define BM_PUT(bm, x, y, b) (bm_safe(bm, x, y) ? BM_UPUT(bm, x, y, b) : 0) |
|
49 |
|
|
50 |
/* free the given bitmap. Leaves errno untouched. */ |
|
51 |
static inline void bm_free(potrace_bitmap_t *bm) { |
|
52 |
if (bm) { |
|
53 |
free(bm->map); |
|
54 |
} |
|
55 |
free(bm); |
|
56 |
} |
|
57 |
|
|
58 |
/* return new un-initialized bitmap. NULL with errno on error */ |
|
59 |
static inline potrace_bitmap_t *bm_new(int w, int h) { |
|
60 |
potrace_bitmap_t *bm; |
|
61 |
int dy = (w + BM_WORDBITS - 1) / BM_WORDBITS; |
|
62 |
|
|
63 |
bm = (potrace_bitmap_t *) malloc(sizeof(potrace_bitmap_t)); |
|
64 |
if (!bm) { |
|
65 |
return NULL; |
|
66 |
} |
|
67 |
bm->w = w; |
|
68 |
bm->h = h; |
|
69 |
bm->dy = dy; |
|
70 |
bm->map = (potrace_word *) malloc(dy * h * BM_WORDSIZE); |
|
71 |
if (!bm->map) { |
|
72 |
free(bm); |
|
73 |
return NULL; |
|
74 |
} |
|
75 |
return bm; |
|
76 |
} |
|
77 |
|
|
78 |
/* clear the given bitmap. Set all bits to c. */ |
|
79 |
static inline void bm_clear(potrace_bitmap_t *bm, int c) { |
|
80 |
memset(bm->map, c ? -1 : 0, bm->dy * bm->h * BM_WORDSIZE); |
|
81 |
} |
|
82 |
|
|
83 |
/* duplicate the given bitmap. Return NULL on error with errno set. */ |
|
84 |
static inline potrace_bitmap_t *bm_dup(const potrace_bitmap_t *bm) { |
|
85 |
potrace_bitmap_t *bm1 = bm_new(bm->w, bm->h); |
|
86 |
if (!bm1) { |
|
87 |
return NULL; |
|
88 |
} |
|
89 |
memcpy(bm1->map, bm->map, bm->dy * bm->h * BM_WORDSIZE); |
|
90 |
return bm1; |
|
91 |
} |
|
92 |
|
|
93 |
/* invert the given bitmap. */ |
|
94 |
static inline void bm_invert(potrace_bitmap_t *bm) { |
|
95 |
int i; |
|
96 |
for (i = 0; i < bm->dy * bm->h; i++) { |
|
97 |
bm->map[i] ^= BM_ALLBITS; |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
#endif /* BITMAP_H */ |
1.10/tags/gvSIG_3D_Animation_1_10_build_21_FINAL/libraries/libjni-potrace/src/main/native/jpotrace/potrace_raster.h | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
#ifndef POTRACE_RASTER_H |
|
20 |
#define POTRACE_RASTER_H |
|
21 |
|
|
22 |
#include "potracelib.h" |
|
23 |
|
|
24 |
/* structure to hold a tilted rectangle */ |
|
25 |
struct rect_s { |
|
26 |
double bb[2]; /* dimensions of bounding box */ |
|
27 |
double orig[2]; /* origin relative to bounding box */ |
|
28 |
}; |
|
29 |
typedef struct rect_s rect_t; |
|
30 |
|
|
31 |
#ifdef USE_A4 |
|
32 |
#define DEFAULT_PAPERWIDTH 595 |
|
33 |
#define DEFAULT_PAPERHEIGHT 842 |
|
34 |
#define DEFAULT_PAPERFORMAT "a4" |
|
35 |
#else |
|
36 |
#define DEFAULT_PAPERWIDTH 612 |
|
37 |
#define DEFAULT_PAPERHEIGHT 792 |
|
38 |
#define DEFAULT_PAPERFORMAT "letter" |
|
39 |
#endif |
|
40 |
|
|
41 |
/* structure to hold a dimensioned value */ |
|
42 |
struct dim_s { |
|
43 |
double x; /* value */ |
|
44 |
double d; /* dimension (in pt), or 0 if not given */ |
|
45 |
}; |
|
46 |
typedef struct dim_s dim_t; |
|
47 |
|
|
48 |
/* structure to hold command line options */ |
|
49 |
struct info_s { |
|
50 |
struct backend_s *backend; /* type of backend (eps,ps,pgm etc) */ |
|
51 |
potrace_param_t *param; /* tracing parameters, see potracelib.h */ |
|
52 |
int debug; /* type of output (0-2) (for BACKEND_PS/EPS only) */ |
|
53 |
dim_t width_d; /* desired width of image */ |
|
54 |
dim_t height_d; /* desired height of image */ |
|
55 |
double rx; /* desired x resolution (in dpi) */ |
|
56 |
double ry; /* desired y resolution (in dpi) */ |
|
57 |
double sx; /* desired x scaling factor */ |
|
58 |
double sy; /* desired y scaling factor */ |
|
59 |
double stretch; /* ry/rx, if not otherwise determined */ |
|
60 |
dim_t lmar_d, rmar_d, tmar_d, bmar_d; /* margins */ |
|
61 |
double angle; /* rotate by this many degrees */ |
|
62 |
int paperwidth, paperheight; /* paper size for ps backend (in pt) */ |
|
63 |
double unit; /* granularity of output grid */ |
|
64 |
int compress; /* apply compression? */ |
|
65 |
int pslevel; /* postscript level to use: affects only compression */ |
|
66 |
int color; /* rgb color code 0xrrggbb: line color */ |
|
67 |
int fillcolor; /* rgb color code 0xrrggbb: fill color */ |
|
68 |
double gamma; /* gamma value for pgm backend */ |
|
69 |
int longcoding; /* do not optimize for file size? */ |
|
70 |
char *outfile; /* output filename, if given */ |
|
71 |
char **infiles; /* array of input filenames */ |
|
72 |
int infilecount; /* number of input filenames */ |
|
73 |
double blacklevel; /* 0 to 1: black/white cutoff in input file */ |
|
74 |
int invert; /* invert bitmap? */ |
|
75 |
int opaque; /* paint white shapes opaquely? */ |
|
76 |
int group; /* group paths together? */ |
|
77 |
int progress; /* should we display a progress bar? */ |
|
78 |
}; |
|
79 |
typedef struct info_s info_t; |
|
80 |
|
|
81 |
extern info_t info; |
|
82 |
|
|
83 |
/* structure to hold per-image information, set e.g. by calc_dimensions */ |
|
84 |
struct imginfo_s { |
|
85 |
int pixwidth; /* width of input pixmap */ |
|
86 |
int pixheight; /* height of input pixmap */ |
|
87 |
double width; /* desired width of image (in pt or pixels) */ |
|
88 |
double height; /* desired height of image (in pt or pixels) */ |
|
89 |
double lmar, rmar, tmar, bmar; /* requested margins (in pt) */ |
|
90 |
rect_t trans; /* specify relative position of a tilted rectangle */ |
|
91 |
}; |
|
92 |
typedef struct imginfo_s imginfo_t; |
|
93 |
|
|
94 |
double* vectorizarBuffer(const long *cbufferIn, int width, int height, int argc, char *argv[]); |
|
95 |
|
|
96 |
#endif /* POTRACE_RASTER_H */ |
1.10/tags/gvSIG_3D_Animation_1_10_build_21_FINAL/libraries/libjni-potrace/src/main/native/jpotrace/getopt1.c | ||
---|---|---|
1 |
/* getopt_long and getopt_long_only entry points for GNU getopt. |
|
2 |
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 |
|
3 |
Free Software Foundation, Inc. |
|
4 |
This file is part of the GNU C Library. |
|
5 |
|
|
6 |
The GNU C Library is free software; you can redistribute it and/or |
|
7 |
modify it under the terms of the GNU Library General Public License as |
|
8 |
published by the Free Software Foundation; either version 2 of the |
|
9 |
License, or (at your option) any later version. |
|
10 |
|
|
11 |
The GNU C Library is distributed in the hope that it will be useful, |
|
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
Library General Public License for more details. |
|
15 |
|
|
16 |
You should have received a copy of the GNU Library General Public |
|
17 |
License along with the GNU C Library; see the file COPYING.LIB. If not, |
|
18 |
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
19 |
Boston, MA 02111-1307, USA. */ |
|
20 |
|
|
21 |
#ifdef HAVE_CONFIG_H |
|
22 |
#include "config.h" |
|
23 |
#endif |
|
24 |
|
|
25 |
#include "getopt.h" |
|
26 |
|
|
27 |
#if !defined __STDC__ || !__STDC__ |
|
28 |
/* This is a separate conditional since some stdc systems |
|
29 |
reject `defined (const)'. */ |
|
30 |
#ifndef const |
|
31 |
#define const |
|
32 |
#endif |
|
33 |
#endif |
|
34 |
|
|
35 |
#include <stdio.h> |
|
36 |
|
|
37 |
/* Comment out all this code if we are using the GNU C Library, and are not |
|
38 |
actually compiling the library itself. This code is part of the GNU C |
|
39 |
Library, but also included in many other GNU distributions. Compiling |
|
40 |
and linking in this code is a waste when using the GNU C library |
|
41 |
(especially if it is a shared library). Rather than having every GNU |
|
42 |
program understand `configure --with-gnu-libc' and omit the object files, |
|
43 |
it is simpler to just do this in the source for each such file. */ |
|
44 |
|
|
45 |
#define GETOPT_INTERFACE_VERSION 2 |
|
46 |
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 |
|
47 |
#include <gnu-versions.h> |
|
48 |
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION |
|
49 |
#define ELIDE_CODE |
|
50 |
#endif |
|
51 |
#endif |
|
52 |
|
|
53 |
#ifndef ELIDE_CODE |
|
54 |
|
|
55 |
|
|
56 |
/* This needs to come after some library #include |
|
57 |
to get __GNU_LIBRARY__ defined. */ |
|
58 |
#ifdef __GNU_LIBRARY__ |
|
59 |
#include <stdlib.h> |
|
60 |
#endif |
|
61 |
|
|
62 |
#ifndef NULL |
|
63 |
#define NULL 0 |
|
64 |
#endif |
|
65 |
|
|
66 |
int |
|
67 |
getopt_long (argc, argv, options, long_options, opt_index) |
|
68 |
int argc; |
|
69 |
char *const *argv; |
|
70 |
const char *options; |
|
71 |
const struct option *long_options; |
|
72 |
int *opt_index; |
|
73 |
{ |
|
74 |
return _getopt_internal (argc, argv, options, long_options, opt_index, 0); |
|
75 |
} |
|
76 |
|
|
77 |
/* Like getopt_long, but '-' as well as '--' can indicate a long option. |
|
78 |
If an option that starts with '-' (not '--') doesn't match a long option, |
|
79 |
but does match a short option, it is parsed as a short option |
|
80 |
instead. */ |
|
81 |
|
|
82 |
int |
|
83 |
getopt_long_only (argc, argv, options, long_options, opt_index) |
|
84 |
int argc; |
|
85 |
char *const *argv; |
|
86 |
const char *options; |
|
87 |
const struct option *long_options; |
|
88 |
int *opt_index; |
|
89 |
{ |
|
90 |
return _getopt_internal (argc, argv, options, long_options, opt_index, 1); |
|
91 |
} |
|
92 |
|
|
93 |
|
|
94 |
#endif /* Not ELIDE_CODE. */ |
|
95 |
|
|
96 |
#ifdef TEST |
|
97 |
|
|
98 |
#include <stdio.h> |
|
99 |
|
|
100 |
int |
|
101 |
main (argc, argv) |
|
102 |
int argc; |
|
103 |
char **argv; |
|
104 |
{ |
|
105 |
int c; |
|
106 |
int digit_optind = 0; |
|
107 |
|
|
108 |
while (1) |
|
109 |
{ |
|
110 |
int this_option_optind = optind ? optind : 1; |
|
111 |
int option_index = 0; |
|
112 |
static struct option long_options[] = |
|
113 |
{ |
|
114 |
{"add", 1, 0, 0}, |
|
115 |
{"append", 0, 0, 0}, |
|
116 |
{"delete", 1, 0, 0}, |
|
117 |
{"verbose", 0, 0, 0}, |
|
118 |
{"create", 0, 0, 0}, |
|
119 |
{"file", 1, 0, 0}, |
|
120 |
{0, 0, 0, 0} |
|
121 |
}; |
|
122 |
|
|
123 |
c = getopt_long (argc, argv, "abc:d:0123456789", |
|
124 |
long_options, &option_index); |
|
125 |
if (c == -1) |
|
126 |
break; |
|
127 |
|
|
128 |
switch (c) |
|
129 |
{ |
|
130 |
case 0: |
|
131 |
printf ("option %s", long_options[option_index].name); |
|
132 |
if (optarg) |
|
133 |
printf (" with arg %s", optarg); |
|
134 |
printf ("\n"); |
|
135 |
break; |
|
136 |
|
|
137 |
case '0': |
|
138 |
case '1': |
|
139 |
case '2': |
|
140 |
case '3': |
|
141 |
case '4': |
|
142 |
case '5': |
|
143 |
case '6': |
|
144 |
case '7': |
|
145 |
case '8': |
|
146 |
case '9': |
|
147 |
if (digit_optind != 0 && digit_optind != this_option_optind) |
|
148 |
printf ("digits occur in two different argv-elements.\n"); |
|
149 |
digit_optind = this_option_optind; |
|
150 |
printf ("option %c\n", c); |
|
151 |
break; |
|
152 |
|
|
153 |
case 'a': |
|
154 |
printf ("option a\n"); |
|
155 |
break; |
|
156 |
|
|
157 |
case 'b': |
|
158 |
printf ("option b\n"); |
|
159 |
break; |
|
160 |
|
|
161 |
case 'c': |
|
162 |
printf ("option c with value `%s'\n", optarg); |
|
163 |
break; |
|
164 |
|
|
165 |
case 'd': |
|
166 |
printf ("option d with value `%s'\n", optarg); |
|
167 |
break; |
|
168 |
|
|
169 |
case '?': |
|
170 |
break; |
|
171 |
|
|
172 |
default: |
|
173 |
printf ("?? getopt returned character code 0%o ??\n", c); |
|
174 |
} |
|
175 |
} |
|
176 |
|
|
177 |
if (optind < argc) |
|
178 |
{ |
|
179 |
printf ("non-option ARGV-elements: "); |
|
180 |
while (optind < argc) |
|
181 |
printf ("%s ", argv[optind++]); |
|
182 |
printf ("\n"); |
|
183 |
} |
|
184 |
|
|
185 |
exit (0); |
|
186 |
} |
|
187 |
|
|
188 |
#endif /* TEST */ |
1.10/tags/gvSIG_3D_Animation_1_10_build_21_FINAL/libraries/libjni-potrace/src/main/native/jpotrace/curve.c | ||
---|---|---|
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 |
/* $Id: curve.c 147 2007-04-09 00:44:09Z selinger $ */ |
|
6 |
/* private part of the path and curve data structures */ |
|
7 |
|
|
8 |
#include <stdio.h> |
|
9 |
#include <stdlib.h> |
|
10 |
#include <string.h> |
|
11 |
|
|
12 |
#include "potracelib.h" |
|
13 |
#include "lists.h" |
|
14 |
#include "curve.h" |
|
15 |
|
|
16 |
#define SAFE_MALLOC(var, n, typ) \ |
|
17 |
if ((var = (typ *)malloc((n)*sizeof(typ))) == NULL) goto malloc_error |
|
18 |
|
|
19 |
/* ---------------------------------------------------------------------- */ |
|
20 |
/* allocate and free path objects */ |
|
21 |
|
|
22 |
path_t *path_new(void) { |
|
23 |
path_t *p = NULL; |
|
24 |
privpath_t *priv = NULL; |
|
25 |
|
|
26 |
SAFE_MALLOC(p, 1, path_t); |
|
27 |
memset(p, 0, sizeof(path_t)); |
|
28 |
SAFE_MALLOC(priv, 1, privpath_t); |
|
29 |
memset(priv, 0, sizeof(privpath_t)); |
|
30 |
p->priv = priv; |
|
31 |
return p; |
|
32 |
|
|
33 |
malloc_error: |
|
34 |
free(p); |
|
35 |
free(priv); |
|
36 |
return NULL; |
|
37 |
} |
|
38 |
|
|
39 |
/* free the members of the given curve structure. Leave errno unchanged. */ |
|
40 |
static void privcurve_free_members(privcurve_t *curve) { |
|
41 |
free(curve->tag); |
|
42 |
free(curve->c); |
|
43 |
free(curve->vertex); |
|
44 |
free(curve->alpha); |
|
45 |
free(curve->alpha0); |
|
46 |
free(curve->beta); |
|
47 |
} |
|
48 |
|
|
49 |
/* free a path. Leave errno untouched. */ |
|
50 |
void path_free(path_t *p) { |
|
51 |
if (p) { |
|
52 |
if (p->priv) { |
|
53 |
free(p->priv->pt); |
|
54 |
free(p->priv->lon); |
|
55 |
free(p->priv->sums); |
|
56 |
free(p->priv->po); |
|
57 |
privcurve_free_members(&p->priv->curve); |
|
58 |
privcurve_free_members(&p->priv->ocurve); |
|
59 |
} |
|
60 |
free(p->priv); |
|
61 |
/* do not free p->fcurve ! */ |
|
62 |
} |
|
63 |
free(p); |
|
64 |
} |
|
65 |
|
|
66 |
/* free a pathlist, leaving errno untouched. */ |
|
67 |
void pathlist_free(path_t *plist) { |
|
68 |
path_t *p; |
|
69 |
|
|
70 |
list_forall_unlink(p, plist) { |
|
71 |
path_free(p); |
|
72 |
} |
|
73 |
} |
|
74 |
|
|
75 |
/* ---------------------------------------------------------------------- */ |
|
76 |
/* initialize and finalize curve structures */ |
|
77 |
|
|
78 |
typedef dpoint_t dpoint3_t[3]; |
|
79 |
|
|
80 |
/* initialize the members of the given curve structure to size m. |
|
81 |
Return 0 on success, 1 on error with errno set. */ |
|
82 |
int privcurve_init(privcurve_t *curve, int n) { |
|
83 |
memset(curve, 0, sizeof(privcurve_t)); |
|
84 |
curve->n = n; |
|
85 |
SAFE_MALLOC(curve->tag, n, int); |
|
86 |
SAFE_MALLOC(curve->c, n, dpoint3_t); |
|
87 |
SAFE_MALLOC(curve->vertex, n, dpoint_t); |
|
88 |
SAFE_MALLOC(curve->alpha, n, double); |
|
89 |
SAFE_MALLOC(curve->alpha0, n, double); |
|
90 |
SAFE_MALLOC(curve->beta, n, double); |
|
91 |
return 0; |
|
92 |
|
|
93 |
malloc_error: |
|
94 |
free(curve->tag); |
|
95 |
free(curve->c); |
|
96 |
free(curve->vertex); |
|
97 |
free(curve->alpha); |
|
98 |
free(curve->alpha0); |
|
99 |
free(curve->beta); |
|
100 |
return 1; |
|
101 |
} |
|
102 |
|
|
103 |
/* copy private to public curve structure */ |
|
104 |
void privcurve_to_curve(privcurve_t *pc, potrace_curve_t *c) { |
|
105 |
c->n = pc->n; |
|
106 |
c->tag = pc->tag; |
|
107 |
c->c = pc->c; |
|
108 |
} |
|
109 |
|
1.10/tags/gvSIG_3D_Animation_1_10_build_21_FINAL/libraries/libjni-potrace/src/main/native/jpotrace/main.c | ||
---|---|---|
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 |
/* $Id: main.c 147 2007-04-09 00:44:09Z selinger $ */ |
|
6 |
|
|
7 |
#include <stdio.h> |
|
8 |
#include <stdlib.h> |
|
9 |
#include <errno.h> |
|
10 |
#include <string.h> |
|
11 |
#include <getopt.h> |
|
12 |
#include <math.h> |
|
13 |
|
|
14 |
#include "main.h" |
|
15 |
#include "potracelib.h" |
|
16 |
#include "backend_pdf.h" |
|
17 |
#include "backend_eps.h" |
|
18 |
#include "backend_pgm.h" |
|
19 |
#include "backend_svg.h" |
|
20 |
#include "backend_gimp.h" |
|
21 |
#include "backend_xfig.h" |
|
22 |
#include "potracelib.h" |
|
23 |
#include "bitmap_io.h" |
|
24 |
#include "bitmap.h" |
|
25 |
#include "platform.h" |
|
26 |
#include "auxiliary.h" |
|
27 |
|
|
28 |
#ifdef HAVE_CONFIG_H |
|
29 |
#include "config.h" |
|
30 |
#endif |
|
31 |
|
|
32 |
#ifndef M_PI |
|
33 |
#define M_PI 3.14159265358979323846 |
|
34 |
#endif |
|
35 |
|
|
36 |
#define UNDEF ((double)(1e30)) /* a value to represent "undefined" */ |
|
37 |
#define INFTY ((double)(1e30)) /* a value to represent +infinity */ |
|
38 |
|
|
39 |
struct info_s info; |
|
40 |
|
|
41 |
#define COL0 "\033[G" /* reset cursor to column 0 */ |
|
42 |
|
|
43 |
/* ---------------------------------------------------------------------- */ |
|
44 |
/* callback function for progress bar */ |
|
45 |
|
|
46 |
struct simple_progress_s { |
|
47 |
char name[22]; /* filename for status bar */ |
|
48 |
double dnext; /* threshold value for next tick */ |
|
49 |
}; |
|
50 |
typedef struct simple_progress_s simple_progress_t; |
|
51 |
|
|
52 |
/* print a simple progress bar. This is a callback function that is |
|
53 |
potentially called often; thus, it has been optimized for the |
|
54 |
typical case, which is when the progress bar does not need updating. */ |
|
55 |
static void simple_progress(double d, void *data) { |
|
56 |
simple_progress_t *p = (simple_progress_t *)data; |
|
57 |
static char b[] = "========================================"; |
|
58 |
int tick; /* number of visible tickmarks, 0..40 */ |
|
59 |
int perc; /* visible percentage, 0..100 */ |
|
60 |
|
|
61 |
/* note: the 0.01 and 0.025 ensure that we always end on 40 |
|
62 |
tickmarks and 100%, despite any rounding errors. The 0.995 |
|
63 |
ensures that tick always increases when d >= p->dnext. */ |
|
64 |
if (d >= p->dnext) { |
|
65 |
tick = (int) floor(d*40+0.01); |
|
66 |
perc = (int) floor(d*100+0.025); |
|
67 |
fprintf(stderr, "%-21s |%-40s| %d%% "COL0"", p->name, b+40-tick, perc); |
|
68 |
p->dnext = (tick+0.995) / 40.0; |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
/* Initialize parameters for simple progress bar. The caller passes an |
|
73 |
allocated simple_progress_t structure to avoid having to malloc it |
|
74 |
here and free it later. */ |
|
75 |
static inline void init_progress(potrace_progress_t *prog, simple_progress_t *p, const char *filename, int count) { |
|
76 |
const char *q, *s; |
|
77 |
int len; |
|
78 |
|
|
79 |
/* initialize callback function's data */ |
|
80 |
p->dnext = 0; |
|
81 |
|
|
82 |
if (count != 0) { |
|
83 |
sprintf(p->name, " (p.%d):", count+1); |
|
84 |
} else { |
|
85 |
s = filename; |
|
86 |
if ((q = strrchr(s, '/')) != NULL) { |
|
87 |
s = q+1; |
|
88 |
} |
|
89 |
len = strlen(s); |
|
90 |
strncpy(p->name, s, 21); |
|
91 |
p->name[20] = 0; |
|
92 |
if (len > 20) { |
|
93 |
p->name[17] = '.'; |
|
94 |
p->name[18] = '.'; |
|
95 |
p->name[19] = '.'; |
|
96 |
} |
|
97 |
strcat(p->name, ":"); |
|
98 |
} |
|
99 |
|
|
100 |
/* initialize progress parameters */ |
|
101 |
prog->callback = &simple_progress; |
|
102 |
prog->data = (void *)p; |
|
103 |
prog->min = 0.0; |
|
104 |
prog->max = 1.0; |
|
105 |
prog->epsilon = 0.0; |
|
106 |
|
|
107 |
/* draw first progress bar */ |
|
108 |
simple_progress(0.0, prog->data); |
|
109 |
return; |
|
110 |
} |
|
111 |
|
|
112 |
/* ---------------------------------------------------------------------- */ |
|
113 |
/* some data structures for option processing */ |
|
114 |
|
|
115 |
struct pageformat_s { |
|
116 |
char *name; |
|
117 |
int w, h; |
|
118 |
}; |
|
119 |
typedef struct pageformat_s pageformat_t; |
|
120 |
|
|
121 |
/* dimensions of the various page formats, in postscript points */ |
|
122 |
static pageformat_t pageformat[] = { |
|
123 |
{ "a4", 595, 842 }, |
|
124 |
{ "a3", 842, 1191 }, |
|
125 |
{ "a5", 421, 595 }, |
|
126 |
{ "b5", 516, 729 }, |
|
127 |
{ "letter", 612, 792 }, |
|
128 |
{ "legal", 612, 1008 }, |
|
129 |
{ "tabloid", 792, 1224 }, |
|
130 |
{ "statement", 396, 612 }, |
|
131 |
{ "executive", 540, 720 }, |
|
132 |
{ "folio", 612, 936 }, |
|
133 |
{ "quarto", 610, 780 }, |
|
134 |
{ "10x14", 720, 1008 }, |
|
135 |
{ NULL, 0, 0 }, |
|
136 |
}; |
|
137 |
|
|
138 |
struct turnpolicy_s { |
|
139 |
char *name; |
|
140 |
int n; |
|
141 |
}; |
|
142 |
typedef struct turnpolicy_s turnpolicy_t; |
|
143 |
|
|
144 |
/* names of turn policies */ |
|
145 |
static turnpolicy_t turnpolicy[] = { |
|
146 |
{"black", POTRACE_TURNPOLICY_BLACK}, |
|
147 |
{"white", POTRACE_TURNPOLICY_WHITE}, |
|
148 |
{"left", POTRACE_TURNPOLICY_LEFT}, |
|
149 |
{"right", POTRACE_TURNPOLICY_RIGHT}, |
|
150 |
{"minority", POTRACE_TURNPOLICY_MINORITY}, |
|
151 |
{"majority", POTRACE_TURNPOLICY_MAJORITY}, |
|
152 |
{"random", POTRACE_TURNPOLICY_RANDOM}, |
|
153 |
{NULL, 0}, |
|
154 |
}; |
|
155 |
|
|
156 |
/* backends and their characteristics */ |
|
157 |
struct backend_s { |
|
158 |
char *name; /* name of this backend */ |
|
159 |
char *ext; /* file extension */ |
|
160 |
int fixed; /* fixed page size backend? */ |
|
161 |
int pixel; /* pixel-based backend? */ |
|
162 |
int multi; /* multi-page backend? */ |
|
163 |
int (*init_f)(FILE *fout); /* initialization function */ |
|
164 |
int (*page_f)(FILE *fout, potrace_path_t *plist, imginfo_t *imginfo); |
|
165 |
/* per-bitmap function */ |
|
166 |
int (*term_f)(FILE *fout); /* finalization function */ |
|
167 |
int opticurve; /* opticurve capable (true Bezier curves?) */ |
|
168 |
}; |
|
169 |
typedef struct backend_s backend_t; |
|
170 |
|
|
171 |
static backend_t backend[] = { |
|
172 |
{"eps", ".eps", 0, 0, 0, NULL, page_eps, NULL, 1}, |
|
173 |
{"postscript", ".ps", 1, 0, 1, init_ps, page_ps, term_ps, 1}, |
|
174 |
{"ps", ".ps", 1, 0, 1, init_ps, page_ps, term_ps, 1}, |
|
175 |
{"pdf", ".pdf", 0, 0, 1, init_pdf,page_pdf, term_pdf, 1}, |
|
176 |
{"svg", ".svg", 0, 0, 0, NULL, page_svg, NULL, 1}, |
|
177 |
{"pgm", ".pgm", 0, 1, 1, NULL, page_pgm, NULL, 1}, |
|
178 |
{"gimppath", ".gimppath", 0, 1, 0, NULL, page_gimp, NULL, 1}, |
|
179 |
{"xfig", ".fig", 1, 0, 0, NULL, page_xfig, NULL, 0}, |
|
180 |
{NULL, NULL, 0, 0, 0, NULL, NULL, NULL}, |
|
181 |
}; |
|
182 |
|
|
183 |
/* look up a backend by name. If found, return 0 and set *bp. If not |
|
184 |
found leave *bp unchanged and return 1, or 2 on ambiguous |
|
185 |
prefix. */ |
|
186 |
static int backend_lookup(char *name, backend_t **bp) { |
|
187 |
int i; |
|
188 |
int m=0; /* prefix matches */ |
|
189 |
backend_t *b = NULL; |
|
190 |
|
|
191 |
for (i=0; backend[i].name; i++) { |
|
192 |
if (strcasecmp(backend[i].name, name)==0) { |
|
193 |
*bp = &backend[i]; |
|
194 |
return 0; |
|
195 |
} else if (strncasecmp(backend[i].name, name, strlen(name))==0) { |
|
196 |
m++; |
|
197 |
b = &backend[i]; |
|
198 |
} |
|
199 |
} |
|
200 |
/* if there was no exact match, and exactly one prefix match, use that */ |
|
201 |
if (m==1) { |
|
202 |
*bp = b; |
|
203 |
return 0; |
|
204 |
} else if (m) { |
|
205 |
return 2; |
|
206 |
} else { |
|
207 |
return 1; |
|
208 |
} |
|
209 |
} |
|
210 |
|
|
211 |
/* list all available backends by name, in a comma separated list. |
|
212 |
Assume the cursor starts in column j, and break lines at length |
|
213 |
linelen. Do not output any trailing punctuation. Return the column |
|
214 |
the cursor is in. */ |
|
215 |
static int backend_list(FILE *fout, int j, int linelen) { |
|
216 |
int i; |
|
217 |
|
|
218 |
for (i=0; backend[i].name; i++) { |
|
219 |
if (j + (int)strlen(backend[i].name) > linelen) { |
|
220 |
fprintf(fout, "\n"); |
|
221 |
j = 0; |
|
222 |
} |
|
223 |
j += fprintf(fout, "%s", backend[i].name); |
|
224 |
if (backend[i+1].name) { |
|
225 |
j += fprintf(fout, ", "); |
|
226 |
} |
|
227 |
} |
|
228 |
return j; |
|
229 |
} |
|
230 |
|
|
231 |
/* ---------------------------------------------------------------------- */ |
|
232 |
/* some info functions */ |
|
233 |
|
|
234 |
static void license(FILE *f) { |
|
235 |
fprintf(f, |
|
236 |
"This program is free software; you can redistribute it and/or modify\n" |
|
237 |
"it under the terms of the GNU General Public License as published by\n" |
|
238 |
"the Free Software Foundation; either version 2 of the License, or\n" |
|
239 |
"(at your option) any later version.\n" |
|
240 |
"\n" |
|
241 |
"This program is distributed in the hope that it will be useful,\n" |
|
242 |
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" |
|
243 |
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" |
|
244 |
"GNU General Public License for more details.\n" |
|
245 |
"\n" |
|
246 |
"You should have received a copy of the GNU General Public License\n" |
|
247 |
"along with this program; if not, write to the Free Software\n" |
|
248 |
"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.\n" |
|
249 |
); |
|
250 |
} |
|
251 |
|
|
252 |
static void show_defaults(FILE *f) { |
|
253 |
fprintf(f, "This version of Potrace was compiled with the following defaults:\n"); |
|
254 |
fprintf(f, "Default unit: "DEFAULT_DIM_NAME"\n"); |
|
255 |
fprintf(f, "Default page size: "DEFAULT_PAPERFORMAT"\n"); |
|
256 |
} |
|
257 |
|
|
258 |
static void usage(FILE *f) { |
|
259 |
int j; |
|
260 |
|
|
261 |
fprintf(f, "Usage: "POTRACE" [options] [file...]\n"); |
|
262 |
fprintf(f, "General options:\n"); |
|
263 |
fprintf(f, " -h, --help - print this help message and exit\n"); |
|
264 |
fprintf(f, " -v, --version - print version info and exit\n"); |
|
265 |
fprintf(f, " -l, --license - print license info and exit\n"); |
|
266 |
fprintf(f, " -V, --show-defaults - print compiled-in defaults and exit\n"); |
|
267 |
fprintf(f, " --progress - show progress bar\n"); |
|
268 |
fprintf(f, "Input/output options:\n"); |
|
269 |
fprintf(f, " -o, --output <file> - output to file\n"); |
|
270 |
fprintf(f, "Backend selection:\n"); |
|
271 |
fprintf(f, " -e, --eps - EPS backend (encapsulated postscript) (default)\n"); |
|
272 |
fprintf(f, " -p, --postscript - Postscript backend\n"); |
|
273 |
fprintf(f, " -s, --svg - SVG backend (scalable vector graphics)\n"); |
|
274 |
fprintf(f, " -g, --pgm - PGM backend (portable greymap)\n"); |
|
275 |
fprintf(f, " -b, --backend <name> - select backend by name\n"); |
|
276 |
fprintf(f, "Algorithm options:\n"); |
|
277 |
fprintf(f, " -z, --turnpolicy <policy> - how to resolve ambiguities in path decomposition\n"); |
|
278 |
fprintf(f, " -t, --turdsize <n> - suppress speckles of up to this size (default 2)\n"); |
|
279 |
fprintf(f, " -a, --alphamax <n> - corner threshold parameter (default 1)\n"); |
|
280 |
fprintf(f, " -n, --longcurve - turn off curve optimization\n"); |
|
281 |
fprintf(f, " -O, --opttolerance <n> - curve optimization tolerance (default 0.2)\n"); |
|
282 |
fprintf(f, " -u, --unit <n> - quantize output to 1/unit pixels (default 10)\n"); |
|
283 |
fprintf(f, " -d, --debug <n> - produce debugging output of type n (n=1,2,3)\n"); |
|
284 |
fprintf(f, "Scaling and placement options:\n"); |
|
285 |
fprintf(f, " -W, --width <dim> - width of output image\n"); |
|
286 |
fprintf(f, " -H, --height <dim> - height of output image\n"); |
|
287 |
fprintf(f, " -r, --resolution <n>[x<n>] - resolution (in dpi)\n"); |
|
288 |
fprintf(f, " -x, --scale <n>[x<n>] - scaling factor (pgm backend)\n"); |
|
289 |
fprintf(f, " -S, --stretch <n> - yresolution/xresolution\n"); |
|
290 |
fprintf(f, " -A, --rotate <angle> - rotate counterclockwise by angle\n"); |
|
291 |
fprintf(f, " -M, --margin <dim> - margin\n"); |
|
292 |
fprintf(f, " -L, --leftmargin <dim> - left margin\n"); |
|
293 |
fprintf(f, " -R, --rightmargin <dim> - right margin\n"); |
|
294 |
fprintf(f, " -T, --topmargin <dim> - top margin\n"); |
|
295 |
fprintf(f, " -B, --bottommargin <dim> - bottom margin\n"); |
|
296 |
fprintf(f, "Output options, supported by some backends:\n"); |
|
297 |
fprintf(f, " -C, --color #rrggbb - set line color (default black)\n"); |
|
298 |
fprintf(f, " --fillcolor #rrggbb - set fill color (default transparent)\n"); |
|
299 |
fprintf(f, " --opaque - make white shapes opaque\n"); |
|
300 |
fprintf(f, " --group - group related paths together\n"); |
|
301 |
fprintf(f, "Postscript/EPS options:\n"); |
|
302 |
fprintf(f, " -P, --pagesize <format> - page size (default is "DEFAULT_PAPERFORMAT")\n"); |
|
303 |
fprintf(f, " -c, --cleartext - do not compress the output\n"); |
|
304 |
fprintf(f, " -2, --level2 - use postscript level 2 compression (default)\n"); |
|
305 |
#ifdef HAVE_ZLIB |
|
306 |
fprintf(f, " -3, --level3 - use postscript level 3 compression\n"); |
|
307 |
#endif |
|
308 |
fprintf(f, " -q, --longcoding - do not optimize for file size\n"); |
|
309 |
fprintf(f, "PGM options:\n"); |
|
310 |
fprintf(f, " -G, --gamma <n> - gamma value for anti-aliasing (default 2.2)\n"); |
|
311 |
fprintf(f, "Frontend options:\n"); |
|
312 |
fprintf(f, " -k, --blacklevel <n> - black/white cutoff in input file (default 0.5)\n"); |
|
313 |
fprintf(f, " -i, --invert - invert bitmap\n"); |
|
314 |
fprintf(f, "\n"); |
|
315 |
fprintf(f, "Dimensions can have optional units, e.g. 6.5in, 15cm, 100pt.\n"); |
|
316 |
fprintf(f, "Default is "DEFAULT_DIM_NAME" (or pixels for pgm and gimppath backends).\n"); |
|
317 |
fprintf(f, "Possible input file formats are: pnm (pbm, pgm, ppm), bmp.\n"); |
|
318 |
j = fprintf(f, "Backends are: "); |
|
319 |
backend_list(f, j, 70); |
|
320 |
fprintf(f, ".\n"); |
|
321 |
} |
|
322 |
|
|
323 |
/* ---------------------------------------------------------------------- */ |
|
324 |
/* auxiliary functions for parameter parsing */ |
|
325 |
|
|
326 |
/* parse a dimension of the kind "1.5in", "7cm", etc. Return result in |
|
327 |
postscript points (=1/72 in). If endptr!=NULL, store pointer to |
|
328 |
next character in *endptr in the manner of strtod(3). */ |
|
329 |
static dim_t parse_dimension(char *s, char **endptr) { |
|
330 |
char *p; |
|
331 |
dim_t res; |
|
332 |
|
|
333 |
res.x = strtod(s, &p); |
|
334 |
res.d = 0; |
|
335 |
if (p!=s) { |
|
336 |
if (!strncasecmp(p, "in", 2)) { |
|
337 |
res.d = DIM_IN; |
|
338 |
p += 2; |
|
339 |
} else if (!strncasecmp(p, "cm", 2)) { |
|
340 |
res.d = DIM_CM; |
|
341 |
p += 2; |
|
342 |
} else if (!strncasecmp(p, "mm", 2)) { |
|
343 |
res.d = DIM_MM; |
|
344 |
p += 2; |
|
345 |
} else if (!strncasecmp(p, "pt", 2)) { |
|
346 |
res.d = DIM_PT; |
|
347 |
p += 2; |
|
348 |
} |
|
349 |
} |
|
350 |
if (endptr!=NULL) { |
|
351 |
*endptr = p; |
|
352 |
} |
|
353 |
return res; |
|
354 |
} |
|
355 |
|
|
356 |
/* parse a pair of dimensions, such as "8.5x11in", "30mmx4cm" */ |
|
357 |
static void parse_dimensions(char *s, char **endptr, dim_t *dxp, dim_t *dyp) { |
|
358 |
char *p, *q; |
|
359 |
dim_t dx, dy; |
|
360 |
|
|
361 |
dx = parse_dimension(s, &p); |
|
362 |
if (p==s) { |
|
363 |
goto fail; |
|
364 |
} |
|
365 |
if (*p != 'x') { |
|
366 |
goto fail; |
|
367 |
} |
|
368 |
p++; |
|
369 |
dy = parse_dimension(p, &q); |
|
370 |
if (q==p) { |
|
371 |
goto fail; |
|
372 |
} |
|
373 |
if (dx.d && !dy.d) { |
|
374 |
dy.d = dx.d; |
|
375 |
} else if (!dx.d && dy.d) { |
|
376 |
dx.d = dy.d; |
|
377 |
} |
|
378 |
*dxp = dx; |
|
379 |
*dyp = dy; |
|
380 |
if (endptr != NULL) { |
|
381 |
*endptr = q; |
|
382 |
} |
|
383 |
return; |
|
384 |
|
|
385 |
fail: |
|
386 |
dx.x = dx.d = dy.x = dy.d = 0; |
|
387 |
*dxp = dx; |
|
388 |
*dyp = dy; |
|
389 |
if (endptr != NULL) { |
|
390 |
*endptr = s; |
|
391 |
} |
|
392 |
return; |
|
393 |
} |
|
394 |
|
|
395 |
static inline double double_of_dim(dim_t d, double def) { |
|
396 |
if (d.d) { |
|
397 |
return d.x * d.d; |
|
398 |
} else { |
|
399 |
return d.x * def; |
|
400 |
} |
|
401 |
} |
|
402 |
|
|
403 |
static int parse_color(char *s) { |
|
404 |
int i, d; |
|
405 |
int col = 0; |
|
406 |
|
|
407 |
if (s[0] != '#' || strlen(s) != 7) { |
|
408 |
return -1; |
|
409 |
} |
|
410 |
for (i=0; i<6; i++) { |
|
411 |
d = s[6-i]; |
|
412 |
if (d >= '0' && d <= '9') { |
|
413 |
col |= (d-'0') << (4*i); |
|
414 |
} else if (d >= 'a' && d <= 'f') { |
|
415 |
col |= (d-'a'+10) << (4*i); |
|
416 |
} else if (d >= 'A' && d <= 'F') { |
|
417 |
col |= (d-'A'+10) << (4*i); |
|
418 |
} else { |
|
419 |
return -1; |
|
420 |
} |
|
421 |
} |
|
422 |
return col; |
|
423 |
} |
|
424 |
|
|
425 |
/* ---------------------------------------------------------------------- */ |
|
426 |
/* option processing */ |
|
427 |
|
|
428 |
/* codes for options that don't have short form */ |
|
429 |
#define OPT_GROUP 300 |
|
430 |
#define OPT_OPAQUE 301 |
|
431 |
#define OPT_FILLCOLOR 302 |
|
432 |
#define OPT_PROGRESS 303 |
|
433 |
|
|
434 |
static struct option longopts[] = { |
|
435 |
{"help", 0, 0, 'h'}, |
|
436 |
{"version", 0, 0, 'v'}, |
|
437 |
{"license", 0, 0, 'l'}, |
|
438 |
{"show-defaults", 0, 0, 'V'}, |
|
439 |
{"progress", 0, 0, OPT_PROGRESS}, |
|
440 |
{"width", 1, 0, 'W'}, |
|
441 |
{"height", 1, 0, 'H'}, |
|
442 |
{"resolution", 1, 0, 'r'}, |
|
443 |
{"scale", 1, 0, 'x'}, |
|
444 |
{"stretch", 1, 0, 'S'}, |
|
445 |
{"margin", 1, 0, 'M'}, |
|
446 |
{"leftmargin", 1, 0, 'L'}, |
|
447 |
{"rightmargin", 1, 0, 'R'}, |
|
448 |
{"topmargin", 1, 0, 'T'}, |
|
449 |
{"bottommargin", 1, 0, 'B'}, |
|
450 |
{"rotate", 1, 0, 'A'}, |
|
451 |
{"pagesize", 1, 0, 'P'}, |
|
452 |
{"turdsize", 1, 0, 't'}, |
|
453 |
{"unit", 1, 0, 'u'}, |
|
454 |
{"cleartext", 0, 0, 'c'}, |
|
455 |
{"level2", 0, 0, '2'}, |
|
456 |
{"level3", 0, 0, '3'}, |
|
457 |
{"eps", 0, 0, 'e'}, |
|
458 |
{"postscript", 0, 0, 'p'}, |
|
459 |
{"svg", 0, 0, 's'}, |
|
460 |
{"pgm", 0, 0, 'g'}, |
|
461 |
{"backend", 1, 0, 'b'}, |
|
462 |
{"debug", 1, 0, 'd'}, |
|
463 |
{"color", 1, 0, 'C'}, |
|
464 |
{"fillcolor", 1, 0, OPT_FILLCOLOR}, |
|
465 |
{"turnpolicy", 1, 0, 'z'}, |
|
466 |
{"gamma", 1, 0, 'G'}, |
|
467 |
{"longcurve", 0, 0, 'n'}, |
|
468 |
{"longcoding", 0, 0, 'q'}, |
|
469 |
{"alphamax", 1, 0, 'a'}, |
|
470 |
{"opttolerance", 1, 0, 'O'}, |
|
471 |
{"output", 1, 0, 'o'}, |
|
472 |
{"blacklevel", 1, 0, 'k'}, |
|
473 |
{"invert", 0, 0, 'i'}, |
|
474 |
{"opaque", 0, 0, OPT_OPAQUE}, |
|
475 |
{"group", 0, 0, OPT_GROUP}, |
|
476 |
|
|
477 |
{0, 0, 0, 0} |
|
478 |
}; |
|
479 |
|
|
480 |
static char *shortopts = "hvlVW:H:r:x:S:M:L:R:T:B:A:P:t:u:c23epsgb:d:C:z:G:nqa:O:o:k:i"; |
|
481 |
|
|
482 |
static void dopts(int ac, char *av[]) { |
|
483 |
int c; |
|
484 |
char *p; |
|
485 |
int i, j, r; |
|
486 |
dim_t dim, dimx, dimy; |
|
487 |
int matches, bestmatch; |
|
488 |
|
|
489 |
/* defaults */ |
|
490 |
backend_lookup("eps", &info.backend); |
|
491 |
info.debug = 0; |
|
492 |
info.width_d.x = UNDEF; |
|
493 |
info.height_d.x = UNDEF; |
|
494 |
info.rx = UNDEF; |
|
495 |
info.ry = UNDEF; |
|
496 |
info.sx = UNDEF; |
|
497 |
info.sy = UNDEF; |
|
498 |
info.stretch = 1; |
|
499 |
info.lmar_d.x = UNDEF; |
|
500 |
info.rmar_d.x = UNDEF; |
|
501 |
info.tmar_d.x = UNDEF; |
|
502 |
info.bmar_d.x = UNDEF; |
|
503 |
info.angle = 0; |
|
504 |
info.paperwidth = DEFAULT_PAPERWIDTH; |
|
505 |
info.paperheight = DEFAULT_PAPERHEIGHT; |
|
506 |
info.unit = 10; |
|
507 |
info.compress = 1; |
|
508 |
info.pslevel = 2; |
|
509 |
info.color = 0x000000; |
|
510 |
info.gamma = 2.2; |
|
511 |
info.param = potrace_param_default(); |
|
512 |
if (!info.param) { |
|
513 |
fprintf(stderr, ""POTRACE": %s\n", strerror(errno)); |
|
514 |
exit(1); |
|
515 |
} |
|
516 |
info.longcoding = 0; |
|
517 |
info.outfile = NULL; |
|
518 |
info.blacklevel = 0.5; |
|
519 |
info.invert = 0; |
|
520 |
info.opaque = 0; |
|
521 |
info.group = 0; |
|
522 |
info.fillcolor = 0xffffff; |
|
523 |
info.progress = 0; |
|
524 |
|
|
525 |
while ((c = getopt_long(ac, av, shortopts, longopts, NULL)) != -1) { |
|
526 |
switch (c) { |
|
527 |
case 'h': |
|
528 |
fprintf(stdout, ""POTRACE" "VERSION". Transforms bitmaps into vector graphics.\n\n"); |
|
529 |
usage(stdout); |
|
530 |
exit(0); |
|
531 |
break; |
|
532 |
case 'v': |
|
533 |
fprintf(stdout, ""POTRACE" "VERSION". Copyright (C) 2001-2007 Peter Selinger.\n"); |
|
534 |
fprintf(stdout, "Library version: %s\n", potrace_version()); |
|
535 |
exit(0); |
|
536 |
break; |
|
537 |
case 'l': |
|
538 |
fprintf(stdout, ""POTRACE" "VERSION". Copyright (C) 2001-2007 Peter Selinger.\n\n"); |
|
539 |
license(stdout); |
|
540 |
exit(0); |
|
541 |
break; |
|
542 |
case 'V': |
|
543 |
fprintf(stdout, ""POTRACE" "VERSION". Copyright (C) 2001-2007 Peter Selinger.\n"); |
|
544 |
show_defaults(stdout); |
|
545 |
exit(0); |
|
546 |
break; |
|
547 |
case OPT_PROGRESS: |
|
548 |
info.progress = 1; |
|
549 |
break; |
|
550 |
case 'W': |
|
551 |
info.width_d = parse_dimension(optarg, &p); |
|
552 |
if (*p) { |
|
553 |
fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg); |
|
554 |
exit(1); |
|
555 |
} |
|
556 |
break; |
|
557 |
case 'H': |
|
558 |
info.height_d = parse_dimension(optarg, &p); |
|
559 |
if (*p) { |
|
560 |
fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg); |
|
561 |
exit(1); |
|
562 |
} |
|
563 |
break; |
|
564 |
case 'r': |
|
565 |
parse_dimensions(optarg, &p, &dimx, &dimy); |
|
566 |
if (*p == 0 && dimx.d == 0 && dimy.d == 0) { |
|
567 |
info.rx = dimx.x; |
|
568 |
info.ry = dimy.x; |
|
569 |
break; |
|
570 |
} |
|
571 |
dim = parse_dimension(optarg, &p); |
|
572 |
if (*p == 0 && dim.d == 0) { |
|
573 |
info.rx = info.ry = dim.x; |
|
574 |
break; |
|
575 |
} |
|
576 |
fprintf(stderr, ""POTRACE": invalid resolution -- %s\n", optarg); |
|
577 |
exit(1); |
|
578 |
break; |
|
579 |
case 'x': |
|
580 |
parse_dimensions(optarg, &p, &dimx, &dimy); |
|
581 |
if (*p == 0 && dimx.d == 0 && dimy.d == 0) { |
|
582 |
info.sx = dimx.x; |
|
583 |
info.sy = dimy.x; |
|
584 |
break; |
|
585 |
} |
|
586 |
dim = parse_dimension(optarg, &p); |
|
587 |
if (*p == 0 && dim.d == 0) { |
|
588 |
info.sx = info.sy = dim.x; |
|
589 |
break; |
|
590 |
} |
|
591 |
fprintf(stderr, ""POTRACE": invalid scaling factor -- %s\n", optarg); |
|
592 |
exit(1); |
|
593 |
break; |
|
594 |
case 'S': |
|
595 |
info.stretch = atof(optarg); |
|
596 |
break; |
|
597 |
case 'M': |
|
598 |
info.lmar_d = parse_dimension(optarg, &p); |
|
599 |
if (*p) { |
|
600 |
fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg); |
|
601 |
exit(1); |
|
602 |
} |
|
603 |
info.rmar_d = info.tmar_d = info.bmar_d = info.lmar_d; |
|
604 |
break; |
|
605 |
case 'L': |
|
606 |
info.lmar_d = parse_dimension(optarg, &p); |
|
607 |
if (*p) { |
|
608 |
fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg); |
|
609 |
exit(1); |
|
610 |
} |
|
611 |
break; |
|
612 |
case 'R': |
|
613 |
info.rmar_d = parse_dimension(optarg, &p); |
|
614 |
if (*p) { |
|
615 |
fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg); |
|
616 |
exit(1); |
|
617 |
} |
|
618 |
break; |
|
619 |
case 'T': |
|
620 |
info.tmar_d = parse_dimension(optarg, &p); |
|
621 |
if (*p) { |
|
622 |
fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg); |
|
623 |
exit(1); |
|
624 |
} |
|
625 |
break; |
|
626 |
case 'B': |
|
627 |
info.bmar_d = parse_dimension(optarg, &p); |
|
628 |
if (*p) { |
|
629 |
fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg); |
|
630 |
exit(1); |
|
631 |
} |
|
632 |
break; |
|
633 |
case 'A': |
|
634 |
info.angle = strtod(optarg, &p); |
|
635 |
if (*p) { |
|
636 |
fprintf(stderr, ""POTRACE": invalid angle -- %s\n", optarg); |
|
637 |
exit(1); |
|
638 |
} |
|
639 |
break; |
|
640 |
case 'P': |
|
641 |
matches = 0; |
|
642 |
bestmatch = 0; |
|
643 |
for (i=0; pageformat[i].name!=NULL; i++) { |
|
644 |
if (strcasecmp(pageformat[i].name, optarg)==0) { |
|
645 |
matches = 1; |
|
646 |
bestmatch = i; |
|
647 |
break; |
|
648 |
} else if (strncasecmp(pageformat[i].name, optarg, strlen(optarg))==0) { |
|
649 |
/* don't allow partial match on "10x14" */ |
|
650 |
if (optarg[0] != '1') { |
|
651 |
matches++; |
|
652 |
bestmatch = i; |
|
653 |
} |
|
654 |
} |
|
655 |
} |
|
656 |
if (matches == 1) { |
|
657 |
info.paperwidth = pageformat[bestmatch].w; |
|
658 |
info.paperheight = pageformat[bestmatch].h; |
|
659 |
break; |
|
660 |
} |
|
661 |
parse_dimensions(optarg, &p, &dimx, &dimy); |
|
662 |
if (*p == 0) { |
|
663 |
info.paperwidth = (int)rint(double_of_dim(dimx, DEFAULT_DIM)); |
|
664 |
info.paperheight = (int)rint(double_of_dim(dimy, DEFAULT_DIM)); |
|
665 |
break; |
|
666 |
} |
|
667 |
if (matches == 0) { |
|
668 |
fprintf(stderr, ""POTRACE": unrecognized page format -- %s\n", optarg); |
|
669 |
} else { |
|
670 |
fprintf(stderr, ""POTRACE": ambiguous page format -- %s\n", optarg); |
|
671 |
} |
|
672 |
j = fprintf(stderr, "Use one of: "); |
|
673 |
for (i=0; pageformat[i].name!=NULL; i++) { |
|
674 |
if (j + strlen(pageformat[i].name) > 75) { |
|
675 |
fprintf(stderr, "\n"); |
|
676 |
j = 0; |
|
677 |
} |
|
678 |
j += fprintf(stderr, "%s, ", pageformat[i].name); |
|
679 |
} |
|
680 |
fprintf(stderr, "or specify <dim>x<dim>.\n"); |
|
681 |
exit(1); |
|
682 |
break; |
|
683 |
case 't': |
|
684 |
info.param->turdsize = atoi(optarg); |
|
685 |
break; |
|
686 |
case 'u': |
|
687 |
info.unit = strtod(optarg, &p); |
|
688 |
if (*p) { |
|
689 |
fprintf(stderr, ""POTRACE": invalid unit -- %s\n", optarg); |
|
690 |
exit(1); |
|
691 |
} |
|
692 |
break; |
|
693 |
case 'c': |
|
694 |
info.pslevel = 2; |
|
695 |
info.compress = 0; |
|
696 |
break; |
|
697 |
case '2': |
|
698 |
info.pslevel = 2; |
|
699 |
info.compress = 1; |
|
700 |
break; |
|
701 |
case '3': |
|
702 |
#ifdef HAVE_ZLIB |
|
703 |
info.pslevel = 3; |
|
704 |
info.compress = 1; |
|
705 |
#else |
|
706 |
fprintf(stderr, ""POTRACE": option -3 not supported, using -2 instead.\n"); |
|
707 |
info.pslevel = 2; |
|
708 |
info.compress = 1; |
|
709 |
#endif |
|
710 |
break; |
|
711 |
case 'e': |
|
712 |
backend_lookup("eps", &info.backend); |
|
713 |
break; |
|
714 |
case 'p': |
|
715 |
backend_lookup("postscript", &info.backend); |
|
716 |
break; |
|
717 |
case 's': |
|
718 |
backend_lookup("svg", &info.backend); |
|
719 |
break; |
|
720 |
case 'g': |
|
721 |
backend_lookup("pgm", &info.backend); |
|
722 |
break; |
|
723 |
case 'b': |
|
724 |
r = backend_lookup(optarg, &info.backend); |
|
725 |
if (r==1 || r==2) { |
|
726 |
if (r==1) { |
|
727 |
fprintf(stderr, ""POTRACE": unrecognized backend -- %s\n", optarg); |
|
728 |
} else { |
|
729 |
fprintf(stderr, ""POTRACE": ambiguous backend -- %s\n", optarg); |
|
730 |
} |
|
731 |
j = fprintf(stderr, "Use one of: "); |
|
732 |
backend_list(stderr, j, 70); |
|
733 |
fprintf(stderr, ".\n"); |
|
734 |
exit(1); |
|
735 |
} |
|
736 |
break; |
|
737 |
case 'd': |
|
738 |
info.debug = atoi(optarg); |
|
739 |
break; |
|
740 |
case 'C': |
|
741 |
info.color = parse_color(optarg); |
|
742 |
if (info.color == -1) { |
|
743 |
fprintf(stderr, ""POTRACE": invalid color -- %s\n", optarg); |
|
744 |
exit(1); |
|
745 |
} |
|
746 |
break; |
|
747 |
case OPT_FILLCOLOR: |
|
748 |
info.fillcolor = parse_color(optarg); |
|
749 |
if (info.fillcolor == -1) { |
|
750 |
fprintf(stderr, ""POTRACE": invalid color -- %s\n", optarg); |
|
751 |
exit(1); |
|
752 |
} |
|
753 |
info.opaque = 1; |
|
754 |
break; |
|
755 |
case 'z': |
|
756 |
matches = 0; |
|
757 |
bestmatch = 0; |
|
758 |
for (i=0; turnpolicy[i].name!=NULL; i++) { |
|
759 |
if (strcasecmp(turnpolicy[i].name, optarg)==0) { |
|
760 |
matches = 1; |
|
761 |
bestmatch = i; |
|
762 |
break; |
|
763 |
} else if (strncasecmp(turnpolicy[i].name, optarg, strlen(optarg))==0) { |
|
764 |
matches++; |
|
765 |
bestmatch = i; |
|
766 |
} |
|
767 |
} |
|
768 |
if (matches == 1) { |
|
769 |
info.param->turnpolicy = turnpolicy[bestmatch].n; |
|
770 |
break; |
|
771 |
} |
|
772 |
if (matches == 0) { |
|
773 |
fprintf(stderr, ""POTRACE": unrecognized turnpolicy -- %s\n", optarg); |
|
774 |
} else { |
|
775 |
fprintf(stderr, ""POTRACE": ambiguous turnpolicy -- %s\n", optarg); |
|
776 |
} |
|
777 |
j = fprintf(stderr, "Use one of: "); |
|
778 |
for (i=0; turnpolicy[i].name!=NULL; i++) { |
|
779 |
if (j + strlen(turnpolicy[i].name) > 75) { |
|
780 |
fprintf(stderr, "\n"); |
|
781 |
j = 0; |
|
782 |
} |
|
783 |
j += fprintf(stderr, "%s%s", turnpolicy[i].name, turnpolicy[i+1].name ? ", " : ""); |
|
784 |
} |
|
785 |
fprintf(stderr, ".\n"); |
|
786 |
exit(1); |
|
787 |
break; |
|
788 |
case 'G': |
|
789 |
info.gamma = atof(optarg); |
|
790 |
break; |
|
791 |
case 'n': |
|
792 |
info.param->opticurve = 0; |
|
793 |
break; |
|
794 |
case 'q': |
|
795 |
info.longcoding = 1; |
|
796 |
break; |
|
797 |
case 'a': |
|
798 |
info.param->alphamax = strtod(optarg, &p); |
|
799 |
if (*p) { |
|
800 |
fprintf(stderr, ""POTRACE": invalid alphamax -- %s\n", optarg); |
|
801 |
exit(1); |
|
802 |
} |
|
803 |
break; |
|
804 |
case 'O': |
|
805 |
info.param->opttolerance = strtod(optarg, &p); |
|
806 |
if (*p) { |
|
807 |
fprintf(stderr, ""POTRACE": invalid opttolerance -- %s\n", optarg); |
|
808 |
exit(1); |
|
809 |
} |
|
810 |
break; |
|
811 |
case 'o': |
|
812 |
free(info.outfile); |
|
813 |
info.outfile = strdup(optarg); |
|
814 |
break; |
|
815 |
case 'k': |
|
816 |
info.blacklevel = strtod(optarg, &p); |
|
817 |
if (*p) { |
|
818 |
fprintf(stderr, ""POTRACE": invalid blacklevel -- %s\n", optarg); |
|
819 |
exit(1); |
|
820 |
} |
|
821 |
break; |
|
822 |
case 'i': |
|
823 |
info.invert = 1; |
|
824 |
break; |
|
825 |
case OPT_OPAQUE: |
|
826 |
info.opaque = 1; |
|
827 |
break; |
|
828 |
case OPT_GROUP: |
|
829 |
info.group = 1; |
|
830 |
break; |
|
831 |
case '?': |
|
832 |
fprintf(stderr, "Try --help for more info\n"); |
|
833 |
exit(1); |
|
834 |
break; |
|
835 |
default: |
|
836 |
fprintf(stderr, ""POTRACE": Unimplemented option -- %c\n", c); |
|
837 |
exit(1); |
|
838 |
} |
|
839 |
} |
|
840 |
info.infiles = &av[optind]; |
Also available in: Unified diff