--- ray/src/px/ra_skel.c 1991/11/12 15:16:41 2.1 +++ ray/src/px/ra_skel.c 1993/11/18 09:55:24 2.8 @@ -1,3 +1,5 @@ +/* Copyright (c) 1992 Regents of the University of California */ + #ifndef lint static char SCCSid[] = "$SunId$ LBL"; #endif @@ -17,12 +19,16 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include +#include +#ifdef MSDOS +#include +#endif #include "color.h" #include "resolu.h" -extern double atof(); +extern char *malloc(); -double gamma = 2.2; /* gamma correction */ +double gamcor = 2.2; /* gamma correction */ int bradj = 0; /* brightness adjustment */ @@ -44,7 +50,7 @@ char *argv[]; if (argv[i][0] == '-') switch (argv[i][1]) { case 'g': /* gamma correction */ - gamma = atof(argv[++i]); + gamcor = atof(argv[++i]); break; case 'e': /* exposure adjustment */ if (argv[i+1][0] != '+' && argv[i+1][0] != '-') @@ -68,11 +74,15 @@ 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); } - setcolrgam(gamma); /* set up gamma correction */ +#ifdef MSDOS + setmode(fileno(stdin), O_BINARY); + setmode(fileno(stdout), O_BINARY); +#endif + setcolrgam(gamcor); /* set up gamma correction */ if (reverse) { /* get their image resolution */ read_skel_head(&xmax, &ymax); @@ -124,10 +134,12 @@ skel2ra() /* convert 24-bit scanlines to Radiance pic quiterr("out of memory in skel2ra"); /* convert image */ for (y = ymax-1; y >= 0; y--) { - scanout[x][RED] = getc(stdin); - scanout[x][GRN] = getc(stdin); - scanout[x][BLU] = getc(stdin); - if (feof(stdin) || ferror(stdin)) + for (x = 0; x < xmax; x++) { + scanout[x][RED] = getc(stdin); + scanout[x][GRN] = getc(stdin); + scanout[x][BLU] = getc(stdin); + } + if (feof(stdin) | ferror(stdin)) quiterr("error reading skel image"); /* undo gamma */ gambs_colrs(scanout, xmax);