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 2.1 by greg, Tue Nov 12 16:04:51 1991 UTC vs.
Revision 2.7 by greg, Mon Sep 21 12:13:48 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 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include <stdio.h>
14  
15 + #ifdef MSDOS
16 + #include <fcntl.h>
17 + #endif
18 +
19   #include <errno.h>
20  
21   #include "color.h"
# Line 34 | Line 38 | struct {
38  
39   int     nfiles;                         /* number of input files */
40  
41 + char    Command[] = "<Command>";
42   char    vcolin[3][4] = {"ri", "gi", "bi"};
43   char    vcolout[3][4] = {"ro", "go", "bo"};
44   char    vbrtin[] = "li";
# Line 63 | Line 68 | int    wrongformat = 0;
68  
69   FILE    *popen();
70  
71 + extern char     *emalloc();
72  
73 +
74   main(argc, argv)
75   int     argc;
76   char    *argv[];
# Line 71 | Line 78 | char   *argv[];
78          int     original;
79          double  f;
80          int     a, i;
81 + #ifdef MSDOS
82 +        extern int  _fmode;
83 +        _fmode = O_BINARY;
84 +        setmode(fileno(stdin), O_BINARY);
85 +        setmode(fileno(stdout), O_BINARY);
86 + #endif
87                                                  /* scan options */
88          for (a = 1; a < argc; a++) {
89                  if (argv[a][0] == '-')
# Line 124 | Line 137 | char   *argv[];
137                                  goto usage;
138                          }
139                  else {
140 <                        input[nfiles].name = argv[a];
141 <                        input[nfiles].fp = argv[a][0]=='!' ?
142 <                                        popen(argv[a]+1, "r") :
143 <                                        fopen(argv[a], "r");
140 >                        if (argv[a][0] == '!') {
141 >                                input[nfiles].name = Command;
142 >                                input[nfiles].fp = popen(argv[a]+1, "r");
143 >                        } else {
144 >                                input[nfiles].name = argv[a];
145 >                                input[nfiles].fp = fopen(argv[a], "r");
146 >                        }
147                          if (input[nfiles].fp == NULL) {
148                                  perror(argv[a]);
149                                  quit(1);
# Line 331 | Line 347 | combine()                      /* combine pictures */
347  
348   advance()                       /* read in data for next scanline */
349   {
350 +        extern double  fabs();
351          int     ytarget;
352          register COLOR  *st;
353          register int    i, j;
# Line 343 | Line 360 | advance()                      /* read in data for next scanline */
360                          input[i].scan[0] = st;
361                          if (yscan <= MIDSCN)            /* hit bottom? */
362                                  continue;
363 <                        if (freadscan(st, xmax, input[i].fp) < 0) {     /* read */
363 >                        if (freadscan(st, xmax, input[i].fp) < 0) {  /* read */
364                                  eputs(input[i].name);
365                                  eputs(": read error\n");
366                                  quit(1);
367                          }
368 <                        for (j = 0; j < xmax; j++)      /* adjust color */
369 <                                multcolor(st[j], input[i].coef);
368 >                        if (fabs(colval(input[i].coef,RED)-1.0) > 1e-3 ||
369 >                                fabs(colval(input[i].coef,GRN)-1.0) > 1e-3 ||
370 >                                fabs(colval(input[i].coef,BLU)-1.0) > 1e-3)
371 >                                for (j = 0; j < xmax; j++)  /* adjust color */
372 >                                        multcolor(st[j], input[i].coef);
373                  }
374   }
375  
# Line 446 | Line 466 | char   *msg;
466   }
467  
468  
469 < quit(code)
470 < int     code;
469 > quit(code)              /* exit gracefully */
470 > int  code;
471   {
472 +        register int  i;
473 +                                /* close input files */
474 +        for (i = 0; i < nfiles; i++)
475 +                if (input[i].name == Command)
476 +                        pclose(input[i].fp);
477 +                else
478 +                        fclose(input[i].fp);
479          exit(code);
480   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines