| 33 |
|
|
| 34 |
|
long picstart; |
| 35 |
|
|
| 36 |
< |
extern BYTE clrtab[][3]; |
| 36 |
> |
BYTE clrtab[256][3]; |
| 37 |
|
|
| 38 |
+ |
extern int samplefac; |
| 39 |
+ |
|
| 40 |
|
extern int getgifpix(); |
| 41 |
|
|
| 42 |
|
COLR *scanln; |
| 69 |
|
setmode(fileno(stdout), O_BINARY); |
| 70 |
|
#endif |
| 71 |
|
progname = argv[0]; |
| 72 |
+ |
samplefac = 0; |
| 73 |
|
|
| 74 |
|
for (i = 1; i < argc; i++) |
| 75 |
|
if (argv[i][0] == '-') |
| 91 |
|
goto userr; |
| 92 |
|
bradj = atoi(argv[++i]); |
| 93 |
|
break; |
| 94 |
+ |
case 'n': |
| 95 |
+ |
samplefac = atoi(argv[++i]); |
| 96 |
+ |
break; |
| 97 |
|
default: |
| 98 |
|
goto userr; |
| 99 |
|
} |
| 161 |
|
if (freadcolrs(scanln, xmax, stdin) < 0) { |
| 162 |
|
fprintf(stderr, "%s: error reading picture (y==%d)\n", |
| 163 |
|
progname, ymax-1-y); |
| 164 |
+ |
exit(1); |
| 165 |
|
} |
| 166 |
|
while (++currow < y); |
| 167 |
|
if (bradj) |
| 168 |
|
shiftcolrs(scanln, xmax, bradj); |
| 169 |
|
colrs_gambs(scanln, xmax); |
| 170 |
|
if (pixscan != NULL) |
| 171 |
< |
dith_colrs(pixscan, scanln, xmax); |
| 171 |
> |
if (samplefac) |
| 172 |
> |
neu_dith_colrs(pixscan, scanln, xmax); |
| 173 |
> |
else |
| 174 |
> |
dith_colrs(pixscan, scanln, xmax); |
| 175 |
|
} |
| 176 |
|
|
| 177 |
|
|
| 180 |
|
{ |
| 181 |
|
register int i; |
| 182 |
|
|
| 183 |
< |
new_histo(); |
| 183 |
> |
if ((samplefac ? neu_init(xmax*ymax) : new_histo(xmax*ymax)) == -1) |
| 184 |
> |
goto memerr; |
| 185 |
|
for (i = 0; i < ymax; i++) { |
| 186 |
|
getrow(i); |
| 187 |
< |
cnt_colrs(scanln, xmax); |
| 187 |
> |
if (samplefac) |
| 188 |
> |
neu_colrs(scanln, xmax); |
| 189 |
> |
else |
| 190 |
> |
cnt_colrs(scanln, xmax); |
| 191 |
|
} |
| 192 |
< |
new_clrtab(nc); |
| 192 |
> |
if (samplefac) |
| 193 |
> |
neu_clrtab(nc); |
| 194 |
> |
else |
| 195 |
> |
new_clrtab(nc); |
| 196 |
|
for (i = 0; i < nc; i++) { |
| 197 |
|
rmap[i] = clrtab[i][RED]; |
| 198 |
|
gmap[i] = clrtab[i][GRN]; |
| 199 |
|
bmap[i] = clrtab[i][BLU]; |
| 200 |
|
} |
| 201 |
< |
if (dither && (pixscan = (BYTE *)malloc(xmax)) == NULL) { |
| 202 |
< |
fprintf(stderr, "%s: out of memory\n", progname); |
| 203 |
< |
exit(1); |
| 204 |
< |
} |
| 201 |
> |
if (dither && (pixscan = (BYTE *)malloc(xmax)) == NULL) |
| 202 |
> |
goto memerr; |
| 203 |
> |
return; |
| 204 |
> |
memerr: |
| 205 |
> |
fprintf(stderr, "%s: out of memory\n", progname); |
| 206 |
> |
exit(1); |
| 207 |
|
} |
| 208 |
|
|
| 209 |
|
|
| 231 |
|
return(normbright(scanln[x])); |
| 232 |
|
if (pixscan != NULL) |
| 233 |
|
return(pixscan[x]); |
| 234 |
< |
return(map_pixel(scanln[x])); |
| 234 |
> |
return(samplefac ? neu_map_pixel(scanln[x]) : map_pixel(scanln[x])); |
| 235 |
|
} |
| 236 |
|
|
| 237 |
|
|