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.28 by greg, Mon Mar 18 09:35:04 1991 UTC vs.
Revision 2.8 by gwlarson, Tue Oct 27 09:08:28 1998 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)
97   int  argc;
98   char  *argv[];
99   {
100 +        extern char  *getenv();
101 +        char  *gv;
102          int  headline();
103          int  i;
104          
105          progname = argv[0];
106 +        if ((gv = getenv("DISPLAY_GAMMA")) != NULL)
107 +                gamcor = atof(gv);
108  
109          for (i = 1; i < argc; i++)
110                  if (argv[i][0] == '-')
# Line 141 | Line 149 | char  *argv[];
149                  }
150          }
151                                  /* get header */
152 <        getheader(fin, headline);
152 >        getheader(fin, headline, NULL);
153                                  /* get picture dimensions */
154 <        if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR))
154 >        if (wrongformat || fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR))
155                  quiterr("bad picture size");
156                                  /* set view parameters */
157          if (gotview && setview(&ourview) != NULL)
# Line 163 | Line 171 | userr:
171   }
172  
173  
174 + int
175   headline(s)             /* get relevant info from header */
176   char  *s;
177   {
178 <        static char  *altname[] = {"rview","rpict",VIEWSTR,NULL};
170 <        register char  **an;
178 >        char  fmt[32];
179  
180          if (isexpos(s))
181                  exposure *= exposval(s);
182 <        else
183 <                for (an = altname; *an != NULL; an++)
184 <                        if (!strncmp(*an, s, strlen(*an))) {
185 <                                if (sscanview(&ourview, s+strlen(*an)) > 0)
186 <                                        gotview++;
187 <                                return;
180 <                        }
182 >        else if (isformat(s)) {
183 >                formatval(fmt, s);
184 >                wrongformat = strcmp(fmt, COLRFMT);
185 >        } else if (isview(s) && sscanview(&ourview, s) > 0)
186 >                gotview++;
187 >        return(0);
188   }
189  
190  
# Line 359 | Line 366 | XKeyEvent  *ekey;
366                  return(0);
367          switch (*cp) {                  /* interpret command */
368          case 'q':
369 <        case CTRL(D):                           /* quit */
369 >        case CTRL('D'):                         /* quit */
370                  quit(0);
371          case '\n':
372          case '\r':
# Line 373 | Line 380 | XKeyEvent  *ekey;
380                          sprintf(buf, "%.3f", intens(cval)/exposure);
381                          break;
382                  case 'l':                               /* luminance */
383 <                        sprintf(buf, "%.0fn", luminance(cval)/exposure);
383 >                        sprintf(buf, "%.0fL", luminance(cval)/exposure);
384                          break;
385                  case 'c':                               /* color */
386                          comp = pow(2.0, (double)scale);
# Line 429 | Line 436 | XKeyEvent  *ekey;
436                  free_raster(ourras);
437                  getras();
438          /* fall through */
439 <        case CTRL(R):                           /* redraw */
440 <        case CTRL(L):
439 >        case CTRL('R'):                         /* redraw */
440 >        case CTRL('L'):
441                  unmap_rcolors(ourras);
442                  XClear(wind);
443                  return(redraw(0, 0, width, height));
# Line 542 | Line 549 | getmono()                      /* get monochrome data */
549   {
550          register unsigned short *dp;
551          register int    x, err;
552 <        int     y;
552 >        int     y, errp;
553          rgbpixel        *inl;
554          short   *cerr;
555  
# Line 556 | Line 563 | getmono()                      /* get monochrome data */
563                  for (x = 0; x < xmax; x++) {
564                          if (!(x&0xf))
565                                  *++dp = 0;
566 +                        errp = err;
567                          err += rgb_bright(&inl[x]) + cerr[x];
568                          if (err > 127)
569                                  err -= 255;
570                          else
571                                  *dp |= 1<<(x&0xf);
572 <                        cerr[x] = err >>= 1;
572 >                        err /= 3;
573 >                        cerr[x] = err + errp;
574                  }
575          }
576          free((char *)inl);
# Line 637 | Line 646 | int  y;
646                  if (fseek(fin, scanpos[y], 0) == -1)
647                          quiterr("fseek error");
648                  cury = y;
649 <        } else if (scanpos != NULL)
649 >        } else if (scanpos != NULL && scanpos[y] == -1)
650                  scanpos[y] = ftell(fin);
651  
652          if (freadcolrs(scanline, xmax, fin) < 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines