diff --git a/README.md b/README.md index d0453d6..4f6e5dc 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,7 @@ # potrace +potrace is a utility for tracing a bitmap, which means, transforming a bitmap into a smooth, scalable image. +The input is a portable bitmap (PBM), and the default output is an encapsulated PostScript file (EPS). +A typical use is to create EPS files from scanned data, such as company or university logos, handwritten notes, etc. +The resulting image is not "jaggy" like a bitmap, but smooth, and it can be scaled to any resolution. + diff --git a/potrace-1.8-xfig.patch b/potrace-1.8-xfig.patch new file mode 100644 index 0000000..8c5bf4a --- /dev/null +++ b/potrace-1.8-xfig.patch @@ -0,0 +1,114 @@ +Index: ChangeLog +=================================================================== +--- ChangeLog (revision 153) ++++ ChangeLog (revision 154) +@@ -1,5 +1,9 @@ + ChangeLog + ++ (2007/05/22) PS1 - xfig backend: added depth to opaque components ++ to avoid them floating to the background. Suggested by Rafael ++ Laboissiere. ++ + v1.8 2007/04/09 + (2007/04/08) PS1 - portability: use 'test' instead of '[' in shell + scripts. +Index: src/backend_xfig.c +=================================================================== +--- src/backend_xfig.c (revision 153) ++++ src/backend_xfig.c (revision 154) +@@ -124,13 +124,13 @@ + return n; + } + +-/* do one path. First should be 1 on the very first path, else 0. */ +-static int xfig_path(FILE *fout, potrace_curve_t *curve, trans_t t, int sign) { ++/* do one path. */ ++static void xfig_path(FILE *fout, potrace_curve_t *curve, trans_t t, int sign, int depth) { + int i; + dpoint_t *c; + int m = curve->n; + +- fprintf(fout, "3 1 0 0 0 %d 50 0 20 0.000 0 0 0 %d\n", sign=='+' ? 32 : 33, npoints(curve, m)); ++ fprintf(fout, "3 1 0 0 0 %d %d 0 20 0.000 0 0 0 %d\n", sign=='+' ? 32 : 33, depth, npoints(curve, m)); + + for (i=0; ic[i]; +@@ -154,15 +154,43 @@ + break; + } + } +- return 0; + } + ++/* render a whole tree */ ++static void xfig_write_paths(FILE *fout, potrace_path_t *plist, trans_t t, int depth) { ++ potrace_path_t *p, *q; ++ ++ for (p=plist; p; p=p->sibling) { ++ xfig_path(fout, &p->curve, t, p->sign, depth); ++ for (q=p->childlist; q; q=q->sibling) { ++ xfig_path(fout, &q->curve, t, q->sign, depth >= 1 ? depth-1 : 0); ++ } ++ for (q=p->childlist; q; q=q->sibling) { ++ xfig_write_paths(fout, q->childlist, t, depth >= 2 ? depth-2 : 0); ++ } ++ } ++} ++ ++/* calculate the depth of a tree. Call with d=0. */ ++static int xfig_get_depth(potrace_path_t *plist) { ++ potrace_path_t *p; ++ int max =0; ++ int d; ++ ++ for (p=plist; p; p=p->sibling) { ++ d = xfig_get_depth(p->childlist); ++ if (d > max) { ++ max = d; ++ } ++ } ++ return max + 1; ++} ++ + /* ---------------------------------------------------------------------- */ + /* Backend. */ + + /* public interface for XFIG */ + int page_xfig(FILE *fout, potrace_path_t *plist, imginfo_t *imginfo) { +- potrace_path_t *p; + trans_t t; + double si, co; + double origx = imginfo->trans.orig[0] + imginfo->lmar; +@@ -174,6 +202,7 @@ + pageformat_t *f; + int i; + int x0, y0, x1, y1; /* in xfig's coordinates */ ++ int depth; + + si = sin(info.angle/180*M_PI); + co = cos(info.angle/180*M_PI); +@@ -220,11 +249,21 @@ + fprintf(fout, "0 33 #%06x\n", info.fillcolor); + fprintf(fout, "6 %d %d %d %d\n", x0-75, y1-35, x1+75, y0+35); /* bounding box */ + ++ /* determine depth of the tree */ ++ depth = xfig_get_depth(plist); ++ ++ /* figure out appropriate xfig starting depth. Note: xfig only has 1000 depths available */ ++ if (depth <= 40) { ++ depth = 50; ++ } else if (depth < 990) { ++ depth += 10; ++ } else { ++ depth = 999; ++ } ++ + /* write paths. Note: can never use "opticurve" with this backend - + it just does not approximate Bezier curves closely enough. */ +- list_forall (p, plist) { +- xfig_path(fout, &p->curve, t, p->sign); +- } ++ xfig_write_paths(fout, plist, t, depth); + + fprintf(fout, "-6\n"); /* end bounding box */ + diff --git a/potrace.spec b/potrace.spec new file mode 100644 index 0000000..ddfd2a6 --- /dev/null +++ b/potrace.spec @@ -0,0 +1,70 @@ +Name: potrace +Version: 1.11 +Release: 1mamba +Summary: Transforms bitmaps into vector graphics +Group: Graphical Desktop/Applications/Graphics +Vendor: openmamba +Distribution: openmamba +Packager: Aleph0 +URL: http://potrace.sourceforge.net/ +Source: http://potrace.sourceforge.net/download/%{name}-%{version}.tar.gz +Patch: %{name}-1.8-xfig.patch +License: GPL +## AUTOBUILDREQ-BEGIN +BuildRequires: glibc-devel +BuildRequires: libz-devel +## AUTOBUILDREQ-END +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +%description +potrace is a utility for tracing a bitmap, which means, transforming a bitmap into a smooth, scalable image. +The input is a portable bitmap (PBM), and the default output is an encapsulated PostScript file (EPS). +A typical use is to create EPS files from scanned data, such as company or university logos, handwritten notes, etc. +The resulting image is not "jaggy" like a bitmap, but smooth, and it can be scaled to any resolution. + +%prep +%setup -q +#%patch -p0 + +%build +%configure +%make + +%install +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" +%makeinstall + +%clean +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" + +%files +%defattr(-,root,root) +%{_bindir}//mkbitmap +%{_bindir}/potrace +%{_mandir}/man1/mkbitmap.* +%{_mandir}/man1/potrace.* +%dir %{_docdir}/potrace +%{_docdir}/potrace/placement.pdf +%doc AUTHORS COPYING ChangeLog NEWS README + +%changelog +* Wed Feb 20 2013 Automatic Build System 1.11-1mamba +- automatic version update by autodist + +* Tue Aug 30 2011 Automatic Build System 1.10-1mamba +- automatic version update by autodist + +* Fri Jan 28 2011 Automatic Build System 1.9-1mamba +- update to 1.9 + +* Thu Jan 27 2011 Automatic Build System 1.9.win64-1mamba +- automatic update by autodist + +* Mon Nov 26 2007 Aleph0 1.8-1mamba +- update to 1.8 + +* Tue May 17 2005 Alessandro Ramazzina 1.7-1qilnx +- new version + +* Fri Sep 17 2004 Matteo Bernasconi 1.5-1qilnx +- first build