45 |
|
{ |
46 |
|
FILE *input; |
47 |
|
int xres, yres; |
48 |
< |
COLOR scanline[NCOLS]; |
48 |
> |
COLR scanline[NCOLS]; |
49 |
|
int i; |
50 |
|
|
51 |
|
if (fname == NULL) { |
70 |
|
fputs("\0333\042", stdout); |
71 |
|
/* put out scanlines */ |
72 |
|
for (i = yres-1; i >= 0; i--) { |
73 |
< |
if (freadscan(scanline, xres, input) < 0) { |
73 |
> |
if (freadcolrs(scanline, xres, input) < 0) { |
74 |
|
fprintf(stderr, "%s: read error (y=%d)\n", fname, i); |
75 |
|
return(-1); |
76 |
|
} |
77 |
+ |
normcolrs(scanline, xres, 0); |
78 |
|
plotscan(scanline, xres, i); |
79 |
|
} |
80 |
|
/* advance page */ |
87 |
|
|
88 |
|
|
89 |
|
plotscan(scan, len, y) /* plot a scanline */ |
90 |
< |
COLOR scan[]; |
90 |
> |
COLR scan[]; |
91 |
|
int len; |
92 |
|
int y; |
93 |
|
{ |
126 |
|
|
127 |
|
|
128 |
|
colbit(col, x, s) /* determine bit value for primary at x */ |
129 |
< |
COLOR col; |
129 |
> |
COLR col; |
130 |
|
register int x; |
131 |
|
int s; |
132 |
|
{ |
133 |
< |
static float cerr[NCOLS][3]; |
134 |
< |
static double err[3]; |
135 |
< |
double b; |
133 |
> |
static int cerr[NCOLS][3]; |
134 |
> |
static int err[3]; |
135 |
> |
int b; |
136 |
|
register int a, ison; |
137 |
|
|
138 |
|
a = sub_add(s); /* use additive primary */ |
139 |
< |
b = colval(col,a); |
139 |
< |
if (b > 1.0) b = 1.0; |
139 |
> |
b = col[a]; |
140 |
|
err[a] += b + cerr[x][a]; |
141 |
< |
ison = err[a] < 0.5; |
142 |
< |
if (!ison) err[a] -= 1.0; |
143 |
< |
cerr[x][a] = err[a] *= 0.5; |
141 |
> |
ison = err[a] < 128; |
142 |
> |
if (!ison) err[a] -= 256; |
143 |
> |
cerr[x][a] = err[a] /= 2; |
144 |
|
return(ison); |
145 |
|
} |