1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
13
/* $Id: gdev3852.c 8250 2007-09-25 13:31:24Z giles $*/
14
/* IBM 3852 JetPrinter color ink jet driver for Ghostscript */
17
This driver program created by Kevin M. Gift <kgift@draper.com> in Sept. 1992.
18
Modified 3/93 to correct bug in cnt_2prn size.
19
Modified 3/93 to dimension page back to 8.5, which seems to
20
work better than the actual page width of 7.6, ie. it uses
21
the full printing width of the printer.
22
It was modeled after the V2.4.1 HP Paintjet driver (gdevpjet.c)
23
Modified by L. Peter Deutsch <ghost@aladdin.com> 1999-01-10 to remove _ss
24
modifiers inappropriately copied from other code.
30
/* X_DPI and Y_DPI must be the same - use the maximum graphics resolution */
31
/* for this printer */
35
/* We round up LINE_SIZE to a multiple of 8 bytes */
36
/* because that's the unit of transposition from pixels to planes. */
37
/* Should = 96 (KMG) */
38
#define LINE_SIZE ((X_DPI * 86 / 10 + 63) / 64 * 8)
40
/* The device descriptor */
41
static dev_proc_print_page(jetp3852_print_page);
42
static gx_device_procs jetp3852_procs =
43
prn_color_procs(gdev_prn_open, gdev_prn_output_page, gdev_prn_close,
44
gdev_pcl_3bit_map_rgb_color, gdev_pcl_3bit_map_color_rgb);
45
const gx_device_printer far_data gs_jetp3852_device =
46
prn_device(jetp3852_procs, "jetp3852",
47
86, /* width_10ths, 8.6" (?) */
48
110, /* height_10ths, 11" */
50
0.0, 0, 0.0, 0, /* left, bottom, right, top margins */
51
3, jetp3852_print_page);
54
/* ------ Internal routines ------ */
56
/* Send the page to the printer. */
58
jetp3852_print_page(gx_device_printer *pdev, FILE *prn_stream)
60
#define DATA_SIZE (LINE_SIZE * 8)
62
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 */
103
{ 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);