| 240 |
|
if (geometry != NULL) { |
| 241 |
|
bzero((char *)&oursizhints, sizeof(oursizhints)); |
| 242 |
|
i = XParseGeometry(geometry, &oursizhints.x, &oursizhints.y, |
| 243 |
< |
&oursizhints.width, &oursizhints.height); |
| 243 |
> |
(unsigned *)&oursizhints.width, |
| 244 |
> |
(unsigned *)&oursizhints.height); |
| 245 |
|
if ((i&(WidthValue|HeightValue)) == (WidthValue|HeightValue)) |
| 246 |
|
oursizhints.flags |= USSize; |
| 247 |
|
else { |
| 337 |
|
} |
| 338 |
|
return; |
| 339 |
|
fail: |
| 340 |
< |
quit("could not create raster image"); |
| 340 |
> |
quiterr("could not create raster image"); |
| 341 |
|
} |
| 342 |
|
|
| 343 |
|
|
| 605 |
|
register unsigned char *dp; |
| 606 |
|
register int x, err; |
| 607 |
|
int y; |
| 607 |
– |
rgbpixel *inl; |
| 608 |
|
short *cerr; |
| 609 |
|
|
| 610 |
< |
if ((inl = (rgbpixel *)malloc(xmax*sizeof(rgbpixel))) == NULL |
| 611 |
< |
|| (cerr = (short *)calloc(xmax,sizeof(short))) == NULL) |
| 612 |
< |
quit("out of memory in getmono"); |
| 610 |
> |
if ((cerr = (short *)calloc(xmax,sizeof(short))) == NULL) |
| 611 |
> |
quiterr("out of memory in getmono"); |
| 612 |
|
dp = ourdata - 1; |
| 613 |
|
for (y = 0; y < ymax; y++) { |
| 614 |
< |
picreadline3(y, inl); |
| 614 |
> |
if (getscan(y) < 0) |
| 615 |
> |
quiterr("seek error in getmono"); |
| 616 |
> |
normcolrs(scanline, xmax, scale); |
| 617 |
|
err = 0; |
| 618 |
|
for (x = 0; x < xmax; x++) { |
| 619 |
|
if (!(x&7)) |
| 620 |
|
*++dp = 0; |
| 621 |
< |
err += rgb_bright(&inl[x]) + cerr[x]; |
| 621 |
> |
err += normbright(scanline[x]) + cerr[x]; |
| 622 |
|
if (err > 127) |
| 623 |
|
err -= 255; |
| 624 |
|
else |
| 626 |
|
cerr[x] = err >>= 1; |
| 627 |
|
} |
| 628 |
|
} |
| 628 |
– |
free((char *)inl); |
| 629 |
|
free((char *)cerr); |
| 630 |
|
} |
| 631 |
|
|
| 633 |
|
getfull() /* get full (24-bit) data */ |
| 634 |
|
{ |
| 635 |
|
int y; |
| 636 |
< |
|
| 637 |
< |
for (y = 0; y < ymax; y++) |
| 638 |
< |
picreadline3(y, (rgbpixel *)(ourdata+y*xmax*3)); |
| 636 |
> |
register unsigned char *dp; |
| 637 |
> |
register int x; |
| 638 |
> |
/* set gamma correction */ |
| 639 |
> |
setcolrgam(gamcor); |
| 640 |
> |
/* read and convert file */ |
| 641 |
> |
dp = ourdata; |
| 642 |
> |
for (y = 0; y < ymax; y++) { |
| 643 |
> |
if (getscan(y) < 0) |
| 644 |
> |
quiterr("seek error in getfull"); |
| 645 |
> |
if (scale) |
| 646 |
> |
shiftcolrs(scanline, xmax, scale); |
| 647 |
> |
colrs_gambs(scanline, xmax); |
| 648 |
> |
for (x = 0; x < xmax; x++) { |
| 649 |
> |
*dp++ = scanline[x][RED]; |
| 650 |
> |
*dp++ = scanline[x][GRN]; |
| 651 |
> |
*dp++ = scanline[x][BLU]; |
| 652 |
> |
} |
| 653 |
> |
} |
| 654 |
|
} |
| 655 |
|
|
| 656 |
|
|
| 689 |
|
if (scanpos == NULL || scanpos[y] == -1) |
| 690 |
|
return(-1); |
| 691 |
|
if (fseek(fin, scanpos[y], 0) == -1) |
| 692 |
< |
quit("fseek error"); |
| 692 |
> |
quiterr("fseek error"); |
| 693 |
|
cury = y; |
| 694 |
|
} else if (scanpos != NULL) |
| 695 |
|
scanpos[y] = ftell(fin); |
| 735 |
|
register int i, val; |
| 736 |
|
|
| 737 |
|
for (i = 0; i < 256; i++) { |
| 738 |
< |
val = pow(i/256.0, 1.0/gamcor) * 256.0; |
| 738 |
> |
val = pow((i+0.5)/256.0, 1.0/gamcor) * 256.0; |
| 739 |
|
map[0][i] = map[1][i] = map[2][i] = val; |
| 740 |
|
} |
| 741 |
|
} |