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? */ |
30 |
|
char *progname; |
31 |
|
|
32 |
|
|
33 |
+ |
int |
34 |
|
headline(s) /* process header line */ |
35 |
|
char *s; |
36 |
|
{ |
43 |
|
rgbinp = 0; |
44 |
|
else |
45 |
|
rgbinp = -2; |
46 |
< |
return; /* don't echo */ |
46 |
> |
return(0); /* don't echo */ |
47 |
|
} |
48 |
|
if (isprims(s)) { /* get input primaries */ |
49 |
|
primsval(inprims, s); |
50 |
< |
return; /* don't echo */ |
50 |
> |
return(0); /* don't echo */ |
51 |
|
} |
52 |
|
/* should I grok colcorr also? */ |
53 |
< |
fputs(s, stdout); |
53 |
> |
return(fputs(s, stdout)); |
54 |
|
} |
55 |
|
|
56 |
|
|
59 |
|
char *argv[]; |
60 |
|
{ |
61 |
|
int i; |
62 |
< |
#ifdef MSDOS |
63 |
< |
extern int _fmode; |
64 |
< |
_fmode = O_BINARY; |
68 |
< |
setmode(fileno(stdin), O_BINARY); |
69 |
< |
setmode(fileno(stdout), O_BINARY); |
70 |
< |
#endif |
62 |
> |
SET_DEFAULT_BINARY(); |
63 |
> |
SET_FILE_BINARY(stdin); |
64 |
> |
SET_FILE_BINARY(stdout); |
65 |
|
progname = argv[0]; |
66 |
|
|
67 |
|
for (i = 1; i < argc; i++) |
152 |
|
/* compute transform */ |
153 |
|
if (rgbout) { |
154 |
|
if (rgbinp) { /* RGBE -> RGBE */ |
155 |
< |
comprgb2rgbmat(xfm, inprims, outprims); |
155 |
> |
comprgb2rgbWBmat(xfm, inprims, outprims); |
156 |
|
} else { /* XYZE -> RGBE */ |
157 |
< |
compxyz2rgbmat(xfm, outprims); |
157 |
> |
compxyz2rgbWBmat(xfm, outprims); |
158 |
|
ourexp *= WHTEFFICACY; |
159 |
|
} |
160 |
|
} else { |
161 |
|
if (rgbinp) { /* RGBE -> XYZE */ |
162 |
< |
comprgb2xyzmat(xfm, inprims); |
162 |
> |
comprgb2xyzWBmat(xfm, inprims); |
163 |
|
ourexp /= WHTEFFICACY; |
164 |
|
} else { /* XYZE -> XYZE */ |
165 |
|
for (y = 0; y < 3; y++) |
210 |
|
quiterr("error writing output picture"); |
211 |
|
} |
212 |
|
/* free scanline */ |
213 |
< |
free((char *)scanin); |
213 |
> |
free((void *)scanin); |
214 |
|
if (scanout != NULL) |
215 |
< |
free((char *)scanout); |
215 |
> |
free((void *)scanout); |
216 |
|
} |