--- ray/src/px/oki20c.c 1992/04/18 09:10:53 2.6 +++ ray/src/px/oki20c.c 2003/10/27 10:24:51 2.14 @@ -1,39 +1,31 @@ -/* Copyright (c) 1991 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: oki20c.c,v 2.14 2003/10/27 10:24:51 schorsch Exp $"; #endif - /* * oki20c.c - program to dump pixel file to OkiMate 20 color printer. - * - * 6/10/87 */ #include +#include +#include "platform.h" +#include "rtprocess.h" #include "color.h" #include "resolu.h" -#define NROWS 1440 /* 10" at 144 dpi */ -#define NCOLS 960 /* 8" at 120 dpi */ +#define NROWS 1440 /* 10" at 144 dpi */ +#define NCOLS 960 /* 8" at 120 dpi */ -#define ASPECT (120./144.) /* pixel aspect ratio */ +#define ASPECT (120./144.) /* pixel aspect ratio */ -#define FILTER "pfilt -1 -x %d -y %d -p %f %s",NCOLS,NROWS,ASPECT +#define FILTER "pfilt -1 -x %d -y %d -p %f %s",NCOLS,NROWS,ASPECT /* - * Subtractive primaries are ordered: Yellow, Magenta, Cyan. + * Subtractive primaries are ordered: Yellow, Magenta, Cyan. */ -#define sub_add(sub) (2-(sub)) /* map subtractive to additive pri. */ +#define sub_add(sub) (2-(sub)) /* map subtractive to additive pri. */ -#ifdef BSD -#define clearlbuf() bzero((char *)lpat, sizeof(lpat)) -#else -#define clearlbuf() (void)memset((char *)lpat, 0, sizeof(lpat)) -#endif - long lpat[NCOLS][3]; int dofilter = 0; /* filter through pfilt first? */ @@ -44,14 +36,13 @@ int argc; char *argv[]; { int i, status = 0; - + SET_DEFAULT_BINARY(); + SET_FILE_BINARY(stdin); + SET_FILE_BINARY(stdout); if (argc > 1 && !strcmp(argv[1], "-p")) { dofilter++; argv++; argc--; } -#ifdef _IOLBF - stdout->_flag &= ~_IOLBF; -#endif if (argc < 2) status = printp(NULL) == -1; else @@ -97,14 +88,12 @@ char *fname; fprintf(stderr, "%s: bad picture size\n", fname); return(-1); } - if (xres > NCOLS || yres > NROWS) { + if (xres > NCOLS) { fprintf(stderr, "%s: resolution mismatch\n", fname); return(-1); } /* set line spacing (overlap for knitting) */ fputs("\0333\042", stdout); - /* clear line buffer */ - clearlbuf(); /* put out scanlines */ for (i = yres-1; i >= 0; i--) { if (freadcolrs(scanline, xres, input) < 0) { @@ -135,39 +124,39 @@ int y; register long c; register int i, j; - if (bpos = y % 23) { + if ( (bpos = y % 23) ) { for (j = 0; j < 3; j++) for (i = 0; i < len; i++) lpat[i][j] |= (long)colbit(scan[i],i,j) << bpos; + return; + } + fputs("\033\031", stdout); - } else { - - fputs("\033\031", stdout); - - for (j = 0; j < 3; j++) { - i = (NCOLS + len)/2; /* center image */ - fputs("\033%O", stdout); - putchar(i & 255); - putchar(i >> 8); - while (i-- > len) { - putchar(0); - putchar(0); - putchar(0); - } - for (i = 0; i < len; i++) { - c = lpat[i][j] | colbit(scan[i],i,j); - /* repeat this row */ + for (j = 0; j < 3; j++) { + i = (NCOLS + len)/2; /* center image */ + fputs("\033%O", stdout); + putchar(i & 255); + putchar(i >> 8); + while (i-- > len) { + putchar(0); + putchar(0); + putchar(0); + } + for (i = 0; i < len; i++) { + c = lpat[i][j] | colbit(scan[i],i,j); + putchar((int)(c>>16)); + putchar((int)(c>>8 & 255)); + putchar((int)(c & 255)); + if (y) /* repeat this row */ lpat[i][j] = (c & 1) << 23; - putchar(c>>16); - putchar(c>>8 & 255); - putchar(c & 255); - } - putchar('\r'); + else /* or clear for next image */ + lpat[i][j] = 0L; } - putchar('\n'); - fflush(stdout); + putchar('\r'); } + putchar('\n'); + fflush(stdout); }