1 |
– |
/* Copyright (c) 1989 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 |
|
* paintjet.c - program to dump pixel file to HP PaintJet color printer. |
6 |
|
* |
8 |
|
*/ |
9 |
|
|
10 |
|
#include <stdio.h> |
11 |
+ |
#include <time.h> |
12 |
|
|
13 |
+ |
#include "platform.h" |
14 |
|
#include "color.h" |
15 |
+ |
#include "resolu.h" |
16 |
|
|
17 |
< |
#define NCOLS 1440 /* 8" at 180 dpi */ |
17 |
> |
#define NCOLS 1440 /* 8" at 180 dpi */ |
18 |
|
|
19 |
+ |
static int printp(char *fname); |
20 |
+ |
static void plotscan(COLR scan[], int len, int y); |
21 |
+ |
static int colbit(COLR col, int x, int a); |
22 |
|
|
23 |
< |
main(argc, argv) |
24 |
< |
int argc; |
25 |
< |
char *argv[]; |
23 |
> |
|
24 |
> |
int |
25 |
> |
main( |
26 |
> |
int argc, |
27 |
> |
char *argv[] |
28 |
> |
) |
29 |
|
{ |
30 |
|
int i, status = 0; |
31 |
< |
|
31 |
> |
SET_DEFAULT_BINARY(); |
32 |
> |
SET_FILE_BINARY(stdin); |
33 |
> |
SET_FILE_BINARY(stdout); |
34 |
|
if (argc < 2) |
35 |
|
status = printp(NULL) == -1; |
36 |
|
else |
40 |
|
} |
41 |
|
|
42 |
|
|
43 |
< |
printp(fname) /* print a picture */ |
44 |
< |
char *fname; |
43 |
> |
static int |
44 |
> |
printp( /* print a picture */ |
45 |
> |
char *fname |
46 |
> |
) |
47 |
|
{ |
48 |
|
FILE *input; |
49 |
|
int xres, yres; |
63 |
|
return(-1); |
64 |
|
} |
65 |
|
/* get picture dimensions */ |
66 |
< |
if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) { |
66 |
> |
if (fgetresolu(&xres, &yres, input) < 0) { |
67 |
|
fprintf(stderr, "%s: bad picture size\n", fname); |
68 |
|
return(-1); |
69 |
|
} |
92 |
|
} |
93 |
|
|
94 |
|
|
95 |
< |
plotscan(scan, len, y) /* plot a scanline */ |
96 |
< |
COLR scan[]; |
97 |
< |
int len; |
98 |
< |
int y; |
95 |
> |
static void |
96 |
> |
plotscan( /* plot a scanline */ |
97 |
> |
COLR scan[], |
98 |
> |
int len, |
99 |
> |
int y |
100 |
> |
) |
101 |
|
{ |
102 |
|
int c; |
103 |
|
register int x, b; |
118 |
|
} |
119 |
|
|
120 |
|
|
121 |
< |
colbit(col, x, a) /* determine bit value for primary at x */ |
122 |
< |
COLR col; |
123 |
< |
register int x; |
124 |
< |
register int a; |
121 |
> |
static int |
122 |
> |
colbit( /* determine bit value for primary at x */ |
123 |
> |
COLR col, |
124 |
> |
register int x, |
125 |
> |
register int a |
126 |
> |
) |
127 |
|
{ |
128 |
|
static int cerr[NCOLS][3]; |
129 |
|
static int err[3]; |
130 |
< |
int b; |
130 |
> |
int b, errp; |
131 |
|
register int ison; |
132 |
|
|
133 |
|
b = col[a]; |
134 |
+ |
errp = err[a]; |
135 |
|
err[a] += b + cerr[x][a]; |
136 |
|
ison = err[a] > 128; |
137 |
|
if (ison) err[a] -= 256; |
138 |
< |
cerr[x][a] = err[a] /= 2; |
138 |
> |
err[a] /= 3; |
139 |
> |
cerr[x][a] = err[a] + errp; |
140 |
|
return(ison); |
141 |
|
} |