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.19 by greg, Mon Oct 16 11:40:09 1995 UTC vs.
Revision 2.31 by greg, Tue Jun 6 19:13:00 2006 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1993 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  "rtprocess.h"
19 + #include  "rterror.h"
20   #include  "color.h"
22
21   #include  "resolu.h"
22  
23 < #define  MAXFILE        64
23 > #define  MAXFILE        512
24  
25   #define  HASMIN         1
26   #define  HASMAX         2
# Line 42 | Line 40 | int  labelht = 24;                     /* label height */
40  
41   int  checkthresh = 0;                   /* check threshold value */
42  
43 + char  StandardInput[] = "<stdin>";
44   char  Command[] = "<Command>";
45   char  Label[] = "<Label>";
46  
# Line 53 | Line 52 | struct {
52          int  xres, yres;                /* picture size */
53          int  xloc, yloc;                /* anchor point */
54          int  flags;                     /* HASMIN, HASMAX */
55 <        COLR  thmin, thmax;             /* thresholds */
55 >        double  thmin, thmax;           /* thresholds */
56   } input[MAXFILE];               /* our input files */
57  
58   int  nfile;                     /* number of files */
# Line 61 | Line 60 | int  nfile;                    /* number of files */
60   char  ourfmt[LPICFMT+1] = PICFMT;
61   int  wrongformat = 0;
62  
64 FILE  *popen(), *lblopen();
63  
64 < extern char  *malloc();
64 > static gethfunc tabputs;
65 > static void compos(void);
66 > static int cmpcolr(COLR  c1, double lv2);
67 > static FILE * lblopen(char  *s, int  *xp, int  *yp);
68  
69  
70 < tabputs(s)                      /* print line preceded by a tab */
71 < char  *s;
70 >
71 > static int
72 > tabputs(                        /* print line preceded by a tab */
73 >        char    *s,
74 >        void    *p
75 > )
76   {
77          char  fmt[32];
78  
79          if (isheadid(s))
80 <                return;
80 >                return(0);
81          if (formatval(fmt, s)) {
82                  if (globmatch(ourfmt, fmt)) {
83                          wrongformat = 0;
# Line 83 | Line 88 | char  *s;
88                  putc('\t', stdout);
89                  fputs(s, stdout);
90          }
91 +        return(0);
92   }
93  
94  
95 < main(argc, argv)
96 < int  argc;
97 < char  *argv[];
95 > int
96 > main(
97 >        int  argc,
98 >        char  *argv[]
99 > )
100   {
101          int  ncolumns = 0;
102          int  autolabel = 0;
# Line 96 | Line 104 | char  *argv[];
104          int  xsgn, ysgn;
105          char  *thislabel;
106          int  an;
107 < #ifdef MSDOS
108 <        extern int  _fmode;
109 <        _fmode = O_BINARY;
102 <        setmode(fileno(stdin), O_BINARY);
103 <        setmode(fileno(stdout), O_BINARY);
104 < #endif
107 >        SET_DEFAULT_BINARY();
108 >        SET_FILE_BINARY(stdin);
109 >        SET_FILE_BINARY(stdout);
110          progname = argv[0];
111  
112          for (an = 1; an < argc && argv[an][0] == '-'; an++)
# Line 150 | Line 155 | char  *argv[];
155                  }
156   dofiles:
157          newheader("RADIANCE", stdout);
158 +        fputnow(stdout);
159          for (nfile = 0; an < argc; nfile++) {
160                  if (nfile >= MAXFILE)
161                          goto toomany;
# Line 163 | Line 169 | dofiles:
169                                  checkthresh = 1;
170                                  if (argv[an][0] == '-') {
171                                          input[nfile].flags |= HASMIN;
172 <                                        setcolr(input[nfile].thmin,
167 <                                                        atof(argv[an+1]),
168 <                                                        atof(argv[an+1]),
169 <                                                        atof(argv[an+1]));
172 >                                        input[nfile].thmin = atof(argv[an+1]);
173                                  } else if (argv[an][0] == '+') {
174                                          input[nfile].flags |= HASMAX;
175 <                                        setcolr(input[nfile].thmax,
173 <                                                        atof(argv[an+1]),
174 <                                                        atof(argv[an+1]),
175 <                                                        atof(argv[an+1]));
175 >                                        input[nfile].thmax = atof(argv[an+1]);
176                                  } else
177                                          goto userr;
178                                  an++;
# Line 207 | Line 207 | getfile:
207                  if (autolabel && thislabel == NULL)
208                          thislabel = argv[an];
209                  if (!strcmp(argv[an], "-")) {
210 <                        input[nfile].name = "<stdin>";
210 >                        input[nfile].name = StandardInput;
211                          input[nfile].fp = stdin;
212                  } else {
213                          if (argv[an][0] == '!') {
# Line 227 | Line 227 | getfile:
227                  printf("%s:\n", input[nfile].name);
228                  getheader(input[nfile].fp, tabputs, NULL);
229                  if (wrongformat) {
230 <                        fprintf(stderr, "%s: bad Radiance input file\n",
230 >                        fprintf(stderr, "%s: incompatible input format\n",
231                                          input[nfile].name);
232                          quit(1);
233                  }
# Line 315 | Line 315 | toomany:
315   labelerr:
316          fprintf(stderr, "%s: error opening label\n", progname);
317          quit(1);
318 +        return 1; /* pro forma return */
319   }
320  
321  
322 < compos()                                /* composite pictures */
322 > static void
323 > compos(void)                            /* composite pictures */
324   {
325          COLR  *scanin, *scanout;
326          int  y;
# Line 372 | Line 374 | compos()                               /* composite pictures */
374                          quit(1);
375                  }
376          }
377 +                                        /* read remainders from streams */
378 +        for (i = 0; i < nfile; i++)
379 +                if (input[i].name[0] == '<')
380 +                        while (getc(input[i].fp) != EOF)
381 +                                ;
382          return;
383   memerr:
384          perror(progname);
# Line 379 | Line 386 | memerr:
386   }
387  
388  
389 < int
390 < cmpcolr(c1, c2)                 /* compare two colr's (improvisation) */
391 < register COLR  c1, c2;
389 > static int
390 > cmpcolr(                        /* compare COLR to luminance */
391 >        register COLR  c1,
392 >        double lv2
393 > )
394   {
395 <        register int  i, j;
396 <
397 <        j = 4;                          /* check exponents first! */
398 <        while (j--)
399 <                if (i = c1[j] - c2[j])
400 <                        return(i);
395 >        double  lv1 = .0;
396 >        
397 >        if (c1[EXP])
398 >                lv1 = ldexp((double)normbright(c1), (int)c1[EXP]-(COLXS+8));
399 >        if (lv1 < lv2) return(-1);
400 >        if (lv1 > lv2) return(1);
401          return(0);
402   }
403  
404  
405 < FILE *
406 < lblopen(s, xp, yp)              /* open pipe to label generator */
407 < char  *s;
408 < int  *xp, *yp;
405 > static FILE *
406 > lblopen(                /* open pipe to label generator */
407 >        char  *s,
408 >        int  *xp,
409 >        int  *yp
410 > )
411   {
412 <        char  com[128];
412 >        char  com[PATH_MAX];
413          FILE  *fp;
414  
415          sprintf(com, "psign -s -.15 -a 2 -x %d -y %d '%.90s'", *xp, *yp, s);
# Line 415 | Line 426 | err:
426   }
427  
428  
429 + void
430   quit(code)              /* exit gracefully */
431   int  code;
432   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines