39 |
|
FILE *input; |
40 |
|
int xres, yres; |
41 |
|
COLR scanline[NCOLS]; |
42 |
– |
char sbuf[256]; |
42 |
|
int i; |
43 |
|
|
44 |
|
if (fname == NULL) { |
49 |
|
return(-1); |
50 |
|
} |
51 |
|
/* discard header */ |
52 |
< |
while (fgets(sbuf, sizeof(sbuf), input) != NULL && sbuf[0] != '\n') |
54 |
< |
; |
52 |
> |
getheader(input, NULL); |
53 |
|
/* get picture dimensions */ |
54 |
|
if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) { |
55 |
|
fprintf(stderr, "%s: bad picture size\n", fname); |
67 |
|
fprintf(stderr, "%s: read error (y=%d)\n", fname, i); |
68 |
|
return(-1); |
69 |
|
} |
70 |
+ |
normcolrs(scanline, xres); |
71 |
|
plotscan(scanline, xres, i); |
72 |
|
} |
73 |
|
|
116 |
|
{ |
117 |
|
static int cerr[NCOLS]; |
118 |
|
static int err; |
120 |
– |
COLR nclr; |
119 |
|
int b; |
120 |
|
register int isblack; |
121 |
|
|
122 |
< |
colr_norm(clr, nclr); |
125 |
< |
b = norm_bright(nclr); |
122 |
> |
b = normbright(clr); |
123 |
|
err += b + cerr[x]; |
124 |
|
isblack = err < 128; |
125 |
|
if (!isblack) err -= 256; |