| 292 |
|
int tmflags; |
| 293 |
|
BMPHeader *hdr; |
| 294 |
|
BMPWriter *wtr; |
| 295 |
– |
RESOLU rs; |
| 295 |
|
FILE *fp; |
| 296 |
|
int xr, yr; |
| 297 |
|
BYTE *pa; |
| 317 |
|
fprintf(stderr, "%s: cannot open\n", fnin); |
| 318 |
|
exit(1); |
| 319 |
|
} |
| 321 |
– |
/* get picture orientation */ |
| 322 |
– |
if (fnin != NULL) { |
| 323 |
– |
if (getheader(fp, NULL, NULL) < 0 || !fgetsresolu(&rs, fp)) |
| 324 |
– |
quiterr("bad Radiance picture format"); |
| 325 |
– |
rewind(fp); |
| 326 |
– |
} else /* assume stdin has normal orient */ |
| 327 |
– |
rs.rt = PIXSTANDARD; |
| 320 |
|
/* tone-map picture */ |
| 321 |
|
if (tmMapPicture(&pa, &xr, &yr, tmflags, monpri, gamval, |
| 322 |
|
0., 0., fnin, fp) != TM_E_OK) |
| 356 |
|
if (fflush((FILE *)wtr->c_data) < 0) |
| 357 |
|
quiterr("error writing BMP output"); |
| 358 |
|
/* clean up */ |
| 359 |
+ |
if (fnin != NULL) |
| 360 |
+ |
fclose(fp); |
| 361 |
|
free((void *)pa); |
| 362 |
|
BMPcloseOutput(wtr); |
| 363 |
|
} |