37 |
|
{ |
38 |
|
FILE *input; |
39 |
|
int xres, yres; |
40 |
< |
COLOR scanline[NCOLS]; |
40 |
> |
COLR scanline[NCOLS]; |
41 |
|
int i; |
42 |
|
|
43 |
|
if (fname == NULL) { |
65 |
|
((NCOLS-xres)>>4)<<5, xres); |
66 |
|
|
67 |
|
for (i = yres-1; i >= 0; i--) { |
68 |
< |
if (freadscan(scanline, xres, input) < 0) |
68 |
> |
if (freadcolrs(scanline, xres, input) < 0) |
69 |
|
return(-1); |
70 |
+ |
normscan(scanline, xres); |
71 |
|
plotscan(scanline, xres, i); |
72 |
|
} |
73 |
|
|
79 |
|
} |
80 |
|
|
81 |
|
|
82 |
+ |
normscan(scan, len) /* normalize a scanline */ |
83 |
+ |
register COLR scan[]; |
84 |
+ |
int len; |
85 |
+ |
{ |
86 |
+ |
register int i; |
87 |
+ |
|
88 |
+ |
for (i = 0; i < len; i++) |
89 |
+ |
colr_norm(scan[i], scan[i]); |
90 |
+ |
} |
91 |
+ |
|
92 |
+ |
|
93 |
|
plotscan(scan, len, y) /* plot a scanline */ |
94 |
< |
COLOR scan[]; |
94 |
> |
COLR scan[]; |
95 |
|
int len; |
96 |
|
int y; |
97 |
|
{ |
115 |
|
|
116 |
|
|
117 |
|
colbit(col, x, a) /* determine bit value for primary at x */ |
118 |
< |
COLOR col; |
118 |
> |
COLR col; |
119 |
|
register int x; |
120 |
|
register int a; |
121 |
|
{ |
122 |
< |
static float cerr[NCOLS][3]; |
123 |
< |
static double err[3]; |
124 |
< |
double b; |
122 |
> |
static int cerr[NCOLS][3]; |
123 |
> |
static int err[3]; |
124 |
> |
int b; |
125 |
|
register int ison; |
126 |
|
|
127 |
< |
b = colval(col,a); |
116 |
< |
if (b > 1.0) b = 1.0; |
127 |
> |
b = col[a]; |
128 |
|
err[a] += b + cerr[x][a]; |
129 |
< |
ison = err[a] > 0.5; |
130 |
< |
if (ison) err[a] -= 1.0; |
131 |
< |
cerr[x][a] = err[a] *= 0.5; |
129 |
> |
ison = err[a] > 128; |
130 |
> |
if (ison) err[a] -= 256; |
131 |
> |
cerr[x][a] = err[a] /= 2; |
132 |
|
return(ison); |
133 |
|
} |