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.h,v 1.6 2002/06/16 07:25:26 lpd Exp $*/ 18 /* Canon BJC command generation library interface */ 19 20 /****** PRELIMINARY, SUBJECT TO CHANGE WITHOUT NOTICE. ******/ 21 22 #ifndef gdevbjcl_INCLUDED 23 # define gdevbjcl_INCLUDED 24 25 #include <stdio.h> /* ****** PATCH FOR stream.h ****** */ 26 #include "stream.h" 27 28 /* 29 * These procedures generate command strings for the Canon BJC family of 30 * printers. Note that not all printers support all commands. 31 */ 32 33 /* ---------------- Printer capabilities ---------------- */ 34 35 /* 36 * Different printer models implement different subsets of the command set. 37 * We define a mask bit for each capability, and a mask for each printer 38 * indicating which capabilities it supports. In some cases, a capability 39 * is a parameter value for a command rather than a separate command. 40 */ 41 42 /* 43 * Single-character commands. 44 * 45 * All BJC models implement CR and FF. 46 */ 47 #define BJC_OPT_NUL 0x00000001 48 #define BJC_OPT_LF 0x00000002 49 50 /* 51 * Session commands. 52 * 53 * All BJC models implement Set initial condition, Initialize, 54 * Print method, and Media Supply. 55 */ 56 #define BJC_OPT_IDENTIFY_CARTRIDGE 0x00000004 57 #define BJC_OPT_MONOCHROME_SMOOTHING 0x00000008 /* for bjc_print_color_t */ 58 59 /* 60 * Page commands. 61 * 62 * All BJC models implement Page margins. 63 */ 64 #define BJC_OPT_EXTENDED_MARGINS 0x00000010 65 #define BJC_OPT_PAGE_ID 0x00000020 66 67 /* 68 * Resolution. This varies considerably from model to model. 69 * The _300 or _360 option gives the base resolution; the other options 70 * indicate which multiples of the base are available. 71 * Note that the resolution multipliers are specified as X, then Y. 72 */ 73 #define BJC_OPT_RESOLUTION_360 0x00000040 74 #define BJC_OPT_RESOLUTION_300 0x00000080 75 #define BJC_OPT_RESOLUTION_HALF 0x00000100 /* 180 or 150 */ 76 #define BJC_OPT_RESOLUTION_QUARTER 0x00000200 /* 90 or 75 */ 77 #define BJC_OPT_RESOLUTION_2X 0x00000400 /* 720 or 600 */ 78 #define BJC_OPT_RESOLUTION_2X_1X 0x00000800 79 #define BJC_OPT_RESOLUTION_4X_2X 0x00001000 80 81 /* 82 * Image commands. 83 * 84 * All BJC models implement Raster resolution, Raster skip, CMYK image, 85 * and Data compression. 86 */ 87 #define BJC_OPT_X_Y_RESOLUTION 0x00002000 /* for raster_resolution */ 88 #define BJC_OPT_MOVE_LINES 0x00004000 89 #define BJC_OPT_IMAGE_FORMAT 0x00008000 90 #define BJC_OPT_CONTINUE_IMAGE 0x00010000 91 #define BJC_OPT_INDEXED_IMAGE 0x00020000 92 #define BJC_OPT_SET_COLOR_COMPONENT 0x00040000 93 94 /* 95 * Define the capabilities of the models that we know about. 96 */ 97 /* 98 * We don't have the documentation for the 50, but Canon says it's the 99 * same as the 80. 100 */ 101 #define BJC_OPT_50\ 102 (BJC_OPT_NUL | BJC_OPT_LF |\ 103 BJC_OPT_IDENTIFY_CARTRIDGE |\ 104 BJC_OPT_EXTENDED_MARGINS | BJC_OPT_PAGE_ID |\ 105 BJC_OPT_RESOLUTION_360 | BJC_OPT_RESOLUTION_HALF |\ 106 BJC_OPT_RESOLUTION_QUARTER | BJC_OPT_RESOLUTION_2X_1X |\ 107 BJC_OPT_X_Y_RESOLUTION | BJC_OPT_MOVE_LINES | BJC_OPT_IMAGE_FORMAT |\ 108 BJC_OPT_CONTINUE_IMAGE) 109 #define BJC_OPT_70\ 110 (BJC_OPT_LF |\ 111 BJC_OPT_IDENTIFY_CARTRIDGE | BJC_OPT_MONOCHROME_SMOOTHING |\ 112 BJC_OPT_RESOLUTION_360) 113 #define BJC_OPT_80\ 114 BJC_OPT_50 115 #define BJC_OPT_210\ 116 (BJC_OPT_IDENTIFY_CARTRIDGE | BJC_OPT_MONOCHROME_SMOOTHING |\ 117 BJC_OPT_EXTENDED_MARGINS |\ 118 BJC_OPT_RESOLUTION_360 |\ 119 BJC_OPT_X_Y_RESOLUTION | BJC_OPT_MOVE_LINES | BJC_OPT_CONTINUE_IMAGE) 120 #define BJC_OPT_250\ 121 (BJC_OPT_LF |\ 122 BJC_OPT_IDENTIFY_CARTRIDGE | BJC_OPT_MONOCHROME_SMOOTHING |\ 123 BJC_OPT_EXTENDED_MARGINS | BJC_OPT_PAGE_ID |\ 124 BJC_OPT_RESOLUTION_360 | BJC_OPT_RESOLUTION_HALF |\ 125 BJC_OPT_RESOLUTION_QUARTER | BJC_OPT_RESOLUTION_2X_1X |\ 126 BJC_OPT_X_Y_RESOLUTION | BJC_OPT_MOVE_LINES | BJC_OPT_IMAGE_FORMAT |\ 127 BJC_OPT_CONTINUE_IMAGE) 128 #define BJC_OPT_610\ 129 (BJC_OPT_LF |\ 130 BJC_OPT_RESOLUTION_360) 131 #define BJC_OPT_620\ 132 BJC_OPT_610 133 #define BJC_OPT_4000\ 134 (BJC_OPT_LF |\ 135 BJC_OPT_IDENTIFY_CARTRIDGE | BJC_OPT_MONOCHROME_SMOOTHING |\ 136 BJC_OPT_RESOLUTION_360 | BJC_OPT_RESOLUTION_HALF |\ 137 BJC_OPT_RESOLUTION_QUARTER) 138 #define BJC_OPT_4100\ 139 (BJC_OPT_IDENTIFY_CARTRIDGE |\ 140 BJC_OPT_EXTENDED_MARGINS |\ 141 BJC_OPT_RESOLUTION_360 |\ 142 BJC_OPT_MOVE_LINES | BJC_OPT_CONTINUE_IMAGE) 143 #define BJC_OPT_4200\ 144 (BJC_OPT_LF |\ 145 BJC_OPT_IDENTIFY_CARTRIDGE |\ 146 BJC_OPT_EXTENDED_MARGINS | BJC_OPT_PAGE_ID |\ 147 BJC_OPT_RESOLUTION_360 |\ 148 BJC_OPT_MOVE_LINES | BJC_OPT_IMAGE_FORMAT | BJC_OPT_CONTINUE_IMAGE) 149 #define BJC_OPT_4300\ 150 BJC_OPT_250 151 #define BJC_OPT_4550\ 152 BJC_OPT_250 153 #define BJC_OPT_4650\ 154 BJC_OPT_250 155 #define BJC_OPT_5500\ 156 (BJC_OPT_IDENTIFY_CARTRIDGE | BJC_OPT_MONOCHROME_SMOOTHING |\ 157 BJC_OPT_EXTENDED_MARGINS |\ 158 BJC_OPT_RESOLUTION_360 |\ 159 BJC_OPT_MOVE_LINES | BJC_OPT_CONTINUE_IMAGE) 160 /* The 7000 is not well documented. The following is a semi-guess. */ 161 #define BJC_OPT_7000\ 162 (BJC_OPT_NUL | BJC_OPT_LF |\ 163 BJC_OPT_IDENTIFY_CARTRIDGE |\ 164 BJC_OPT_EXTENDED_MARGINS | BJC_OPT_PAGE_ID |\ 165 BJC_OPT_RESOLUTION_300 | BJC_OPT_RESOLUTION_2X_1X |\ 166 BJC_OPT_RESOLUTION_4X_2X |\ 167 BJC_OPT_MOVE_LINES | BJC_OPT_IMAGE_FORMAT | BJC_OPT_CONTINUE_IMAGE |\ 168 BJC_OPT_INDEXED_IMAGE | BJC_OPT_SET_COLOR_COMPONENT) 169 170 /* 171 * Enumerate the options for all the printer models we know about. 172 * m(x, y) will normally be {x, y}, to generate a table. 173 */ 174 #define BJC_ENUMERATE_OPTIONS(m)\ 175 m(50, BJC_OPT_50)\ 176 m(70, BJC_OPT_70)\ 177 m(80, BJC_OPT_80)\ 178 m(210, BJC_OPT_210)\ 179 m(250, BJC_OPT_250)\ 180 m(610, BJC_OPT_610)\ 181 m(620, BJC_OPT_620)\ 182 m(4000, BJC_OPT_4000)\ 183 m(4100, BJC_OPT_4100)\ 184 m(4200, BJC_OPT_4200)\ 185 m(4300, BJC_OPT_4300)\ 186 m(4550, BJC_OPT_4550)\ 187 m(4650, BJC_OPT_4650)\ 188 m(5500, BJC_OPT_5500)\ 189 m(7000, BJC_OPT_7000) 190 191 /* ---------------- Command generation ---------------- */ 192 193 /* 194 * Single-character commands. 195 */ 196 197 /* Carriage return (^M) */ 198 void bjc_put_CR(stream *s); 199 200 /* Form feed (^L) */ 201 void bjc_put_FF(stream *s); 202 203 /* Line feed (^J) */ 204 void bjc_put_LF(stream *s); 205 206 /* 207 * Session commands. 208 */ 209 210 /* Set initial condition */ 211 void bjc_put_initial_condition(stream *s); 212 213 /* Return to initial condition */ 214 void bjc_put_initialize(stream *s); 215 216 /* Select print method */ 217 /****** DIFFERENT FOR 7000 ******/ 218 typedef enum { 219 BJC_PRINT_COLOR_COLOR = 0x0, 220 BJC_PRINT_COLOR_MONOCHROME = 0x1, 221 BJC_PRINT_COLOR_MONOCHROME_WITH_SMOOTHING = 0x2 /* option */ 222 } bjc_print_color_t; 223 typedef enum { 224 BJC_PRINT_MEDIA_PLAIN_PAPER = 0x0, 225 BJC_PRINT_MEDIA_COATED_PAPER = 0x1, 226 BJC_PRINT_MEDIA_TRANSPARENCY_FILM = 0x2, 227 BJC_PRINT_MEDIA_BACK_PRINT_FILM = 0x3, 228 BJC_PRINT_MEDIA_TEXTILE_SHEET = 0x4, 229 BJC_PRINT_MEDIA_GLOSSY_PAPER = 0x5, 230 BJC_PRINT_MEDIA_HIGH_GLOSS_FILM = 0x6, 231 BJC_PRINT_MEDIA_HIGH_RESOLUTION_PAPER = 0x7 /* BJC-80 only */ 232 } bjc_print_media_t; 233 typedef enum { 234 BJC_PRINT_QUALITY_NORMAL = 0x0, 235 BJC_PRINT_QUALITY_HIGH = 0x1, 236 BJC_PRINT_QUALITY_DRAFT = 0x2, 237 BJC_PRINT_QUALITY_COLOR_NON_BLEED = 0x8 /* not 6x0 */ 238 } bjc_print_quality_t; 239 typedef enum { 240 /* 6x0 only */ 241 BJC_BLACK_DENSITY_NORMAL = 0x0, 242 BJC_BLACK_DENSITY_HIGH = 0x1 243 } bjc_black_density_t; 244 void bjc_put_print_method(stream *s, bjc_print_color_t color, 245 bjc_print_media_t media, 246 bjc_print_quality_t quality, 247 bjc_black_density_t density); 248 typedef enum { 249 /* 70, 4000, 4550, 4650 */ 250 BJC_70_PRINT_COLOR_SHORT_FINE = 0x0, /* also 0x1, 0x2 */ 251 BJC_70_PRINT_COLOR_SHORT_HQ = 0x3, 252 BJC_70_PRINT_COLOR_SHORT_ECO = 0x4, 253 /* 80, 250, 4200, 4300 */ 254 BJC_80_PRINT_COLOR_SHORT_STD = 0x0, 255 BJC_80_PRINT_COLOR_SHORT_STD_SPECIALTY = 0x1, 256 BJC_80_PRINT_COLOR_SHORT_HQ_SPECIALTY = 0x2, 257 BJC_80_PRINT_COLOR_SHORT_HQ = 0x3, 258 BJC_80_PRINT_COLOR_SHORT_HIGH_SPEED = 0x4, 259 /* 210, 4100 */ 260 BJC_210_PRINT_COLOR_SHORT_HQ = 0x0, /* also 0x1 */ 261 BJC_210_PRINT_COLOR_SHORT_FINE = 0x2, /* also 0x3 */ 262 BJC_210_PRINT_COLOR_SHORT_HIGH_SPEED = 0x4, 263 /* 5500 */ 264 BJC_5500_PRINT_COLOR_SHORT_COATED = 0x0, 265 BJC_5500_PRINT_COLOR_SHORT_TRANSPARENCY = 0x1, 266 BJC_5500_PRINT_COLOR_SHORT_PLAIN = 0x2, 267 BJC_5500_PRINT_COLOR_SHORT_HQ_NON_BLEED = 0x3, 268 BJC_5500_PRINT_COLOR_SHORT_HIGH_SPEED = 0x4 269 } bjc_print_color_short_t; 270 void bjc_put_print_method_short(stream *s, bjc_print_color_short_t color); 271 272 /* Set media supply method */ 273 /****** DIFFERENT FOR 7000 ******/ 274 typedef enum { 275 /* 70, 210, 250, 6x0, 4100 */ 276 BJC_70_MEDIA_SUPPLY_MANUAL_1 = 0x0, 277 BJC_70_MEDIA_SUPPLY_MANUAL_2 = 0x1, 278 BJC_70_MEDIA_SUPPLY_ASF = 0x4, 279 /* 250, 4000, 4300, 4650, 5500 */ 280 BJC_250_MEDIA_SUPPLY_CONTINUOUS_FORM = 0x2, 281 BJC_250_MEDIA_SUPPLY_ASF_BIN_2 = 0x5, 282 /* 250, 4650, 5500 */ 283 BJC_250_MEDIA_SUPPLY_AUTO_SWITCH = 0xf, 284 /* 4000, 4300, 4650 */ 285 BJC_4000_MEDIA_SUPPLY_CASSETTE = 0x8, 286 /* 80 */ 287 BJC_80_MEDIA_SUPPLY_ASF_OFFLINE = 0x0, 288 BJC_80_MEDIA_SUPPLY_ASF_ONLINE = 0x1 /* also 0x4 */ 289 } bjc_media_supply_t; 290 typedef enum { 291 BJC_MEDIA_TYPE_PLAIN_PAPER = 0x0, 292 BJC_MEDIA_TYPE_COATED_PAPER = 0x1, 293 BJC_MEDIA_TYPE_TRANSPARENCY_FILM = 0x2, 294 BJC_MEDIA_TYPE_BACK_PRINT_FILM = 0x3, 295 BJC_MEDIA_TYPE_PAPER_WITH_LEAD = 0x4, 296 BJC_MEDIA_TYPE_TEXTILE_SHEET = 0x5, 297 BJC_MEDIA_TYPE_GLOSSY_PAPER = 0x6, 298 BJC_MEDIA_TYPE_HIGH_GLOSS_FILM = 0x7, 299 BJC_MEDIA_TYPE_ENVELOPE = 0x8, 300 BJC_MEDIA_TYPE_CARD = 0x9, 301 BJC_MEDIA_TYPE_HIGH_RESOLUTION_6X0 = 0xa, /* 6x0 only */ 302 BJC_MEDIA_TYPE_HIGH_RESOLUTION = 0xb, /* 720x720, other models */ 303 BJC_MEDIA_TYPE_FULL_BLEED = 0xc, 304 BJC_MEDIA_TYPE_BANNER = 0xd 305 } bjc_media_type_t; 306 void bjc_put_media_supply(stream *s, bjc_media_supply_t supply, 307 bjc_media_type_t type); 308 309 /* Identify ink cartridge */ 310 typedef enum { 311 BJC_IDENTIFY_CARTRIDGE_PREPARE = 0x0, 312 BJC_IDENTIFY_CARTRIDGE_REQUEST = 0x1 313 } bjc_identify_cartridge_command_t; 314 void bjc_put_identify_cartridge(stream *s, 315 bjc_identify_cartridge_command_t command); 316 317 /* 318 * Page commands. 319 */ 320 321 /* Set page margins */ 322 /* Left margin is 1-origin; margins are both from left edge; indent <= 8 */ 323 void bjc_put_page_margins(stream *s, int length10ths, int lm10ths, 324 int rm10ths, int indent60ths); 325 326 /* Set extended margins */ 327 /* All values are 0-origin; margins are both from left edge; indent <= 8 */ 328 void bjc_put_extended_margins(stream *s, int length60ths, int lm60ths, 329 int rm60ths, int indent60ths); 330 331 /* Page ID */ 332 /* 0 <= id <= 127 */ 333 void bjc_put_page_id(stream *s, int id); 334 335 /* 336 * Image commands. 337 */ 338 339 /* Set raster compression */ 340 typedef enum { 341 BJC_RASTER_COMPRESSION_NONE = 0x0, 342 BJC_RASTER_COMPRESSION_PACKBITS = 0x1 343 } bjc_raster_compression_t; 344 void bjc_put_compression(stream *s, bjc_raster_compression_t compression); 345 346 /* Set raster resolution */ 347 void bjc_put_raster_resolution(stream *s, int x_resolution, int y_resolution); 348 349 /* Raster skip */ 350 /* Maximum skip on 6x0 and 4000 is 0x17ff */ 351 void bjc_put_raster_skip(stream *s, int skip); 352 353 /* CMYK raster image */ 354 typedef enum { 355 BJC_CMYK_IMAGE_CYAN = 'C', 356 BJC_CMYK_IMAGE_MAGENTA = 'M', 357 BJC_CMYK_IMAGE_YELLOW = 'Y', 358 BJC_CMYK_IMAGE_BLACK = 'K', 359 } bjc_cmyk_image_component_t; 360 void bjc_put_cmyk_image(stream *s, bjc_cmyk_image_component_t component, 361 const byte *data, int count); 362 363 /* Move by raster lines */ 364 /* Distance must be a multiple of the raster resolution */ 365 void bjc_put_move_lines(stream *s, int lines); 366 367 /* Set unit for movement by raster lines */ 368 /* unit = 360 for printers other than 7000 */ 369 /* unit = 300 or 600 for 7000 */ 370 void bjc_put_move_lines_unit(stream *s, int unit); 371 372 /* Set image format */ 373 /* depth is 1 or 2 */ 374 /****** DIFFERENT FOR 7000 ******/ 375 typedef enum { 376 BJC_IMAGE_FORMAT_REGULAR = 0x00, 377 BJC_IMAGE_FORMAT_INDEXED = 0x80 378 } bjc_image_format_t; 379 typedef enum { 380 BJC_INK_SYSTEM_REGULAR = 0x01, 381 BJC_INK_SYSTEM_PHOTO = 0x02, 382 BJC_INK_SYSTEM_REGULAR_DVM = 0x09, /* drop volume modulation */ 383 BJC_INK_SYSTEM_PHOTO_DVM = 0x0a /* drop volume modulation */ 384 } bjc_ink_system_t; 385 void bjc_put_image_format(stream *s, int depth, 386 bjc_image_format_t format, 387 bjc_ink_system_t ink); 388 /* 4550 only */ 389 void bjc_put_photo_image(stream *s, bool photo); 390 391 /* Continue raster image */ 392 void bjc_put_continue_image(stream *s, const byte *data, int count); 393 394 /* BJ indexed image */ 395 void bjc_put_indexed_image(stream *s, int dot_rows, int dot_cols, int layers); 396 397 #endif /* gdevbjcl_INCLUDED */ 398