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.1 by greg, Thu Feb 2 10:49:22 1989 UTC vs.
Revision 1.5 by greg, Tue Sep 12 13:04:22 1989 UTC

# Line 24 | Line 24 | struct {
24          char    *name;          /* file name */
25          FILE    *fp;            /* stream pointer */
26          COLOR   *scan;          /* input scanline */
27 +        COLOR   coef;           /* coefficient */
28   }       input[MAXINP];                  /* input pictures */
29  
30   int     nfiles;                         /* number of input files */
# Line 53 | Line 54 | main(argc, argv)
54   int     argc;
55   char    *argv[];
56   {
57 <        extern double   l_redin(), l_grnin(), l_bluin();
57 >        extern double   l_redin(), l_grnin(), l_bluin(), atof();
58 >        double  f;
59          int     a;
60          
61          funset(vcolin[RED], 1, l_redin);
# Line 64 | Line 66 | char   *argv[];
66                  if (argv[a][0] == '-')
67                          switch (argv[a][1]) {
68                          case '\0':
69 +                        case 's':
70 +                        case 'c':
71                                  goto getfiles;
72                          case 'x':
73                                  xres = atoi(argv[++a]);
# Line 81 | Line 85 | char   *argv[];
85                                  scompile(NULL, argv[++a]);
86                                  break;
87                          default:
88 <                                eputs("Usage: ");
85 <                                eputs(argv[0]);
86 <        eputs(" [-w][-x xres][-y yres][-e expr][-f file] [picture ..]\n");
87 <                                quit(1);
88 >                                goto usage;
89                          }
90                  else
91                          break;
92   getfiles:
93 +        for (nfiles = 0; nfiles < MAXINP; nfiles++)
94 +                setcolor(input[nfiles].coef, 1.0, 1.0, 1.0);
95          nfiles = 0;
96          for ( ; a < argc; a++) {
97                  if (nfiles >= MAXINP) {
# Line 96 | Line 99 | getfiles:
99                          eputs(": too many picture files\n");
100                          quit(1);
101                  }
102 <                if (argv[a][0] == '-') {
103 <                        input[nfiles].name = "<stdin>";
104 <                        input[nfiles].fp = stdin;
105 <                } else {
102 >                if (argv[a][0] == '-')
103 >                        switch (argv[a][1]) {
104 >                        case '\0':
105 >                                input[nfiles].name = "<stdin>";
106 >                                input[nfiles].fp = stdin;
107 >                                break;
108 >                        case 's':
109 >                                f = atof(argv[++a]);
110 >                                scalecolor(input[nfiles].coef, f);
111 >                                continue;
112 >                        case 'c':
113 >                                colval(input[nfiles].coef,RED)*=atof(argv[++a]);
114 >                                colval(input[nfiles].coef,GRN)*=atof(argv[++a]);
115 >                                colval(input[nfiles].coef,BLU)*=atof(argv[++a]);
116 >                                continue;
117 >                        default:
118 >                                goto usage;
119 >                        }
120 >                else {
121                          input[nfiles].name = argv[a];
122                          input[nfiles].fp = fopen(argv[a], "r");
123                          if (input[nfiles].fp == NULL) {
# Line 111 | Line 129 | getfiles:
129                  fputs(input[nfiles].name, stdout);
130                  fputs(":\n", stdout);
131                  getheader(input[nfiles].fp, tputs);
132 <                if (fscanf(input[nfiles].fp, "-Y %d +X %d\n", &ypos, &xpos) != 2) {
132 >                if (fgetresolu(&xpos, &ypos, input[nfiles].fp) !=
133 >                                (YMAJOR|YDECR)) {
134                          eputs(input[nfiles].name);
135                          eputs(": bad picture size\n");
136                          quit(1);
# Line 129 | Line 148 | getfiles:
148          }
149          printargs(argc, argv, stdout);
150          putchar('\n');
151 <        printf("-Y %d +X %d\n", yres, xres);
151 >        fputresolu(YMAJOR|YDECR, xres, yres, stdout);
152          combine();
153          quit(0);
154 + usage:
155 +        eputs("Usage: ");
156 +        eputs(argv[0]);
157 + eputs(" [-w][-x xr][-y yr][-e expr][-f file] [ [-s f][-c r g b] picture ..]\n");
158 +        quit(1);
159   }
160  
161  
162   combine()                       /* combine pictures */
163   {
164 <        int     coldef[3];
164 >        EPNODE  *coldef[3];
165          COLOR   *scanout;
166          register int    i, j;
167                                                  /* check defined variables */
168 <        for (j = 0; j < 3; j++)
169 <                coldef[j] = vardefined(vcolout[j]);
168 >        for (j = 0; j < 3; j++) {
169 >                if (vardefined(vcolout[j]))
170 >                        coldef[j] = eparse(vcolout[j]);
171 >                else
172 >                        coldef[j] = NULL;
173 >        }
174                                                  /* allocate scanline */
175          scanout = (COLOR *)emalloc(xres*sizeof(COLOR));
176                                                  /* combine files */
# Line 157 | Line 185 | combine()                      /* combine pictures */
185                  for (xpos = 0; xpos < xres; xpos++) {
186                          varset(vxpos, (double)xpos);
187                          eclock++;
188 <                        for (j = 0; j < 3; j++)
189 <                                if (coldef[j]) {
190 <                                        colval(scanout[xpos],j) = varvalue(vcolout[j]);
191 <                                        if (colval(scanout[xpos],j) < 0.0)
164 <                                                colval(scanout[xpos],j) = 0.0;
188 >                        for (j = 0; j < 3; j++) {
189 >                                if (coldef[j] != NULL) {
190 >                                        colval(scanout[xpos],j) =
191 >                                                evalue(coldef[j]);
192                                  } else {
193                                          colval(scanout[xpos],j) = 0.0;
194                                          for (i = 0; i < nfiles; i++)
195 <                                                colval(scanout[xpos],j) += colval(input[i].scan[xpos],j);
196 <                                        colval(scanout[xpos],j) /= (double)nfiles;
195 >                                                colval(scanout[xpos],j) +=
196 >                                                colval(input[i].coef,j) *
197 >                                                colval(input[i].scan[xpos],j);
198                                  }
199 +                                if (colval(scanout[xpos],j) < 0.0)
200 +                                        colval(scanout[xpos],j) = 0.0;
201 +                        }
202                  }
203                  if (fwritescan(scanout, xres, stdout) < 0) {
204                          eputs("write error\n");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines