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.28 by greg, Mon Mar 15 21:16:54 2004 UTC vs.
Revision 2.33 by greg, Mon Aug 10 04:26:38 2009 UTC

# Line 16 | Line 16 | static const char      RCSid[] = "$Id$";
16  
17   #include  "platform.h"
18   #include  "rtprocess.h"
19 + #include  "rterror.h"
20   #include  "color.h"
21   #include  "resolu.h"
22  
23 < #define  MAXFILE        64
23 > #define  MAXFILE        1024
24  
25   #define  HASMIN         1
26   #define  HASMAX         2
# Line 51 | 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 */
59  
60 + int  echoheader = 1;
61   char  ourfmt[LPICFMT+1] = PICFMT;
62   int  wrongformat = 0;
63  
62 FILE  *lblopen();
63 void  quit();
64  
65 < static gethfunc tabputs;
65 > static gethfunc headline;
66 > static void compos(void);
67 > static int cmpcolr(COLR  c1, double lv2);
68 > static FILE * lblopen(char  *s, int  *xp, int  *yp);
69  
70  
71 +
72   static int
73 < tabputs(                        /* print line preceded by a tab */
73 > headline(                       /* print line preceded by a tab */
74          char    *s,
75          void    *p
76   )
# Line 81 | Line 85 | tabputs(                       /* print line preceded by a tab */
85                          strcpy(ourfmt, fmt);
86                  } else
87                          wrongformat = 1;
88 <        } else {
88 >        } else if (echoheader) {
89                  putc('\t', stdout);
90                  fputs(s, stdout);
91          }
# Line 89 | Line 93 | tabputs(                       /* print line preceded by a tab */
93   }
94  
95  
96 < main(argc, argv)
97 < int  argc;
98 < char  *argv[];
96 > int
97 > main(
98 >        int  argc,
99 >        char  *argv[]
100 > )
101   {
102          int  ncolumns = 0;
103          int  autolabel = 0;
# Line 106 | Line 112 | char  *argv[];
112  
113          for (an = 1; an < argc && argv[an][0] == '-'; an++)
114                  switch (argv[an][1]) {
115 +                case 'h':
116 +                        echoheader = !echoheader;
117 +                        break;
118                  case 'x':
119                          xsiz = atoi(argv[++an]);
120                          break;
# Line 164 | Line 173 | dofiles:
173                                  checkthresh = 1;
174                                  if (argv[an][0] == '-') {
175                                          input[nfile].flags |= HASMIN;
176 <                                        setcolr(input[nfile].thmin,
168 <                                                        atof(argv[an+1]),
169 <                                                        atof(argv[an+1]),
170 <                                                        atof(argv[an+1]));
176 >                                        input[nfile].thmin = atof(argv[an+1]);
177                                  } else if (argv[an][0] == '+') {
178                                          input[nfile].flags |= HASMAX;
179 <                                        setcolr(input[nfile].thmax,
174 <                                                        atof(argv[an+1]),
175 <                                                        atof(argv[an+1]),
176 <                                                        atof(argv[an+1]));
179 >                                        input[nfile].thmax = atof(argv[an+1]);
180                                  } else
181                                          goto userr;
182                                  an++;
# Line 225 | Line 228 | getfile:
228                  }
229                  an++;
230                                                  /* get header */
231 <                printf("%s:\n", input[nfile].name);
232 <                getheader(input[nfile].fp, tabputs, NULL);
231 >                if (echoheader)
232 >                        printf("%s:\n", input[nfile].name);
233 >                getheader(input[nfile].fp, headline, NULL);
234                  if (wrongformat) {
235                          fprintf(stderr, "%s: incompatible input format\n",
236                                          input[nfile].name);
# Line 305 | Line 309 | getfile:
309          quit(0);
310   userr:
311          fprintf(stderr,
312 <        "Usage: %s [-x xr][-y yr][-b r g b][-a n][-s p][-o x0 y0][-la][-lh h] ",
312 >        "Usage: %s [-h][-x xr][-y yr][-b r g b][-a n][-s p][-o x0 y0][-la][-lh h] ",
313                          progname);
314          fprintf(stderr, "[-t min1][+t max1][-l lab][=SS] pic1 x1 y1 ..\n");
315          quit(1);
# Line 316 | Line 320 | toomany:
320   labelerr:
321          fprintf(stderr, "%s: error opening label\n", progname);
322          quit(1);
323 +        return 1; /* pro forma return */
324   }
325  
326  
327 < compos()                                /* composite pictures */
327 > static void
328 > compos(void)                            /* composite pictures */
329   {
330          COLR  *scanin, *scanout;
331          int  y;
# Line 385 | Line 391 | memerr:
391   }
392  
393  
394 < int
395 < cmpcolr(c1, c2)                 /* compare two colr's (improvisation) */
396 < register COLR  c1, c2;
394 > static int
395 > cmpcolr(                        /* compare COLR to luminance */
396 >        register COLR  c1,
397 >        double lv2
398 > )
399   {
400 <        register int  i, j;
401 <
402 <        j = 4;                          /* check exponents first! */
403 <        while (j--)
404 <                if ( (i = c1[j] - c2[j]) )
405 <                        return(i);
400 >        double  lv1 = .0;
401 >        
402 >        if (c1[EXP])
403 >                lv1 = ldexp((double)normbright(c1), (int)c1[EXP]-(COLXS+8));
404 >        if (lv1 < lv2) return(-1);
405 >        if (lv1 > lv2) return(1);
406          return(0);
407   }
408  
409  
410 < FILE *
411 < lblopen(s, xp, yp)              /* open pipe to label generator */
412 < char  *s;
413 < int  *xp, *yp;
410 > static FILE *
411 > lblopen(                /* open pipe to label generator */
412 >        char  *s,
413 >        int  *xp,
414 >        int  *yp
415 > )
416   {
417          char  com[PATH_MAX];
418          FILE  *fp;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines