24 |
|
double pixaspect = 1.0; /* pixel aspect ratio */ |
25 |
|
|
26 |
|
int bradj = 0; /* brightness adjustment */ |
27 |
+ |
int ncopies = 1; /* number of copies */ |
28 |
|
|
29 |
|
char *progname; |
30 |
|
|
60 |
|
goto userr; |
61 |
|
bradj = atoi(argv[++i]); |
62 |
|
break; |
63 |
+ |
case 'n': /* number of copies */ |
64 |
+ |
ncopies = atoi(argv[++i]); |
65 |
+ |
break; |
66 |
|
default: |
67 |
|
goto userr; |
68 |
|
} |
119 |
|
printf("%%!\n"); |
120 |
|
printf("%%%%Title: %s\n", name); |
121 |
|
printf("%%%%Creator: %s\n", progname); |
122 |
< |
printf("%%%%Pages: 1\n"); |
122 |
> |
printf("%%%%Pages: %d\n", ncopies); |
123 |
|
if (landscape = xmax > pixaspect*ymax) |
124 |
|
printf("%%%%Landscape\n"); |
125 |
|
else |
126 |
|
printf("%%%%Portrait\n"); |
127 |
|
printf("%%%%EndComments\n"); |
124 |
– |
printf("gsave\n"); |
128 |
|
printf("64 dict begin\n"); |
129 |
|
/* define image reader */ |
130 |
|
PSprocdef("read6bit"); |
158 |
|
PStrailer() /* print PostScript trailer */ |
159 |
|
{ |
160 |
|
puts("%%Trailer"); |
161 |
< |
puts("end"); |
161 |
> |
if (ncopies > 1) |
162 |
> |
printf("/#copies %d def\n", ncopies); |
163 |
|
puts("showpage"); |
164 |
< |
puts("grestore"); |
164 |
> |
puts("end"); |
165 |
|
puts("%%EOF"); |
166 |
|
} |
167 |
|
|
171 |
|
{ |
172 |
|
short itab[128]; |
173 |
|
register int i; |
174 |
< |
|
175 |
< |
for (i = 0; i < 128; i++) |
174 |
> |
/* assign code values */ |
175 |
> |
for (i = 0; i < 128; i++) /* clear */ |
176 |
|
itab[i] = -1; |
177 |
< |
for (i = 0; i < 64; i++) |
177 |
> |
for (i = 1; i < 63; i++) /* assign greys */ |
178 |
|
itab[code[i]] = i<<2 | 2; |
179 |
+ |
itab[code[0]] = 0; /* black is black */ |
180 |
+ |
itab[code[63]] = 255; /* and white is white */ |
181 |
|
printf("/decode ["); |
182 |
|
for (i = 0; i < 128; i++) { |
183 |
|
if (!(i & 0xf)) |