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.19 by greg, Thu May 30 09:47:14 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 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16  
17   #include "color.h"
18  
19 + #include  "resolu.h"
20 +
21   #include "calcomp.h"
22  
23   #define MAXINP          32              /* maximum number of input files */
24   #define WINSIZ          9               /* scanline window size */
25   #define MIDSCN          4               /* current scan position */
26  
25 #define BRT             (-1)            /* special index for brightness */
26
27   struct {
28          char    *name;          /* file or command name */
29          FILE    *fp;            /* stream pointer */
# Line 34 | Line 34 | struct {
34  
35   int     nfiles;                         /* number of input files */
36  
37 < char    *vcolin[3] = {"ri", "gi", "bi"};
38 < char    *vcolout[3] = {"ro", "go", "bo"};
37 > char    Command[] = "<Command>";
38 > char    vcolin[3][4] = {"ri", "gi", "bi"};
39 > char    vcolout[3][4] = {"ro", "go", "bo"};
40   char    vbrtin[] = "li";
41   char    vbrtout[] = "lo";
42 < char    *vcolexp[3] = {"re", "ge", "be"};
42 > char    vcolexp[3][4] = {"re", "ge", "be"};
43   char    vbrtexp[] = "le";
44  
45   char    vnfiles[] = "nfiles";
# Line 68 | Line 69 | main(argc, argv)
69   int     argc;
70   char    *argv[];
71   {
71        char    buf[128];
72          int     original;
73          double  f;
74          int     a, i;
# Line 111 | Line 111 | char   *argv[];
111                                  break;
112                          case 'o':
113                                  original++;
114 <                                break;
114 >                                continue;
115                          case 's':
116                                  f = atof(argv[++a]);
117                                  scalecolor(input[nfiles].coef, f);
# Line 125 | 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 152 | Line 155 | char   *argv[];
155                  if (argv[a][0] == '-')
156                          switch (argv[a][1]) {
157                          case 'x':
158 <                                strcpy(buf, vxres);
156 <                                strcat(buf, ":");
157 <                                strcat(buf, argv[++a]);
158 <                                scompile(buf, NULL, 0);
158 >                                varset(vxres, ':', eval(argv[++a]));
159                                  continue;
160                          case 'y':
161 <                                strcpy(buf, vyres);
162 <                                strcat(buf, ":");
163 <                                strcat(buf, argv[++a]);
164 <                                scompile(buf, NULL, 0);
161 >                                varset(vyres, ':', eval(argv[++a]));
162                                  continue;
163                          case 'w':
164                                  continue;
# Line 190 | Line 187 | char   *argv[];
187          printargs(argc, argv, stdout);
188          fputformat(COLRFMT, stdout);
189          putchar('\n');
190 <        fputresolu(YMAJOR|YDECR, xres, yres, stdout);
190 >        fprtresolu(xres, yres, stdout);
191                                                  /* combine pictures */
192          combine();
193          quit(0);
# Line 198 | Line 195 | usage:
195          eputs("Usage: ");
196          eputs(argv[0]);
197          eputs(
198 < " [-w][-h][-x xr][-y yr][-e expr][-f file] [ [-s f][-c r g b] pic ..]\n");
198 > " [-w][-x xr][-y yr][-e expr][-f file] [ [-s f][-c r g b] pic ..]\n");
199          quit(1);
200   }
201  
# Line 241 | Line 238 | checkfile()                    /* ready a file */
238                  eputs(": not in Radiance picture format\n");
239                  quit(1);
240          }
241 <        if (fgetresolu(&xinp, &yinp, input[nfiles].fp) != (YMAJOR|YDECR)) {
241 >        if (fgetresolu(&xinp, &yinp, input[nfiles].fp) < 0) {
242                  eputs(input[nfiles].name);
243                  eputs(": bad picture size\n");
244                  quit(1);
# Line 338 | 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 350 | 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 453 | 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