--- ray/src/px/oki20c.c 1989/09/12 13:04:20 1.2 +++ ray/src/px/oki20c.c 1989/10/20 20:36:02 1.7 @@ -45,7 +45,7 @@ char *fname; { FILE *input; int xres, yres; - COLOR scanline[NCOLS]; + COLR scanline[NCOLS]; int i; if (fname == NULL) { @@ -66,17 +66,18 @@ char *fname; fprintf(stderr, "%s: resolution mismatch\n", fname); return(-1); } - - fputs("\033A\014\0332", stdout); - + /* set line spacing (overlap for knitting) */ + fputs("\0333\042", stdout); + /* put out scanlines */ for (i = yres-1; i >= 0; i--) { - if (freadscan(scanline, xres, input) < 0) { + if (freadcolrs(scanline, xres, input) < 0) { fprintf(stderr, "%s: read error (y=%d)\n", fname, i); return(-1); } + normcolrs(scanline, xres); plotscan(scanline, xres, i); } - + /* advance page */ putchar('\f'); fclose(input); @@ -86,7 +87,7 @@ char *fname; plotscan(scan, len, y) /* plot a scanline */ -COLOR scan[]; +COLR scan[]; int len; int y; { @@ -95,7 +96,7 @@ int y; register long c; register int i, j; - if (bpos = y % 24) { + if (bpos = y % 23) { for (j = 0; j < 3; j++) for (i = 0; i < len; i++) @@ -111,7 +112,8 @@ int y; putchar(len >> 8); for (i = 0; i < len; i++) { c = pat[i][j] | colbit(scan[i],i,j); - pat[i][j] = 0; + /* repeat this row */ + pat[i][j] = (c & 1) << 23; putchar(c>>16); putchar(c>>8 & 255); putchar(c & 255); @@ -124,21 +126,20 @@ int y; colbit(col, x, s) /* determine bit value for primary at x */ -COLOR col; +COLR col; register int x; int s; { - static float cerr[NCOLS][3]; - static double err[3]; - double b; + static int cerr[NCOLS][3]; + static int err[3]; + int b; register int a, ison; a = sub_add(s); /* use additive primary */ - b = colval(col,a); - if (b > 1.0) b = 1.0; + b = col[a]; err[a] += b + cerr[x][a]; - ison = err[a] < 0.5; - if (!ison) err[a] -= 1.0; - cerr[x][a] = err[a] *= 0.5; + ison = err[a] < 128; + if (!ison) err[a] -= 256; + cerr[x][a] = err[a] /= 2; return(ison); }