312 |
|
SET_FILE_BINARY(stdout); |
313 |
|
/* get header */ |
314 |
|
if (header) { |
315 |
< |
if (checkheader(fin, fmtid, stdout) < 0) { |
316 |
< |
fprintf(stderr, "%s: wrong input format\n", |
317 |
< |
progname); |
315 |
> |
getheader(fin, checkhead, stdout); |
316 |
> |
if (wrongformat) { |
317 |
> |
fprintf(stderr, "%s: wrong input format (expected %s)\n", |
318 |
> |
progname, fmtid); |
319 |
|
quit(1); |
320 |
|
} |
321 |
|
if (fin2 != NULL) { |
362 |
|
if ((format != 'a') & (format != 'i')) |
363 |
|
SET_FILE_BINARY(stdout); |
364 |
|
/* get header */ |
365 |
< |
getheader(fin, checkhead, NULL); |
365 |
> |
getheader(fin, checkhead, header ? stdout : (FILE *)NULL); |
366 |
|
if (wrongformat) { |
367 |
|
fprintf(stderr, |
368 |
|
"%s: input not a Radiance RGBE picture\n", |
403 |
|
void *p |
404 |
|
) |
405 |
|
{ |
406 |
+ |
FILE *fout = (FILE *)p; |
407 |
|
char fmt[MAXFMTLEN]; |
408 |
|
double d; |
409 |
|
COLOR ctmp; |
410 |
|
int rv; |
411 |
|
|
412 |
|
if (formatval(fmt, line)) { |
413 |
< |
if (!strcmp(fmt, CIEFMT)) |
413 |
> |
if (reverse) |
414 |
> |
wrongformat = strcmp(fmt, fmtid); |
415 |
> |
else if (!strcmp(fmt, CIEFMT)) |
416 |
|
mybright = &xyz_bright; |
417 |
|
else if (!strcmp(fmt, COLRFMT)) |
418 |
|
mybright = &rgb_bright; |
428 |
|
colval(exposure,GRN)/colval(ctmp,GRN), |
429 |
|
colval(exposure,BLU)/colval(ctmp,BLU)); |
430 |
|
doexposure++; |
431 |
< |
} else if (reverse && (rv = isbigendian(line)) >= 0) { |
432 |
< |
swapbytes = (nativebigendian() != rv); |
433 |
< |
} else if (header) |
434 |
< |
fputs(line, stdout); |
431 |
> |
} else if ((rv = isbigendian(line)) >= 0) { |
432 |
> |
if (reverse) |
433 |
> |
swapbytes = (nativebigendian() != rv); |
434 |
> |
} else if (fout != NULL) |
435 |
> |
fputs(line, fout); |
436 |
|
return(0); |
437 |
|
} |
438 |
|
|