18 |
|
|
19 |
|
extern char *malloc(); |
20 |
|
|
21 |
< |
double gamma = 2.2; /* gamma correction */ |
21 |
> |
double gamcor = 2.2; /* gamma correction */ |
22 |
|
|
23 |
|
int bradj = 0; /* brightness adjustment */ |
24 |
|
|
41 |
|
if (argv[i][0] == '-') |
42 |
|
switch (argv[i][1]) { |
43 |
|
case 'g': /* gamma correction */ |
44 |
< |
gamma = atof(argv[++i]); |
44 |
> |
gamcor = atof(argv[++i]); |
45 |
|
break; |
46 |
|
case 'e': /* exposure adjustment */ |
47 |
|
if (argv[i+1][0] != '+' && argv[i+1][0] != '-') |
65 |
|
exit(1); |
66 |
|
} |
67 |
|
if (i == argc-2 && freopen(argv[i+1], "w", stdout) == NULL) { |
68 |
< |
fprintf(stderr, "can't open output \"%s\"\n", |
68 |
> |
fprintf(stderr, "%s: can't open output \"%s\"\n", |
69 |
|
progname, argv[i+1]); |
70 |
|
exit(1); |
71 |
|
} |
73 |
|
setmode(fileno(stdin), O_BINARY); |
74 |
|
setmode(fileno(stdout), O_BINARY); |
75 |
|
#endif |
76 |
< |
setcolrgam(gamma); /* set up gamma correction */ |
76 |
> |
setcolrgam(gamcor); /* set up gamma correction */ |
77 |
|
if (reverse) { |
78 |
|
/* get their image resolution */ |
79 |
|
xmax = getint(4, stdin); |
80 |
|
ymax = getint(4, stdin); |
81 |
+ |
if (feof(stdin)) |
82 |
+ |
quiterr("empty input file"); |
83 |
|
/* put our header */ |
84 |
+ |
newheader("RADIANCE", stdout); |
85 |
|
printargs(i, argv, stdout); |
86 |
|
fputformat(COLRFMT, stdout); |
87 |
|
putchar('\n'); |
130 |
|
quiterr("out of memory in avs2ra"); |
131 |
|
/* convert image */ |
132 |
|
for (y = ymax-1; y >= 0; y--) { |
133 |
< |
(void)getc(stdin); /* toss alpha */ |
134 |
< |
scanout[x][RED] = getc(stdin); |
135 |
< |
scanout[x][GRN] = getc(stdin); |
136 |
< |
scanout[x][BLU] = getc(stdin); |
137 |
< |
if (feof(stdin) || ferror(stdin)) |
133 |
> |
for (x = 0; x < xmax; x++) { |
134 |
> |
(void)getc(stdin); /* toss alpha */ |
135 |
> |
scanout[x][RED] = getc(stdin); |
136 |
> |
scanout[x][GRN] = getc(stdin); |
137 |
> |
scanout[x][BLU] = getc(stdin); |
138 |
> |
} |
139 |
> |
if (feof(stdin) | ferror(stdin)) |
140 |
|
quiterr("error reading AVS image"); |
141 |
|
/* undo gamma */ |
142 |
|
gambs_colrs(scanout, xmax); |