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 |
6 |
– |
|
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 |
10 |
> |
* cc $(CFLAGS) -o ra_skel ra_skel.o -lrtrad -lm |
11 |
|
* ra_skel.o: ../common/color.h ../common/resolu.h |
12 |
|
* |
13 |
|
* If you like to do things the hard way, you can link directly |
14 |
|
* to the object files "color.o colrops.o resolu.o header.o" in |
15 |
< |
* the common subdirectory instead of using the -lrt library. |
15 |
> |
* the common subdirectory instead of using the -lrtrad library. |
16 |
|
*/ |
17 |
|
|
18 |
|
#include <stdio.h> |
19 |
|
#include <math.h> |
20 |
< |
#ifdef MSDOS |
21 |
< |
#include <fcntl.h> |
22 |
< |
#endif |
20 |
> |
#include <time.h> |
21 |
> |
|
22 |
> |
#include "platform.h" |
23 |
|
#include "color.h" |
24 |
|
#include "resolu.h" |
25 |
|
|
26 |
< |
extern char *malloc(); |
26 |
> |
double gamcor = 2.2; /* gamma correction */ |
27 |
|
|
31 |
– |
double gamma = 2.2; /* gamma correction */ |
32 |
– |
|
28 |
|
int bradj = 0; /* brightness adjustment */ |
29 |
|
|
30 |
|
char *progname; |
45 |
|
if (argv[i][0] == '-') |
46 |
|
switch (argv[i][1]) { |
47 |
|
case 'g': /* gamma correction */ |
48 |
< |
gamma = atof(argv[++i]); |
48 |
> |
gamcor = atof(argv[++i]); |
49 |
|
break; |
50 |
|
case 'e': /* exposure adjustment */ |
51 |
|
if (argv[i+1][0] != '+' && argv[i+1][0] != '-') |
69 |
|
exit(1); |
70 |
|
} |
71 |
|
if (i == argc-2 && freopen(argv[i+1], "w", stdout) == NULL) { |
72 |
< |
fprintf(stderr, "can't open output \"%s\"\n", |
72 |
> |
fprintf(stderr, "%s: can't open output \"%s\"\n", |
73 |
|
progname, argv[i+1]); |
74 |
|
exit(1); |
75 |
|
} |
76 |
< |
#ifdef MSDOS |
77 |
< |
setmode(fileno(stdin), O_BINARY); |
78 |
< |
setmode(fileno(stdout), O_BINARY); |
84 |
< |
#endif |
85 |
< |
setcolrgam(gamma); /* set up gamma correction */ |
76 |
> |
SET_FILE_BINARY(stdin); |
77 |
> |
SET_FILE_BINARY(stdout); |
78 |
> |
setcolrgam(gamcor); /* set up gamma correction */ |
79 |
|
if (reverse) { |
80 |
|
/* get their image resolution */ |
81 |
|
read_skel_head(&xmax, &ymax); |
82 |
|
/* put our header */ |
83 |
+ |
newheader("RADIANCE", stdout); |
84 |
|
printargs(i, argv, stdout); |
85 |
|
fputformat(COLRFMT, stdout); |
86 |
|
putchar('\n'); |
128 |
|
quiterr("out of memory in skel2ra"); |
129 |
|
/* convert image */ |
130 |
|
for (y = ymax-1; y >= 0; y--) { |
131 |
< |
scanout[x][RED] = getc(stdin); |
132 |
< |
scanout[x][GRN] = getc(stdin); |
133 |
< |
scanout[x][BLU] = getc(stdin); |
134 |
< |
if (feof(stdin) || ferror(stdin)) |
131 |
> |
for (x = 0; x < xmax; x++) { |
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 skel image"); |
138 |
|
/* undo gamma */ |
139 |
|
gambs_colrs(scanout, xmax); |
143 |
|
quiterr("error writing Radiance picture"); |
144 |
|
} |
145 |
|
/* free scanline */ |
146 |
< |
free((char *)scanout); |
146 |
> |
free((void *)scanout); |
147 |
|
} |
148 |
|
|
149 |
|
|
172 |
|
quiterr("error writing skel file"); |
173 |
|
} |
174 |
|
/* free scanline */ |
175 |
< |
free((char *)scanin); |
175 |
> |
free((void *)scanin); |
176 |
|
} |