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.16 by greg, Fri Jun 4 14:47:01 1993 UTC vs.
Revision 2.23 by schorsch, Thu Jul 3 22:41:44 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>
14
11   #include  <math.h>
12 + #include  <time.h>
13 + #include  <string.h>
14  
15 < #ifdef MSDOS
18 < #include  <fcntl.h>
19 < #endif
15 > #include "copyright.h"
16  
17 + #include  "platform.h"
18   #include  "color.h"
22
19   #include  "resolu.h"
20  
21   #define  MAXFILE        64
22  
23 + #define  HASMIN         1
24 + #define  HASMAX         2
25 +
26                                          /* output picture size */
27   int  xsiz = 0;
28   int  ysiz = 0;
# Line 49 | Line 48 | struct {
48          FILE  *fp;                      /* stream pointer */
49          int  xres, yres;                /* picture size */
50          int  xloc, yloc;                /* anchor point */
51 <        int  hasmin, hasmax;            /* has threshold values */
51 >        int  flags;                     /* HASMIN, HASMAX */
52          COLR  thmin, thmax;             /* thresholds */
53   } input[MAXFILE];               /* our input files */
54  
55   int  nfile;                     /* number of files */
56  
57 + char  ourfmt[LPICFMT+1] = PICFMT;
58   int  wrongformat = 0;
59  
60 < FILE  *popen(), *lblopen();
60 > FILE  *lblopen();
61 > void  quit();
62  
62 extern char  *malloc();
63  
64
64   tabputs(s)                      /* print line preceded by a tab */
65   char  *s;
66   {
67          char  fmt[32];
68  
69 <        if (isformat(s)) {
70 <                formatval(fmt, s);
71 <                wrongformat = strcmp(fmt, COLRFMT);
69 >        if (isheadid(s))
70 >                return(0);
71 >        if (formatval(fmt, s)) {
72 >                if (globmatch(ourfmt, fmt)) {
73 >                        wrongformat = 0;
74 >                        strcpy(ourfmt, fmt);
75 >                } else
76 >                        wrongformat = 1;
77          } else {
78                  putc('\t', stdout);
79                  fputs(s, stdout);
80          }
81 +        return(0);
82   }
83  
84  
# Line 84 | Line 89 | char  *argv[];
89          int  ncolumns = 0;
90          int  autolabel = 0;
91          int  curcol = 0, x0 = 0, curx = 0, cury = 0, spacing = 0;
92 +        int  xsgn, ysgn;
93          char  *thislabel;
94          int  an;
95 < #ifdef MSDOS
96 <        extern int  _fmode;
97 <        _fmode = O_BINARY;
92 <        setmode(fileno(stdin), O_BINARY);
93 <        setmode(fileno(stdout), O_BINARY);
94 < #endif
95 >        SET_DEFAULT_BINARY();
96 >        SET_FILE_BINARY(stdin);
97 >        SET_FILE_BINARY(stdout);
98          progname = argv[0];
99  
100          for (an = 1; an < argc && argv[an][0] == '-'; an++)
# Line 139 | Line 142 | char  *argv[];
142                          goto userr;
143                  }
144   dofiles:
145 +        newheader("RADIANCE", stdout);
146 +        fputnow(stdout);
147          for (nfile = 0; an < argc; nfile++) {
148                  if (nfile >= MAXFILE)
149                          goto toomany;
150                  thislabel = NULL;
151 <                input[nfile].hasmin = input[nfile].hasmax = 0;
152 <                while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+'))
151 >                input[nfile].flags = 0;
152 >                xsgn = ysgn = '-';
153 >                while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+'
154 >                                || argv[an][0] == '=')) {
155                          switch (argv[an][1]) {
156                          case 't':
157                                  checkthresh = 1;
158                                  if (argv[an][0] == '-') {
159 <                                        input[nfile].hasmin = 1;
159 >                                        input[nfile].flags |= HASMIN;
160                                          setcolr(input[nfile].thmin,
161                                                          atof(argv[an+1]),
162                                                          atof(argv[an+1]),
163                                                          atof(argv[an+1]));
164 <                                } else {
165 <                                        input[nfile].hasmax = 1;
164 >                                } else if (argv[an][0] == '+') {
165 >                                        input[nfile].flags |= HASMAX;
166                                          setcolr(input[nfile].thmax,
167                                                          atof(argv[an+1]),
168                                                          atof(argv[an+1]),
169                                                          atof(argv[an+1]));
170 <                                }
171 <                                an += 2;
170 >                                } else
171 >                                        goto userr;
172 >                                an++;
173                                  break;
174                          case 'l':
175                                  if (strcmp(argv[an], "-l"))
176                                          goto userr;
177 <                                thislabel = argv[an+1];
170 <                                an += 2;
177 >                                thislabel = argv[++an];
178                                  break;
179 +                        case '+':
180 +                        case '-':
181 +                        case '0':
182 +                                if (argv[an][0] != '=')
183 +                                        goto userr;
184 +                                xsgn = argv[an][1];
185 +                                ysgn = argv[an][2];
186 +                                if (ysgn != '+' && ysgn != '-' && ysgn != '0')
187 +                                        goto userr;
188 +                                break;
189                          case '\0':
190                                  if (argv[an][0] == '-')
191                                          goto getfile;
# Line 176 | Line 193 | dofiles:
193                          default:
194                                  goto userr;
195                          }
196 +                        an++;
197 +                }
198   getfile:
199                  if (argc-an < (ncolumns ? 1 : 3))
200                          goto userr;
# Line 202 | Line 221 | getfile:
221                  printf("%s:\n", input[nfile].name);
222                  getheader(input[nfile].fp, tabputs, NULL);
223                  if (wrongformat) {
224 <                        fprintf(stderr, "%s: not a Radiance picture\n",
224 >                        fprintf(stderr, "%s: incompatible input format\n",
225                                          input[nfile].name);
226                          quit(1);
227                  }
# Line 225 | Line 244 | getfile:
244                          curcol++;
245                  } else {
246                          input[nfile].xloc = atoi(argv[an++]);
247 +                        if (xsgn == '+')
248 +                                input[nfile].xloc -= input[nfile].xres;
249 +                        else if (xsgn == '0')
250 +                                input[nfile].xloc -= input[nfile].xres/2;
251                          input[nfile].yloc = atoi(argv[an++]);
252 +                        if (ysgn == '+')
253 +                                input[nfile].yloc -= input[nfile].yres;
254 +                        else if (ysgn == '0')
255 +                                input[nfile].yloc -= input[nfile].yres/2;
256                  }
257                  if (input[nfile].xloc < xmin)
258                          xmin = input[nfile].xloc;
# Line 239 | Line 266 | getfile:
266                          if (++nfile >= MAXFILE)
267                                  goto toomany;
268                          input[nfile].name = Label;
269 <                        input[nfile].hasmin = input[nfile].hasmax = 0;
269 >                        input[nfile].flags = 0;
270                          input[nfile].xres = input[nfile-1].xres;
271                          input[nfile].yres = labelht;
272                          if ((input[nfile].fp = lblopen(thislabel,
# Line 261 | Line 288 | getfile:
288                  ymax = ysiz;
289                                          /* add new header info. */
290          printargs(argc, argv, stdout);
291 <        fputformat(COLRFMT, stdout);
291 >        if (strcmp(ourfmt, PICFMT))
292 >                fputformat(ourfmt, stdout);     /* print format if known */
293          putchar('\n');
294          fprtresolu(xsiz, ysiz, stdout);
295  
# Line 272 | Line 300 | userr:
300          fprintf(stderr,
301          "Usage: %s [-x xr][-y yr][-b r g b][-a n][-s p][-o x0 y0][-la][-lh h] ",
302                          progname);
303 <        fprintf(stderr, "[-t min1][+t max1][-l lab] pic1 x1 y1 ..\n");
303 >        fprintf(stderr, "[-t min1][+t max1][-l lab][=SS] pic1 x1 y1 ..\n");
304          quit(1);
305   toomany:
306          fprintf(stderr, "%s: only %d files and labels allowed\n",
# Line 321 | Line 349 | compos()                               /* composite pictures */
349                                  if (x > xsiz)
350                                          x = xsiz;
351                                  for (x--; x >= 0 && x >= input[i].xloc; x--) {
352 <                                        if (input[i].hasmin &&
352 >                                        if (input[i].flags & HASMIN &&
353                                          cmpcolr(scanin[x], input[i].thmin) <= 0)
354                                                  continue;
355 <                                        if (input[i].hasmax &&
355 >                                        if (input[i].flags & HASMAX &&
356                                          cmpcolr(scanin[x], input[i].thmax) >= 0)
357                                                  continue;
358                                          copycolr(scanout[x], scanin[x]);
# Line 381 | Line 409 | err:
409   }
410  
411  
412 + void
413   quit(code)              /* exit gracefully */
414   int  code;
415   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines