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.4 by greg, Thu Aug 13 10:49:08 1992 UTC

# 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    vcolin[3][4] = {"ri", "gi", "bi"};
38 > char    vcolout[3][4] = {"ro", "go", "bo"};
39   char    vbrtin[] = "li";
40   char    vbrtout[] = "lo";
41 < char    *vcolexp[3] = {"re", "ge", "be"};
41 > char    vcolexp[3][4] = {"re", "ge", "be"};
42   char    vbrtexp[] = "le";
43  
44   char    vnfiles[] = "nfiles";
# Line 68 | Line 68 | main(argc, argv)
68   int     argc;
69   char    *argv[];
70   {
71        char    buf[128];
71          int     original;
72          double  f;
73          int     a, i;
# Line 111 | Line 110 | char   *argv[];
110                                  break;
111                          case 'o':
112                                  original++;
113 <                                break;
113 >                                continue;
114                          case 's':
115                                  f = atof(argv[++a]);
116                                  scalecolor(input[nfiles].coef, f);
# Line 125 | Line 124 | char   *argv[];
124                                  goto usage;
125                          }
126                  else {
127 <                        input[nfiles].name = argv[a];
128 <                        input[nfiles].fp = argv[a][0]=='!' ?
129 <                                        popen(argv[a]+1, "r") :
130 <                                        fopen(argv[a], "r");
127 >                        if (argv[a][0] == '!') {
128 >                                input[nfiles].name = "<Command>";
129 >                                input[nfiles].fp = popen(argv[a]+1, "r");
130 >                        } else {
131 >                                input[nfiles].name = argv[a];
132 >                                input[nfiles].fp = fopen(argv[a], "r");
133 >                        }
134                          if (input[nfiles].fp == NULL) {
135                                  perror(argv[a]);
136                                  quit(1);
# Line 152 | Line 154 | char   *argv[];
154                  if (argv[a][0] == '-')
155                          switch (argv[a][1]) {
156                          case 'x':
157 <                                strcpy(buf, vxres);
156 <                                strcat(buf, ":");
157 <                                strcat(buf, argv[++a]);
158 <                                scompile(buf, NULL, 0);
157 >                                varset(vxres, ':', eval(argv[++a]));
158                                  continue;
159                          case 'y':
160 <                                strcpy(buf, vyres);
162 <                                strcat(buf, ":");
163 <                                strcat(buf, argv[++a]);
164 <                                scompile(buf, NULL, 0);
160 >                                varset(vyres, ':', eval(argv[++a]));
161                                  continue;
162                          case 'w':
163                                  continue;
# Line 190 | Line 186 | char   *argv[];
186          printargs(argc, argv, stdout);
187          fputformat(COLRFMT, stdout);
188          putchar('\n');
189 <        fputresolu(YMAJOR|YDECR, xres, yres, stdout);
189 >        fprtresolu(xres, yres, stdout);
190                                                  /* combine pictures */
191          combine();
192          quit(0);
# Line 198 | Line 194 | usage:
194          eputs("Usage: ");
195          eputs(argv[0]);
196          eputs(
197 < " [-w][-h][-x xr][-y yr][-e expr][-f file] [ [-s f][-c r g b] pic ..]\n");
197 > " [-w][-x xr][-y yr][-e expr][-f file] [ [-s f][-c r g b] pic ..]\n");
198          quit(1);
199   }
200  
# Line 241 | Line 237 | checkfile()                    /* ready a file */
237                  eputs(": not in Radiance picture format\n");
238                  quit(1);
239          }
240 <        if (fgetresolu(&xinp, &yinp, input[nfiles].fp) != (YMAJOR|YDECR)) {
240 >        if (fgetresolu(&xinp, &yinp, input[nfiles].fp) < 0) {
241                  eputs(input[nfiles].name);
242                  eputs(": bad picture size\n");
243                  quit(1);
# Line 338 | Line 334 | combine()                      /* combine pictures */
334  
335   advance()                       /* read in data for next scanline */
336   {
337 +        extern double  fabs();
338          int     ytarget;
339          register COLOR  *st;
340          register int    i, j;
# Line 350 | Line 347 | advance()                      /* read in data for next scanline */
347                          input[i].scan[0] = st;
348                          if (yscan <= MIDSCN)            /* hit bottom? */
349                                  continue;
350 <                        if (freadscan(st, xmax, input[i].fp) < 0) {     /* read */
350 >                        if (freadscan(st, xmax, input[i].fp) < 0) {  /* read */
351                                  eputs(input[i].name);
352                                  eputs(": read error\n");
353                                  quit(1);
354                          }
355 <                        for (j = 0; j < xmax; j++)      /* adjust color */
356 <                                multcolor(st[j], input[i].coef);
355 >                        if (fabs(colval(input[i].coef,RED)-1.0) > 1e-3 ||
356 >                                fabs(colval(input[i].coef,GRN)-1.0) > 1e-3 ||
357 >                                fabs(colval(input[i].coef,BLU)-1.0) > 1e-3)
358 >                                for (j = 0; j < xmax; j++)  /* adjust color */
359 >                                        multcolor(st[j], input[i].coef);
360                  }
361   }
362  
# Line 453 | Line 453 | char   *msg;
453   }
454  
455  
456 + #ifdef  NIX
457 +
458   quit(code)
459 < int     code;
459 > int  code;
460   {
461          exit(code);
462   }
463 +
464 + #else
465 +
466 + #include  <signal.h>
467 +
468 + quit(code)              /* exit gracefully */
469 + int  code;
470 + {
471 +        int  status;
472 +
473 +        if (code) {             /* abnormal exit -- kill children */
474 +                signal(SIGPIPE, SIG_IGN);
475 +                kill(0, SIGPIPE);
476 +        }
477 +                                /* reap any children */
478 +        while (wait(&status) != -1)
479 +                if (code == 0)
480 +                        code = status>>8 & 0xff;
481 +        exit(code);
482 + }
483 +
484 + #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines