--- ray/src/px/ra_ps.c 1992/07/13 10:53:42 2.3 +++ ray/src/px/ra_ps.c 1992/09/21 12:15:08 2.6 @@ -9,6 +9,9 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include +#ifdef MSDOS +#include +#endif #include "color.h" #include "random.h" @@ -21,15 +24,18 @@ char code[] = /* 6-bit code lookup table */ "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@+"; int wrongformat = 0; /* input in wrong format? */ -double pixaspect = 1.0; /* pixel aspect ratio */ +double pixaspect = 1.0; /* pixel aspect ratio */ int bradj = 0; /* brightness adjustment */ +int ncopies = 1; /* number of copies */ char *progname; int xmax, ymax; +extern char *malloc(); + headline(s) /* check header line */ char *s; { @@ -59,6 +65,9 @@ char *argv[]; goto userr; bradj = atoi(argv[++i]); break; + case 'n': /* number of copies */ + ncopies = atoi(argv[++i]); + break; default: goto userr; } @@ -77,6 +86,9 @@ char *argv[]; progname, argv[i+1]); exit(1); } +#ifdef MSDOS + setmode(fileno(stdin), O_BINARY); +#endif /* get our header */ getheader(stdin, headline, NULL); if (wrongformat || fgetresolu(&xmax, &ymax, stdin) < 0) @@ -109,19 +121,18 @@ PSheader(name) /* print PostScript header */ char *name; { int landscape = 0; - double pwidth, pheight; - double iwidth, iheight; + double pwidth, pheight; + double iwidth, iheight; printf("%%!\n"); printf("%%%%Title: %s\n", name); printf("%%%%Creator: %s\n", progname); - printf("%%%%Pages: 1\n"); + printf("%%%%Pages: %d\n", ncopies); if (landscape = xmax > pixaspect*ymax) printf("%%%%Landscape\n"); else printf("%%%%Portrait\n"); printf("%%%%EndComments\n"); - printf("gsave\n"); printf("64 dict begin\n"); /* define image reader */ PSprocdef("read6bit"); @@ -155,9 +166,10 @@ char *name; PStrailer() /* print PostScript trailer */ { puts("%%Trailer"); - puts("end"); + if (ncopies > 1) + printf("/#copies %d def\n", ncopies); puts("showpage"); - puts("grestore"); + puts("end"); puts("%%EOF"); } @@ -167,11 +179,13 @@ char *nam; { short itab[128]; register int i; - - for (i = 0; i < 128; i++) + /* assign code values */ + for (i = 0; i < 128; i++) /* clear */ itab[i] = -1; - for (i = 0; i < 64; i++) + for (i = 1; i < 63; i++) /* assign greys */ itab[code[i]] = i<<2 | 2; + itab[code[0]] = 0; /* black is black */ + itab[code[63]] = 255; /* and white is white */ printf("/decode ["); for (i = 0; i < 128; i++) { if (!(i & 0xf)) @@ -203,7 +217,7 @@ ra2ps() /* convert Radiance scanlines to 6-bit */ for (y = ymax-1; y >= 0; y--) { if (freadcolrs(scanin, xmax, stdin) < 0) quiterr("error reading Radiance picture"); - normcolrs(scanin, xmax, bradj); /* normalize */ + normcolrs(scanin, xmax, bradj); /* normalize */ for (x = 0; x < xmax; x++) { if (!(col++ & 0x3f)) putchar('\n');