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 2.14 by greg, Tue Sep 8 10:36:22 1992 UTC vs.
Revision 2.26 by schorsch, Mon Nov 10 12:28:56 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  pcompos.c - program to composite pictures.
6   *
# Line 11 | Line 8 | static char SCCSid[] = "$SunId$ LBL";
8   */
9  
10   #include  <stdio.h>
11 + #include  <math.h>
12 + #include  <time.h>
13 + #include  <string.h>
14  
15 < #include  "color.h"
15 > #include "copyright.h"
16  
17 + #include  "platform.h"
18 + #include  "rtprocess.h"
19 + #include  "color.h"
20   #include  "resolu.h"
21  
22 < #define  MAXFILE        64
22 > #define  MAXFILE        64
23  
24 + #define  HASMIN         1
25 + #define  HASMAX         2
26 +
27                                          /* output picture size */
28   int  xsiz = 0;
29   int  ysiz = 0;
# Line 43 | Line 49 | struct {
49          FILE  *fp;                      /* stream pointer */
50          int  xres, yres;                /* picture size */
51          int  xloc, yloc;                /* anchor point */
52 <        int  hasmin, hasmax;            /* has threshold values */
52 >        int  flags;                     /* HASMIN, HASMAX */
53          COLR  thmin, thmax;             /* thresholds */
54   } input[MAXFILE];               /* our input files */
55  
56   int  nfile;                     /* number of files */
57  
58 + char  ourfmt[LPICFMT+1] = PICFMT;
59   int  wrongformat = 0;
60  
61 < FILE  *popen(), *lblopen();
61 > FILE  *lblopen();
62 > void  quit();
63  
64  
65   tabputs(s)                      /* print line preceded by a tab */
# Line 59 | Line 67 | char  *s;
67   {
68          char  fmt[32];
69  
70 <        if (isformat(s)) {
71 <                formatval(fmt, s);
72 <                wrongformat = strcmp(fmt, COLRFMT);
70 >        if (isheadid(s))
71 >                return(0);
72 >        if (formatval(fmt, s)) {
73 >                if (globmatch(ourfmt, fmt)) {
74 >                        wrongformat = 0;
75 >                        strcpy(ourfmt, fmt);
76 >                } else
77 >                        wrongformat = 1;
78          } else {
79                  putc('\t', stdout);
80                  fputs(s, stdout);
81          }
82 +        return(0);
83   }
84  
85  
# Line 76 | Line 90 | char  *argv[];
90          int  ncolumns = 0;
91          int  autolabel = 0;
92          int  curcol = 0, x0 = 0, curx = 0, cury = 0, spacing = 0;
93 +        int  xsgn, ysgn;
94          char  *thislabel;
95          int  an;
96 <
96 >        SET_DEFAULT_BINARY();
97 >        SET_FILE_BINARY(stdin);
98 >        SET_FILE_BINARY(stdout);
99          progname = argv[0];
100  
101          for (an = 1; an < argc && argv[an][0] == '-'; an++)
# Line 126 | Line 143 | char  *argv[];
143                          goto userr;
144                  }
145   dofiles:
146 +        newheader("RADIANCE", stdout);
147 +        fputnow(stdout);
148          for (nfile = 0; an < argc; nfile++) {
149                  if (nfile >= MAXFILE)
150                          goto toomany;
151                  thislabel = NULL;
152 <                input[nfile].hasmin = input[nfile].hasmax = 0;
153 <                while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+'))
152 >                input[nfile].flags = 0;
153 >                xsgn = ysgn = '-';
154 >                while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+'
155 >                                || argv[an][0] == '=')) {
156                          switch (argv[an][1]) {
157                          case 't':
158                                  checkthresh = 1;
159                                  if (argv[an][0] == '-') {
160 <                                        input[nfile].hasmin = 1;
160 >                                        input[nfile].flags |= HASMIN;
161                                          setcolr(input[nfile].thmin,
162                                                          atof(argv[an+1]),
163                                                          atof(argv[an+1]),
164                                                          atof(argv[an+1]));
165 <                                } else {
166 <                                        input[nfile].hasmax = 1;
165 >                                } else if (argv[an][0] == '+') {
166 >                                        input[nfile].flags |= HASMAX;
167                                          setcolr(input[nfile].thmax,
168                                                          atof(argv[an+1]),
169                                                          atof(argv[an+1]),
170                                                          atof(argv[an+1]));
171 <                                }
172 <                                an += 2;
171 >                                } else
172 >                                        goto userr;
173 >                                an++;
174                                  break;
175                          case 'l':
176                                  if (strcmp(argv[an], "-l"))
177                                          goto userr;
178 <                                thislabel = argv[an+1];
157 <                                an += 2;
178 >                                thislabel = argv[++an];
179                                  break;
180 +                        case '+':
181 +                        case '-':
182 +                        case '0':
183 +                                if (argv[an][0] != '=')
184 +                                        goto userr;
185 +                                xsgn = argv[an][1];
186 +                                ysgn = argv[an][2];
187 +                                if (ysgn != '+' && ysgn != '-' && ysgn != '0')
188 +                                        goto userr;
189 +                                break;
190                          case '\0':
191                                  if (argv[an][0] == '-')
192                                          goto getfile;
# Line 163 | Line 194 | dofiles:
194                          default:
195                                  goto userr;
196                          }
197 +                        an++;
198 +                }
199   getfile:
200                  if (argc-an < (ncolumns ? 1 : 3))
201                          goto userr;
# Line 189 | Line 222 | getfile:
222                  printf("%s:\n", input[nfile].name);
223                  getheader(input[nfile].fp, tabputs, NULL);
224                  if (wrongformat) {
225 <                        fprintf(stderr, "%s: not a Radiance picture\n",
225 >                        fprintf(stderr, "%s: incompatible input format\n",
226                                          input[nfile].name);
227                          quit(1);
228                  }
# Line 212 | Line 245 | getfile:
245                          curcol++;
246                  } else {
247                          input[nfile].xloc = atoi(argv[an++]);
248 +                        if (xsgn == '+')
249 +                                input[nfile].xloc -= input[nfile].xres;
250 +                        else if (xsgn == '0')
251 +                                input[nfile].xloc -= input[nfile].xres/2;
252                          input[nfile].yloc = atoi(argv[an++]);
253 +                        if (ysgn == '+')
254 +                                input[nfile].yloc -= input[nfile].yres;
255 +                        else if (ysgn == '0')
256 +                                input[nfile].yloc -= input[nfile].yres/2;
257                  }
258                  if (input[nfile].xloc < xmin)
259                          xmin = input[nfile].xloc;
# Line 226 | Line 267 | getfile:
267                          if (++nfile >= MAXFILE)
268                                  goto toomany;
269                          input[nfile].name = Label;
270 <                        input[nfile].hasmin = input[nfile].hasmax = 0;
270 >                        input[nfile].flags = 0;
271                          input[nfile].xres = input[nfile-1].xres;
272                          input[nfile].yres = labelht;
273                          if ((input[nfile].fp = lblopen(thislabel,
# Line 248 | Line 289 | getfile:
289                  ymax = ysiz;
290                                          /* add new header info. */
291          printargs(argc, argv, stdout);
292 <        fputformat(COLRFMT, stdout);
292 >        if (strcmp(ourfmt, PICFMT))
293 >                fputformat(ourfmt, stdout);     /* print format if known */
294          putchar('\n');
295          fprtresolu(xsiz, ysiz, stdout);
296  
# Line 259 | Line 301 | userr:
301          fprintf(stderr,
302          "Usage: %s [-x xr][-y yr][-b r g b][-a n][-s p][-o x0 y0][-la][-lh h] ",
303                          progname);
304 <        fprintf(stderr, "[-t min1][+t max1][-l lab] pic1 x1 y1 ..\n");
304 >        fprintf(stderr, "[-t min1][+t max1][-l lab][=SS] pic1 x1 y1 ..\n");
305          quit(1);
306   toomany:
307          fprintf(stderr, "%s: only %d files and labels allowed\n",
# Line 308 | Line 350 | compos()                               /* composite pictures */
350                                  if (x > xsiz)
351                                          x = xsiz;
352                                  for (x--; x >= 0 && x >= input[i].xloc; x--) {
353 <                                        if (input[i].hasmin &&
353 >                                        if (input[i].flags & HASMIN &&
354                                          cmpcolr(scanin[x], input[i].thmin) <= 0)
355                                                  continue;
356 <                                        if (input[i].hasmax &&
356 >                                        if (input[i].flags & HASMAX &&
357                                          cmpcolr(scanin[x], input[i].thmax) >= 0)
358                                                  continue;
359                                          copycolr(scanout[x], scanin[x]);
# Line 340 | Line 382 | register COLR  c1, c2;
382  
383          j = 4;                          /* check exponents first! */
384          while (j--)
385 <                if (i = c1[j] - c2[j])
385 >                if ( (i = c1[j] - c2[j]) )
386                          return(i);
387          return(0);
388   }
# Line 351 | Line 393 | lblopen(s, xp, yp)             /* open pipe to label generator */
393   char  *s;
394   int  *xp, *yp;
395   {
396 <        char  com[128];
396 >        char  com[PATH_MAX];
397          FILE  *fp;
398  
399          sprintf(com, "psign -s -.15 -a 2 -x %d -y %d '%.90s'", *xp, *yp, s);
# Line 368 | Line 410 | err:
410   }
411  
412  
413 + void
414   quit(code)              /* exit gracefully */
415   int  code;
416   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines