/******************************************************************* NOTE FOR ALL WHO FOUND THIS PAGE LOOKING FOR A DIFFERENT "A2PS" PROGRAM: Try looking at: http://thompson.mbt.washington.edu/sequest.html#_a2ps That link has information on converting ascii to postscript, a freely distributed program. For information on my program (listed below) with a similar name: http://www.physics.emory.edu/~weeks/graphics/graph.html ************************************************************ Program: a2ps.c Eric Weeks 6-18-95 3-10-94: modified by Eric Weeks to print filename on picture 9-13-94: -t option to remove title 6-18-95: a2ps.c started from mat2las.c; designed for (perhaps) CA's added in -xy options *******************************************************************/ #include #define DTXSCALE 1.0787 /* used to be 1.25 ?!?!? */ #define DTYSCALE 1.0 #define DTHRES 513 #define DTVRES 481 #define XOFFSET 54 /* 3/4 inch. 72 units = 1 inch. */ #define YOFFSET 288 /* 4 inches. */ main(argc,argv) int argc; char **argv; { int i,j,c,count,title; double atof(),scale,xscale,yscale,blah,xsc,ysc; int hres,vres,xoffset,yoffset,nbits,invert; unsigned char pixel; FILE *fp, *fopen(); extern int optind; extern char *optarg; nbits = 8; scale = 1.0; invert = 0; count = 0; title = 1; xsc = 1.0; ysc = 1.0; while ((c = getopt(argc, argv, "his:x:y:t")) != EOF) switch (c) { case 'h': fprintf(stderr,"Usage: a2ps [options] [<] [file] | laser\n"); fprintf(stderr," -h : this help message\n"); fprintf(stderr," -s # : scale of picture\n"); fprintf(stderr," 1.0 = almost width of page\n"); fprintf(stderr," less than 1 = smaller\n"); fprintf(stderr," -x # : change x-scale independently of y\n"); fprintf(stderr," -y # : change y-scale independently of x\n"); fprintf(stderr," -i : invert colors [default:no]\n"); fprintf(stderr," -t : don't print filename as title\n"); fprintf(stderr,"\nExample: a2ps -i picfile | laser\n"); fprintf(stderr, " ^^^^^^^\n"); fprintf(stderr, " the filename will be printed on the page\n"); fprintf(stderr, " if it appears in the position shown above.\n"); exit(1); break; case 's': scale = atof(optarg); break; case 'i': invert = 1; break; case 't': title = 0; break; case 'x': xsc = atof(optarg); break; case 'y': ysc = atof(optarg); break; } argc -= (optind-1) ; argv += (optind-1) ; fp = (argc > 1) ? fopen(*++argv, "r") : stdin; /* Set up scale factors and offsets. */ xscale = DTXSCALE * scale * 432 * xsc; yscale = DTYSCALE * scale * 432 * ysc; xoffset = XOFFSET; yoffset = YOFFSET; hres = DTHRES; vres = DTVRES; fscanf(fp,"%ld %ld",&hres,&vres); /* Write the necessary starting junk */ printf("%%!\n"); /* Identifies job as Postscript. */ printf("gsave\n"); if (title==1) { printf("/Times-Roman findfont 30 scalefont setfont\n"); printf("50.0 50.0 moveto\n"); printf("(%s) show\n",*argv); } printf("0 0 moveto\ngrestore\n"); printf("/picstr %d string def\n", hres); printf("%d %d translate\n", xoffset, yoffset); printf("%d %d scale\n", (int) xscale, (int) yscale); printf("%d %d %d\n", hres, vres, nbits); printf("[%d 0 0 -%d 0 %d]\n", hres, vres, vres); printf("{currentfile\n"); printf(" picstr readhexstring pop}\n"); printf("image\n"); /* Now, read in the rest of the file, converting each character to hexadecimal and punching to std. output. */ for(j=0;j.3) { fprintf(stderr,"%5.1f percent of picture is black,\nyou might want to consider using -i option!\n\nUse 'cancel' command to stop laserwriter output.\n",blah*100.0); } /* Now, finish off the job with a "showpage" call. */ printf("showpage\n"); }