gdevbjcl.h 13 KB

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