1 |
< |
/* Copyright (c) 1991 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
6 |
|
|
7 |
|
/* |
8 |
|
* oki20c.c - program to dump pixel file to OkiMate 20 color printer. |
9 |
– |
* |
10 |
– |
* 6/10/87 |
9 |
|
*/ |
10 |
|
|
11 |
|
#include <stdio.h> |
12 |
+ |
#ifdef MSDOS |
13 |
+ |
#include <fcntl.h> |
14 |
+ |
#endif |
15 |
|
|
16 |
|
#include "color.h" |
17 |
|
#include "resolu.h" |
18 |
|
|
19 |
< |
#define NROWS 1440 /* 10" at 144 dpi */ |
20 |
< |
#define NCOLS 960 /* 8" at 120 dpi */ |
19 |
> |
#define NROWS 1440 /* 10" at 144 dpi */ |
20 |
> |
#define NCOLS 960 /* 8" at 120 dpi */ |
21 |
|
|
22 |
< |
#define ASPECT (120./144.) /* pixel aspect ratio */ |
22 |
> |
#define ASPECT (120./144.) /* pixel aspect ratio */ |
23 |
|
|
24 |
< |
#define FILTER "pfilt -1 -x %d -y %d -p %f %s",NCOLS,NROWS,ASPECT |
24 |
> |
#define FILTER "pfilt -1 -x %d -y %d -p %f %s",NCOLS,NROWS,ASPECT |
25 |
|
|
26 |
|
/* |
27 |
< |
* Subtractive primaries are ordered: Yellow, Magenta, Cyan. |
27 |
> |
* Subtractive primaries are ordered: Yellow, Magenta, Cyan. |
28 |
|
*/ |
29 |
|
|
30 |
< |
#define sub_add(sub) (2-(sub)) /* map subtractive to additive pri. */ |
30 |
> |
#define sub_add(sub) (2-(sub)) /* map subtractive to additive pri. */ |
31 |
|
|
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 |
– |
|
32 |
|
long lpat[NCOLS][3]; |
33 |
|
|
34 |
|
int dofilter = 0; /* filter through pfilt first? */ |
35 |
|
|
36 |
+ |
extern FILE *popen(); |
37 |
|
|
38 |
+ |
|
39 |
|
main(argc, argv) |
40 |
|
int argc; |
41 |
|
char *argv[]; |
42 |
|
{ |
43 |
|
int i, status = 0; |
44 |
< |
|
44 |
> |
#ifdef MSDOS |
45 |
> |
extern int _fmode; |
46 |
> |
_fmode = O_BINARY; |
47 |
> |
setmode(fileno(stdin), O_BINARY); |
48 |
> |
setmode(fileno(stdout), O_BINARY); |
49 |
> |
#endif |
50 |
|
if (argc > 1 && !strcmp(argv[1], "-p")) { |
51 |
|
dofilter++; |
52 |
|
argv++; argc--; |
105 |
|
} |
106 |
|
/* set line spacing (overlap for knitting) */ |
107 |
|
fputs("\0333\042", stdout); |
106 |
– |
/* clear line buffer */ |
107 |
– |
clearlbuf(); |
108 |
|
/* put out scanlines */ |
109 |
|
for (i = yres-1; i >= 0; i--) { |
110 |
|
if (freadcolrs(scanline, xres, input) < 0) { |
140 |
|
for (j = 0; j < 3; j++) |
141 |
|
for (i = 0; i < len; i++) |
142 |
|
lpat[i][j] |= (long)colbit(scan[i],i,j) << bpos; |
143 |
+ |
return; |
144 |
+ |
} |
145 |
+ |
fputs("\033\031", stdout); |
146 |
|
|
147 |
< |
} else { |
148 |
< |
|
149 |
< |
fputs("\033\031", stdout); |
150 |
< |
|
151 |
< |
for (j = 0; j < 3; j++) { |
152 |
< |
i = (NCOLS + len)/2; /* center image */ |
153 |
< |
fputs("\033%O", stdout); |
154 |
< |
putchar(i & 255); |
155 |
< |
putchar(i >> 8); |
156 |
< |
while (i-- > len) { |
157 |
< |
putchar(0); |
158 |
< |
putchar(0); |
159 |
< |
putchar(0); |
160 |
< |
} |
161 |
< |
for (i = 0; i < len; i++) { |
162 |
< |
c = lpat[i][j] | colbit(scan[i],i,j); |
160 |
< |
/* repeat this row */ |
147 |
> |
for (j = 0; j < 3; j++) { |
148 |
> |
i = (NCOLS + len)/2; /* center image */ |
149 |
> |
fputs("\033%O", stdout); |
150 |
> |
putchar(i & 255); |
151 |
> |
putchar(i >> 8); |
152 |
> |
while (i-- > len) { |
153 |
> |
putchar(0); |
154 |
> |
putchar(0); |
155 |
> |
putchar(0); |
156 |
> |
} |
157 |
> |
for (i = 0; i < len; i++) { |
158 |
> |
c = lpat[i][j] | colbit(scan[i],i,j); |
159 |
> |
putchar((int)(c>>16)); |
160 |
> |
putchar((int)(c>>8 & 255)); |
161 |
> |
putchar((int)(c & 255)); |
162 |
> |
if (y) /* repeat this row */ |
163 |
|
lpat[i][j] = (c & 1) << 23; |
164 |
< |
putchar(c>>16); |
165 |
< |
putchar(c>>8 & 255); |
164 |
< |
putchar(c & 255); |
165 |
< |
} |
166 |
< |
putchar('\r'); |
164 |
> |
else /* or clear for next image */ |
165 |
> |
lpat[i][j] = 0L; |
166 |
|
} |
167 |
< |
putchar('\n'); |
169 |
< |
fflush(stdout); |
167 |
> |
putchar('\r'); |
168 |
|
} |
169 |
+ |
putchar('\n'); |
170 |
+ |
fflush(stdout); |
171 |
|
} |
172 |
|
|
173 |
|
|