1 |
– |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
4 |
< |
|
4 |
> |
/* |
5 |
> |
* Skeletal 24-bit image conversion program. Replace "skel" |
6 |
|
* in this file with a more appropriate image type identifier. |
7 |
|
* |
8 |
< |
* The Makefile entry should look something like this: |
8 |
> |
* The Rmakefile entry should look something like this: |
9 |
|
* ra_skel: ra_skel.o |
10 |
|
* cc $(CFLAGS) -o ra_skel ra_skel.o -lrt -lm |
11 |
|
* ra_skel.o: ../common/color.h ../common/resolu.h |
16 |
|
*/ |
17 |
|
|
18 |
|
#include <stdio.h> |
19 |
+ |
#include <math.h> |
20 |
|
#ifdef MSDOS |
21 |
|
#include <fcntl.h> |
22 |
|
#endif |
23 |
+ |
#include <time.h> |
24 |
|
#include "color.h" |
25 |
|
#include "resolu.h" |
26 |
|
|
27 |
< |
extern char *malloc(); |
27 |
> |
double gamcor = 2.2; /* gamma correction */ |
28 |
|
|
28 |
– |
double gamma = 2.2; /* gamma correction */ |
29 |
– |
|
29 |
|
int bradj = 0; /* brightness adjustment */ |
30 |
|
|
31 |
|
char *progname; |
46 |
|
if (argv[i][0] == '-') |
47 |
|
switch (argv[i][1]) { |
48 |
|
case 'g': /* gamma correction */ |
49 |
< |
gamma = atof(argv[++i]); |
49 |
> |
gamcor = atof(argv[++i]); |
50 |
|
break; |
51 |
|
case 'e': /* exposure adjustment */ |
52 |
|
if (argv[i+1][0] != '+' && argv[i+1][0] != '-') |
70 |
|
exit(1); |
71 |
|
} |
72 |
|
if (i == argc-2 && freopen(argv[i+1], "w", stdout) == NULL) { |
73 |
< |
fprintf(stderr, "can't open output \"%s\"\n", |
73 |
> |
fprintf(stderr, "%s: can't open output \"%s\"\n", |
74 |
|
progname, argv[i+1]); |
75 |
|
exit(1); |
76 |
|
} |
78 |
|
setmode(fileno(stdin), O_BINARY); |
79 |
|
setmode(fileno(stdout), O_BINARY); |
80 |
|
#endif |
81 |
< |
setcolrgam(gamma); /* set up gamma correction */ |
81 |
> |
setcolrgam(gamcor); /* set up gamma correction */ |
82 |
|
if (reverse) { |
83 |
|
/* get their image resolution */ |
84 |
|
read_skel_head(&xmax, &ymax); |
85 |
|
/* put our header */ |
86 |
+ |
newheader("RADIANCE", stdout); |
87 |
|
printargs(i, argv, stdout); |
88 |
|
fputformat(COLRFMT, stdout); |
89 |
|
putchar('\n'); |
131 |
|
quiterr("out of memory in skel2ra"); |
132 |
|
/* convert image */ |
133 |
|
for (y = ymax-1; y >= 0; y--) { |
134 |
< |
scanout[x][RED] = getc(stdin); |
135 |
< |
scanout[x][GRN] = getc(stdin); |
136 |
< |
scanout[x][BLU] = getc(stdin); |
137 |
< |
if (feof(stdin) || ferror(stdin)) |
134 |
> |
for (x = 0; x < xmax; x++) { |
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 skel image"); |
141 |
|
/* undo gamma */ |
142 |
|
gambs_colrs(scanout, xmax); |
146 |
|
quiterr("error writing Radiance picture"); |
147 |
|
} |
148 |
|
/* free scanline */ |
149 |
< |
free((char *)scanout); |
149 |
> |
free((void *)scanout); |
150 |
|
} |
151 |
|
|
152 |
|
|
175 |
|
quiterr("error writing skel file"); |
176 |
|
} |
177 |
|
/* free scanline */ |
178 |
< |
free((char *)scanin); |
178 |
> |
free((void *)scanin); |
179 |
|
} |