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.22 by greg, Thu Jan 18 23:58:26 1990 UTC vs.
Revision 2.1 by greg, Tue Nov 12 16:05:14 1991 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 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 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 168 | Line 172 | char  *s;
172   {
173          static char  *altname[] = {"rview","rpict",VIEWSTR,NULL};
174          register char  **an;
175 +        char  fmt[32];
176  
177          if (isexpos(s))
178                  exposure *= exposval(s);
179 <        else
179 >        else if (isformat(s)) {
180 >                formatval(fmt, s);
181 >                wrongformat = strcmp(fmt, COLRFMT);
182 >        } else
183                  for (an = altname; *an != NULL; an++)
184                          if (!strncmp(*an, s, strlen(*an))) {
185                                  if (sscanview(&ourview, s+strlen(*an)) > 0)
# Line 287 | Line 295 | getras()                               /* get raster file */
295          }
296          return;
297   memerr:
298 <        quit("out of memory");
298 >        quiterr("out of memory");
299   }
300  
301  
# Line 373 | Line 381 | XKeyEvent  *ekey;
381                          sprintf(buf, "%.3f", intens(cval)/exposure);
382                          break;
383                  case 'l':                               /* luminance */
384 <                        sprintf(buf, "%.0fn", bright(cval)*683.0/exposure);
384 >                        sprintf(buf, "%.0fL", luminance(cval)/exposure);
385                          break;
386                  case 'c':                               /* color */
387                          comp = pow(2.0, (double)scale);
# Line 407 | Line 415 | XKeyEvent  *ekey;
415                          XFeep(0);
416                          return(-1);
417                  }
418 <                viewray(rorg, rdir, &ourview, (ekey->x-xoff+.5)/xmax,
419 <                                (ymax-1-ekey->y+yoff+.5)/ymax);
418 >                if (viewray(rorg, rdir, &ourview, (ekey->x-xoff+.5)/xmax,
419 >                                (ymax-1-ekey->y+yoff+.5)/ymax) < 0)
420 >                        return(-1);
421                  printf("%e %e %e ", rorg[0], rorg[1], rorg[2]);
422                  printf("%e %e %e\n", rdir[0], rdir[1], rdir[2]);
423                  fflush(stdout);
# Line 541 | Line 550 | getmono()                      /* get monochrome data */
550   {
551          register unsigned short *dp;
552          register int    x, err;
553 <        int     y;
554 <        rgbpixel        *inline;
553 >        int     y, errp;
554 >        rgbpixel        *inl;
555          short   *cerr;
556  
557 <        if ((inline = (rgbpixel *)malloc(xmax*sizeof(rgbpixel))) == NULL
557 >        if ((inl = (rgbpixel *)malloc(xmax*sizeof(rgbpixel))) == NULL
558                          || (cerr = (short *)calloc(xmax,sizeof(short))) == NULL)
559 <                quit("out of memory in getmono");
559 >                quiterr("out of memory in getmono");
560          dp = ourras->data.m - 1;
561          for (y = 0; y < ymax; y++) {
562 <                picreadline3(y, inline);
562 >                picreadline3(y, inl);
563                  err = 0;
564                  for (x = 0; x < xmax; x++) {
565                          if (!(x&0xf))
566                                  *++dp = 0;
567 <                        err += rgb_bright(&inline[x]) + cerr[x];
567 >                        errp = err;
568 >                        err += rgb_bright(&inl[x]) + cerr[x];
569                          if (err > 127)
570                                  err -= 255;
571                          else
572                                  *dp |= 1<<(x&0xf);
573 <                        cerr[x] = err >>= 1;
573 >                        err /= 3;
574 >                        cerr[x] = err + errp;
575                  }
576          }
577 <        free((char *)inline);
577 >        free((char *)inl);
578          free((char *)cerr);
579   }
580  
# Line 634 | Line 645 | int  y;
645                  if (scanpos == NULL || scanpos[y] == -1)
646                          return(-1);
647                  if (fseek(fin, scanpos[y], 0) == -1)
648 <                        quit("fseek error");
648 >                        quiterr("fseek error");
649                  cury = y;
650          } else if (scanpos != NULL)
651                  scanpos[y] = ftell(fin);
# Line 656 | Line 667 | register rgbpixel  *l3;
667          if (getscan(y) < 0)
668                  quiterr("cannot seek for picreadline");
669                                                          /* convert scanline */
670 <        if (scale)
660 <                for (i = 0; i < xmax; i++)
661 <                        if (scanline[i][EXP])
662 <                                scanline[i][EXP] += scale;
663 <        normcolrs(scanline, xmax);
670 >        normcolrs(scanline, xmax, scale);
671          for (i = 0; i < xmax; i++) {
672                  l3[i].r = scanline[i][RED];
673                  l3[i].g = scanline[i][GRN];
# Line 684 | Line 691 | colormap  map;
691          register int  i, val;
692  
693          for (i = 0; i < 256; i++) {
694 <                val = pow(i/256.0, 1.0/gamcor) * 256.0;
694 >                val = pow((i+0.5)/256.0, 1.0/gamcor) * 256.0;
695                  map[0][i] = map[1][i] = map[2][i] = val;
696          }
697   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines