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.3 by greg, Tue Apr 11 17:09:13 1989 UTC vs.
Revision 1.12 by greg, Fri Oct 20 20:36:10 1989 UTC

# Line 38 | Line 38 | static char SCCSid[] = "$SunId$ LBL";
38   #define  BORWIDTH       5               /* border width */
39   #define  BARHEIGHT      25              /* menu bar size */
40  
41 < double  gamcor = 2.0;                   /* gamma correction */
41 > double  gamcor = 2.2;                   /* gamma correction */
42  
43   XRASTER  *ourras = NULL;                /* our stored raster image */
44  
# Line 137 | Line 137 | char  *argv[];
137                          sprintf(errmsg, "can't open file \"%s\"", fname);
138                          quiterr(errmsg);
139                  }
140 <        } else
141 <                goto userr;
142 <
140 >        }
141                                  /* get header */
142          getheader(fin, headline);
143                                  /* get picture dimensions */
144 <        if (fscanf(fin, "-Y %d +X %d\n", &ymax, &xmax) != 2)
144 >        if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR))
145                  quiterr("bad picture size");
146                                  /* set view parameters */
147 <        if (gotview) {
150 <                ourview.hresolu = xmax;
151 <                ourview.vresolu = ymax;
147 >        if (gotview)
148                  if (setview(&ourview) != NULL)
149                          gotview = 0;
150 <        }
150 >
151          if ((scanline = (COLR *)malloc(xmax*sizeof(COLR))) == NULL)
152                  quiterr("out of memory");
153  
# Line 170 | Line 166 | userr:
166   headline(s)             /* get relevant info from header */
167   char  *s;
168   {
169 <        static char  *altname[] = {"rview","rpict","VIEW=",NULL};
169 >        static char  *altname[] = {"rview","rpict",VIEWSTR,NULL};
170          register char  **an;
171  
172          if (!strncmp(s, "EXPOSURE=", 9))
# Line 347 | Line 343 | redraw(x, y, w, h)                     /* redraw section of window */
343   int  x, y;
344   int  w, h;
345   {
346 <        if (map_rcolors(ourras) == NULL) {
346 >        if (ourras->ncolors && map_rcolors(ourras) == NULL) {
347                  fprintf(stderr, "%s: cannot allocate colors\n", progname);
348                  return(-1);
349          }
# Line 419 | Line 415 | XKeyEvent  *ekey;
415                  if (avgbox(cval) == -1)
416                          return(-1);
417                  n = log(.5/bright(cval))/.69315 - scale;        /* truncate */
418 <                if (n == 0) {
423 <                        XFeep(0);
418 >                if (n == 0)
419                          return(0);
425                }
420                  scale_rcolors(ourras, pow(2.0, (double)n));
421                  scale += n;
422                  sprintf(buf, "%+d", scale);
# Line 433 | Line 427 | XKeyEvent  *ekey;
427                  getras();
428          /* fall through */
429          case CTRL(R):                           /* redraw */
430 +        case CTRL(L):
431                  XClear(wind);
432                  return(redraw(0, 0, width, height));
433          case ' ':                               /* clear */
# Line 651 | Line 646 | picreadline3(y, l3)                    /* read in 3-byte scanline */
646   int  y;
647   register rgbpixel  *l3;
648   {
649 <        register BYTE   *l4;
650 <        register int    shift, c;
656 <        int     i;
657 <
649 >        register int    i;
650 >                                                        /* read scanline */
651          if (getscan(y) < 0)
652                  quiterr("cannot seek for picreadline");
653                                                          /* convert scanline */
654 <        for (l4=scanline[0], i=xmax; i--; l4+=4, l3++) {
655 <                shift = l4[EXP] - COLXS + scale;
656 <                if (shift >= 8) {
657 <                        l3->r = l3->g = l3->b = 255;
658 <                } else if (shift <= -8) {
666 <                        l3->r = l3->g = l3->b = 0;
667 <                } else if (shift > 0) {
668 <                        c = l4[RED] << shift;
669 <                        l3->r = c > 255 ? 255 : c;
670 <                        c = l4[GRN] << shift;
671 <                        l3->g = c > 255 ? 255 : c;
672 <                        c = l4[BLU] << shift;
673 <                        l3->b = c > 255 ? 255 : c;
674 <                } else if (shift < 0) {
675 <                        l3->r = l4[RED] >> -shift;
676 <                        l3->g = l4[GRN] >> -shift;
677 <                        l3->b = l4[BLU] >> -shift;
678 <                } else {
679 <                        l3->r = l4[RED];
680 <                        l3->g = l4[GRN];
681 <                        l3->b = l4[BLU];
682 <                }
654 >        normcolrs(scanline, xmax);
655 >        for (i = 0; i < xmax; i++) {
656 >                l3[i].r = scanline[i][RED];
657 >                l3[i].g = scanline[i][GRN];
658 >                l3[i].b = scanline[i][BLU];
659          }
660   }
661  
# Line 692 | Line 668 | pixel  *l;
668   }
669  
670  
671 < picreadcm(map)                  /* do gamcor correction */
671 > picreadcm(map)                  /* do gamma correction */
672   colormap  map;
673   {
674          extern double  pow();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines