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.9 by greg, Thu Apr 18 10:19:48 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  
43   int     nowarn = 0;                     /* no warning messages? */
44  
45 + int     original = 0;                   /* origninal values? */
46 +
47   int     xres=0, yres=0;                 /* picture resolution */
48  
49   int     xpos, ypos;                     /* picture position */
# Line 45 | Line 52 | int    xpos, ypos;                     /* picture position */
52   tputs(s)                        /* put out string preceded by a tab */
53   char    *s;
54   {
55 +        double  d;
56 +        COLOR   ctmp;
57 +                                /* echo header line */
58          putchar('\t');
59          fputs(s, stdout);
60 +        if (!original)
61 +                return;
62 +                                /* check for exposure */
63 +        if (isexpos(s)) {
64 +                d = 1.0/exposval(s);
65 +                scalecolor(input[nfiles].coef, d);
66 +        } else if (iscolcor(s)) {
67 +                colcorval(ctmp, s);
68 +                colval(input[nfiles].coef,RED) /= colval(ctmp,RED);
69 +                colval(input[nfiles].coef,GRN) /= colval(ctmp,GRN);
70 +                colval(input[nfiles].coef,BLU) /= colval(ctmp,BLU);
71 +        }
72   }
73  
74  
# Line 54 | Line 76 | main(argc, argv)
76   int     argc;
77   char    *argv[];
78   {
79 <        extern double   l_redin(), l_grnin(), l_bluin(), atof();
79 >        extern double   l_redin(), l_grnin(), l_bluin(), l_brtin(), atof();
80          double  f;
81          int     a;
82          
83          funset(vcolin[RED], 1, l_redin);
84          funset(vcolin[GRN], 1, l_grnin);
85          funset(vcolin[BLU], 1, l_bluin);
86 +        funset(vbrtin, 1, l_brtin);
87          
88          for (a = 1; a < argc; a++)
89                  if (argv[a][0] == '-')
# Line 78 | Line 101 | char   *argv[];
101                          case 'w':
102                                  nowarn = !nowarn;
103                                  break;
104 +                        case 'o':
105 +                                original = !original;
106 +                                break;
107                          case 'f':
108                                  fcompile(argv[++a]);
109                                  break;
# Line 153 | Line 179 | getfiles:
179   usage:
180          eputs("Usage: ");
181          eputs(argv[0]);
182 < eputs(" [-w][-x xr][-y yr][-e expr][-f file] [ [-s f][-c r g b] picture ..]\n");
182 >        eputs(
183 > " [-w][-h][-x xr][-y yr][-e expr][-f file] [ [-s f][-c r g b] pic ..]\n");
184          quit(1);
185   }
186  
187  
188   combine()                       /* combine pictures */
189   {
190 <        EPNODE  *coldef[3];
190 >        EPNODE  *coldef[3], *brtdef;
191          COLOR   *scanout;
192 +        double  d;
193          register int    i, j;
194                                                  /* check defined variables */
195          for (j = 0; j < 3; j++) {
# Line 170 | Line 198 | combine()                      /* combine pictures */
198                  else
199                          coldef[j] = NULL;
200          }
201 +        if (vardefined(vbrtout))
202 +                brtdef = eparse(vbrtout);
203 +        else
204 +                brtdef = NULL;
205 +                                                /* predefine variables */
206 +        varset(vnfiles, (double)nfiles);
207 +        varset(vxres, (double)xres);
208 +        varset(vyres, (double)yres);
209                                                  /* allocate scanline */
210          scanout = (COLOR *)emalloc(xres*sizeof(COLOR));
211                                                  /* combine files */
212          for (ypos = yres-1; ypos >= 0; ypos--) {
213 +            for (i = 0; i < nfiles; i++)
214 +                    if (freadscan(input[i].scan, xres, input[i].fp) < 0) {
215 +                            eputs(input[i].name);
216 +                            eputs(": read error\n");
217 +                            quit(1);
218 +                    }
219 +            varset(vypos, (double)ypos);
220 +            for (xpos = 0; xpos < xres; xpos++) {
221                  for (i = 0; i < nfiles; i++)
222 <                        if (freadscan(input[i].scan, xres, input[i].fp) < 0) {
223 <                                eputs(input[i].name);
224 <                                eputs(": read error\n");
225 <                                quit(1);
222 >                        multcolor(input[i].scan[xpos],input[i].coef);
223 >                varset(vxpos, (double)xpos);
224 >                eclock++;
225 >                if (brtdef != NULL) {
226 >                    d = evalue(brtdef);
227 >                    if (d < 0.0)
228 >                        d = 0.0;
229 >                    setcolor(scanout[xpos], d, d, d);
230 >                } else {
231 >                    for (j = 0; j < 3; j++) {
232 >                        if (coldef[j] != NULL) {
233 >                                colval(scanout[xpos],j) = evalue(coldef[j]);
234 >                        } else {
235 >                            colval(scanout[xpos],j) = 0.0;
236 >                            for (i = 0; i < nfiles; i++)
237 >                                colval(scanout[xpos],j) +=
238 >                                        colval(input[i].scan[xpos],j);
239                          }
240 <                varset(vypos, (double)ypos);
241 <                for (xpos = 0; xpos < xres; xpos++) {
242 <                        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 <                        }
240 >                        if (colval(scanout[xpos],j) < 0.0)
241 >                            colval(scanout[xpos],j) = 0.0;
242 >                    }
243                  }
244 <                if (fwritescan(scanout, xres, stdout) < 0) {
245 <                        perror("write error");
246 <                        quit(1);
247 <                }
244 >            }
245 >            if (fwritescan(scanout, xres, stdout) < 0) {
246 >                    perror("write error");
247 >                    quit(1);
248 >            }
249          }
250          efree(scanout);
251   }
# Line 240 | Line 283 | double
283   l_bluin()                       /* get blue color */
284   {
285          return(colin((int)(argument(1)+.5), BLU));
286 + }
287 +
288 +
289 + double
290 + l_brtin()                       /* get brightness value */
291 + {
292 +        register int    fn;
293 +
294 +        fn = argument(1)+.5;
295 +        if (fn == 0)
296 +                return((double)nfiles);
297 +        if (fn < 1 || fn > nfiles) {
298 +                errno = EDOM;
299 +                return(0.0);
300 +        }
301 +        return(bright(input[fn-1].scan[xpos]));
302   }
303  
304  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines