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