38 |
|
{ |
39 |
|
FILE *input; |
40 |
|
int xres, yres; |
41 |
< |
COLOR scanline[NCOLS]; |
41 |
> |
COLR scanline[NCOLS]; |
42 |
|
char sbuf[256]; |
43 |
|
int i; |
44 |
|
|
65 |
|
fputs("\033[6~\033[7z", stdout); |
66 |
|
|
67 |
|
for (i = yres-1; i >= 0; i--) { |
68 |
< |
if (freadscan(scanline, xres, input) < 0) { |
68 |
> |
if (freadcolrs(scanline, xres, input) < 0) { |
69 |
|
fprintf(stderr, "%s: read error (y=%d)\n", fname, i); |
70 |
|
return(-1); |
71 |
|
} |
81 |
|
|
82 |
|
|
83 |
|
plotscan(scan, len, y) /* plot a scanline */ |
84 |
< |
COLOR scan[]; |
84 |
> |
COLR scan[]; |
85 |
|
int len; |
86 |
|
int y; |
87 |
|
{ |
111 |
|
} |
112 |
|
|
113 |
|
|
114 |
< |
bit(col, x) /* return bit for color at x */ |
115 |
< |
COLOR col; |
114 |
> |
bit(clr, x) /* return bit for color at x */ |
115 |
> |
COLR clr; |
116 |
|
register int x; |
117 |
|
{ |
118 |
< |
static float cerr[NCOLS]; |
119 |
< |
static double err; |
120 |
< |
double b; |
118 |
> |
static int cerr[NCOLS]; |
119 |
> |
static int err; |
120 |
> |
COLR nclr; |
121 |
> |
int b; |
122 |
|
register int isblack; |
123 |
|
|
124 |
< |
b = bright(col); |
125 |
< |
if (b > 1.0) b = 1.0; |
124 |
> |
colr_norm(clr, nclr); |
125 |
> |
b = norm_bright(nclr); |
126 |
|
err += b + cerr[x]; |
127 |
< |
isblack = err < 0.5; |
128 |
< |
if (!isblack) err -= 1.0; |
129 |
< |
cerr[x] = err *= 0.5; |
127 |
> |
isblack = err < 128; |
128 |
> |
if (!isblack) err -= 256; |
129 |
> |
cerr[x] = err /= 2; |
130 |
|
return(isblack); |
131 |
|
} |