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

Comparing ray/src/px/ximage.c (file contents):
Revision 1.27 by greg, Wed Nov 7 13:10:39 1990 UTC vs.
Revision 2.4 by greg, Tue Apr 28 09:40:36 1992 UTC

# Line 23 | Line 23 | static char SCCSid[] = "$SunId$ LBL";
23  
24   #include  "color.h"
25  
26 + #include  "resolu.h"
27 +
28   #include  "xraster.h"
29  
30   #include  "view.h"
# Line 35 | Line 37 | static char SCCSid[] = "$SunId$ LBL";
37  
38   #define  FONTNAME       "9x15"          /* text font we'll use */
39  
40 < #define  CTRL(c)        ('c'-'@')
40 > #define  CTRL(c)        ((c)-'@')
41  
42   #define  BORWIDTH       5               /* border width */
43   #define  BARHEIGHT      25              /* menu bar size */
# Line 72 | Line 74 | int  cury = 0;                         /* current scan location */
74  
75   double  exposure = 1.0;                 /* exposure compensation used */
76  
77 + int  wrongformat = 0;                   /* input in another format */
78 +
79   struct {
80          int  xmin, ymin, xsiz, ysiz;
81   }  box = {0, 0, 0, 0};                  /* current box */
# Line 86 | Line 90 | extern long  ftell();
90  
91   extern char  *malloc(), *calloc();
92  
93 < extern double  atof(), pow(), log();
93 > extern double  pow(), log();
94  
95  
96   main(argc, argv)
# Line 141 | Line 145 | char  *argv[];
145                  }
146          }
147                                  /* get header */
148 <        getheader(fin, headline);
148 >        getheader(fin, headline, NULL);
149                                  /* get picture dimensions */
150 <        if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR))
150 >        if (wrongformat || fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR))
151                  quiterr("bad picture size");
152                                  /* set view parameters */
153          if (gotview && setview(&ourview) != NULL)
# Line 166 | Line 170 | userr:
170   headline(s)             /* get relevant info from header */
171   char  *s;
172   {
173 <        static char  *altname[] = {"rview","rpict",VIEWSTR,NULL};
170 <        register char  **an;
173 >        char  fmt[32];
174  
175          if (isexpos(s))
176                  exposure *= exposval(s);
177 <        else
178 <                for (an = altname; *an != NULL; an++)
179 <                        if (!strncmp(*an, s, strlen(*an))) {
180 <                                if (sscanview(&ourview, s+strlen(*an)) > 0)
181 <                                        gotview++;
179 <                                return;
180 <                        }
177 >        else if (isformat(s)) {
178 >                formatval(fmt, s);
179 >                wrongformat = strcmp(fmt, COLRFMT);
180 >        } else if (isview(s) && sscanview(&ourview, s) > 0)
181 >                gotview++;
182   }
183  
184  
# Line 359 | Line 360 | XKeyEvent  *ekey;
360                  return(0);
361          switch (*cp) {                  /* interpret command */
362          case 'q':
363 <        case CTRL(D):                           /* quit */
363 >        case CTRL('D'):                         /* quit */
364                  quit(0);
365          case '\n':
366          case '\r':
# Line 373 | Line 374 | XKeyEvent  *ekey;
374                          sprintf(buf, "%.3f", intens(cval)/exposure);
375                          break;
376                  case 'l':                               /* luminance */
377 <                        sprintf(buf, "%.0fn", bright(cval)*683.0/exposure);
377 >                        sprintf(buf, "%.0fL", luminance(cval)/exposure);
378                          break;
379                  case 'c':                               /* color */
380                          comp = pow(2.0, (double)scale);
# Line 429 | Line 430 | XKeyEvent  *ekey;
430                  free_raster(ourras);
431                  getras();
432          /* fall through */
433 <        case CTRL(R):                           /* redraw */
434 <        case CTRL(L):
433 >        case CTRL('R'):                         /* redraw */
434 >        case CTRL('L'):
435                  unmap_rcolors(ourras);
436                  XClear(wind);
437                  return(redraw(0, 0, width, height));
# Line 542 | Line 543 | getmono()                      /* get monochrome data */
543   {
544          register unsigned short *dp;
545          register int    x, err;
546 <        int     y;
546 >        int     y, errp;
547          rgbpixel        *inl;
548          short   *cerr;
549  
# Line 556 | Line 557 | getmono()                      /* get monochrome data */
557                  for (x = 0; x < xmax; x++) {
558                          if (!(x&0xf))
559                                  *++dp = 0;
560 +                        errp = err;
561                          err += rgb_bright(&inl[x]) + cerr[x];
562                          if (err > 127)
563                                  err -= 255;
564                          else
565                                  *dp |= 1<<(x&0xf);
566 <                        cerr[x] = err >>= 1;
566 >                        err /= 3;
567 >                        cerr[x] = err + errp;
568                  }
569          }
570          free((char *)inl);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines