--- ray/src/px/ttyimage.c 1989/10/20 16:44:35 1.3 +++ ray/src/px/ttyimage.c 1991/11/12 16:05:29 2.1 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1991 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -13,6 +13,7 @@ static char SCCSid[] = "$SunId$ LBL"; #include #include "color.h" +#include "resolu.h" #define NCOLS 133 @@ -25,7 +26,6 @@ char **argv; FILE *input; int xres, yres; COLR scanline[NCOLS]; - char sbuf[256]; register int i, j; if (argc < 2) @@ -35,12 +35,10 @@ char **argv; exit(1); } - /* discard header */ - while (fgets(sbuf, sizeof(sbuf), input) != NULL && sbuf[0] != '\n') - ; /* get picture dimensions */ - if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) { - fprintf(stderr, "%s: bad picture size\n", argv[0]); + if (checkheader(input, COLRFMT, NULL) < 0 || + fgetresolu(&xres, &yres, input) < 0) { + fprintf(stderr, "%s: bad picture format\n", argv[0]); exit(1); } if (xres > NCOLS) { @@ -53,6 +51,7 @@ char **argv; fprintf(stderr, "%s: read error\n", argv[0]); exit(1); } + normcolrs(scanline, xres, 0); for (j = 0; j < xres; j++) putchar(shade(scanline[j])); putchar('\n'); @@ -69,13 +68,8 @@ COLR clr; #define NSHADES 13 static char shadech[NSHADES+1] = " .,:;+?%&*$@#"; - COLR nclr; - register int b; - colr_norm(clr, nclr); - b = norm_bright(nclr); - b = b*NSHADES/256; - return(shadech[b]); + return(shadech[normbright(clr)*NSHADES/256]); #undef NSHADES }