--- ray/src/px/aedimage.c 1989/10/20 20:35:57 1.5 +++ ray/src/px/aedimage.c 2003/02/22 02:07:27 2.5 @@ -1,9 +1,6 @@ -/* Copyright (c) 1986 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: aedimage.c,v 2.5 2003/02/22 02:07:27 greg Exp $"; #endif - /* * aedimage.c - RADIANCE driver for AED 512 terminal. * @@ -13,6 +10,8 @@ static char SCCSid[] = "$SunId$ LBL"; #include +#include + #include #include @@ -97,8 +96,8 @@ FILE *fin; extern long ftell(); long scanpos[NROWS]; -extern double atof(); double exposure = 1.0; +int wrong_fmt = 0; main(argc, argv) @@ -140,9 +139,11 @@ char *argv[]; quitmsg(errmsg); } /* get header */ - getheader(fin, checkhead); + getheader(fin, checkhead, NULL); + if (wrong_fmt) + quitmsg("input must be a Radiance picture"); /* get picture dimensions */ - if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR)) + if (fgetresolu(&xmax, &ymax, fin) < 0) quitmsg("bad picture size"); if (xmax > NCOLS || ymax > NROWS) quitmsg("resolution mismatch"); @@ -166,11 +167,19 @@ userr: } +int checkhead(line) /* deal with line from header */ char *line; { - if (!strncmp(line, "EXPOSURE=", 9)) - exposure *= atof(line+9); + char fmt[32]; + + if (isexpos(line)) + exposure *= exposval(line); + else if (isformat(line)) { + formatval(fmt, line); + wrong_fmt = strcmp(fmt, COLRFMT); + } + return(0); } @@ -235,6 +244,7 @@ char *err; } +void eputs(s) char *s; { @@ -242,6 +252,7 @@ char *s; } +void quit(status) int status; { @@ -315,7 +326,7 @@ loopcom() /* print pixel values interactively */ break; case 'l': case 'L': - printf("%-3gL", bright(cval)*683.0/exposure); + printf("%-3gL", luminance(cval)/exposure); break; case 'c': case 'C': @@ -400,7 +411,7 @@ register rgbpixel *l3; /* read scanline */ getscan(y); /* convert scanline */ - normcolrs(scanline, xmax); + normcolrs(scanline, xmax, 0); for (i = 0; i < xmax; i++) { l3[i].r = scanline[i][RED]; l3[i].g = scanline[i][GRN]; @@ -511,11 +522,10 @@ int offset[3]; picreadcm(map) /* do gamma correction */ colormap map; { - extern double pow(); register int i, val; for (i = 0; i < 256; i++) { - val = pow(i/256.0, 1.0/GAMMA) * 256.0; + val = pow((i+0.5)/256.0, 1.0/GAMMA) * 256.0; map[0][i] = map[1][i] = map[2][i] = val; } }