1 |
– |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Program to convert between RADIANCE RGBE and XYZE formats |
6 |
+ |
* Added white-balance adjustment 10/01 (GW). |
7 |
|
*/ |
8 |
|
|
9 |
|
#include <stdio.h> |
10 |
+ |
#include <string.h> |
11 |
|
#include <math.h> |
12 |
+ |
#include <time.h> |
13 |
+ |
|
14 |
+ |
#include "platform.h" |
15 |
|
#include "color.h" |
16 |
|
#include "resolu.h" |
17 |
|
|
16 |
– |
#ifdef MSDOS |
17 |
– |
#include <fcntl.h> |
18 |
– |
#endif |
19 |
– |
|
20 |
– |
extern char *malloc(), *strcpy(); |
21 |
– |
|
18 |
|
int rgbinp = -1; /* input is RGBE? */ |
19 |
|
|
20 |
|
int rgbout = 0; /* output should be RGBE? */ |
29 |
|
|
30 |
|
char *progname; |
31 |
|
|
32 |
+ |
static gethfunc headline; |
33 |
|
|
34 |
< |
int |
35 |
< |
headline(s) /* process header line */ |
36 |
< |
char *s; |
34 |
> |
|
35 |
> |
static int |
36 |
> |
headline( /* process header line */ |
37 |
> |
char *s, |
38 |
> |
void *p |
39 |
> |
) |
40 |
|
{ |
41 |
|
char fmt[32]; |
42 |
|
|
63 |
|
char *argv[]; |
64 |
|
{ |
65 |
|
int i; |
66 |
< |
#ifdef MSDOS |
67 |
< |
extern int _fmode; |
68 |
< |
_fmode = O_BINARY; |
69 |
< |
setmode(fileno(stdin), O_BINARY); |
70 |
< |
setmode(fileno(stdout), O_BINARY); |
71 |
< |
#endif |
66 |
> |
SET_DEFAULT_BINARY(); |
67 |
> |
SET_FILE_BINARY(stdin); |
68 |
> |
SET_FILE_BINARY(stdout); |
69 |
|
progname = argv[0]; |
70 |
|
|
71 |
|
for (i = 1; i < argc; i++) |
156 |
|
/* compute transform */ |
157 |
|
if (rgbout) { |
158 |
|
if (rgbinp) { /* RGBE -> RGBE */ |
159 |
< |
comprgb2rgbmat(xfm, inprims, outprims); |
159 |
> |
comprgb2rgbWBmat(xfm, inprims, outprims); |
160 |
|
} else { /* XYZE -> RGBE */ |
161 |
< |
compxyz2rgbmat(xfm, outprims); |
161 |
> |
compxyz2rgbWBmat(xfm, outprims); |
162 |
|
ourexp *= WHTEFFICACY; |
163 |
|
} |
164 |
|
} else { |
165 |
|
if (rgbinp) { /* RGBE -> XYZE */ |
166 |
< |
comprgb2xyzmat(xfm, inprims); |
166 |
> |
comprgb2xyzWBmat(xfm, inprims); |
167 |
|
ourexp /= WHTEFFICACY; |
168 |
|
} else { /* XYZE -> XYZE */ |
169 |
|
for (y = 0; y < 3; y++) |
214 |
|
quiterr("error writing output picture"); |
215 |
|
} |
216 |
|
/* free scanline */ |
217 |
< |
free((char *)scanin); |
217 |
> |
free((void *)scanin); |
218 |
|
if (scanout != NULL) |
219 |
< |
free((char *)scanout); |
219 |
> |
free((void *)scanout); |
220 |
|
} |