--- ray/src/px/ra_ps.c 1992/08/14 13:27:52 2.4 +++ ray/src/px/ra_ps.c 1993/11/18 09:55:17 2.7 @@ -9,6 +9,9 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include +#ifdef MSDOS +#include +#endif #include "color.h" #include "random.h" @@ -21,7 +24,7 @@ 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 */ @@ -30,7 +33,9 @@ char *progname; int xmax, ymax; +extern char *malloc(); + headline(s) /* check header line */ char *s; { @@ -77,10 +82,13 @@ char *argv[]; exit(1); } if (i == argc-2 && freopen(argv[i+1], "w", stdout) == NULL) { - fprintf(stderr, "can't open output \"%s\"\n", + fprintf(stderr, "%s: can't open output \"%s\"\n", 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) @@ -113,8 +121,8 @@ 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); @@ -125,7 +133,6 @@ char *name; else printf("%%%%Portrait\n"); printf("%%%%EndComments\n"); - printf("gsave\n"); printf("64 dict begin\n"); /* define image reader */ PSprocdef("read6bit"); @@ -172,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)) @@ -208,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');