Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/planix-v0/sys/src/cmd/gs/src/gdevbjcl.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/* Copyright (C) 1998 Aladdin Enterprises.  All rights reserved.
2
 
3
  This software is provided AS-IS with no warranty, either express or
4
  implied.
5
 
6
  This software is distributed under license and may not be copied,
7
  modified or distributed except as expressly authorized under the terms
8
  of the license contained in the file LICENSE in this distribution.
9
 
10
  For more information about licensing, please refer to
11
  http://www.ghostscript.com/licensing/. For information on
12
  commercial licensing, go to http://www.artifex.com/licensing/ or
13
  contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14
  San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
*/
16
 
17
/* $Id: gdevbjcl.c,v 1.4 2002/02/21 22:24:51 giles Exp $*/
18
/* Canon BJC command generation library */
19
#include "std.h"
20
#include "gdevbjcl.h"
21
 
22
/****** PRELIMINARY, SUBJECT TO CHANGE WITHOUT NOTICE. ******/
23
 
24
/* ---------------- Utilities ---------------- */
25
 
26
private void
27
bjc_put_bytes(stream *s, const byte *data, uint count)
28
{
29
    uint ignore;
30
 
31
    sputs(s, data, count, &ignore);
32
}
33
 
34
private void
35
bjc_put_hi_lo(stream *s, int value)
36
{
37
    spputc(s, value >> 8);
38
    spputc(s, value & 0xff);
39
}
40
 
41
private void
42
bjc_put_lo_hi(stream *s, int value)
43
{
44
    spputc(s, value & 0xff);
45
    spputc(s, value >> 8);
46
}
47
 
48
private void
49
bjc_put_command(stream *s, int ch, int count)
50
{
51
    spputc(s, 033 /*ESC*/);
52
    spputc(s, '(');
53
    spputc(s, ch);
54
    bjc_put_lo_hi(s, count);
55
}
56
 
57
/* ---------------- Commands ---------------- */
58
 
59
/* Line feed (^J) */
60
void
61
bjc_put_LF(stream *s)
62
{
63
    spputc(s, 0x0a);
64
}
65
 
66
/* Form feed (^L) */
67
void
68
bjc_put_FF(stream *s)
69
{
70
    spputc(s, 0x0c);
71
}
72
 
73
/* Carriage return (^M) */
74
void
75
bjc_put_CR(stream *s)
76
{
77
    spputc(s, 0x0d);
78
}
79
 
80
/* Return to initial condition (ESC @) */
81
void
82
bjc_put_initialize(stream *s)
83
{
84
    bjc_put_bytes(s, (const byte *)"\033@", 2);
85
}
86
 
87
/* Set initial condition (ESC [ K <count> <init> <id> <parm1> <parm2>) */
88
void
89
bjc_put_set_initial(stream *s)
90
{
91
    bjc_put_bytes(s, (const byte *)"\033[K\002\000\000\017", 7);
92
}
93
 
94
/* Set data compression (ESC [ b <count> <state>) */
95
void
96
bjc_put_set_compression(stream *s, bjc_raster_compression_t compression)
97
{
98
    bjc_put_command(s, 'b', 1);
99
    spputc(s, compression);
100
}
101
 
102
/* Select print method (ESC ( c <count> <parm1> <parm2> [<parm3>]) */
103
void
104
bjc_put_print_method_short(stream *s, bjc_print_color_short_t color)
105
{
106
    bjc_put_command(s, 'c', 1);
107
    spputc(s, color);
108
}
109
void
110
bjc_put_print_method(stream *s, bjc_print_color_t color,
111
		     bjc_print_media_t media, bjc_print_quality_t quality,
112
		     bjc_black_density_t density)
113
{
114
    bjc_put_command(s, 'c', 2 + (density != 0));
115
    spputc(s, 0x10 | color);
116
    spputc(s, (media << 4) | quality);
117
    if (density)
118
	spputc(s, density << 4);
119
}
120
 
121
/* Set raster resolution (ESC ( d <count> <y_res> [<x_res>]) */
122
void
123
bjc_put_raster_resolution(stream *s, int x_resolution, int y_resolution)
124
{
125
    if (x_resolution == y_resolution) {
126
	bjc_put_command(s, 'd', 2);
127
    } else {
128
	bjc_put_command(s, 'd', 4);
129
	bjc_put_hi_lo(s, y_resolution);
130
    }
131
    bjc_put_hi_lo(s, x_resolution);
132
}
133
 
134
/* Raster skip (ESC ( e <count> <skip>) */
135
void
136
bjc_put_raster_skip(stream *s, int skip)
137
{
138
    bjc_put_command(s, 'e', 2);
139
    bjc_put_hi_lo(s, skip);
140
}
141
 
142
/* Set page margins (ESC ( g <count> <length> <lm> <rm> <top>) */
143
void
144
bjc_put_page_margins(stream *s, int length, int lm, int rm, int top)
145
{
146
    byte parms[4];
147
    int count;
148
 
149
    parms[0] = length, parms[1] = lm, parms[2] = rm, parms[3] = top;
150
    count = 4;		/* could be 1..3 */
151
    bjc_put_command(s, 'g', count);
152
    bjc_put_bytes(s, parms, count);
153
}
154
 
155
/* Set media supply method (ESC * l <count> <parm1> <parm2>) */
156
void
157
bjc_put_media_supply(stream *s, bjc_media_supply_t supply,
158
		     bjc_media_type_t type)
159
{
160
    bjc_put_command(s, 'l', 2);
161
    spputc(s, 0x10 | supply);
162
    spputc(s, type << 4);
163
}
164
 
165
/* Identify ink cartridge (ESC ( m <count> <type>) */
166
void
167
bjc_put_identify_cartridge(stream *s,
168
			   bjc_identify_cartridge_command_t command)
169
{
170
    bjc_put_command(s, 'm', 1);
171
    spputc(s, command);
172
}
173
 
174
/* CMYK raster image (ESC ( A <count> <color>) */
175
void
176
bjc_put_cmyk_image(stream *s, bjc_cmyk_image_component_t component,
177
		   const byte *data, int count)
178
{
179
    bjc_put_command(s, 'A', count + 1);
180
    spputc(s, component);
181
    bjc_put_bytes(s, data, count);
182
}
183
 
184
/* Move by raster lines (ESC ( n <count> <lines>) */
185
void
186
bjc_put_move_lines(stream *s, int lines)
187
{
188
    bjc_put_command(s, 'n', 2);
189
    bjc_put_hi_lo(s, lines);
190
}
191
 
192
/* Set unit for movement by raster lines (ESC ( o <count> <unit>) */
193
void
194
bjc_put_move_lines_unit(stream *s, int unit)
195
{
196
    bjc_put_command(s, 'o', 2);
197
    bjc_put_hi_lo(s, unit);
198
}
199
 
200
/* Set extended margins (ESC ( p <count> <length60ths> <lm60ths> */
201
/*   <rm60ths> <top60ths>) */
202
void
203
bjc_put_extended_margins(stream *s, int length, int lm, int rm, int top)
204
{
205
    bjc_put_command(s, 'p', 8);
206
    bjc_put_hi_lo(s, length);
207
    bjc_put_hi_lo(s, lm);
208
    bjc_put_hi_lo(s, rm);
209
    bjc_put_hi_lo(s, top);
210
}
211
 
212
/* Set image format (ESC ( t <count> <depth> <format> <ink>) */
213
void
214
bjc_put_image_format(stream *s, int depth, bjc_image_format_t format,
215
			     bjc_ink_system_t ink)
216
 
217
{
218
    bjc_put_command(s, 't', 3);
219
    spputc(s, depth);
220
    spputc(s, format);
221
    spputc(s, ink);
222
}
223
 
224
/* Page ID (ESC ( q <count> <id>) */
225
void
226
bjc_put_page_id(stream *s, int id)
227
{
228
    bjc_put_command(s, 'q', 1);
229
    spputc(s, id);
230
}
231
 
232
/* Continue raster image (ESC ( F <count> <data>) */
233
void
234
bjc_put_continue_image(stream *s, const byte *data, int count)
235
{
236
    bjc_put_command(s, 'F', count);
237
    bjc_put_bytes(s, data, count);
238
}
239
 
240
/* BJ indexed image (ESC ( f <count> R <dot_rows> <dot_cols> <layers> */
241
/*   <index>) */
242
void
243
bjc_put_indexed_image(stream *s, int dot_rows, int dot_cols, int layers)
244
{
245
    bjc_put_command(s, 'f', 5);
246
    spputc(s, 'R');			/* per spec */
247
    spputc(s, dot_rows);
248
    spputc(s, dot_cols);
249
    spputc(s, layers);
250
}