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 |
+ |
#include <time.h> |
10 |
+ |
#include <math.h> |
11 |
|
|
12 |
< |
#ifdef MSDOS |
14 |
< |
#include <fcntl.h> |
15 |
< |
#endif |
16 |
< |
|
12 |
> |
#include "platform.h" |
13 |
|
#include "rasterfile.h" |
18 |
– |
|
14 |
|
#include "color.h" |
20 |
– |
|
15 |
|
#include "resolu.h" |
16 |
|
|
17 |
< |
extern double pow(); |
17 |
> |
double gamcor = 2.2; /* gamma correction */ |
18 |
|
|
25 |
– |
extern char *malloc(); |
26 |
– |
|
27 |
– |
double gamma = 2.2; /* gamma correction */ |
28 |
– |
|
19 |
|
int bradj = 0; /* brightness adjustment */ |
20 |
|
|
21 |
|
char *progname; |
30 |
|
struct rasterfile head; |
31 |
|
int reverse = 0; |
32 |
|
int i; |
33 |
< |
#ifdef MSDOS |
34 |
< |
extern int _fmode; |
35 |
< |
_fmode = O_BINARY; |
46 |
< |
setmode(fileno(stdin), O_BINARY); |
47 |
< |
setmode(fileno(stdout), O_BINARY); |
48 |
< |
#endif |
33 |
> |
SET_DEFAULT_BINARY(); |
34 |
> |
SET_FILE_BINARY(stdin); |
35 |
> |
SET_FILE_BINARY(stdout); |
36 |
|
progname = argv[0]; |
37 |
|
|
38 |
|
head.ras_type = RT_STANDARD; |
40 |
|
if (argv[i][0] == '-') |
41 |
|
switch (argv[i][1]) { |
42 |
|
case 'g': |
43 |
< |
gamma = atof(argv[++i]); |
43 |
> |
gamcor = atof(argv[++i]); |
44 |
|
break; |
45 |
|
case 'e': |
46 |
|
if (argv[i+1][0] != '+' && argv[i+1][0] != '-') |
67 |
|
exit(1); |
68 |
|
} |
69 |
|
if (i == argc-2 && freopen(argv[i+1], "w", stdout) == NULL) { |
70 |
< |
fprintf(stderr, "can't open output \"%s\"\n", |
70 |
> |
fprintf(stderr, "%s: can't open output \"%s\"\n", |
71 |
|
progname, argv[i+1]); |
72 |
|
exit(1); |
73 |
|
} |
74 |
< |
setcolrgam(gamma); |
74 |
> |
setcolrgam(gamcor); |
75 |
|
if (reverse) { |
76 |
|
/* get header */ |
77 |
|
if (fread((char *)&head, sizeof(head), 1, stdin) != 1) |
86 |
|
|| head.ras_depth != 24) |
87 |
|
quiterr("incompatible format"); |
88 |
|
/* put header */ |
89 |
+ |
newheader("RADIANCE", stdout); |
90 |
|
printargs(i, argv, stdout); |
91 |
|
fputformat(COLRFMT, stdout); |
92 |
|
putchar('\n'); |
164 |
|
quiterr("error writing Radiance picture"); |
165 |
|
} |
166 |
|
/* free scanline */ |
167 |
< |
free((char *)scanout); |
167 |
> |
free((void *)scanout); |
168 |
|
} |
169 |
|
|
170 |
|
|
210 |
|
quiterr("error writing rasterfile"); |
211 |
|
} |
212 |
|
/* free scanline */ |
213 |
< |
free((char *)scanin); |
213 |
> |
free((void *)scanin); |
214 |
|
} |