60
59
#define DATA_SIZE (LINE_SIZE * 8)
62
61
unsigned int cnt_2prn;
63
unsigned int count,tempcnt;
64
unsigned char vtp,cntc1,cntc2;
65
int line_size_color_plane;
68
byte plane_data[LINE_SIZE * 3];
70
/* Set initial condition for printer */
71
fputs("\033@",prn_stream);
73
/* Send each scan line in turn */
75
int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
76
int num_blank_lines = 0;
77
for ( lnum = 0; lnum < pdev->height; lnum++ )
78
{ byte *end_data = data + line_size;
79
gdev_prn_copy_scan_lines(pdev, lnum,
80
(byte *)data, line_size);
81
/* Remove trailing 0s. */
82
while ( end_data > data && end_data[-1] == 0 )
84
if ( end_data == data )
93
/* Pad with 0s to fill out the last */
94
/* block of 8 bytes. */
95
memset(end_data, 0, 7);
97
/* Transpose the data to get pixel planes. */
98
for ( i = 0, odp = plane_data; i < DATA_SIZE;
101
{ /* The following is for 16-bit machines */
62
unsigned int count,tempcnt;
63
unsigned char vtp,cntc1,cntc2;
64
int line_size_color_plane;
67
byte plane_data[LINE_SIZE * 3];
69
/* Set initial condition for printer */
70
fputs("\033@",prn_stream);
72
/* Send each scan line in turn */
74
int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
75
int num_blank_lines = 0;
76
for ( lnum = 0; lnum < pdev->height; lnum++ )
77
{ byte *end_data = data + line_size;
78
gdev_prn_copy_scan_lines(pdev, lnum,
79
(byte *)data, line_size);
80
/* Remove trailing 0s. */
81
while ( end_data > data && end_data[-1] == 0 )
83
if ( end_data == data )
92
/* Pad with 0s to fill out the last */
93
/* block of 8 bytes. */
94
memset(end_data, 0, 7);
96
/* Transpose the data to get pixel planes. */
97
for ( i = 0, odp = plane_data; i < DATA_SIZE;
100
{ /* The following is for 16-bit machines */
102
101
#define spread3(c)\
103
102
{ 0, c, c*0x100, c*0x101, c*0x10000L, c*0x10001L, c*0x10100L, c*0x10101L }
104
static ulong spr40[8] = spread3(0x40);
105
static ulong spr8[8] = spread3(8);
106
static ulong spr2[8] = spread3(2);
107
register byte *dp = data + i;
108
register ulong pword =
109
(spr40[dp[0]] << 1) +
111
(spr40[dp[2]] >> 1) +
117
odp[0] = (byte)(pword >> 16);
118
odp[LINE_SIZE] = (byte)(pword >> 8);
119
odp[LINE_SIZE*2] = (byte)(pword);
121
/* Skip blank lines if any */
122
if ( num_blank_lines > 0 )
125
{ /* Skip down the page from the top */
126
/* set line spacing = 1/8 inch */
127
fputs("\0330",prn_stream);
128
/* Set vertical tab */
129
vtp = (num_blank_lines / 8);
130
fprintf(prn_stream,"\033B%c\000",vtp);
131
/* Do vertical tab */
132
fputs("\013",prn_stream);
136
{ /* Do "dot skips" */
137
while(num_blank_lines > 255)
139
fputs("\033e\377",prn_stream);
140
num_blank_lines -= 255;
142
vtp = num_blank_lines;
143
fprintf(prn_stream,"\033e%c",vtp);
148
/* Transfer raster graphics in the order R, G, B. */
149
/* Apparently it is stored in B, G, R */
150
/* Calculate the amount of data to send by what */
151
/* Ghostscript tells us the scan line_size in (bytes) */
153
count = line_size / 3;
154
line_size_color_plane = count / 3;
155
cnt_2prn = line_size_color_plane * 3 + 5;
157
cntc1 = (tempcnt & 0xFF00) >> 8;
158
cntc2 = (tempcnt & 0x00FF);
159
fprintf(prn_stream, "\033[O%c%c\200\037",cntc2,cntc1);
160
fputc('\000',prn_stream);
161
fputs("\124\124",prn_stream);
163
for ( row = plane_data + LINE_SIZE * 2, i = 0;
164
i < 3; row -= LINE_SIZE, i++ )
168
/* Complement bytes */
169
for (jj=0; jj< line_size_color_plane; jj++)
173
fwrite(row, sizeof(byte),
174
line_size_color_plane, prn_stream);
181
fputs("\014", prn_stream);
103
static ulong spr40[8] = spread3(0x40);
104
static ulong spr8[8] = spread3(8);
105
static ulong spr2[8] = spread3(2);
106
register byte *dp = data + i;
107
register ulong pword =
108
(spr40[dp[0]] << 1) +
110
(spr40[dp[2]] >> 1) +
116
odp[0] = (byte)(pword >> 16);
117
odp[LINE_SIZE] = (byte)(pword >> 8);
118
odp[LINE_SIZE*2] = (byte)(pword);
120
/* Skip blank lines if any */
121
if ( num_blank_lines > 0 )
124
{ /* Skip down the page from the top */
125
/* set line spacing = 1/8 inch */
126
fputs("\0330",prn_stream);
127
/* Set vertical tab */
128
vtp = (num_blank_lines / 8);
129
fprintf(prn_stream,"\033B%c\000",vtp);
130
/* Do vertical tab */
131
fputs("\013",prn_stream);
135
{ /* Do "dot skips" */
136
while(num_blank_lines > 255)
138
fputs("\033e\377",prn_stream);
139
num_blank_lines -= 255;
141
vtp = num_blank_lines;
142
fprintf(prn_stream,"\033e%c",vtp);
147
/* Transfer raster graphics in the order R, G, B. */
148
/* Apparently it is stored in B, G, R */
149
/* Calculate the amount of data to send by what */
150
/* Ghostscript tells us the scan line_size in (bytes) */
152
count = line_size / 3;
153
line_size_color_plane = count / 3;
154
cnt_2prn = line_size_color_plane * 3 + 5;
156
cntc1 = (tempcnt & 0xFF00) >> 8;
157
cntc2 = (tempcnt & 0x00FF);
158
fprintf(prn_stream, "\033[O%c%c\200\037",cntc2,cntc1);
159
fputc('\000',prn_stream);
160
fputs("\124\124",prn_stream);
162
for ( row = plane_data + LINE_SIZE * 2, i = 0;
163
i < 3; row -= LINE_SIZE, i++ )
167
/* Complement bytes */
168
for (jj=0; jj< line_size_color_plane; jj++)
172
fwrite(row, sizeof(byte),
173
line_size_color_plane, prn_stream);
180
fputs("\014", prn_stream);