| 118 |
|
case 'o': /* original values */ |
| 119 |
|
original = argv[i][0] == '-'; |
| 120 |
|
break; |
| 121 |
+ |
case 'O': /* original watts/sr/m^2 */ |
| 122 |
+ |
original = -(argv[i][0] == '-'); |
| 123 |
+ |
break; |
| 124 |
|
case 'g': /* gamma correction */ |
| 125 |
|
gamcor = atof(argv[i+1]); |
| 126 |
|
if (argv[i][0] == '+') |
| 176 |
|
} |
| 177 |
|
break; |
| 178 |
|
case 'd': /* data only (no indices) */ |
| 179 |
< |
dataonly = argv[i][0] == '-'; |
| 179 |
> |
dataonly = (argv[i][0] == '-'); |
| 180 |
|
switch (argv[i][2]) { |
| 181 |
|
case '\0': |
| 182 |
|
case 'a': /* ascii */ |
| 315 |
|
SET_FILE_BINARY(stdout); |
| 316 |
|
/* get header */ |
| 317 |
|
if (header) { |
| 318 |
< |
if (checkheader(fin, fmtid, stdout) < 0) { |
| 319 |
< |
fprintf(stderr, "%s: wrong input format\n", |
| 320 |
< |
progname); |
| 318 |
> |
getheader(fin, checkhead, stdout); |
| 319 |
> |
if (wrongformat) { |
| 320 |
> |
fprintf(stderr, "%s: wrong input format (expected %s)\n", |
| 321 |
> |
progname, fmtid); |
| 322 |
|
quit(1); |
| 323 |
|
} |
| 324 |
|
if (fin2 != NULL) { |
| 356 |
|
if (outprims != stdprims) |
| 357 |
|
fputprims(outprims, stdout); |
| 358 |
|
fputformat(COLRFMT, stdout); |
| 359 |
< |
} else /* XYZ data */ |
| 359 |
> |
} else { /* XYZ data */ |
| 360 |
> |
if (original < 0) { |
| 361 |
> |
scalecolor(exposure, WHTEFFICACY); |
| 362 |
> |
doexposure++; |
| 363 |
> |
} |
| 364 |
|
fputformat(CIEFMT, stdout); |
| 365 |
+ |
} |
| 366 |
|
putchar('\n'); |
| 367 |
|
fputsresolu(&picres, stdout); /* always put resolution */ |
| 368 |
|
valtopix(); |
| 370 |
|
if ((format != 'a') & (format != 'i')) |
| 371 |
|
SET_FILE_BINARY(stdout); |
| 372 |
|
/* get header */ |
| 373 |
< |
getheader(fin, checkhead, NULL); |
| 373 |
> |
getheader(fin, checkhead, header ? stdout : (FILE *)NULL); |
| 374 |
|
if (wrongformat) { |
| 375 |
|
fprintf(stderr, |
| 376 |
|
"%s: input not a Radiance RGBE picture\n", |
| 381 |
|
fprintf(stderr, "%s: missing resolution\n", progname); |
| 382 |
|
quit(1); |
| 383 |
|
} |
| 384 |
+ |
if (original < 0 && mybright == &xyz_bright) { |
| 385 |
+ |
scalecolor(exposure, 1./WHTEFFICACY); |
| 386 |
+ |
doexposure++; |
| 387 |
+ |
} |
| 388 |
|
if (header) { |
| 389 |
|
printargs(i, argv, stdout); |
| 390 |
+ |
printf("NCOMP=%d\n", putprim==ALL ? 3 : 1); |
| 391 |
+ |
if (!resolution && dataonly && !uniq) |
| 392 |
+ |
printf("NCOLS=%d\nNROWS=%d\n", scanlen(&picres), |
| 393 |
+ |
numscans(&picres)); |
| 394 |
|
if (expval < .99 || expval > 1.01) |
| 395 |
|
fputexpos(expval, stdout); |
| 396 |
|
if (swapbytes) { |
| 398 |
|
puts("BigEndian=0"); |
| 399 |
|
else |
| 400 |
|
puts("BigEndian=1"); |
| 401 |
< |
} else if ((format != 'a') & (format != 'i')) |
| 401 |
> |
} else if ((format != 'a') & (format != 'i') & |
| 402 |
> |
(format != 'b')) |
| 403 |
|
fputendian(stdout); |
| 404 |
|
fputformat(fmtid, stdout); |
| 405 |
|
putchar('\n'); |
| 420 |
|
void *p |
| 421 |
|
) |
| 422 |
|
{ |
| 423 |
+ |
FILE *fout = (FILE *)p; |
| 424 |
|
char fmt[MAXFMTLEN]; |
| 425 |
|
double d; |
| 426 |
|
COLOR ctmp; |
| 427 |
|
int rv; |
| 428 |
|
|
| 429 |
|
if (formatval(fmt, line)) { |
| 430 |
< |
if (!strcmp(fmt, CIEFMT)) |
| 430 |
> |
if (reverse) |
| 431 |
> |
wrongformat = strcmp(fmt, fmtid); |
| 432 |
> |
else if (!strcmp(fmt, CIEFMT)) |
| 433 |
|
mybright = &xyz_bright; |
| 434 |
|
else if (!strcmp(fmt, COLRFMT)) |
| 435 |
|
mybright = &rgb_bright; |
| 436 |
|
else |
| 437 |
|
wrongformat++; |
| 438 |
< |
} else if (original && isexpos(line)) { |
| 438 |
> |
return(1); |
| 439 |
> |
} |
| 440 |
> |
if (!strncmp(line,"NROWS=",6) || |
| 441 |
> |
!strncmp(line,"NCOLS=",6) || |
| 442 |
> |
!strncmp(line,"NCOMP=",6)) |
| 443 |
> |
return(1); |
| 444 |
> |
|
| 445 |
> |
if (original && isexpos(line)) { |
| 446 |
|
d = 1.0/exposval(line); |
| 447 |
|
scalecolor(exposure, d); |
| 448 |
|
doexposure++; |
| 449 |
< |
} else if (original && iscolcor(line)) { |
| 449 |
> |
return(1); |
| 450 |
> |
} |
| 451 |
> |
if (original && iscolcor(line)) { |
| 452 |
|
colcorval(ctmp, line); |
| 453 |
|
setcolor(exposure, colval(exposure,RED)/colval(ctmp,RED), |
| 454 |
|
colval(exposure,GRN)/colval(ctmp,GRN), |
| 455 |
|
colval(exposure,BLU)/colval(ctmp,BLU)); |
| 456 |
|
doexposure++; |
| 457 |
< |
} else if (reverse && (rv = isbigendian(line)) >= 0) { |
| 458 |
< |
swapbytes = (nativebigendian() != rv); |
| 459 |
< |
} else if (header) |
| 460 |
< |
fputs(line, stdout); |
| 457 |
> |
return(1); |
| 458 |
> |
} |
| 459 |
> |
if ((rv = isbigendian(line)) >= 0) { |
| 460 |
> |
if (reverse) |
| 461 |
> |
swapbytes = (nativebigendian() != rv); |
| 462 |
> |
return(1); |
| 463 |
> |
} |
| 464 |
> |
if (fout != NULL) |
| 465 |
> |
fputs(line, fout); |
| 466 |
|
return(0); |
| 467 |
|
} |
| 468 |
|
|