--- ray/src/px/mt160r.c 1990/01/26 08:17:31 1.6 +++ ray/src/px/mt160r.c 1993/08/02 14:39:10 2.5 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1992 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -11,10 +11,14 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include +#ifdef MSDOS +#include +#endif #include "color.h" +#include "resolu.h" -#define NCOLS 880 /* for wide carriage */ +#define NCOLS 880 /* for wide carriage */ main(argc, argv) @@ -23,7 +27,12 @@ char *argv[]; { int i; int status = 0; - +#ifdef MSDOS + extern int _fmode; + _fmode = O_BINARY; + setmode(fileno(stdin), O_BINARY); + setmode(fileno(stdout), O_BINARY); +#endif if (argc < 2) status += printp(NULL) == -1; else @@ -40,7 +49,7 @@ char *fname; int xres, yres; COLR scanline[NCOLS]; int i; - + if (fname == NULL) { input = stdin; fname = ""; @@ -49,9 +58,12 @@ char *fname; return(-1); } /* discard header */ - getheader(input, NULL); + if (checkheader(input, COLRFMT, NULL) < 0) { + fprintf(stderr, "%s: not a Radiance picture\n", fname); + return(-1); + } /* get picture dimensions */ - if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) { + if (fgetresolu(&xres, &yres, input) < 0) { fprintf(stderr, "%s: bad picture size\n", fname); return(-1); } @@ -106,6 +118,7 @@ int y; } putchar('\r'); putchar('\n'); + fflush(stdout); } } @@ -116,13 +129,15 @@ register int x; { static int cerr[NCOLS]; static int err; - int b; + int b, errp; register int isblack; b = normbright(clr); + errp = err; err += b + cerr[x]; isblack = err < 128; if (!isblack) err -= 256; - cerr[x] = err /= 2; + err /= 3; + cerr[x] = err + errp; return(isblack); }