ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/pcompos.c
(Generate patch)

Comparing ray/src/px/pcompos.c (file contents):
Revision 1.2 by greg, Mon Jun 12 10:07:29 1989 UTC vs.
Revision 1.6 by greg, Thu Apr 18 14:35:19 1991 UTC

# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15   #include  "color.h"
16  
17  
18 < #define  MAXFILE        16
18 > #define  MAXFILE        32
19  
20                                          /* output picture size */
21   int  xsiz = 0;
# Line 43 | Line 43 | struct {
43  
44   int  nfile;                     /* number of files */
45  
46 + int  wrongformat = 0;
47  
48 +
49   tabputs(s)                      /* print line preceded by a tab */
50   char  *s;
51   {
52 <        putc('\t', stdout);
53 <        fputs(s, stdout);
52 >        char  fmt[32];
53 >
54 >        if (isformat(s)) {
55 >                formatval(fmt, s);
56 >                wrongformat = strcmp(fmt, COLRFMT);
57 >        } else {
58 >                putc('\t', stdout);
59 >                fputs(s, stdout);
60 >        }
61   }
62  
63  
# Line 123 | Line 132 | getfile:
132                  } else {
133                          input[nfile].name = argv[an];
134                          if ((input[nfile].fp = fopen(argv[an], "r")) == NULL) {
135 <                                fprintf(stderr, "%s: cannot open\n", argv[an]);
135 >                                perror(argv[an]);
136                                  quit(1);
137                          }
138                  }
139                  an++;
140                                                  /* get header */
141                  printf("%s:\n", input[nfile].name);
142 <                getheader(input[nfile].fp, tabputs);
142 >                getheader(input[nfile].fp, tabputs, NULL);
143 >                if (wrongformat) {
144 >                        fprintf(stderr, "%s: not a Radiance picture\n",
145 >                                        input[nfile].name);
146 >                        quit(1);
147 >                }
148                                                  /* get picture size */
149 <                if (fscanf(input[nfile].fp, "-Y %d +X %d\n",
150 <                                &input[nfile].yres, &input[nfile].xres) != 2) {
149 >                if (fgetresolu(&input[nfile].xres, &input[nfile].yres,
150 >                                input[nfile].fp) != (YMAJOR|YDECR)) {
151                          fprintf(stderr, "%s: bad picture size\n",
152                                          input[nfile].name);
153                          quit(1);
# Line 155 | Line 169 | getfile:
169                  ysiz = ymax;
170                                          /* add new header info. */
171          printargs(argc, argv, stdout);
172 +        fputformat(COLRFMT, stdout);
173          printf("\n-Y %d +X %d\n", ysiz, xsiz);
174  
175          compos();
# Line 173 | Line 188 | compos()                               /* composite pictures */
188          int  y;
189          register int  x, i;
190  
191 <        scanin = (COLR *)malloc((xmax-xmin)*sizeof(COLR)) - xmin;
177 <        scanin = (COLR *)malloc((xmax-xmin)*sizeof(COLR)) - xmin;
191 >        scanin = (COLR *)malloc((xmax-xmin)*sizeof(COLR));
192          if (scanin == NULL)
193                  goto memerr;
194          scanin -= xmin;
# Line 218 | Line 232 | compos()                               /* composite pictures */
232                  if (y >= ysiz)
233                          continue;
234                  if (fwritecolrs(scanout, xsiz, stdout) < 0) {
235 <                        fprintf(stderr, "%s: write error\n", progname);
235 >                        perror(progname);
236                          quit(1);
237                  }
238          }
239          return;
240   memerr:
241 <        fprintf(stderr, "%s: out of memory\n", progname);
241 >        perror(progname);
242          quit(1);
243   }
244  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines