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.27 by schorsch, Fri Jan 2 12:47:01 2004 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 + static gethfunc tabputs;
65  
66 < tabputs(s)                      /* print line preceded by a tab */
67 < char  *s;
66 >
67 > static int
68 > tabputs(                        /* print line preceded by a tab */
69 >        char    *s,
70 >        void    *p
71 > )
72   {
73          char  fmt[32];
74  
75 <        if (isformat(s)) {
76 <                formatval(fmt, s);
77 <                wrongformat = strcmp(fmt, COLRFMT);
75 >        if (isheadid(s))
76 >                return(0);
77 >        if (formatval(fmt, s)) {
78 >                if (globmatch(ourfmt, fmt)) {
79 >                        wrongformat = 0;
80 >                        strcpy(ourfmt, fmt);
81 >                } else
82 >                        wrongformat = 1;
83          } else {
84                  putc('\t', stdout);
85                  fputs(s, stdout);
86          }
87 +        return(0);
88   }
89  
90  
# Line 76 | Line 95 | char  *argv[];
95          int  ncolumns = 0;
96          int  autolabel = 0;
97          int  curcol = 0, x0 = 0, curx = 0, cury = 0, spacing = 0;
98 +        int  xsgn, ysgn;
99          char  *thislabel;
100          int  an;
101 <
101 >        SET_DEFAULT_BINARY();
102 >        SET_FILE_BINARY(stdin);
103 >        SET_FILE_BINARY(stdout);
104          progname = argv[0];
105  
106          for (an = 1; an < argc && argv[an][0] == '-'; an++)
# Line 126 | Line 148 | char  *argv[];
148                          goto userr;
149                  }
150   dofiles:
151 +        newheader("RADIANCE", stdout);
152 +        fputnow(stdout);
153          for (nfile = 0; an < argc; nfile++) {
154                  if (nfile >= MAXFILE)
155                          goto toomany;
156                  thislabel = NULL;
157 <                input[nfile].hasmin = input[nfile].hasmax = 0;
158 <                while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+'))
157 >                input[nfile].flags = 0;
158 >                xsgn = ysgn = '-';
159 >                while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+'
160 >                                || argv[an][0] == '=')) {
161                          switch (argv[an][1]) {
162                          case 't':
163                                  checkthresh = 1;
164                                  if (argv[an][0] == '-') {
165 <                                        input[nfile].hasmin = 1;
165 >                                        input[nfile].flags |= HASMIN;
166                                          setcolr(input[nfile].thmin,
167                                                          atof(argv[an+1]),
168                                                          atof(argv[an+1]),
169                                                          atof(argv[an+1]));
170 <                                } else {
171 <                                        input[nfile].hasmax = 1;
170 >                                } else if (argv[an][0] == '+') {
171 >                                        input[nfile].flags |= HASMAX;
172                                          setcolr(input[nfile].thmax,
173                                                          atof(argv[an+1]),
174                                                          atof(argv[an+1]),
175                                                          atof(argv[an+1]));
176 <                                }
177 <                                an += 2;
176 >                                } else
177 >                                        goto userr;
178 >                                an++;
179                                  break;
180                          case 'l':
181                                  if (strcmp(argv[an], "-l"))
182                                          goto userr;
183 <                                thislabel = argv[an+1];
157 <                                an += 2;
183 >                                thislabel = argv[++an];
184                                  break;
185 +                        case '+':
186 +                        case '-':
187 +                        case '0':
188 +                                if (argv[an][0] != '=')
189 +                                        goto userr;
190 +                                xsgn = argv[an][1];
191 +                                ysgn = argv[an][2];
192 +                                if (ysgn != '+' && ysgn != '-' && ysgn != '0')
193 +                                        goto userr;
194 +                                break;
195                          case '\0':
196                                  if (argv[an][0] == '-')
197                                          goto getfile;
# Line 163 | Line 199 | dofiles:
199                          default:
200                                  goto userr;
201                          }
202 +                        an++;
203 +                }
204   getfile:
205                  if (argc-an < (ncolumns ? 1 : 3))
206                          goto userr;
# Line 189 | Line 227 | getfile:
227                  printf("%s:\n", input[nfile].name);
228                  getheader(input[nfile].fp, tabputs, NULL);
229                  if (wrongformat) {
230 <                        fprintf(stderr, "%s: not a Radiance picture\n",
230 >                        fprintf(stderr, "%s: incompatible input format\n",
231                                          input[nfile].name);
232                          quit(1);
233                  }
# Line 212 | Line 250 | getfile:
250                          curcol++;
251                  } else {
252                          input[nfile].xloc = atoi(argv[an++]);
253 +                        if (xsgn == '+')
254 +                                input[nfile].xloc -= input[nfile].xres;
255 +                        else if (xsgn == '0')
256 +                                input[nfile].xloc -= input[nfile].xres/2;
257                          input[nfile].yloc = atoi(argv[an++]);
258 +                        if (ysgn == '+')
259 +                                input[nfile].yloc -= input[nfile].yres;
260 +                        else if (ysgn == '0')
261 +                                input[nfile].yloc -= input[nfile].yres/2;
262                  }
263                  if (input[nfile].xloc < xmin)
264                          xmin = input[nfile].xloc;
# Line 226 | Line 272 | getfile:
272                          if (++nfile >= MAXFILE)
273                                  goto toomany;
274                          input[nfile].name = Label;
275 <                        input[nfile].hasmin = input[nfile].hasmax = 0;
275 >                        input[nfile].flags = 0;
276                          input[nfile].xres = input[nfile-1].xres;
277                          input[nfile].yres = labelht;
278                          if ((input[nfile].fp = lblopen(thislabel,
# Line 248 | Line 294 | getfile:
294                  ymax = ysiz;
295                                          /* add new header info. */
296          printargs(argc, argv, stdout);
297 <        fputformat(COLRFMT, stdout);
297 >        if (strcmp(ourfmt, PICFMT))
298 >                fputformat(ourfmt, stdout);     /* print format if known */
299          putchar('\n');
300          fprtresolu(xsiz, ysiz, stdout);
301  
# Line 259 | Line 306 | userr:
306          fprintf(stderr,
307          "Usage: %s [-x xr][-y yr][-b r g b][-a n][-s p][-o x0 y0][-la][-lh h] ",
308                          progname);
309 <        fprintf(stderr, "[-t min1][+t max1][-l lab] pic1 x1 y1 ..\n");
309 >        fprintf(stderr, "[-t min1][+t max1][-l lab][=SS] pic1 x1 y1 ..\n");
310          quit(1);
311   toomany:
312          fprintf(stderr, "%s: only %d files and labels allowed\n",
# Line 308 | Line 355 | compos()                               /* composite pictures */
355                                  if (x > xsiz)
356                                          x = xsiz;
357                                  for (x--; x >= 0 && x >= input[i].xloc; x--) {
358 <                                        if (input[i].hasmin &&
358 >                                        if (input[i].flags & HASMIN &&
359                                          cmpcolr(scanin[x], input[i].thmin) <= 0)
360                                                  continue;
361 <                                        if (input[i].hasmax &&
361 >                                        if (input[i].flags & HASMAX &&
362                                          cmpcolr(scanin[x], input[i].thmax) >= 0)
363                                                  continue;
364                                          copycolr(scanout[x], scanin[x]);
# Line 340 | Line 387 | register COLR  c1, c2;
387  
388          j = 4;                          /* check exponents first! */
389          while (j--)
390 <                if (i = c1[j] - c2[j])
390 >                if ( (i = c1[j] - c2[j]) )
391                          return(i);
392          return(0);
393   }
# Line 351 | Line 398 | lblopen(s, xp, yp)             /* open pipe to label generator */
398   char  *s;
399   int  *xp, *yp;
400   {
401 <        char  com[128];
401 >        char  com[PATH_MAX];
402          FILE  *fp;
403  
404          sprintf(com, "psign -s -.15 -a 2 -x %d -y %d '%.90s'", *xp, *yp, s);
# Line 368 | Line 415 | err:
415   }
416  
417  
418 + void
419   quit(code)              /* exit gracefully */
420   int  code;
421   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines