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.14 by greg, Tue Oct 1 01:16:26 2024 UTC vs.
Revision 2.17 by greg, Sat Jun 7 05:09:46 2025 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7   */
8  
9   #include  <math.h>
10
10   #include  "platform.h"
11   #include  "color.h"
12   #include  "resolu.h"
# Line 21 | Line 20 | RGBPRIMS  outprims = STDPRIMS;         /* output primaries */
20   double  expcomp = 1.0;                  /* exposure compensation */
21   int  doflat = -1;                       /* produce flat file? */
22   double  origexp = -1.0;                 /* original exposure */
24 char  *progname;
23  
24   static gethfunc headline;
25   static void quiterr(char *err);
# Line 74 | Line 72 | int
72   main(int  argc, char  *argv[])
73   {
74          int  i;
75 +
76          SET_DEFAULT_BINARY();
77          SET_FILE_BINARY(stdin);
78          SET_FILE_BINARY(stdout);
79 <        progname = argv[0];
79 >        fixargv0(argv[0]);
80  
81          for (i = 1; i < argc; i++)
82                  if (argv[i][0] == '-')
# Line 134 | Line 133 | main(int  argc, char  *argv[])
133          getheader(stdin, headline, NULL);
134          if (infmt == InpUNK)
135                  quiterr("unrecognized/missing input file format");
136 +        if (infmt == InpSPEC ? (NCSAMP <= 3) | (NCSAMP > MAXCSAMP) :
137 +                        NCSAMP != 3)
138 +                quiterr("bad number of color components");
139          printargs(argc, argv, stdout);          /* add to header */
140          convert();                              /* convert picture */
141          exit(0);
# Line 161 | Line 163 | static void
163   myreadscan(COLOR *scn, int len)
164   {
165          if (infmt == InpSPEC) {         /* read & convert to XYZ */
166 <                SCOLR   sclr;
167 <                SCOLOR  scol;
166 >                static COLOR    *scomp = NULL;
167 >                SCOLR           sclr;
168 >                SCOLOR          scol;
169 >                COLOR           xyz;
170 >                int             n;
171 >                if (scomp == NULL) {    /* initialize conversion */
172 >                        scomp = (COLOR *)malloc(sizeof(COLOR)*NCSAMP);
173 >                        if (scomp == NULL)
174 >                                quiterr("out of memory in myreadscan");
175 >                        for (n = NCSAMP; n--; )
176 >                                spec_cie(scomp[n],
177 >                                        WLPART[0] + (WLPART[3] - WLPART[0])*(n+1)/NCSAMP,
178 >                                        WLPART[0] + (WLPART[3] - WLPART[0])*n/NCSAMP);
179 >                }
180                  while (len-- > 0) {
181                          if (getbinary(sclr, LSCOLR, 1, stdin) != 1)
182                                  goto readerr;
183                          scolr_scolor(scol, sclr);
184 <                        scolor_cie(*scn++, scol);
184 >                        setcolor(*scn, 0, 0, 0);
185 >                        for (n = NCSAMP; n--; ) {
186 >                                copycolor(xyz, scomp[n]);
187 >                                scalecolor(xyz, scol[n]);
188 >                                addcolor(*scn, xyz);
189 >                        }
190 >                        scn++;
191                  }
192                  return;
193          }                               /* else read as RGBE/XYZE */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines