173 |
|
} |
174 |
|
break; |
175 |
|
case 'd': /* data only (no indices) */ |
176 |
< |
dataonly = argv[i][0] == '-'; |
176 |
> |
dataonly = (argv[i][0] == '-'); |
177 |
|
switch (argv[i][2]) { |
178 |
|
case '\0': |
179 |
|
case 'a': /* ascii */ |
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", |
375 |
|
} |
376 |
|
if (header) { |
377 |
|
printargs(i, argv, stdout); |
378 |
+ |
printf("NCOMP=%d\n", putprim==ALL ? 3 : 1); |
379 |
+ |
if (!resolution && dataonly && !uniq) |
380 |
+ |
printf("NCOLS=%d\nNROWS=%d\n", scanlen(&picres), |
381 |
+ |
numscans(&picres)); |
382 |
|
if (expval < .99 || expval > 1.01) |
383 |
|
fputexpos(expval, stdout); |
384 |
|
if (swapbytes) { |
386 |
|
puts("BigEndian=0"); |
387 |
|
else |
388 |
|
puts("BigEndian=1"); |
389 |
< |
} else if ((format != 'a') & (format != 'i')) |
389 |
> |
} else if ((format != 'a') & (format != 'i') & |
390 |
> |
(format != 'b')) |
391 |
|
fputendian(stdout); |
392 |
|
fputformat(fmtid, stdout); |
393 |
|
putchar('\n'); |
408 |
|
void *p |
409 |
|
) |
410 |
|
{ |
411 |
+ |
FILE *fout = (FILE *)p; |
412 |
|
char fmt[MAXFMTLEN]; |
413 |
|
double d; |
414 |
|
COLOR ctmp; |
415 |
|
int rv; |
416 |
|
|
417 |
|
if (formatval(fmt, line)) { |
418 |
< |
if (!strcmp(fmt, CIEFMT)) |
418 |
> |
if (reverse) |
419 |
> |
wrongformat = strcmp(fmt, fmtid); |
420 |
> |
else if (!strcmp(fmt, CIEFMT)) |
421 |
|
mybright = &xyz_bright; |
422 |
|
else if (!strcmp(fmt, COLRFMT)) |
423 |
|
mybright = &rgb_bright; |
424 |
|
else |
425 |
|
wrongformat++; |
426 |
< |
} else if (original && isexpos(line)) { |
426 |
> |
return(1); |
427 |
> |
} |
428 |
> |
if (original && isexpos(line)) { |
429 |
|
d = 1.0/exposval(line); |
430 |
|
scalecolor(exposure, d); |
431 |
|
doexposure++; |
432 |
< |
} else if (original && iscolcor(line)) { |
432 |
> |
return(1); |
433 |
> |
} |
434 |
> |
if (original && iscolcor(line)) { |
435 |
|
colcorval(ctmp, line); |
436 |
|
setcolor(exposure, colval(exposure,RED)/colval(ctmp,RED), |
437 |
|
colval(exposure,GRN)/colval(ctmp,GRN), |
438 |
|
colval(exposure,BLU)/colval(ctmp,BLU)); |
439 |
|
doexposure++; |
440 |
< |
} else if (reverse && (rv = isbigendian(line)) >= 0) { |
441 |
< |
swapbytes = (nativebigendian() != rv); |
442 |
< |
} else if (header) |
443 |
< |
fputs(line, stdout); |
440 |
> |
return(1); |
441 |
> |
} |
442 |
> |
if ((rv = isbigendian(line)) >= 0) { |
443 |
> |
if (reverse) |
444 |
> |
swapbytes = (nativebigendian() != rv); |
445 |
> |
return(1); |
446 |
> |
} |
447 |
> |
if (fout != NULL) |
448 |
> |
fputs(line, fout); |
449 |
|
return(0); |
450 |
|
} |
451 |
|
|