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.23 by greg, Mon Nov 11 14:01:24 1991 UTC vs.
Revision 2.6 by greg, Tue Sep 8 10:35:05 1992 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1991 Regents of the University of California */
1 > /* Copyright (c) 1992 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 34 | Line 34 | struct {
34  
35   int     nfiles;                         /* number of input files */
36  
37 + char    Command[] = "<Command>";
38   char    vcolin[3][4] = {"ri", "gi", "bi"};
39   char    vcolout[3][4] = {"ro", "go", "bo"};
40   char    vbrtin[] = "li";
# Line 124 | Line 125 | char   *argv[];
125                                  goto usage;
126                          }
127                  else {
128 <                        input[nfiles].name = argv[a];
129 <                        input[nfiles].fp = argv[a][0]=='!' ?
130 <                                        popen(argv[a]+1, "r") :
131 <                                        fopen(argv[a], "r");
128 >                        if (argv[a][0] == '!') {
129 >                                input[nfiles].name = Command;
130 >                                input[nfiles].fp = popen(argv[a]+1, "r");
131 >                        } else {
132 >                                input[nfiles].name = argv[a];
133 >                                input[nfiles].fp = fopen(argv[a], "r");
134 >                        }
135                          if (input[nfiles].fp == NULL) {
136                                  perror(argv[a]);
137                                  quit(1);
# Line 331 | Line 335 | combine()                      /* combine pictures */
335  
336   advance()                       /* read in data for next scanline */
337   {
338 +        extern double  fabs();
339          int     ytarget;
340          register COLOR  *st;
341          register int    i, j;
# Line 343 | Line 348 | advance()                      /* read in data for next scanline */
348                          input[i].scan[0] = st;
349                          if (yscan <= MIDSCN)            /* hit bottom? */
350                                  continue;
351 <                        if (freadscan(st, xmax, input[i].fp) < 0) {     /* read */
351 >                        if (freadscan(st, xmax, input[i].fp) < 0) {  /* read */
352                                  eputs(input[i].name);
353                                  eputs(": read error\n");
354                                  quit(1);
355                          }
356 <                        for (j = 0; j < xmax; j++)      /* adjust color */
357 <                                multcolor(st[j], input[i].coef);
356 >                        if (fabs(colval(input[i].coef,RED)-1.0) > 1e-3 ||
357 >                                fabs(colval(input[i].coef,GRN)-1.0) > 1e-3 ||
358 >                                fabs(colval(input[i].coef,BLU)-1.0) > 1e-3)
359 >                                for (j = 0; j < xmax; j++)  /* adjust color */
360 >                                        multcolor(st[j], input[i].coef);
361                  }
362   }
363  
# Line 446 | Line 454 | char   *msg;
454   }
455  
456  
457 < quit(code)
458 < int     code;
457 > quit(code)              /* exit gracefully */
458 > int  code;
459   {
460 +        register int  i;
461 +                                /* close input files */
462 +        for (i = 0; i < nfiles; i++)
463 +                if (input[i].name == Command)
464 +                        pclose(input[i].fp);
465 +                else
466 +                        fclose(input[i].fp);
467          exit(code);
468   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines