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) { |
397 |
+ |
if (nativebigendian()) |
398 |
+ |
puts("BigEndian=0"); |
399 |
+ |
else |
400 |
+ |
puts("BigEndian=1"); |
401 |
+ |
} else if ((format != 'a') & (format != 'i') & |
402 |
+ |
(format != 'b')) |
403 |
+ |
fputendian(stdout); |
404 |
|
fputformat(fmtid, stdout); |
405 |
|
putchar('\n'); |
406 |
|
} |
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 (original && isexpos(line)) { |
441 |
|
d = 1.0/exposval(line); |
442 |
|
scalecolor(exposure, d); |
443 |
|
doexposure++; |
444 |
< |
} else if (original && iscolcor(line)) { |
444 |
> |
return(1); |
445 |
> |
} |
446 |
> |
if (original && iscolcor(line)) { |
447 |
|
colcorval(ctmp, line); |
448 |
|
setcolor(exposure, colval(exposure,RED)/colval(ctmp,RED), |
449 |
|
colval(exposure,GRN)/colval(ctmp,GRN), |
450 |
|
colval(exposure,BLU)/colval(ctmp,BLU)); |
451 |
|
doexposure++; |
452 |
< |
} else if (header) |
453 |
< |
fputs(line, stdout); |
452 |
> |
return(1); |
453 |
> |
} |
454 |
> |
if ((rv = isbigendian(line)) >= 0) { |
455 |
> |
if (reverse) |
456 |
> |
swapbytes = (nativebigendian() != rv); |
457 |
> |
return(1); |
458 |
> |
} |
459 |
> |
if (fout != NULL) |
460 |
> |
fputs(line, fout); |
461 |
|
return(0); |
462 |
|
} |
463 |
|
|