38 |
|
extern int getgifpix(); |
39 |
|
|
40 |
|
COLR *scanln; |
41 |
+ |
BYTE *pixscan; |
42 |
|
|
43 |
|
int xmax, ymax; /* picture size */ |
44 |
|
|
46 |
|
|
47 |
|
int greyscale = 0; /* convert to B&W? */ |
48 |
|
|
49 |
+ |
int dither = 1; /* dither colors? */ |
50 |
+ |
|
51 |
|
int bradj = 0; /* brightness adjustment */ |
52 |
|
|
53 |
|
char *progname; |
77 |
|
case 'b': |
78 |
|
greyscale = 1; |
79 |
|
break; |
80 |
+ |
case 'd': |
81 |
+ |
dither = !dither; |
82 |
+ |
break; |
83 |
|
case 'c': |
84 |
|
ncolors = atoi(argv[++i]); |
85 |
|
break; |
155 |
|
if (freadcolrs(scanln, xmax, stdin) < 0) { |
156 |
|
fprintf(stderr, "%s: error reading picture (y==%d)\n", |
157 |
|
progname, ymax-1-y); |
158 |
+ |
exit(1); |
159 |
|
} |
160 |
|
while (++currow < y); |
161 |
|
if (bradj) |
162 |
|
shiftcolrs(scanln, xmax, bradj); |
163 |
|
colrs_gambs(scanln, xmax); |
164 |
+ |
if (pixscan != NULL) |
165 |
+ |
dith_colrs(pixscan, scanln, xmax); |
166 |
|
} |
167 |
|
|
168 |
|
|
182 |
|
gmap[i] = clrtab[i][GRN]; |
183 |
|
bmap[i] = clrtab[i][BLU]; |
184 |
|
} |
185 |
+ |
if (dither && (pixscan = (BYTE *)malloc(xmax)) == NULL) { |
186 |
+ |
fprintf(stderr, "%s: out of memory\n", progname); |
187 |
+ |
exit(1); |
188 |
+ |
} |
189 |
|
} |
190 |
|
|
191 |
|
|
211 |
|
getrow(y); |
212 |
|
if (greyscale) |
213 |
|
return(normbright(scanln[x])); |
214 |
+ |
if (pixscan != NULL) |
215 |
+ |
return(pixscan[x]); |
216 |
|
return(map_pixel(scanln[x])); |
217 |
|
} |
218 |
|
|