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 |
+ |
normcolrs(scanline, xres, 0); |
71 |
|
plotscan(scanline, xres, i); |
72 |
|
} |
73 |
|
|
80 |
|
|
81 |
|
|
82 |
|
plotscan(scan, len, y) /* plot a scanline */ |
83 |
< |
COLOR scan[]; |
83 |
> |
COLR scan[]; |
84 |
|
int len; |
85 |
|
int y; |
86 |
|
{ |
104 |
|
|
105 |
|
|
106 |
|
colbit(col, x, a) /* determine bit value for primary at x */ |
107 |
< |
COLOR col; |
107 |
> |
COLR col; |
108 |
|
register int x; |
109 |
|
register int a; |
110 |
|
{ |
111 |
< |
static float cerr[NCOLS][3]; |
112 |
< |
static double err[3]; |
113 |
< |
double b; |
111 |
> |
static int cerr[NCOLS][3]; |
112 |
> |
static int err[3]; |
113 |
> |
int b; |
114 |
|
register int ison; |
115 |
|
|
116 |
< |
b = colval(col,a); |
116 |
< |
if (b > 1.0) b = 1.0; |
116 |
> |
b = col[a]; |
117 |
|
err[a] += b + cerr[x][a]; |
118 |
< |
ison = err[a] > 0.5; |
119 |
< |
if (ison) err[a] -= 1.0; |
120 |
< |
cerr[x][a] = err[a] *= 0.5; |
118 |
> |
ison = err[a] > 128; |
119 |
> |
if (ison) err[a] -= 256; |
120 |
> |
cerr[x][a] = err[a] /= 2; |
121 |
|
return(ison); |
122 |
|
} |