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: gdevlbp8.c 8250 2007-09-25 13:31:24Z giles $*/
14
/* Canon LBP-8II and LIPS III driver */
20
Changed CSI command into ESC [. DCS commands may still need to be changed
23
Corrected LBP-8II margins again. Real problem was that (0,0) is NOT
25
Now using relative addressing for vertical addressing. This avoids
27
when printing to paper with wrong size.
28
18.6.96 Lauri Paatero, lauri.paatero@paatero.pp.fi
29
Corrected LBP-8II margins.
30
Added logic to recognize (and optimize away) long strings of 00's in data.
31
For LBP-8II removed use of 8-bit CSI (this does not work if 8-bit character
32
set has been configured in LBP-8II. (Perhaps this should also be done
35
LBP8 driver: Tom Quinn (trq@prg.oxford.ac.uk)
36
LIPS III driver: Kenji Okamoto (okamoto@okamoto.cias.osakafu-u.ac.jp)
42
#define LINE_SIZE ((X_DPI * 85 / 10 + 7) / 8) /* bytes per line */
44
/* The device descriptors */
45
static dev_proc_print_page(lbp8_print_page);
47
static dev_proc_print_page(lips3_print_page);
50
const gx_device_printer far_data gs_lbp8_device =
51
prn_device(prn_std_procs, "lbp8",
52
DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
54
0.16, 0.2, 0.32, 0.21, /* margins: left, bottom, right, top */
58
const gx_device_printer far_data gs_lips3_device =
59
prn_device(prn_std_procs, "lips3",
60
82, /* width_10ths, 8.3" */
61
117, /* height_10ths, 11.7" */
63
0.16, 0.27, 0.23, 0.27, /* margins */
67
/* ------ Internal routines ------ */
69
#define ESC (char)0x1b
74
static const char lbp8_init[] = {
75
ESC, ';', ESC, 'c', ESC, ';', /* reset, ISO */
76
ESC, '[', '2', '&', 'z', /* fullpaint mode */
77
ESC, '[', '1', '4', 'p', /* select page type (A4) */
78
ESC, '[', '1', '1', 'h', /* set mode */
79
ESC, '[', '7', ' ', 'I', /* select unit size (300dpi)*/
80
ESC, '[', '6', '3', 'k', /* Move 63 dots up (to top of printable area) */
83
static const char *lbp8_end = NULL;
86
static const char lips3_init[] = {
87
ESC, '<', /* soft reset */
88
DCS, '0', 'J', ST, /* JOB END */
89
DCS, '3', '1', ';', '3', '0', '0', ';', '2', 'J', ST, /* 300dpi, LIPS3 JOB START */
90
ESC, '<', /* soft reset */
91
DCS, '2', 'y', 'P', 'r', 'i', 'n', 't', 'i', 'n', 'g', '(', 'g', 's', ')', ST, /* Printing (gs) display */
92
ESC, '[', '?', '1', 'l', /* auto cr-lf disable */
93
ESC, '[', '?', '2', 'h', /* auto ff disable */
94
ESC, '[', '1', '1', 'h', /* set mode */
95
ESC, '[', '7', ' ', 'I', /* select unit size (300dpi)*/
96
ESC, '[', 'f' /* move to home position */
99
static const char lips3_end[] = {
100
DCS, '0', 'J', ST /* JOB END */
104
/* Send the page to the printer. */
106
can_print_page(gx_device_printer *pdev, FILE *prn_stream,
107
const char *init, int init_size, const char *end, int end_size)
109
char data[LINE_SIZE*2];
111
int last_line_nro = 0;
113
fwrite(init, init_size, 1, prn_stream); /* initialize */
115
/* Send each scan line in turn */
118
int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
119
byte rmask = (byte)(0xff << (-pdev->width & 7));
121
for ( lnum = 0; lnum < pdev->height; lnum++ ) {
122
char *end_data = data + LINE_SIZE;
123
gdev_prn_copy_scan_lines(pdev, lnum,
124
(byte *)data, line_size);
125
/* Mask off 1-bits beyond the line width. */
126
end_data[-1] &= rmask;
127
/* Remove trailing 0s. */
128
while ( end_data > data && end_data[-1] == 0 )
130
if ( end_data != data ) {
137
fprintf(prn_stream, "%c[%de",
138
ESC, lnum-last_line_nro );
139
last_line_nro = lnum;
141
while (out_data < end_data) {
142
/* Remove leading 0s*/
143
while(out_data < end_data && *out_data == 0) {
148
out_count = end_data - out_data;
151
/* if there is a lot data, find if there is sequence of zeros */
156
while(out_data+out_count+zero_count < end_data) {
157
if (out_data[zero_count+out_count] != 0) {
158
out_count += 1+zero_count;
173
/* move down and across*/
174
fprintf(prn_stream, "%c[%d`",
176
/* transfer raster graphic command */
177
fprintf(prn_stream, "%c[%d;%d;300;.r",
178
ESC, out_count, out_count);
181
fwrite(out_data, sizeof(char),
182
out_count, prn_stream);
184
out_data += out_count+zero_count;
185
num_cols += 8*(out_count+zero_count);
192
fprintf(prn_stream, "%c=", ESC);
196
fwrite(end, end_size, 1, prn_stream);
201
/* Print an LBP-8 page. */
203
lbp8_print_page(gx_device_printer *pdev, FILE *prn_stream)
204
{ return can_print_page(pdev, prn_stream, lbp8_init, sizeof(lbp8_init),
205
lbp8_end, sizeof(lbp8_end));
209
/* Print a LIPS III page. */
211
lips3_print_page(gx_device_printer *pdev, FILE *prn_stream)
212
{ return can_print_page(pdev, prn_stream, lips3_init, sizeof(lips3_init),
213
lips3_end, sizeof(lips3_end));