--- ray/src/px/ximage.c 1989/12/01 15:50:26 1.17 +++ ray/src/px/ximage.c 1990/01/26 08:17:43 1.23 @@ -58,7 +58,7 @@ int scale = 0; /* scalefactor; power of two */ int xoff = 0; /* x image offset */ int yoff = 0; /* y image offset */ -VIEW ourview = STDVIEW(0); /* image view parameters */ +VIEW ourview = STDVIEW; /* image view parameters */ int gotview = 0; /* got parameters from file */ COLR *scanline; /* scan line buffer */ @@ -146,12 +146,8 @@ char *argv[]; if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR)) quiterr("bad picture size"); /* set view parameters */ - if (gotview) { - ourview.hresolu = xmax; - ourview.vresolu = ymax; - if (setview(&ourview) != NULL) - gotview = 0; - } + if (gotview && setview(&ourview) != NULL) + gotview = 0; if ((scanline = (COLR *)malloc(xmax*sizeof(COLR))) == NULL) quiterr("out of memory"); @@ -173,28 +169,18 @@ char *s; static char *altname[] = {"rview","rpict",VIEWSTR,NULL}; register char **an; - if (!strncmp(s, "EXPOSURE=", 9)) - exposure *= atof(s+9); + if (isexpos(s)) + exposure *= exposval(s); else for (an = altname; *an != NULL; an++) if (!strncmp(*an, s, strlen(*an))) { - if (sscanview(&ourview, s+strlen(*an)) == 0) + if (sscanview(&ourview, s+strlen(*an)) > 0) gotview++; return; } } -char * -sskip(s) /* skip a word */ -register char *s; -{ - while (isspace(*s)) s++; - while (*s && !isspace(*s)) s++; - return(s); -} - - init() /* get data and open window */ { register int i; @@ -421,8 +407,8 @@ XKeyEvent *ekey; XFeep(0); return(-1); } - rayview(rorg, rdir, &ourview, - ekey->x-xoff + .5, ymax-1-ekey->y+yoff + .5); + viewray(rorg, rdir, &ourview, (ekey->x-xoff+.5)/xmax, + (ymax-1-ekey->y+yoff+.5)/ymax); printf("%e %e %e ", rorg[0], rorg[1], rorg[2]); printf("%e %e %e\n", rdir[0], rdir[1], rdir[2]); fflush(stdout); @@ -670,11 +656,7 @@ register rgbpixel *l3; if (getscan(y) < 0) quiterr("cannot seek for picreadline"); /* convert scanline */ - if (scale != 0) - for (i = 0; i < xmax; i++) - if (scanline[i][EXP]+scale >= 0) - scanline[i][EXP] += scale; - normcolrs(scanline, xmax); + normcolrs(scanline, xmax, scale); for (i = 0; i < xmax; i++) { l3[i].r = scanline[i][RED]; l3[i].g = scanline[i][GRN]; @@ -687,7 +669,7 @@ picwriteline(y, l) /* add 8-bit scanline to image */ int y; pixel *l; { - bcopy(l, ourras->data.bz+BZPixmapSize(xmax,y), BZPixmapSize(xmax,1)); + bcopy((char *)l, (char *)ourras->data.bz+BZPixmapSize(xmax,y), BZPixmapSize(xmax,1)); }