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 |
|
} |
72 |
+ |
normcolrs(scanline, xres); |
73 |
|
plotscan(scanline, xres, i); |
74 |
|
} |
75 |
|
|
82 |
|
|
83 |
|
|
84 |
|
plotscan(scan, len, y) /* plot a scanline */ |
85 |
< |
COLOR scan[]; |
85 |
> |
COLR scan[]; |
86 |
|
int len; |
87 |
|
int y; |
88 |
|
{ |
112 |
|
} |
113 |
|
|
114 |
|
|
115 |
< |
bit(col, x) /* return bit for color at x */ |
116 |
< |
COLOR col; |
115 |
> |
bit(clr, x) /* return bit for color at x */ |
116 |
> |
COLR clr; |
117 |
|
register int x; |
118 |
|
{ |
119 |
< |
static float cerr[NCOLS]; |
120 |
< |
static double err; |
121 |
< |
double b; |
119 |
> |
static int cerr[NCOLS]; |
120 |
> |
static int err; |
121 |
> |
int b; |
122 |
|
register int isblack; |
123 |
|
|
124 |
< |
b = bright(col); |
124 |
< |
if (b > 1.0) b = 1.0; |
124 |
> |
b = normbright(clr); |
125 |
|
err += b + cerr[x]; |
126 |
< |
isblack = err < 0.5; |
127 |
< |
if (!isblack) err -= 1.0; |
128 |
< |
cerr[x] = err *= 0.5; |
126 |
> |
isblack = err < 128; |
127 |
> |
if (!isblack) err -= 256; |
128 |
> |
cerr[x] = err /= 2; |
129 |
|
return(isblack); |
130 |
|
} |