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.30 by greg, Wed May 25 04:44:26 2005 UTC vs.
Revision 2.34 by greg, Thu Jun 4 01:19:30 2015 UTC

# Line 20 | Line 20 | static const char      RCSid[] = "$Id$";
20   #include  "color.h"
21   #include  "resolu.h"
22  
23 < #define  MAXFILE        512
23 > #define  MAXFILE        1024
24  
25   #define  HASMIN         1
26   #define  HASMAX         2
# Line 52 | 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  
64  
65 < static gethfunc tabputs;
65 > static gethfunc headline;
66   static void compos(void);
67 < static int cmpcolr(COLR  c1, COLR  c2);
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 84 | 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 111 | Line 112 | main(
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 169 | Line 173 | dofiles:
173                                  checkthresh = 1;
174                                  if (argv[an][0] == '-') {
175                                          input[nfile].flags |= HASMIN;
176 <                                        setcolr(input[nfile].thmin,
173 <                                                        atof(argv[an+1]),
174 <                                                        atof(argv[an+1]),
175 <                                                        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,
179 <                                                        atof(argv[an+1]),
180 <                                                        atof(argv[an+1]),
181 <                                                        atof(argv[an+1]));
179 >                                        input[nfile].thmax = atof(argv[an+1]);
180                                  } else
181                                          goto userr;
182                                  an++;
# Line 230 | 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 244 | Line 243 | getfile:
243                                          input[nfile].name);
244                          quit(1);
245                  }
246 <                if (ncolumns > 0) {
247 <                        if (curcol >= ncolumns) {
246 >                if (ncolumns) {
247 >                        if (curcol >= abs(ncolumns)) {
248                                  cury = ymax + spacing;
249                                  curx = x0;
250                                  curcol = 0;
# Line 298 | Line 297 | getfile:
297                  ysiz = ymax;
298          else if (ysiz > ymax)
299                  ymax = ysiz;
300 +        if (ncolumns < 0) {             /* reverse rows if requested */
301 +                int     i = nfile;
302 +                while (i--)
303 +                        input[i].yloc = ymax - input[i].yres - input[i].yloc;
304 +        }
305                                          /* add new header info. */
306          printargs(argc, argv, stdout);
307          if (strcmp(ourfmt, PICFMT))
# Line 310 | Line 314 | getfile:
314          quit(0);
315   userr:
316          fprintf(stderr,
317 <        "Usage: %s [-x xr][-y yr][-b r g b][-a n][-s p][-o x0 y0][-la][-lh h] ",
317 >        "Usage: %s [-h][-x xr][-y yr][-b r g b][-a n][-s p][-o x0 y0][-la][-lh h] ",
318                          progname);
319          fprintf(stderr, "[-t min1][+t max1][-l lab][=SS] pic1 x1 y1 ..\n");
320          quit(1);
# Line 393 | Line 397 | memerr:
397  
398  
399   static int
400 < cmpcolr(                        /* compare two colr's (improvisation) */
400 > cmpcolr(                        /* compare COLR to luminance */
401          register COLR  c1,
402 <        register COLR  c2
402 >        double lv2
403   )
404   {
405 <        register int  i, j;
406 <
407 <        j = 4;                          /* check exponents first! */
408 <        while (j--)
409 <                if ( (i = c1[j] - c2[j]) )
410 <                        return(i);
405 >        double  lv1 = .0;
406 >        
407 >        if (c1[EXP])
408 >                lv1 = ldexp((double)normbright(c1), (int)c1[EXP]-(COLXS+8));
409 >        if (lv1 < lv2) return(-1);
410 >        if (lv1 > lv2) return(1);
411          return(0);
412   }
413  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines