| 970 |
|
getmapped() /* get color-mapped data */ |
| 971 |
|
{ |
| 972 |
|
int y; |
| 973 |
+ |
/* make sure we can do it first */ |
| 974 |
+ |
if (fname == NULL) |
| 975 |
+ |
quiterr("cannot map colors from standard input"); |
| 976 |
|
/* set gamma correction */ |
| 977 |
|
setcolrgam(gamcor); |
| 978 |
|
/* make histogram */ |
| 979 |
|
new_histo(); |
| 980 |
|
for (y = 0; y < ymax; y++) { |
| 981 |
|
if (getscan(y) < 0) |
| 982 |
< |
quiterr("seek error in getmapped"); |
| 982 |
> |
break; |
| 983 |
|
add2icon(y, scanline); |
| 984 |
|
if (scale) |
| 985 |
|
shiftcolrs(scanline, xmax, scale); |
| 990 |
|
if (!new_clrtab(maxcolors)) |
| 991 |
|
quiterr("cannot create color map"); |
| 992 |
|
for (y = 0; y < ymax; y++) { |
| 993 |
< |
if (getscan(y) < 0) |
| 991 |
< |
quiterr("seek error in getmapped"); |
| 993 |
> |
getscan(y); |
| 994 |
|
if (scale) |
| 995 |
|
shiftcolrs(scanline, xmax, scale); |
| 996 |
|
colrs_gambs(scanline, xmax); |
| 1033 |
|
getscan(y) |
| 1034 |
|
int y; |
| 1035 |
|
{ |
| 1036 |
+ |
static int trunced = -1; /* truncated file? */ |
| 1037 |
+ |
skipit: |
| 1038 |
+ |
if (trunced >= 0 && y >= trunced) { |
| 1039 |
+ |
bzero(scanline, xmax*sizeof(COLR)); |
| 1040 |
+ |
return(-1); |
| 1041 |
+ |
} |
| 1042 |
|
if (y != cury) { |
| 1043 |
|
if (scanpos == NULL || scanpos[y] == -1) |
| 1044 |
|
return(-1); |
| 1048 |
|
} else if (scanpos != NULL && scanpos[y] == -1) |
| 1049 |
|
scanpos[y] = ftell(fin); |
| 1050 |
|
|
| 1051 |
< |
if (freadcolrs(scanline, xmax, fin) < 0) |
| 1052 |
< |
quiterr("read error"); |
| 1053 |
< |
|
| 1051 |
> |
if (freadcolrs(scanline, xmax, fin) < 0) { |
| 1052 |
> |
fprintf(stderr, "%s: %s: unfinished picture\n", |
| 1053 |
> |
progname, fname==NULL?"<stdin>":fname); |
| 1054 |
> |
trunced = y; |
| 1055 |
> |
goto skipit; |
| 1056 |
> |
} |
| 1057 |
|
cury++; |
| 1058 |
|
return(0); |
| 1059 |
|
} |