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 |
|
* program to convert between RADIANCE and 24-bit rasterfiles. |
6 |
|
*/ |
7 |
|
|
8 |
|
#include <stdio.h> |
9 |
< |
|
13 |
< |
#ifdef MSDOS |
14 |
< |
#include <fcntl.h> |
15 |
< |
#endif |
16 |
< |
|
9 |
> |
#include <time.h> |
10 |
|
#include <math.h> |
11 |
+ |
#include <string.h> |
12 |
|
|
13 |
+ |
#include "platform.h" |
14 |
|
#include "rasterfile.h" |
20 |
– |
|
15 |
|
#include "color.h" |
22 |
– |
|
16 |
|
#include "resolu.h" |
17 |
|
|
25 |
– |
extern char *malloc(); |
26 |
– |
|
18 |
|
double gamcor = 2.2; /* gamma correction */ |
28 |
– |
|
19 |
|
int bradj = 0; /* brightness adjustment */ |
30 |
– |
|
20 |
|
char *progname; |
32 |
– |
|
21 |
|
int xmax, ymax; |
22 |
|
|
23 |
+ |
static void quiterr(char *err); |
24 |
+ |
static void pr2ra(int rf, int pad); |
25 |
+ |
static void ra2pr(int rf, int pad); |
26 |
|
|
27 |
< |
main(argc, argv) |
28 |
< |
int argc; |
29 |
< |
char *argv[]; |
27 |
> |
|
28 |
> |
int |
29 |
> |
main(int argc, char *argv[]) |
30 |
|
{ |
31 |
|
struct rasterfile head; |
32 |
|
int reverse = 0; |
33 |
|
int i; |
34 |
< |
#ifdef MSDOS |
35 |
< |
extern int _fmode; |
36 |
< |
_fmode = O_BINARY; |
46 |
< |
setmode(fileno(stdin), O_BINARY); |
47 |
< |
setmode(fileno(stdout), O_BINARY); |
48 |
< |
#endif |
34 |
> |
SET_DEFAULT_BINARY(); |
35 |
> |
SET_FILE_BINARY(stdin); |
36 |
> |
SET_FILE_BINARY(stdout); |
37 |
|
progname = argv[0]; |
38 |
|
|
39 |
|
head.ras_type = RT_STANDARD; |
87 |
|
|| head.ras_depth != 24) |
88 |
|
quiterr("incompatible format"); |
89 |
|
/* put header */ |
90 |
+ |
newheader("RADIANCE", stdout); |
91 |
|
printargs(i, argv, stdout); |
92 |
|
fputformat(COLRFMT, stdout); |
93 |
|
putchar('\n'); |
119 |
|
} |
120 |
|
|
121 |
|
|
122 |
< |
quiterr(err) /* print message and exit */ |
123 |
< |
char *err; |
122 |
> |
static void |
123 |
> |
quiterr( /* print message and exit */ |
124 |
> |
char *err |
125 |
> |
) |
126 |
|
{ |
127 |
|
if (err != NULL) { |
128 |
|
fprintf(stderr, "%s: %s\n", progname, err); |
132 |
|
} |
133 |
|
|
134 |
|
|
135 |
< |
pr2ra(rf, pad) /* convert 24-bit scanlines to Radiance picture */ |
136 |
< |
int rf; |
137 |
< |
int pad; |
135 |
> |
static void |
136 |
> |
pr2ra( /* convert 24-bit scanlines to Radiance picture */ |
137 |
> |
int rf, |
138 |
> |
int pad |
139 |
> |
) |
140 |
|
{ |
141 |
|
COLR *scanout; |
142 |
|
register int x; |
169 |
|
quiterr("error writing Radiance picture"); |
170 |
|
} |
171 |
|
/* free scanline */ |
172 |
< |
free((char *)scanout); |
172 |
> |
free((void *)scanout); |
173 |
|
} |
174 |
|
|
175 |
|
|
176 |
< |
ra2pr(rf, pad) /* convert Radiance scanlines to 24-bit rasterfile */ |
177 |
< |
int rf; |
178 |
< |
int pad; |
176 |
> |
static void |
177 |
> |
ra2pr( /* convert Radiance scanlines to 24-bit rasterfile */ |
178 |
> |
int rf, |
179 |
> |
int pad |
180 |
> |
) |
181 |
|
{ |
182 |
|
int ord[3]; |
183 |
|
COLR *scanin; |
217 |
|
quiterr("error writing rasterfile"); |
218 |
|
} |
219 |
|
/* free scanline */ |
220 |
< |
free((char *)scanin); |
220 |
> |
free((void *)scanin); |
221 |
|
} |