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.18 by greg, Fri Dec 8 11:08:47 1989 UTC vs.
Revision 1.30 by greg, Wed May 1 12:40:03 1991 UTC

# Line 58 | Line 58 | int  scale = 0;                                /* scalefactor; power of two */
58   int  xoff = 0;                          /* x image offset */
59   int  yoff = 0;                          /* y image offset */
60  
61 < VIEW  ourview = STDVIEW(0);             /* image view parameters */
61 > VIEW  ourview = STDVIEW;                /* image view parameters */
62   int  gotview = 0;                       /* got parameters from file */
63  
64   COLR  *scanline;                        /* scan line buffer */
# Line 72 | Line 72 | int  cury = 0;                         /* current scan location */
72  
73   double  exposure = 1.0;                 /* exposure compensation used */
74  
75 + int  wrongformat = 0;                   /* input in another format */
76 +
77   struct {
78          int  xmin, ymin, xsiz, ysiz;
79   }  box = {0, 0, 0, 0};                  /* current box */
# Line 141 | Line 143 | char  *argv[];
143                  }
144          }
145                                  /* get header */
146 <        getheader(fin, headline);
146 >        getheader(fin, headline, NULL);
147                                  /* get picture dimensions */
148 <        if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR))
148 >        if (wrongformat || fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR))
149                  quiterr("bad picture size");
150                                  /* set view parameters */
151 <        if (gotview) {
152 <                ourview.hresolu = xmax;
151 <                ourview.vresolu = ymax;
152 <                if (setview(&ourview) != NULL)
153 <                        gotview = 0;
154 <        }
151 >        if (gotview && setview(&ourview) != NULL)
152 >                gotview = 0;
153          if ((scanline = (COLR *)malloc(xmax*sizeof(COLR))) == NULL)
154                  quiterr("out of memory");
155  
# Line 172 | Line 170 | char  *s;
170   {
171          static char  *altname[] = {"rview","rpict",VIEWSTR,NULL};
172          register char  **an;
173 +        char  fmt[32];
174  
175 <        if (!strncmp(s, "EXPOSURE=", 9))
176 <                exposure *= atof(s+9);
177 <        else
175 >        if (isexpos(s))
176 >                exposure *= exposval(s);
177 >        else if (isformat(s)) {
178 >                formatval(fmt, s);
179 >                wrongformat = strcmp(fmt, COLRFMT);
180 >        } else
181                  for (an = altname; *an != NULL; an++)
182                          if (!strncmp(*an, s, strlen(*an))) {
183 <                                if (sscanview(&ourview, s+strlen(*an)) == 0)
183 >                                if (sscanview(&ourview, s+strlen(*an)) > 0)
184                                          gotview++;
185                                  return;
186                          }
187   }
188  
189  
188 char *
189 sskip(s)                /* skip a word */
190 register char  *s;
191 {
192        while (isspace(*s)) s++;
193        while (*s && !isspace(*s)) s++;
194        return(s);
195 }
196
197
190   init()                  /* get data and open window */
191   {
192          register int  i;
# Line 301 | Line 293 | getras()                               /* get raster file */
293          }
294          return;
295   memerr:
296 <        quit("out of memory");
296 >        quiterr("out of memory");
297   }
298  
299  
# Line 387 | Line 379 | XKeyEvent  *ekey;
379                          sprintf(buf, "%.3f", intens(cval)/exposure);
380                          break;
381                  case 'l':                               /* luminance */
382 <                        sprintf(buf, "%.0fn", bright(cval)*683.0/exposure);
382 >                        sprintf(buf, "%.0fL", luminance(cval)/exposure);
383                          break;
384                  case 'c':                               /* color */
385                          comp = pow(2.0, (double)scale);
# Line 421 | Line 413 | XKeyEvent  *ekey;
413                          XFeep(0);
414                          return(-1);
415                  }
416 <                rayview(rorg, rdir, &ourview,
417 <                                ekey->x-xoff + .5, ymax-1-ekey->y+yoff + .5);
416 >                if (viewray(rorg, rdir, &ourview, (ekey->x-xoff+.5)/xmax,
417 >                                (ymax-1-ekey->y+yoff+.5)/ymax) < 0)
418 >                        return(-1);
419                  printf("%e %e %e ", rorg[0], rorg[1], rorg[2]);
420                  printf("%e %e %e\n", rdir[0], rdir[1], rdir[2]);
421                  fflush(stdout);
# Line 556 | Line 549 | getmono()                      /* get monochrome data */
549          register unsigned short *dp;
550          register int    x, err;
551          int     y;
552 <        rgbpixel        *inline;
552 >        rgbpixel        *inl;
553          short   *cerr;
554  
555 <        if ((inline = (rgbpixel *)malloc(xmax*sizeof(rgbpixel))) == NULL
555 >        if ((inl = (rgbpixel *)malloc(xmax*sizeof(rgbpixel))) == NULL
556                          || (cerr = (short *)calloc(xmax,sizeof(short))) == NULL)
557 <                quit("out of memory in getmono");
557 >                quiterr("out of memory in getmono");
558          dp = ourras->data.m - 1;
559          for (y = 0; y < ymax; y++) {
560 <                picreadline3(y, inline);
560 >                picreadline3(y, inl);
561                  err = 0;
562                  for (x = 0; x < xmax; x++) {
563                          if (!(x&0xf))
564                                  *++dp = 0;
565 <                        err += rgb_bright(&inline[x]) + cerr[x];
565 >                        err += rgb_bright(&inl[x]) + cerr[x];
566                          if (err > 127)
567                                  err -= 255;
568                          else
# Line 577 | Line 570 | getmono()                      /* get monochrome data */
570                          cerr[x] = err >>= 1;
571                  }
572          }
573 <        free((char *)inline);
573 >        free((char *)inl);
574          free((char *)cerr);
575   }
576  
# Line 648 | Line 641 | int  y;
641                  if (scanpos == NULL || scanpos[y] == -1)
642                          return(-1);
643                  if (fseek(fin, scanpos[y], 0) == -1)
644 <                        quit("fseek error");
644 >                        quiterr("fseek error");
645                  cury = y;
646          } else if (scanpos != NULL)
647                  scanpos[y] = ftell(fin);
# Line 670 | Line 663 | register rgbpixel  *l3;
663          if (getscan(y) < 0)
664                  quiterr("cannot seek for picreadline");
665                                                          /* convert scanline */
666 <        if (scale)
674 <                for (i = 0; i < xmax; i++)
675 <                        if (scanline[i][EXP])
676 <                                scanline[i][EXP] += scale;
677 <        normcolrs(scanline, xmax);
666 >        normcolrs(scanline, xmax, scale);
667          for (i = 0; i < xmax; i++) {
668                  l3[i].r = scanline[i][RED];
669                  l3[i].g = scanline[i][GRN];
# Line 687 | Line 676 | picwriteline(y, l)             /* add 8-bit scanline to image */
676   int  y;
677   pixel  *l;
678   {
679 <        bcopy(l, ourras->data.bz+BZPixmapSize(xmax,y), BZPixmapSize(xmax,1));
679 >        bcopy((char *)l, (char *)ourras->data.bz+BZPixmapSize(xmax,y), BZPixmapSize(xmax,1));
680   }
681  
682  
# Line 698 | Line 687 | colormap  map;
687          register int  i, val;
688  
689          for (i = 0; i < 256; i++) {
690 <                val = pow(i/256.0, 1.0/gamcor) * 256.0;
690 >                val = pow((i+0.5)/256.0, 1.0/gamcor) * 256.0;
691                  map[0][i] = map[1][i] = map[2][i] = val;
692          }
693   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines