1 |
– |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* oki20c.c - program to dump pixel file to OkiMate 20 color printer. |
9 |
– |
* |
10 |
– |
* 6/10/87 |
6 |
|
*/ |
7 |
|
|
8 |
|
#include <stdio.h> |
9 |
+ |
#include <time.h> |
10 |
|
|
11 |
+ |
#include "platform.h" |
12 |
+ |
#include "rtprocess.h" |
13 |
|
#include "color.h" |
14 |
|
#include "resolu.h" |
15 |
|
|
16 |
< |
#define NROWS 1440 /* 10" at 144 dpi */ |
17 |
< |
#define NCOLS 960 /* 8" at 120 dpi */ |
16 |
> |
#define NROWS 1440 /* 10" at 144 dpi */ |
17 |
> |
#define NCOLS 960 /* 8" at 120 dpi */ |
18 |
|
|
19 |
< |
#define ASPECT (120./144.) /* pixel aspect ratio */ |
19 |
> |
#define ASPECT (120./144.) /* pixel aspect ratio */ |
20 |
|
|
21 |
< |
#define FILTER "pfilt -1 -x %d -y %d -p %f %s",NCOLS,NROWS,ASPECT |
21 |
> |
#define FILTER "pfilt -1 -x %d -y %d -p %f %s",NCOLS,NROWS,ASPECT |
22 |
|
|
23 |
|
/* |
24 |
< |
* Subtractive primaries are ordered: Yellow, Magenta, Cyan. |
24 |
> |
* Subtractive primaries are ordered: Yellow, Magenta, Cyan. |
25 |
|
*/ |
26 |
|
|
27 |
< |
#define sub_add(sub) (2-(sub)) /* map subtractive to additive pri. */ |
27 |
> |
#define sub_add(sub) (2-(sub)) /* map subtractive to additive pri. */ |
28 |
|
|
31 |
– |
#ifdef BSD |
32 |
– |
#define clearlbuf() bzero((char *)lpat, sizeof(lpat)) |
33 |
– |
#else |
34 |
– |
#define clearlbuf() (void)memset((char *)lpat, 0, sizeof(lpat)) |
35 |
– |
#endif |
36 |
– |
|
29 |
|
long lpat[NCOLS][3]; |
30 |
|
|
31 |
|
int dofilter = 0; /* filter through pfilt first? */ |
36 |
|
char *argv[]; |
37 |
|
{ |
38 |
|
int i, status = 0; |
39 |
< |
|
39 |
> |
SET_DEFAULT_BINARY(); |
40 |
> |
SET_FILE_BINARY(stdin); |
41 |
> |
SET_FILE_BINARY(stdout); |
42 |
|
if (argc > 1 && !strcmp(argv[1], "-p")) { |
43 |
|
dofilter++; |
44 |
|
argv++; argc--; |
45 |
|
} |
52 |
– |
#ifdef _IOLBF |
53 |
– |
stdout->_flag &= ~_IOLBF; |
54 |
– |
#endif |
46 |
|
if (argc < 2) |
47 |
|
status = printp(NULL) == -1; |
48 |
|
else |
88 |
|
fprintf(stderr, "%s: bad picture size\n", fname); |
89 |
|
return(-1); |
90 |
|
} |
91 |
< |
if (xres > NCOLS || yres > NROWS) { |
91 |
> |
if (xres > NCOLS) { |
92 |
|
fprintf(stderr, "%s: resolution mismatch\n", fname); |
93 |
|
return(-1); |
94 |
|
} |
95 |
|
/* set line spacing (overlap for knitting) */ |
96 |
|
fputs("\0333\042", stdout); |
106 |
– |
/* clear line buffer */ |
107 |
– |
clearlbuf(); |
97 |
|
/* put out scanlines */ |
98 |
|
for (i = yres-1; i >= 0; i--) { |
99 |
|
if (freadcolrs(scanline, xres, input) < 0) { |
124 |
|
register long c; |
125 |
|
register int i, j; |
126 |
|
|
127 |
< |
if (bpos = y % 23) { |
127 |
> |
if ( (bpos = y % 23) ) { |
128 |
|
|
129 |
|
for (j = 0; j < 3; j++) |
130 |
|
for (i = 0; i < len; i++) |
131 |
|
lpat[i][j] |= (long)colbit(scan[i],i,j) << bpos; |
132 |
+ |
return; |
133 |
+ |
} |
134 |
+ |
fputs("\033\031", stdout); |
135 |
|
|
136 |
< |
} else { |
137 |
< |
|
138 |
< |
fputs("\033\031", stdout); |
139 |
< |
|
140 |
< |
for (j = 0; j < 3; j++) { |
141 |
< |
i = (NCOLS + len)/2; /* center image */ |
142 |
< |
fputs("\033%O", stdout); |
143 |
< |
putchar(i & 255); |
144 |
< |
putchar(i >> 8); |
145 |
< |
while (i-- > len) { |
146 |
< |
putchar(0); |
147 |
< |
putchar(0); |
148 |
< |
putchar(0); |
149 |
< |
} |
150 |
< |
for (i = 0; i < len; i++) { |
151 |
< |
c = lpat[i][j] | colbit(scan[i],i,j); |
160 |
< |
/* repeat this row */ |
136 |
> |
for (j = 0; j < 3; j++) { |
137 |
> |
i = (NCOLS + len)/2; /* center image */ |
138 |
> |
fputs("\033%O", stdout); |
139 |
> |
putchar(i & 255); |
140 |
> |
putchar(i >> 8); |
141 |
> |
while (i-- > len) { |
142 |
> |
putchar(0); |
143 |
> |
putchar(0); |
144 |
> |
putchar(0); |
145 |
> |
} |
146 |
> |
for (i = 0; i < len; i++) { |
147 |
> |
c = lpat[i][j] | colbit(scan[i],i,j); |
148 |
> |
putchar((int)(c>>16)); |
149 |
> |
putchar((int)(c>>8 & 255)); |
150 |
> |
putchar((int)(c & 255)); |
151 |
> |
if (y) /* repeat this row */ |
152 |
|
lpat[i][j] = (c & 1) << 23; |
153 |
< |
putchar(c>>16); |
154 |
< |
putchar(c>>8 & 255); |
164 |
< |
putchar(c & 255); |
165 |
< |
} |
166 |
< |
putchar('\r'); |
153 |
> |
else /* or clear for next image */ |
154 |
> |
lpat[i][j] = 0L; |
155 |
|
} |
156 |
< |
putchar('\n'); |
169 |
< |
fflush(stdout); |
156 |
> |
putchar('\r'); |
157 |
|
} |
158 |
+ |
putchar('\n'); |
159 |
+ |
fflush(stdout); |
160 |
|
} |
161 |
|
|
162 |
|
|