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

Comparing ray/src/px/pcomb.c (file contents):
Revision 2.21 by gwlarson, Tue Oct 27 09:08:25 1998 UTC vs.
Revision 2.31 by greg, Mon Mar 15 21:16:54 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   *  Combine picture files according to calcomp functions.
6   *
7   *      1/4/89
8   */
9  
10 < #include "standard.h"
11 <
10 > #include "platform.h"
11 > #include "rtprocess.h"
12 > #include "rterror.h"
13   #include "color.h"
16
17 #include "resolu.h"
18
14   #include "calcomp.h"
20
15   #include "view.h"
16  
17   #define MAXINP          32              /* maximum number of input files */
18 < #define WINSIZ          17              /* scanline window size */
18 > #define WINSIZ          64              /* scanline window size */
19   #define MIDSCN          ((WINSIZ-1)/2+1)
20  
21   struct {
# Line 39 | Line 33 | int    nfiles;                         /* number of input files */
33  
34   char    ourfmt[LPICFMT+1] = PICFMT;     /* input picture format */
35  
36 + char    StandardInput[] = "<stdin>";
37   char    Command[] = "<Command>";
38   char    vcolin[3][4] = {"ri", "gi", "bi"};
39   char    vcolout[3][4] = {"ro", "go", "bo"};
# Line 76 | Line 71 | char   *progname;                      /* global argv[0] */
71   int     wrongformat = 0;
72   int     gotview;
73  
79 FILE    *popen();
74  
75   extern char     *emalloc();
76  
77 + static gethfunc tabputs;
78  
79   main(argc, argv)
80   int     argc;
# Line 88 | Line 83 | char   *argv[];
83          int     original;
84          double  f;
85          int     a, i;
86 < #ifdef MSDOS
87 <        extern int  _fmode;
88 <        _fmode = O_BINARY;
94 <        setmode(fileno(stdin), O_BINARY);
95 <        setmode(fileno(stdout), O_BINARY);
96 < #endif
86 >        SET_DEFAULT_BINARY();
87 >        SET_FILE_BINARY(stdin);
88 >        SET_FILE_BINARY(stdout);
89          progname = argv[0];
90                                                  /* scan options */
91          for (a = 1; a < argc; a++) {
# Line 114 | Line 106 | char   *argv[];
106                  break;
107          }
108          newheader("RADIANCE", stdout);  /* start header */
109 +        fputnow(stdout);
110                                          /* process files */
111          for (nfiles = 0; nfiles < MAXINP; nfiles++) {
112                  setcolor(input[nfiles].coef, 1.0, 1.0, 1.0);
113                  setcolor(input[nfiles].expos, 1.0, 1.0, 1.0);
114 <                copystruct(&input[nfiles].vw, &stdview);
114 >                input[nfiles].vw = stdview;
115                  input[nfiles].pa = 1.0;
116          }
117          nfiles = 0;
# Line 132 | Line 125 | char   *argv[];
125                  if (argv[a][0] == '-')
126                          switch (argv[a][1]) {
127                          case '\0':
128 <                                input[nfiles].name = "<stdin>";
128 >                                input[nfiles].name = StandardInput;
129                                  input[nfiles].fp = stdin;
130                                  break;
131                          case 'o':
# Line 171 | Line 164 | char   *argv[];
164                                          colval(input[nfiles].expos,GRN);
165                          colval(input[nfiles].coef,BLU) /=
166                                          colval(input[nfiles].expos,BLU);
167 +                        setcolor(input[nfiles].expos, 1.0, 1.0, 1.0);
168                  }
169                  nfiles++;
170                  original = 0;
# Line 227 | Line 221 | usage:
221   }
222  
223  
224 < tputs(s)                        /* put out string preceded by a tab */
225 < char    *s;
224 > static int
225 > tabputs(                        /* put out string preceded by a tab */
226 >        char    *s,
227 >        void    *p
228 > )
229   {
230          char    fmt[32];
231          double  d;
# Line 241 | Line 238 | char   *s;
238                          wrongformat = 0;
239                          strcpy(ourfmt, fmt);
240                  } else
241 <                        wrongformat = 1;
241 >                        wrongformat = globmatch(PICFMT, fmt) ? 1 : -1;
242                  return(0);      /* don't echo */
243          }
244          if (isexpos(s)) {                       /* exposure */
# Line 267 | Line 264 | checkfile()                    /* ready a file */
264          gotview = 0;
265          fputs(input[nfiles].name, stdout);
266          fputs(":\n", stdout);
267 <        getheader(input[nfiles].fp, tputs, NULL);
268 <        if (wrongformat) {
267 >        getheader(input[nfiles].fp, tabputs, NULL);
268 >        if (wrongformat < 0) {
269                  eputs(input[nfiles].name);
270 <                eputs(": not in Radiance picture format\n");
270 >                eputs(": not a Radiance picture\n");
271                  quit(1);
272          }
273 +        if (wrongformat > 0) {
274 +                wputs(input[nfiles].name);
275 +                wputs(": warning -- incompatible picture format\n");
276 +        }
277          if (!gotview || setview(&input[nfiles].vw) != NULL)
278                  input[nfiles].vw.type = 0;
279          if (!fgetsresolu(&input[nfiles].rs, input[nfiles].fp)) {
# Line 316 | Line 317 | double (*ourbright)() = rgb_bright;
317  
318   init()                                  /* perform final setup */
319   {
320 <        double  l_colin(), l_expos(), l_pixaspect(), l_ray(), l_psize();
320 >        double  l_colin(char *), l_expos(char *), l_pixaspect(char *),
321 >                        l_ray(char *), l_psize(char *);
322          register int    i;
323                                                  /* define constants */
324          varset("PI", ':', PI);
# Line 397 | Line 399 | combine()                      /* combine pictures */
399                      quit(1);
400              }
401          }
402 <        efree(scanout);
402 >        efree((char *)scanout);
403   }
404  
405  
# Line 450 | Line 452 | register char  *nam;
452  
453  
454   double
455 < l_pixaspect()                   /* return pixel aspect ratio */
455 > l_pixaspect(char *nm)           /* return pixel aspect ratio */
456   {
457          register int    fn;
458  
# Line 522 | Line 524 | register char  *nam;
524          static unsigned long    ltick[MAXINP];
525          static FVECT    lorg[MAXINP], ldir[MAXINP];
526          static double   ldist[MAXINP];
527 <        FLOAT   loc[2];
527 >        RREAL   loc[2];
528          int     fn;
529          register int    i;
530  
# Line 531 | Line 533 | register char  *nam;
533                  errno = EDOM;
534                  return(0.0);
535          }
536 <        if (ltick[fn] < eclock) {               /* need to compute? */
536 >        if (ltick[fn] != eclock) {              /* need to compute? */
537                  lorg[fn][0] = lorg[fn][1] = lorg[fn][2] = 0.0;
538                  ldir[fn][0] = ldir[fn][1] = ldir[fn][2] = 0.0;
539                  ldist[fn] = -1.0;
# Line 555 | Line 557 | register char  *nam;
557  
558  
559   double
560 < l_psize()                       /* compute pixel size in steradians */
560 > l_psize(char *nm)               /* compute pixel size in steradians */
561   {
562          static unsigned long    ltick[MAXINP];
563          static double   psize[MAXINP];
564          FVECT   dir0, org, dirx, diry;
565 <        FLOAT   locx[2], locy[2];
565 >        RREAL   locx[2], locy[2];
566          double  d;
567          int     fn;
568          register int    i;
# Line 571 | Line 573 | l_psize()                      /* compute pixel size in steradians */
573                  return(0.0);
574          }
575          fn = d - .5;
576 <        if (ltick[fn] < eclock) {               /* need to compute? */
576 >        if (ltick[fn] != eclock) {              /* need to compute? */
577                  psize[fn] = 0.0;
578                  if (input[fn].vw.type == 0)
579                          errno = EDOM;
# Line 591 | Line 593 | l_psize()                      /* compute pixel size in steradians */
593                                          diry[i] -= dir0[i];
594                                  }
595                                  fcross(dir0, dirx, diry);
596 <                                psize[fn] = 0.5 * sqrt(DOT(dir0,dir0));
596 >                                psize[fn] = sqrt(DOT(dir0,dir0));
597                          }
598                  }
599                  ltick[fn] = eclock;
# Line 600 | Line 602 | l_psize()                      /* compute pixel size in steradians */
602   }
603  
604  
605 < wputs(msg)
606 < char    *msg;
605 > extern void
606 > wputs(char      *msg)
607   {
608          if (!nowarn)
609                  eputs(msg);
610   }
611  
612  
613 < eputs(msg)
614 < char    *msg;
613 > extern void
614 > eputs(char *msg)
615   {
616          fputs(msg, stderr);
617   }
618  
619  
620 < quit(code)              /* exit gracefully */
621 < int  code;
620 > extern void
621 > quit(int code)          /* exit gracefully */
622   {
623          register int  i;
624                                  /* close input files */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines