ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/ra_xyze.c
(Generate patch)

Comparing ray/src/px/ra_xyze.c (file contents):
Revision 2.4 by gregl, Tue Jul 22 10:17:53 1997 UTC vs.
Revision 2.9 by schorsch, Sun Mar 28 20:33:14 2004 UTC

# Line 1 | Line 1
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? */
23
19   int  rgbout = 0;                        /* output should be RGBE? */
25
20   RGBPRIMS  inprims = STDPRIMS;           /* input primaries */
27
21   RGBPRIMS  outprims = STDPRIMS;          /* output primaries */
29
22   double  expcomp = 1.0;                  /* exposure compensation */
31
23   int  doflat = -1;                       /* produce flat file? */
33
24   char  *progname;
25  
26 + static gethfunc headline;
27 + static void quiterr(char *err);
28 + static void convert(void);
29  
30 < headline(s)                             /* process header line */
31 < char    *s;
30 >
31 >
32 > static int
33 > headline(                               /* process header line */
34 >        char    *s,
35 >        void    *p
36 > )
37   {
38          char    fmt[32];
39  
# Line 46 | Line 44 | char   *s;
44                          rgbinp = 0;
45                  else
46                          rgbinp = -2;
47 <                return;                 /* don't echo */
47 >                return(0);              /* don't echo */
48          }
49          if (isprims(s)) {               /* get input primaries */
50                  primsval(inprims, s);
51 <                return;                 /* don't echo */
51 >                return(0);              /* don't echo */
52          }
53                                          /* should I grok colcorr also? */
54 <        fputs(s, stdout);
54 >        return(fputs(s, stdout));
55   }
56  
57  
58 < main(argc, argv)
59 < int  argc;
62 < char  *argv[];
58 > int
59 > main(int  argc, 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++)
# Line 134 | Line 128 | userr:
128   }
129  
130  
131 < quiterr(err)            /* print message and exit */
132 < char  *err;
131 > static void
132 > quiterr(                /* print message and exit */
133 >        char  *err
134 > )
135   {
136          if (err != NULL) {
137                  fprintf(stderr, "%s: %s\n", progname, err);
# Line 145 | Line 141 | char  *err;
141   }
142  
143  
144 < convert()                               /* convert to XYZE or RGBE picture */
144 > static void
145 > convert(void)                           /* convert to XYZE or RGBE picture */
146   {
147          int     order;
148          int     xmax, ymax;
# Line 158 | Line 155 | convert()                              /* convert to XYZE or RGBE picture */
155                                                  /* compute transform */
156          if (rgbout) {
157                  if (rgbinp) {                   /* RGBE -> RGBE */
158 <                        comprgb2rgbmat(xfm, inprims, outprims);
158 >                        comprgb2rgbWBmat(xfm, inprims, outprims);
159                  } else {                        /* XYZE -> RGBE */
160 <                        compxyz2rgbmat(xfm, outprims);
160 >                        compxyz2rgbWBmat(xfm, outprims);
161                          ourexp *= WHTEFFICACY;
162                  }
163          } else {
164                  if (rgbinp) {                   /* RGBE -> XYZE */
165 <                        comprgb2xyzmat(xfm, inprims);
165 >                        comprgb2xyzWBmat(xfm, inprims);
166                          ourexp /= WHTEFFICACY;
167                  } else {                        /* XYZE -> XYZE */
168                          for (y = 0; y < 3; y++)
# Line 216 | Line 213 | convert()                              /* convert to XYZE or RGBE picture */
213                          quiterr("error writing output picture");
214          }
215                                                  /* free scanline */
216 <        free((char *)scanin);
216 >        free((void *)scanin);
217          if (scanout != NULL)
218 <                free((char *)scanout);
218 >                free((void *)scanout);
219   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines