8 |
|
* Skeletal 24-bit image conversion program. Replace "skel" |
9 |
|
* in this file with a more appropriate image type identifier. |
10 |
|
* |
11 |
< |
* The Makefile entry should look something like this: |
11 |
> |
* The Rmakefile entry should look something like this: |
12 |
|
* ra_skel: ra_skel.o |
13 |
|
* cc $(CFLAGS) -o ra_skel ra_skel.o -lrt -lm |
14 |
|
* ra_skel.o: ../common/color.h ../common/resolu.h |
28 |
|
|
29 |
|
extern char *malloc(); |
30 |
|
|
31 |
< |
double gamma = 2.2; /* gamma correction */ |
31 |
> |
double gamcor = 2.2; /* gamma correction */ |
32 |
|
|
33 |
|
int bradj = 0; /* brightness adjustment */ |
34 |
|
|
50 |
|
if (argv[i][0] == '-') |
51 |
|
switch (argv[i][1]) { |
52 |
|
case 'g': /* gamma correction */ |
53 |
< |
gamma = atof(argv[++i]); |
53 |
> |
gamcor = atof(argv[++i]); |
54 |
|
break; |
55 |
|
case 'e': /* exposure adjustment */ |
56 |
|
if (argv[i+1][0] != '+' && argv[i+1][0] != '-') |
74 |
|
exit(1); |
75 |
|
} |
76 |
|
if (i == argc-2 && freopen(argv[i+1], "w", stdout) == NULL) { |
77 |
< |
fprintf(stderr, "can't open output \"%s\"\n", |
77 |
> |
fprintf(stderr, "%s: can't open output \"%s\"\n", |
78 |
|
progname, argv[i+1]); |
79 |
|
exit(1); |
80 |
|
} |
82 |
|
setmode(fileno(stdin), O_BINARY); |
83 |
|
setmode(fileno(stdout), O_BINARY); |
84 |
|
#endif |
85 |
< |
setcolrgam(gamma); /* set up gamma correction */ |
85 |
> |
setcolrgam(gamcor); /* set up gamma correction */ |
86 |
|
if (reverse) { |
87 |
|
/* get their image resolution */ |
88 |
|
read_skel_head(&xmax, &ymax); |
89 |
|
/* put our header */ |
90 |
+ |
newheader("RADIANCE", stdout); |
91 |
|
printargs(i, argv, stdout); |
92 |
|
fputformat(COLRFMT, stdout); |
93 |
|
putchar('\n'); |
135 |
|
quiterr("out of memory in skel2ra"); |
136 |
|
/* convert image */ |
137 |
|
for (y = ymax-1; y >= 0; y--) { |
138 |
< |
scanout[x][RED] = getc(stdin); |
139 |
< |
scanout[x][GRN] = getc(stdin); |
140 |
< |
scanout[x][BLU] = getc(stdin); |
141 |
< |
if (feof(stdin) || ferror(stdin)) |
138 |
> |
for (x = 0; x < xmax; x++) { |
139 |
> |
scanout[x][RED] = getc(stdin); |
140 |
> |
scanout[x][GRN] = getc(stdin); |
141 |
> |
scanout[x][BLU] = getc(stdin); |
142 |
> |
} |
143 |
> |
if (feof(stdin) | ferror(stdin)) |
144 |
|
quiterr("error reading skel image"); |
145 |
|
/* undo gamma */ |
146 |
|
gambs_colrs(scanout, xmax); |