~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to src/gdevbjcl.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

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