1 /* BJC-210/240/250/265/1000 Bubble Jet Printer driver for GhostScript
2  * header file
3  *
4  * Copyright 2000, 2001, 2002 Gergely Sz�sz (Gergely Sza'sz)
5  * mailto://szaszg@hu.inter.net http://bjc250gs.sourceforge.net
6  *
7  *   This program may be distributed and/or modified under the terms of
8  *   the GNU General Public License as published by the Free Software
9  *   Foundation (the "GPL"); either version 2 of the GPL, or (at your option)
10  *   any later version.
11  *
12  *   When distributed under the terms of the GPL, this program is distributed
13  *   in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
14  *   even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  *   PURPOSE.  See the GPL for more details.
16  *
17  *   If this program is being distributed under the terms of the GPL, you
18  *   should have received a copy of the GPL along with this program, normally
19  *   in a plain ASCII text file named COPYING; if not, write to the Free
20  *   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111
21  *   U.S.A.
22  */
23 
24 /* Copyright (C) 1989, 2000 Aladdin Enterprises.  All rights reserved.
25 
26    This program may also be distributed as part of AFPL Ghostscript, under the
27    terms of the Aladdin Free Public License (the "License").
28 
29    AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No
30    author or distributor accepts any responsibility for the consequences of
31    using it, or for whether it serves any particular purpose or works at
32    all, unless he or she says so in writing.  Refer to the License for full
33    details.
34 
35    Every copy of AFPL Ghostscript must include a copy of the License,
36    normally in a plain ASCII text file named PUBLIC.  The License grants you
37    the right to copy, modify and redistribute AFPL Ghostscript, but only
38    under certain conditions described in the License.  Among other things,
39    the License requires that the copyright notice and this notice be
40    preserved on all copies.
41 */
42 
43 /* BJC printer drivers definitions and utility interfaces */
44 
45 #ifndef gdevbjc_INCLUDED
46 #  define gdevbjc_INCLUDED
47 
48 /* Define the default X and Y resolution. */
49 #define X_DPI 360
50 #define Y_DPI 360
51 
52 #define CMYK_K 'K'
53 #define CMYK_C 'C'
54 #define CMYK_M 'M'
55 #define CMYK_Y 'Y'
56 
57 #define INK_K 8
58 #define INK_C 1
59 #define INK_M 2
60 #define INK_Y 4
61 
62 typedef struct {
63     gs_param_string p_string;
64     int             p_value;
65 } stringParamDescription;
66 
67 /* Definitions of device parameters */
68 struct skip_s {
69     bool skipC;
70     bool skipM;
71     bool skipY;
72     bool skipK;
73 };
74 
75 typedef struct skip_s skip_t;
76 
77 typedef struct {
78     unsigned char l;
79     unsigned char c;
80 } media_t;
81 
82 struct gx_device_bjc_printer_s {
83     gx_device_common;
84     gx_prn_device_common;
85     int printerType;         /* BJC-250, BJC-250ex, BJC1000, ... */
86     int feeder;              /* Needed paper feeder */
87     int mediaType;           /* paper type */
88     int quality;
89     int ink;
90     int rnd;
91     bool inverse;
92     bool compress;
93     bool smooth;
94     bool limit;               /* paper color correction limit check */
95     bool compose;             /* color K decomposition */
96     float gamma;
97     float redGamma;
98     float greenGamma;
99     float blueGamma;
100     struct {
101 	int red;
102 	int green;
103 	int blue;
104     } paperColor;                      /* paper color for color correction */
105 };
106 
107 typedef struct gx_device_bjc_printer_s gx_device_bjc_printer;
108 
109 #define bjc_device_margins_body(dtype, procs, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page)\
110 	std_device_full_body_type(dtype, &procs, dname, &st_device_printer,\
111 	  (int)((long)(w10) * (xdpi) / 10),\
112 	  (int)((long)(h10) * (ydpi) / 10),\
113 	  xdpi, ydpi,\
114 	  ncomp, depth, mg, mc, dg, dc,\
115 	  -(lo) * (xdpi), -(to) * (ydpi),\
116 	  (lm) * 72.0, (bm) * 72.0,\
117 	  (rm) * 72.0, (tm) * 72.0\
118 	),\
119 	prn_device_body_rest_(print_page)
120 
121 #define bjc_device_margins(procs, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page, def_ink)\
122 { bjc_device_margins_body(gx_device_bjc_printer, procs, dname,\
123     w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, \
124     ncomp, depth, mg, mc, dg, dc, print_page),\
125     (int) 0,                /* def, printer: BJC250 */ \
126     (int) 0x10,             /* Auto Feeder */          \
127     (int) 0,                /*  Plain paper */         \
128     (int) 0,                /*  Normal quality */      \
129     (int) def_ink,          /* Black monochrome ink */ \
130     (int) 15,               /* Randomness is 15% */    \
131     (bool) false,           /* Normal printing */      \
132     (bool) true,            /* Use compression */      \
133     (bool) false,           /* no smoothing */         \
134     (bool) false,           /* no limit check */       \
135     (bool) true,            /* yes we run decomp */    \
136     (float) 1.0,            /* initiaal gamma */       \
137     (float) 1.0,            /* initiaal gamma */       \
138     (float) 1.0,            /* initiaal gamma */       \
139     (float) 1.0,            /* initiaal gamma */       \
140     {  (int) 255,           /* White  paper  */        \
141        (int) 255,           /*               */        \
142        (int) 255 }          /*               */        \
143 };
144 
145 
146 #define bjc_device(procs, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page, def_ink)\
147   bjc_device_margins(procs, dname, w10, h10, xdpi, ydpi,\
148     lm, tm, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page, def_ink)
149 
150 
151 #define bjc_cmyk_param_procs(v_prn_open, v_prn_output_page, v_prn_close, \
152                  p_map_color_rgb, p_map_cmyk_color, \
153 		 v_prn_get_params, v_prn_put_params)\
154    {v_prn_open, NULL, NULL, v_prn_output_page, v_prn_close,\
155     NULL, p_map_color_rgb, NULL, NULL, NULL, NULL, NULL, NULL,\
156     v_prn_get_params, v_prn_put_params,\
157     p_map_cmyk_color, NULL, NULL, NULL, gx_page_device_get_page_device}
158 
159 
160 /* There are the definitions of commands for the Canon BJC printers. */
161 
162 #define BJC_BJL_CLEANING     0x00  //   "@Cleaning=1\n"
163 #define BJC_BJL_POWER_OFF    0x01  //   "@PowerOff\n"
164 #define BJC_BJL_ROCLEANING   0x02  //   "@RollerCleaning\n"
165 #define BJC_BJL_NOZZLECHK    0x03  //   "@TestPrint=NozzleCheck\n"
166 #define BJC_BJL_TESTA        0x04  //   "@TestPrint=A\012"
167 #define BJC_BJL_TESTB        0x05  //   "@TestPrint=B\012"
168 #define BJC_BJL_TESTC        0x06  //   "@TestPrint=A\012"
169 #define BJC_BJL_DEMO         0x07  //   "@TestPrint=DemoPrint\012"
170 
171 #define BJC_BJL_ON_ENABLE    0x20  //   "AutoPowerOn=Enable\n"
172 #define BJC_BJL_ON_DISABLE   0x21  //   "AutoPowerOn=Disable\n"
173 #define BJC_BJL_OFF_1MIN     0x22  //   "AutoPowerOff=1\n"
174 #define BJC_BJL_OFF_10MIN    0x23  //   "AutoPowerOff=10\n"
175 #define BJC_BJL_OFF_30MIN    0x24  //   "AutoPowerOff=30\n"
176 #define BJC_BJL_OFF_60MIN    0x25  //   "AutoPowerOff=60\n"
177 #define BJC_BJL_OFF_DISABLE  0x26  //   "AutoPowerOff=Disable\n"
178 
179 typedef struct {
180     const char *string;
181     int         numeric;
182     int         length; } BJL_command;
183 
184 /* Put a BJL command to stream */
185 
186 void bjc_put_bjl_command(P2(FILE * file, int bjl_command));
187 
188 void bjc_put_LF(P1(FILE *file));
189 void bjc_put_FF(P1(FILE *file));
190 void bjc_put_CR(P1(FILE *file));
191 void bjc_put_initialize(P1(FILE *file));
192 void bjc_put_set_initial(P1(FILE *file));
193 void bjc_put_set_compression(P2(FILE *file, char compression));
194 void bjc_put_print_method_short(P2(FILE *file, char color));
195 void bjc_put_print_method(P5(FILE *file, char color, char media, char quality, char density));
196 void bjc_put_raster_resolution(P3(FILE *file, int x_resolution, int y_resolution));
197 void bjc_put_raster_skip(P2(FILE *file, int skip));
198 void bjc_put_page_margins(P5(FILE *file, int length, int lm, int rm, int top));
199 void bjc_put_media_supply(P3(FILE *file, char supply, char type));
200 void bjc_put_cmyk_image(P4(FILE *file, char component, const char *data, int count));
201 void bjc_put_move_lines(P2(FILE *file, int lines));
202 void bjc_put_move_lines_unit(P2(FILE *file, int unit));
203 void bjc_put_extended_margins(P5(FILE *file, int length, int lm, int rm, int top));
204 void bjc_put_image_format(P4(FILE *file, char depth, char format, char ink));
205 void bjc_put_page_id(P2(FILE *file, int id));
206 void bjc_put_continue_image(P3(FILE *file, const char *data, int count));
207 void bjc_put_indexed_image(P4(FILE *file, int dot_rows, int dot_cols, int layers));
208 
209 bool bjc_invert_bytes(P4(byte *row, uint raster, bool inverse, byte lastmask));
210 bool bjc_invert_cmyk_bytes(P8(byte *rowC,byte *rowM, byte *rowY, byte *rowK, uint raster,
211                               bool inverse, byte lastmask, skip_t *skip));
212 uint bjc_compress(P3(const byte *row, uint raster, byte *compressed));
213 
214 int  FloydSteinbergInitG(P1(gx_device_printer * pdev));
215 void FloydSteinbergDitheringG(P5(byte *row, byte *dithered, uint width, uint raster, bool limit_extr));
216 void FloydSteinbergCloseG(P1(gx_device_printer *pdev));
217 
218 int  FloydSteinbergForwardCut(P5(int error, int *Errors, int i, byte *dithered, byte bitmask));
219 int  FloydSteinbergBckwardCut(P5(int error, int *Errors, int i, byte *dithered, byte bitmask));
220 int  FloydSteinbergInitC(P1(gx_device_printer * pdev));
221 void FloydSteinbergDitheringC(P6(byte *row, byte *dithered, uint width, uint raster,
222                                  bool limit_extr, bool composeK));
223 void FloydSteinbergCloseC(P1(gx_device_printer *pdev));
224 
225 void bjc_build_gamma_table(P2(float gamma, char color));
226 void bjc_rgb_to_cmy (P6(byte r, byte g, byte b, int *c, int *m, int *y));
227 void bjc_rgb_to_gray(P4(byte r, byte g, byte b, int *k));
228 uint bjc_rand(void);
229 void bjc_init_tresh(P1(int rnd));
230 #endif				/* gdevbjc_INCLUDED */
231