99 |
|
|
100 |
|
extern double atof(); |
101 |
|
double exposure = 1.0; |
102 |
+ |
int wrong_fmt = 0; |
103 |
|
|
104 |
|
|
105 |
|
main(argc, argv) |
141 |
|
quitmsg(errmsg); |
142 |
|
} |
143 |
|
/* get header */ |
144 |
< |
getheader(fin, checkhead); |
144 |
> |
getheader(fin, checkhead, NULL); |
145 |
> |
if (wrong_fmt) |
146 |
> |
quitmsg("input must be a Radiance picture"); |
147 |
|
/* get picture dimensions */ |
148 |
< |
if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR)) |
148 |
> |
if (fgetresolu(&xmax, &ymax, fin) < 0) |
149 |
|
quitmsg("bad picture size"); |
150 |
|
if (xmax > NCOLS || ymax > NROWS) |
151 |
|
quitmsg("resolution mismatch"); |
172 |
|
checkhead(line) /* deal with line from header */ |
173 |
|
char *line; |
174 |
|
{ |
175 |
+ |
char fmt[32]; |
176 |
+ |
|
177 |
|
if (isexpos(line)) |
178 |
|
exposure *= exposval(line); |
179 |
+ |
else if (isformat(line)) { |
180 |
+ |
formatval(fmt, line); |
181 |
+ |
wrong_fmt = strcmp(fmt, COLRFMT); |
182 |
+ |
} |
183 |
|
} |
184 |
|
|
185 |
|
|
324 |
|
break; |
325 |
|
case 'l': |
326 |
|
case 'L': |
327 |
< |
printf("%-3gL", bright(cval)*683.0/exposure); |
327 |
> |
printf("%-3gL", luminance(cval)/exposure); |
328 |
|
break; |
329 |
|
case 'c': |
330 |
|
case 'C': |
409 |
|
/* read scanline */ |
410 |
|
getscan(y); |
411 |
|
/* convert scanline */ |
412 |
< |
normcolrs(scanline, xmax); |
412 |
> |
normcolrs(scanline, xmax, 0); |
413 |
|
for (i = 0; i < xmax; i++) { |
414 |
|
l3[i].r = scanline[i][RED]; |
415 |
|
l3[i].g = scanline[i][GRN]; |
524 |
|
register int i, val; |
525 |
|
|
526 |
|
for (i = 0; i < 256; i++) { |
527 |
< |
val = pow(i/256.0, 1.0/GAMMA) * 256.0; |
527 |
> |
val = pow((i+0.5)/256.0, 1.0/GAMMA) * 256.0; |
528 |
|
map[0][i] = map[1][i] = map[2][i] = val; |
529 |
|
} |
530 |
|
} |