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 */ |
146 |
|
if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR)) |
147 |
|
quiterr("bad picture size"); |
148 |
|
/* set view parameters */ |
149 |
< |
if (gotview) { |
150 |
< |
ourview.hresolu = xmax; |
151 |
< |
ourview.vresolu = ymax; |
152 |
< |
if (setview(&ourview) != NULL) |
153 |
< |
gotview = 0; |
154 |
< |
} |
149 |
> |
if (gotview && setview(&ourview) != NULL) |
150 |
> |
gotview = 0; |
151 |
|
if ((scanline = (COLR *)malloc(xmax*sizeof(COLR))) == NULL) |
152 |
|
quiterr("out of memory"); |
153 |
|
|
169 |
|
static char *altname[] = {"rview","rpict",VIEWSTR,NULL}; |
170 |
|
register char **an; |
171 |
|
|
172 |
< |
if (!strncmp(s, "EXPOSURE=", 9)) |
173 |
< |
exposure *= atof(s+9); |
172 |
> |
if (isexpos(s)) |
173 |
> |
exposure *= exposval(s); |
174 |
|
else |
175 |
|
for (an = altname; *an != NULL; an++) |
176 |
|
if (!strncmp(*an, s, strlen(*an))) { |
177 |
< |
if (sscanview(&ourview, s+strlen(*an)) == 0) |
177 |
> |
if (sscanview(&ourview, s+strlen(*an)) > 0) |
178 |
|
gotview++; |
179 |
|
return; |
180 |
|
} |
181 |
|
} |
182 |
|
|
183 |
|
|
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 |
– |
|
184 |
|
init() /* get data and open window */ |
185 |
|
{ |
186 |
|
register int i; |
287 |
|
} |
288 |
|
return; |
289 |
|
memerr: |
290 |
< |
quit("out of memory"); |
290 |
> |
quiterr("out of memory"); |
291 |
|
} |
292 |
|
|
293 |
|
|
373 |
|
sprintf(buf, "%.3f", intens(cval)/exposure); |
374 |
|
break; |
375 |
|
case 'l': /* luminance */ |
376 |
< |
sprintf(buf, "%.0fn", bright(cval)*683.0/exposure); |
376 |
> |
sprintf(buf, "%.0fn", luminance(cval)/exposure); |
377 |
|
break; |
378 |
|
case 'c': /* color */ |
379 |
|
comp = pow(2.0, (double)scale); |
407 |
|
XFeep(0); |
408 |
|
return(-1); |
409 |
|
} |
410 |
< |
rayview(rorg, rdir, &ourview, |
411 |
< |
ekey->x-xoff + .5, ymax-1-ekey->y+yoff + .5); |
410 |
> |
if (viewray(rorg, rdir, &ourview, (ekey->x-xoff+.5)/xmax, |
411 |
> |
(ymax-1-ekey->y+yoff+.5)/ymax) < 0) |
412 |
> |
return(-1); |
413 |
|
printf("%e %e %e ", rorg[0], rorg[1], rorg[2]); |
414 |
|
printf("%e %e %e\n", rdir[0], rdir[1], rdir[2]); |
415 |
|
fflush(stdout); |
543 |
|
register unsigned short *dp; |
544 |
|
register int x, err; |
545 |
|
int y; |
546 |
< |
rgbpixel *inline; |
546 |
> |
rgbpixel *inl; |
547 |
|
short *cerr; |
548 |
|
|
549 |
< |
if ((inline = (rgbpixel *)malloc(xmax*sizeof(rgbpixel))) == NULL |
549 |
> |
if ((inl = (rgbpixel *)malloc(xmax*sizeof(rgbpixel))) == NULL |
550 |
|
|| (cerr = (short *)calloc(xmax,sizeof(short))) == NULL) |
551 |
< |
quit("out of memory in getmono"); |
551 |
> |
quiterr("out of memory in getmono"); |
552 |
|
dp = ourras->data.m - 1; |
553 |
|
for (y = 0; y < ymax; y++) { |
554 |
< |
picreadline3(y, inline); |
554 |
> |
picreadline3(y, inl); |
555 |
|
err = 0; |
556 |
|
for (x = 0; x < xmax; x++) { |
557 |
|
if (!(x&0xf)) |
558 |
|
*++dp = 0; |
559 |
< |
err += rgb_bright(&inline[x]) + cerr[x]; |
559 |
> |
err += rgb_bright(&inl[x]) + cerr[x]; |
560 |
|
if (err > 127) |
561 |
|
err -= 255; |
562 |
|
else |
564 |
|
cerr[x] = err >>= 1; |
565 |
|
} |
566 |
|
} |
567 |
< |
free((char *)inline); |
567 |
> |
free((char *)inl); |
568 |
|
free((char *)cerr); |
569 |
|
} |
570 |
|
|
635 |
|
if (scanpos == NULL || scanpos[y] == -1) |
636 |
|
return(-1); |
637 |
|
if (fseek(fin, scanpos[y], 0) == -1) |
638 |
< |
quit("fseek error"); |
638 |
> |
quiterr("fseek error"); |
639 |
|
cury = y; |
640 |
|
} else if (scanpos != NULL) |
641 |
|
scanpos[y] = ftell(fin); |
657 |
|
if (getscan(y) < 0) |
658 |
|
quiterr("cannot seek for picreadline"); |
659 |
|
/* convert scanline */ |
660 |
< |
if (scale) |
674 |
< |
for (i = 0; i < xmax; i++) |
675 |
< |
if (scanline[i][EXP]) |
676 |
< |
scanline[i][EXP] += scale; |
677 |
< |
normcolrs(scanline, xmax); |
660 |
> |
normcolrs(scanline, xmax, scale); |
661 |
|
for (i = 0; i < xmax; i++) { |
662 |
|
l3[i].r = scanline[i][RED]; |
663 |
|
l3[i].g = scanline[i][GRN]; |
670 |
|
int y; |
671 |
|
pixel *l; |
672 |
|
{ |
673 |
< |
bcopy(l, ourras->data.bz+BZPixmapSize(xmax,y), BZPixmapSize(xmax,1)); |
673 |
> |
bcopy((char *)l, (char *)ourras->data.bz+BZPixmapSize(xmax,y), BZPixmapSize(xmax,1)); |
674 |
|
} |
675 |
|
|
676 |
|
|
681 |
|
register int i, val; |
682 |
|
|
683 |
|
for (i = 0; i < 256; i++) { |
684 |
< |
val = pow(i/256.0, 1.0/gamcor) * 256.0; |
684 |
> |
val = pow((i+0.5)/256.0, 1.0/gamcor) * 256.0; |
685 |
|
map[0][i] = map[1][i] = map[2][i] = val; |
686 |
|
} |
687 |
|
} |