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

Comparing ray/src/px/pcomb.c (file contents):
Revision 1.7 by greg, Fri Jul 20 14:38:06 1990 UTC vs.
Revision 1.8 by greg, Thu Apr 18 08:05:57 1991 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1989 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 31 | Line 31 | int    nfiles;                         /* number of input files */
31  
32   char    *vcolin[3] = {"ri", "gi", "bi"};
33   char    *vcolout[3] = {"ro", "go", "bo"};
34 + #define vbrtin          "li"
35 + #define vbrtout         "lo"
36  
37 + #define vnfiles         "nfiles"
38 + #define vxres           "xres"
39 + #define vyres           "yres"
40   #define vxpos           "x"
41   #define vypos           "y"
42  
# Line 54 | Line 59 | main(argc, argv)
59   int     argc;
60   char    *argv[];
61   {
62 <        extern double   l_redin(), l_grnin(), l_bluin(), atof();
62 >        extern double   l_redin(), l_grnin(), l_bluin(), l_brtin(), atof();
63          double  f;
64          int     a;
65          
66          funset(vcolin[RED], 1, l_redin);
67          funset(vcolin[GRN], 1, l_grnin);
68          funset(vcolin[BLU], 1, l_bluin);
69 +        funset(vbrtin, 1, l_brtin);
70          
71          for (a = 1; a < argc; a++)
72                  if (argv[a][0] == '-')
# Line 160 | Line 166 | eputs(" [-w][-x xr][-y yr][-e expr][-f file] [ [-s f][
166  
167   combine()                       /* combine pictures */
168   {
169 <        EPNODE  *coldef[3];
169 >        EPNODE  *coldef[3], *brtdef;
170          COLOR   *scanout;
171 +        double  d;
172          register int    i, j;
173                                                  /* check defined variables */
174          for (j = 0; j < 3; j++) {
# Line 170 | Line 177 | combine()                      /* combine pictures */
177                  else
178                          coldef[j] = NULL;
179          }
180 +        if (vardefined(vbrtout))
181 +                brtdef = eparse(vbrtout);
182 +        else
183 +                brtdef = NULL;
184 +                                                /* predefine variables */
185 +        varset(vnfiles, (double)nfiles);
186 +        varset(vxres, (double)xres);
187 +        varset(vyres, (double)yres);
188                                                  /* allocate scanline */
189          scanout = (COLOR *)emalloc(xres*sizeof(COLOR));
190                                                  /* combine files */
191          for (ypos = yres-1; ypos >= 0; ypos--) {
192 <                for (i = 0; i < nfiles; i++)
193 <                        if (freadscan(input[i].scan, xres, input[i].fp) < 0) {
194 <                                eputs(input[i].name);
195 <                                eputs(": read error\n");
196 <                                quit(1);
192 >            for (i = 0; i < nfiles; i++)
193 >                    if (freadscan(input[i].scan, xres, input[i].fp) < 0) {
194 >                            eputs(input[i].name);
195 >                            eputs(": read error\n");
196 >                            quit(1);
197 >                    }
198 >            varset(vypos, (double)ypos);
199 >            for (xpos = 0; xpos < xres; xpos++) {
200 >                varset(vxpos, (double)xpos);
201 >                eclock++;
202 >                if (brtdef != NULL) {
203 >                    d = evalue(brtdef);
204 >                    if (d < 0.0)
205 >                        d = 0.0;
206 >                    setcolor(scanout[xpos], d, d, d);
207 >                } else {
208 >                    for (j = 0; j < 3; j++) {
209 >                        if (coldef[j] != NULL) {
210 >                                colval(scanout[xpos],j) = evalue(coldef[j]);
211 >                        } else {
212 >                            colval(scanout[xpos],j) = 0.0;
213 >                            for (i = 0; i < nfiles; i++)
214 >                                colval(scanout[xpos],j) +=
215 >                                        colval(input[i].coef,j) *
216 >                                        colval(input[i].scan[xpos],j);
217                          }
218 <                varset(vypos, (double)ypos);
219 <                for (xpos = 0; xpos < xres; xpos++) {
220 <                        varset(vxpos, (double)xpos);
186 <                        eclock++;
187 <                        for (j = 0; j < 3; j++) {
188 <                                if (coldef[j] != NULL) {
189 <                                        colval(scanout[xpos],j) =
190 <                                                evalue(coldef[j]);
191 <                                } else {
192 <                                        colval(scanout[xpos],j) = 0.0;
193 <                                        for (i = 0; i < nfiles; i++)
194 <                                                colval(scanout[xpos],j) +=
195 <                                                colval(input[i].coef,j) *
196 <                                                colval(input[i].scan[xpos],j);
197 <                                }
198 <                                if (colval(scanout[xpos],j) < 0.0)
199 <                                        colval(scanout[xpos],j) = 0.0;
200 <                        }
218 >                        if (colval(scanout[xpos],j) < 0.0)
219 >                            colval(scanout[xpos],j) = 0.0;
220 >                    }
221                  }
222 <                if (fwritescan(scanout, xres, stdout) < 0) {
223 <                        perror("write error");
224 <                        quit(1);
225 <                }
222 >            }
223 >            if (fwritescan(scanout, xres, stdout) < 0) {
224 >                    perror("write error");
225 >                    quit(1);
226 >            }
227          }
228          efree(scanout);
229   }
# Line 240 | Line 261 | double
261   l_bluin()                       /* get blue color */
262   {
263          return(colin((int)(argument(1)+.5), BLU));
264 + }
265 +
266 +
267 + double
268 + l_brtin()                       /* get brightness value */
269 + {
270 +        register int    fn;
271 +
272 +        fn = argument(1)+.5;
273 +        if (fn == 0)
274 +                return((double)nfiles);
275 +        if (fn < 1 || fn > nfiles) {
276 +                errno = EDOM;
277 +                return(0.0);
278 +        }
279 +        return(bright(input[fn-1].scan[xpos]));
280   }
281  
282  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines