--- ray/src/px/ra_avs.c 1993/07/12 12:41:13 2.4 +++ ray/src/px/ra_avs.c 2003/02/22 02:07:27 2.9 @@ -1,9 +1,6 @@ -/* Copyright (c) 1993 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: ra_avs.c,v 2.9 2003/02/22 02:07:27 greg Exp $"; #endif - /* * Convert Radiance file to/from AVS file. */ @@ -13,11 +10,10 @@ static char SCCSid[] = "$SunId$ LBL"; #ifdef MSDOS #include #endif +#include #include "color.h" #include "resolu.h" -extern char *malloc(); - double gamcor = 2.2; /* gamma correction */ int bradj = 0; /* brightness adjustment */ @@ -65,7 +61,7 @@ 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); } @@ -78,7 +74,10 @@ char *argv[]; /* get their image resolution */ xmax = getint(4, stdin); ymax = getint(4, stdin); + if (feof(stdin)) + quiterr("empty input file"); /* put our header */ + newheader("RADIANCE", stdout); printargs(i, argv, stdout); fputformat(COLRFMT, stdout); putchar('\n'); @@ -127,11 +126,13 @@ avs2ra() /* convert 24-bit scanlines to Radiance pict quiterr("out of memory in avs2ra"); /* convert image */ for (y = ymax-1; y >= 0; y--) { - (void)getc(stdin); /* toss alpha */ - 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++) { + (void)getc(stdin); /* toss alpha */ + scanout[x][RED] = getc(stdin); + scanout[x][GRN] = getc(stdin); + scanout[x][BLU] = getc(stdin); + } + if (feof(stdin) | ferror(stdin)) quiterr("error reading AVS image"); /* undo gamma */ gambs_colrs(scanout, xmax); @@ -141,7 +142,7 @@ avs2ra() /* convert 24-bit scanlines to Radiance pict quiterr("error writing Radiance picture"); } /* free scanline */ - free((char *)scanout); + free((void *)scanout); } @@ -171,5 +172,5 @@ ra2avs() /* convert Radiance scanlines to 24-bit */ quiterr("error writing AVS file"); } /* free scanline */ - free((char *)scanin); + free((void *)scanin); }