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 |
+ |
normscan(scanline, xres); |
78 |
|
plotscan(scanline, xres, i); |
79 |
|
} |
80 |
|
/* advance page */ |
86 |
|
} |
87 |
|
|
88 |
|
|
89 |
+ |
normscan(scan, len) /* normalize a scanline */ |
90 |
+ |
register COLR scan[]; |
91 |
+ |
int len; |
92 |
+ |
{ |
93 |
+ |
register int i; |
94 |
+ |
|
95 |
+ |
for (i = 0; i < len; i++) |
96 |
+ |
colr_norm(scan[i], scan[i]); |
97 |
+ |
} |
98 |
+ |
|
99 |
+ |
|
100 |
|
plotscan(scan, len, y) /* plot a scanline */ |
101 |
< |
COLOR scan[]; |
101 |
> |
COLR scan[]; |
102 |
|
int len; |
103 |
|
int y; |
104 |
|
{ |
137 |
|
|
138 |
|
|
139 |
|
colbit(col, x, s) /* determine bit value for primary at x */ |
140 |
< |
COLOR col; |
140 |
> |
COLR col; |
141 |
|
register int x; |
142 |
|
int s; |
143 |
|
{ |
144 |
< |
static float cerr[NCOLS][3]; |
145 |
< |
static double err[3]; |
146 |
< |
double b; |
144 |
> |
static int cerr[NCOLS][3]; |
145 |
> |
static int err[3]; |
146 |
> |
int b; |
147 |
|
register int a, ison; |
148 |
|
|
149 |
|
a = sub_add(s); /* use additive primary */ |
150 |
< |
b = colval(col,a); |
139 |
< |
if (b > 1.0) b = 1.0; |
150 |
> |
b = col[a]; |
151 |
|
err[a] += b + cerr[x][a]; |
152 |
< |
ison = err[a] < 0.5; |
153 |
< |
if (!ison) err[a] -= 1.0; |
154 |
< |
cerr[x][a] = err[a] *= 0.5; |
152 |
> |
ison = err[a] < 128; |
153 |
> |
if (!ison) err[a] -= 256; |
154 |
> |
cerr[x][a] = err[a] /= 2; |
155 |
|
return(ison); |
156 |
|
} |