9 |
|
*/ |
10 |
|
|
11 |
|
#include <stdio.h> |
12 |
+ |
#include <math.h> |
13 |
|
#ifdef MSDOS |
14 |
|
#include <fcntl.h> |
15 |
|
#endif |
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] != '-') |
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); |
127 |
|
quiterr("out of memory in avs2ra"); |
128 |
|
/* convert image */ |
129 |
|
for (y = ymax-1; y >= 0; y--) { |
130 |
< |
(void)getc(stdin); /* toss alpha */ |
131 |
< |
scanout[x][RED] = getc(stdin); |
132 |
< |
scanout[x][GRN] = getc(stdin); |
133 |
< |
scanout[x][BLU] = getc(stdin); |
134 |
< |
if (feof(stdin) || ferror(stdin)) |
130 |
> |
for (x = 0; x < xmax; x++) { |
131 |
> |
(void)getc(stdin); /* toss alpha */ |
132 |
> |
scanout[x][RED] = getc(stdin); |
133 |
> |
scanout[x][GRN] = getc(stdin); |
134 |
> |
scanout[x][BLU] = getc(stdin); |
135 |
> |
} |
136 |
> |
if (feof(stdin) | ferror(stdin)) |
137 |
|
quiterr("error reading AVS image"); |
138 |
|
/* undo gamma */ |
139 |
|
gambs_colrs(scanout, xmax); |