Debian Codegraph @

src/main/print-escp2.c

raw symbols SCIP
1 /*
2 *
3 * Print plug-in EPSON ESC/P2 driver for the GIMP.
4 *
5 * Copyright 1997-2000 Michael Sweet ([email protected]) and
6 * Robert Krawitz ([email protected])
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 /*
23 * This file must include only standard C header files. The core code must
24 * compile on generic platforms that don't support glib, gimp, gtk, etc.
25 */
26
27 #ifdef HAVE_CONFIG_H
28 #include <config.h>
29 #endif
30 #include <gutenprint/gutenprint.h>
31 #include <gutenprint/gutenprint-intl-internal.h>
32 #include "gutenprint-internal.h"
33 #include <string.h>
34 #include <math.h>
35 #include <limits.h>
36 #include "print-escp2.h"
37
38 #ifdef __GNUC__
39 #define inline __inline__
40 #endif
41
42 #define OP_JOB_START 1
43 #define OP_JOB_PRINT 2
44 #define OP_JOB_END 4
45
46 #ifndef MAX
47 # define MAX(a, b) ((a) > (b) ? (a) : (b))
48 #endif /* !MAX */
49
50 typedef struct
51 {
52 unsigned count;
53 const char *name;
54 } channel_count_t;
55
56 static const channel_count_t escp2_channel_counts[] =
57 {
58 { 1, "1" },
59 { 2, "2" },
60 { 3, "3" },
61 { 4, "4" },
62 { 5, "5" },
63 { 6, "6" },
64 { 7, "7" },
65 { 8, "8" },
66 { 9, "9" },
67 { 10, "10" },
68 { 11, "11" },
69 { 12, "12" },
70 { 13, "13" },
71 { 14, "14" },
72 { 15, "15" },
73 { 16, "16" },
74 { 17, "17" },
75 { 18, "18" },
76 { 19, "19" },
77 { 20, "20" },
78 { 21, "21" },
79 { 22, "22" },
80 { 23, "23" },
81 { 24, "24" },
82 { 25, "25" },
83 { 26, "26" },
84 { 27, "27" },
85 { 28, "28" },
86 { 29, "29" },
87 { 30, "30" },
88 { 31, "31" },
89 { 32, "32" },
90 { 33, "33" },
91 { 34, "34" },
92 { 35, "35" },
93 { 36, "36" },
94 { 37, "37" },
95 { 38, "38" },
96 { 39, "39" },
97 { 40, "40" },
98 };
99
100 static stp_curve_t *hue_curve_bounds = NULL;
101 static int escp2_channel_counts_count =
102 sizeof(escp2_channel_counts) / sizeof(channel_count_t);
103
104 static const double ink_darknesses[] =
105 {
106 1.0, 0.31 / .4, 0.61 / .96, 0.08, 0.31 * 0.33 / .4, 0.61 * 0.33 / .96, 0.33, 1.0
107 };
108
109 #define INCH(x) (72 * x)
110
111 #define PARAMETER_INT(s) \
112 { \
113 "escp2_" #s, "escp2_" #s, \
114 "Color=Yes,Category=Advanced Printer Functionality", NULL, \
115 STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE, \
116 STP_PARAMETER_LEVEL_INTERNAL, 0, 1, STP_CHANNEL_NONE, 1, 0 \
117 }
118
119 #define PARAMETER_DIMENSION(s) \
120 { \
121 "escp2_" #s, "escp2_" #s, \
122 "Color=Yes,Category=Advanced Printer Functionality", NULL, \
123 STP_PARAMETER_TYPE_DIMENSION, STP_PARAMETER_CLASS_FEATURE, \
124 STP_PARAMETER_LEVEL_INTERNAL, 0, 1, STP_CHANNEL_NONE, 1, 0 \
125 }
126
127 #define PARAMETER_INT_RO(s) \
128 { \
129 "escp2_" #s, "escp2_" #s, \
130 "Color=Yes,Category=Advanced Printer Functionality", NULL, \
131 STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE, \
132 STP_PARAMETER_LEVEL_INTERNAL, 0, 1, STP_CHANNEL_NONE, 1, 1 \
133 }
134
135 #define PARAMETER_RAW(s) \
136 { \
137 "escp2_" #s, "escp2_" #s, \
138 "Color=Yes,Category=Advanced Printer Functionality", NULL, \
139 STP_PARAMETER_TYPE_RAW, STP_PARAMETER_CLASS_FEATURE, \
140 STP_PARAMETER_LEVEL_INTERNAL, 0, 1, STP_CHANNEL_NONE, 1, 0 \
141 }
142
143 typedef struct
144 {
145 const stp_parameter_t param;
146 double min;
147 double max;
148 double defval;
149 int color_only;
150 } float_param_t;
151
152 typedef struct
153 {
154 const stp_parameter_t param;
155 int min;
156 int max;
157 int defval;
158 } int_param_t;
159
160 static const stp_parameter_t the_parameters[] =
161 {
162 #if 0
163 {
164 "AutoMode", N_("Automatic Printing Mode"), "Color=Yes,Category=Basic Output Adjustment",
165 N_("Automatic printing mode"),
166 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
167 STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0
168 },
169 #endif
170 /*
171 * Don't check this parameter. We may offer different settings for
172 * different papers, but we need to be able to handle settings from PPD
173 * files that don't have constraints set up.
174 */
175 {
176 "Quality", N_("Print Quality"), "Color=Yes,Category=Basic Output Adjustment",
177 N_("Print Quality"),
178 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
179 STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 0, 0
180 },
181 {
182 "PageSize", N_("Page Size"), "Color=No,Category=Basic Printer Setup",
183 N_("Size of the paper being printed to"),
184 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_CORE,
185 STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0
186 },
187 {
188 "MediaType", N_("Media Type"), "Color=Yes,Category=Basic Printer Setup",
189 N_("Type of media (plain paper, photo paper, etc.)"),
190 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
191 STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0
192 },
193 {
194 "InputSlot", N_("Media Source"), "Color=No,Category=Basic Printer Setup",
195 N_("Source (input slot) of the media"),
196 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
197 STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0
198 },
199 {
200 "Duplex", N_("Double-Sided Printing"), "Color=No,Category=Basic Printer Setup",
201 N_("Duplex/Tumble Setting"),
202 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
203 STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0
204 },
205 {
206 "CDInnerRadius", N_("CD Hub Size"), "Color=No,Category=Basic Printer Setup",
207 N_("Print only outside of the hub of the CD, or all the way to the hole"),
208 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
209 STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0
210 },
211 {
212 "CDOuterDiameter", N_("CD Size (Custom)"), "Color=No,Category=Basic Printer Setup",
213 N_("Variable adjustment for the outer diameter of CD"),
214 STP_PARAMETER_TYPE_DIMENSION, STP_PARAMETER_CLASS_FEATURE,
215 STP_PARAMETER_LEVEL_ADVANCED, 1, 1, STP_CHANNEL_NONE, 1, 0
216 },
217 {
218 "CDInnerDiameter", N_("CD Hub Size (Custom)"), "Color=No,Category=Basic Printer Setup",
219 N_("Variable adjustment to the inner hub of the CD"),
220 STP_PARAMETER_TYPE_DIMENSION, STP_PARAMETER_CLASS_FEATURE,
221 STP_PARAMETER_LEVEL_ADVANCED, 1, 1, STP_CHANNEL_NONE, 1, 0
222 },
223 {
224 "CDXAdjustment", N_("CD Horizontal Fine Adjustment"), "Color=No,Category=Advanced Printer Setup",
225 N_("Fine adjustment to horizontal position for CD printing"),
226 STP_PARAMETER_TYPE_DIMENSION, STP_PARAMETER_CLASS_FEATURE,
227 STP_PARAMETER_LEVEL_ADVANCED, 1, 1, STP_CHANNEL_NONE, 1, 0
228 },
229 {
230 "CDYAdjustment", N_("CD Vertical Fine Adjustment"), "Color=No,Category=Advanced Printer Setup",
231 N_("Fine adjustment to horizontal position for CD printing"),
232 STP_PARAMETER_TYPE_DIMENSION, STP_PARAMETER_CLASS_FEATURE,
233 STP_PARAMETER_LEVEL_ADVANCED, 1, 1, STP_CHANNEL_NONE, 1, 0
234 },
235 {
236 "CDAllowOtherMedia", N_("CD Allow Other Media Sizes"), "Color=No,Category=Advanced Printer Setup",
237 N_("Allow non-CD media sizes when printing to CD"),
238 STP_PARAMETER_TYPE_BOOLEAN, STP_PARAMETER_CLASS_FEATURE,
239 STP_PARAMETER_LEVEL_ADVANCED, 1, 1, STP_CHANNEL_NONE, 1, 0
240 },
241 {
242 "Resolution", N_("Resolution"), "Color=Yes,Category=Basic Printer Setup",
243 N_("Resolution of the print"),
244 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
245 STP_PARAMETER_LEVEL_ADVANCED, 1, 1, STP_CHANNEL_NONE, 1, 0
246 },
247 /*
248 * Don't check this parameter. We may offer different settings for
249 * different ink sets, but we need to be able to handle settings from PPD
250 * files that don't have constraints set up.
251 */
252 {
253 "InkType", N_("Ink Type"), "Color=Yes,Category=Advanced Printer Setup",
254 N_("Type of ink in the printer"),
255 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
256 STP_PARAMETER_LEVEL_ADVANCED2, 1, 1, STP_CHANNEL_NONE, 0, 0
257 },
258 {
259 "UseGloss", N_("Enhanced Gloss"), "Color=Yes,Category=Basic Printer Setup",
260 N_("Add gloss enhancement"),
261 STP_PARAMETER_TYPE_BOOLEAN, STP_PARAMETER_CLASS_FEATURE,
262 STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 0, 0
263 },
264 {
265 "InkSet", N_("Ink Set"), "Color=Yes,Category=Basic Printer Setup",
266 N_("Type of ink in the printer"),
267 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
268 STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0
269 },
270 {
271 "PrintingDirection", N_("Printing Direction"), "Color=Yes,Category=Advanced Output Adjustment",
272 N_("Printing direction (unidirectional is higher quality, but slower)"),
273 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
274 STP_PARAMETER_LEVEL_ADVANCED1, 1, 1, STP_CHANNEL_NONE, 1, 0
275 },
276 {
277 "FullBleed", N_("Borderless"), "Color=No,Category=Basic Printer Setup",
278 N_("Print without borders"),
279 STP_PARAMETER_TYPE_BOOLEAN, STP_PARAMETER_CLASS_FEATURE,
280 STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0
281 },
282 {
283 "Weave", N_("Interleave Method"), "Color=Yes,Category=Advanced Output Adjustment",
284 N_("Interleave pattern to use"),
285 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
286 STP_PARAMETER_LEVEL_ADVANCED1, 1, 1, STP_CHANNEL_NONE, 1, 0
287 },
288 {
289 "OutputOrder", N_("Output Order"), "Color=No,Category=Basic Printer Setup",
290 N_("Output Order"),
291 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
292 STP_PARAMETER_LEVEL_BASIC, 0, 0, STP_CHANNEL_NONE, 0, 0
293 },
294 {
295 "AlignmentPasses", N_("Alignment Passes"), "Color=No,Category=Advanced Printer Functionality",
296 N_("Alignment Passes"),
297 STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE,
298 STP_PARAMETER_LEVEL_INTERNAL, 0, 0, STP_CHANNEL_NONE, 0, 0
299 },
300 {
301 "AlignmentChoices", N_("Alignment Choices"), "Color=No,Category=Advanced Printer Functionality",
302 N_("Alignment Choices"),
303 STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE,
304 STP_PARAMETER_LEVEL_INTERNAL, 0, 0, STP_CHANNEL_NONE, 0, 0
305 },
306 {
307 "InkChange", N_("Ink change command"), "Color=No,Category=Advanced Printer Functionality",
308 N_("Ink change command"),
309 STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE,
310 STP_PARAMETER_LEVEL_INTERNAL, 0, 0, STP_CHANNEL_NONE, 0, 0
311 },
312 {
313 "AlternateAlignmentPasses", N_("Alternate Alignment Passes"), "Color=No,Category=Advanced Printer Functionality",
314 N_("Alternate Alignment Passes"),
315 STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE,
316 STP_PARAMETER_LEVEL_INTERNAL, 0, 0, STP_CHANNEL_NONE, 0, 0
317 },
318 {
319 "AlternateAlignmentChoices", N_("Alternate Alignment Choices"), "Color=No,Category=Advanced Printer Functionality",
320 N_("Alternate Alignment Choices"),
321 STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE,
322 STP_PARAMETER_LEVEL_INTERNAL, 0, 0, STP_CHANNEL_NONE, 0, 0
323 },
324 {
325 "SupportsPacketMode", N_("Supports Packet Mode"), "Color=No,Category=Advanced Printer Functionality",
326 N_("Supports D4 Packet Mode"),
327 STP_PARAMETER_TYPE_BOOLEAN, STP_PARAMETER_CLASS_FEATURE,
328 STP_PARAMETER_LEVEL_INTERNAL, 0, 0, STP_CHANNEL_NONE, 0, 0
329 },
330 {
331 "InterchangeableInk", N_("Has Interchangeable Ink Cartridges"), "Color=No,Category=Advanced Printer Functionality",
332 N_("Has multiple choices of ink cartridges"),
333 STP_PARAMETER_TYPE_BOOLEAN, STP_PARAMETER_CLASS_FEATURE,
334 STP_PARAMETER_LEVEL_INTERNAL, 0, 0, STP_CHANNEL_NONE, 0, 0
335 },
336 {
337 "InkChannels", N_("Ink Channels"), "Color=No,Category=Advanced Printer Functionality",
338 N_("Ink Channels"),
339 STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE,
340 STP_PARAMETER_LEVEL_INTERNAL, 0, 0, STP_CHANNEL_NONE, 0, 0
341 },
342 {
343 "RawChannelNames", N_("Raw Channel Names"), "Color=No,Category=Advanced Printer Functionality",
344 N_("Raw Channel Names"),
345 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
346 STP_PARAMETER_LEVEL_INTERNAL, 0, 0, STP_CHANNEL_NONE, 0, 0
347 },
348 {
349 "CommandFilterName", N_("Command filter name"), "Color=No,Category=Job Mode",
350 N_("Command filter name"),
351 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
352 STP_PARAMETER_LEVEL_INTERNAL, 1, 0, STP_CHANNEL_NONE, 0, 1
353 },
354 {
355 "CommandFilterCommands", N_("Filter commands supported"), "Color=No,Category=Job Mode",
356 N_("Filter commands supported"),
357 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
358 STP_PARAMETER_LEVEL_INTERNAL, 1, 0, STP_CHANNEL_NONE, 0, 1
359 },
360 {
361 "ChannelNames", N_("Channel Names"), "Color=No,Category=Advanced Printer Functionality",
362 N_("Channel Names"),
363 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
364 STP_PARAMETER_LEVEL_INTERNAL, 0, 0, STP_CHANNEL_NONE, 0, 0
365 },
366 {
367 "PrintingMode", N_("Printing Mode"), "Color=Yes,Category=Core Parameter",
368 N_("Printing Output Mode"),
369 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_CORE,
370 STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0
371 },
372 {
373 "RawChannels", N_("Raw Channels"), "Color=Yes,Category=Core Parameter",
374 N_("Raw Channel Count"),
375 STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_CORE,
376 STP_PARAMETER_LEVEL_BASIC, 0, 1, STP_CHANNEL_NONE, 1, 0
377 },
378 {
379 "CyanHueCurve", N_("Cyan Map"), "Color=Yes,Category=Advanced Output Control",
380 N_("Adjust the cyan map"),
381 STP_PARAMETER_TYPE_CURVE, STP_PARAMETER_CLASS_OUTPUT,
382 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, 1, 1, 0
383 },
384 {
385 "MagentaHueCurve", N_("Magenta Map"), "Color=Yes,Category=Advanced Output Control",
386 N_("Adjust the magenta map"),
387 STP_PARAMETER_TYPE_CURVE, STP_PARAMETER_CLASS_OUTPUT,
388 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, 2, 1, 0
389 },
390 {
391 "YellowHueCurve", N_("Yellow Map"), "Color=Yes,Category=Advanced Output Control",
392 N_("Adjust the yellow map"),
393 STP_PARAMETER_TYPE_CURVE, STP_PARAMETER_CLASS_OUTPUT,
394 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, 3, 1, 0
395 },
396 {
397 "BlueHueCurve", N_("Blue Map"), "Color=Yes,Category=Advanced Output Control",
398 N_("Adjust the blue map"),
399 STP_PARAMETER_TYPE_CURVE, STP_PARAMETER_CLASS_OUTPUT,
400 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, 4, 1, 0
401 },
402 {
403 "OrangeHueCurve", N_("Orange Map"), "Color=Yes,Category=Advanced Output Control",
404 N_("Adjust the orange map"),
405 STP_PARAMETER_TYPE_CURVE, STP_PARAMETER_CLASS_OUTPUT,
406 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, 4, 1, 0
407 },
408 {
409 "RedHueCurve", N_("Red Map"), "Color=Yes,Category=Advanced Output Control",
410 N_("Adjust the red map"),
411 STP_PARAMETER_TYPE_CURVE, STP_PARAMETER_CLASS_OUTPUT,
412 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, 5, 1, 0
413 },
414 {
415 "GreenHueCurve", N_("Green Map"), "Color=Yes,Category=Advanced Output Control",
416 N_("Adjust the green map"),
417 STP_PARAMETER_TYPE_CURVE, STP_PARAMETER_CLASS_OUTPUT,
418 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, 5, 1, 0
419 },
420 PARAMETER_INT(max_hres),
421 PARAMETER_INT(max_vres),
422 PARAMETER_INT(min_hres),
423 PARAMETER_INT(min_vres),
424 PARAMETER_INT(nozzles),
425 PARAMETER_INT(black_nozzles),
426 PARAMETER_INT(fast_nozzles),
427 PARAMETER_INT(min_nozzles),
428 PARAMETER_INT(min_black_nozzles),
429 PARAMETER_INT(min_fast_nozzles),
430 PARAMETER_INT(nozzle_start),
431 PARAMETER_INT(black_nozzle_start),
432 PARAMETER_INT(fast_nozzle_start),
433 PARAMETER_INT(nozzle_separation),
434 PARAMETER_INT(black_nozzle_separation),
435 PARAMETER_INT(fast_nozzle_separation),
436 PARAMETER_INT(separation_rows),
437 PARAMETER_INT(roll_lb),
438 PARAMETER_DIMENSION(max_paper_width),
439 PARAMETER_DIMENSION(max_paper_height),
440 PARAMETER_DIMENSION(min_paper_width),
441 PARAMETER_DIMENSION(min_paper_height),
442 PARAMETER_DIMENSION(max_imageable_width),
443 PARAMETER_DIMENSION(max_imageable_height),
444 PARAMETER_INT(extra_feed),
445 PARAMETER_INT(pseudo_separation_rows),
446 PARAMETER_INT(base_separation),
447 PARAMETER_INT(resolution_scale),
448 PARAMETER_INT(initial_vertical_offset),
449 PARAMETER_INT(black_initial_vertical_offset),
450 PARAMETER_INT(printing_initial_vertical_offset),
451 PARAMETER_INT(max_black_resolution),
452 PARAMETER_INT(zero_margin_offset),
453 PARAMETER_INT(extra_720dpi_separation),
454 PARAMETER_INT(micro_left_margin),
455 PARAMETER_INT(min_horizontal_position_alignment),
456 PARAMETER_INT(base_horizontal_position_alignment),
457 PARAMETER_INT(bidirectional_upper_limit),
458 PARAMETER_INT(physical_channels),
459 PARAMETER_DIMENSION(left_margin),
460 PARAMETER_DIMENSION(right_margin),
461 PARAMETER_DIMENSION(top_margin),
462 PARAMETER_DIMENSION(bottom_margin),
463 PARAMETER_INT(ink_type),
464 PARAMETER_INT(bits),
465 PARAMETER_INT(base_res),
466 PARAMETER_INT_RO(alignment_passes),
467 PARAMETER_INT_RO(alignment_choices),
468 PARAMETER_INT_RO(alternate_alignment_passes),
469 PARAMETER_INT_RO(alternate_alignment_choices),
470 PARAMETER_DIMENSION(cd_page_width),
471 PARAMETER_DIMENSION(cd_page_height),
472 PARAMETER_DIMENSION(cd_x_offset),
473 PARAMETER_DIMENSION(cd_y_offset),
474 PARAMETER_INT(paper_extra_bottom),
475 PARAMETER_RAW(preinit_sequence),
476 PARAMETER_RAW(preinit_remote_sequence),
477 PARAMETER_RAW(postinit_remote_sequence),
478 PARAMETER_RAW(vertical_borderless_sequence)
479 };
480
481 static const int the_parameter_count =
482 sizeof(the_parameters) / sizeof(const stp_parameter_t);
483
484 static const float_param_t float_parameters[] =
485 {
486 {
487 {
488 "CyanDensity", N_("Cyan Density"), "Color=Yes,Category=Output Level Adjustment",
489 N_("Adjust the cyan density"),
490 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
491 STP_PARAMETER_LEVEL_ADVANCED, 0, 1, 1, 1, 0
492 }, 0.0, 2.0, 1.0, 1
493 },
494 {
495 {
496 "MagentaDensity", N_("Magenta Density"), "Color=Yes,Category=Output Level Adjustment",
497 N_("Adjust the magenta density"),
498 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
499 STP_PARAMETER_LEVEL_ADVANCED, 0, 1, 2, 1, 0
500 }, 0.0, 2.0, 1.0, 1
501 },
502 {
503 {
504 "YellowDensity", N_("Yellow Density"), "Color=Yes,Category=Output Level Adjustment",
505 N_("Adjust the yellow density"),
506 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
507 STP_PARAMETER_LEVEL_ADVANCED, 0, 1, 3, 1, 0
508 }, 0.0, 2.0, 1.0, 1
509 },
510 {
511 {
512 "BlackDensity", N_("Black Density"), "Color=Yes,Category=Output Level Adjustment",
513 N_("Adjust the black density"),
514 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
515 STP_PARAMETER_LEVEL_ADVANCED, 0, 1, 0, 1, 0
516 }, 0.0, 2.0, 1.0, 1
517 },
518 {
519 {
520 "BlueDensity", N_("Blue Density"), "Color=Yes,Category=Output Level Adjustment",
521 N_("Adjust the blue density"),
522 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
523 STP_PARAMETER_LEVEL_ADVANCED, 0, 1, 4, 1, 0
524 }, 0.0, 2.0, 1.0, 1
525 },
526 {
527 {
528 "OrangeDensity", N_("Orange Density"), "Color=Yes,Category=Output Level Adjustment",
529 N_("Adjust the orange density"),
530 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
531 STP_PARAMETER_LEVEL_ADVANCED, 0, 1, 4, 1, 0
532 }, 0.0, 2.0, 1.0, 1
533 },
534 {
535 {
536 "RedDensity", N_("Red Density"), "Color=Yes,Category=Output Level Adjustment",
537 N_("Adjust the red density"),
538 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
539 STP_PARAMETER_LEVEL_ADVANCED, 0, 1, 5, 1, 0
540 }, 0.0, 2.0, 1.0, 1
541 },
542 {
543 {
544 "GreenDensity", N_("Green Density"), "Color=Yes,Category=Output Level Adjustment",
545 N_("Adjust the green density"),
546 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
547 STP_PARAMETER_LEVEL_ADVANCED, 0, 1, 5, 1, 0
548 }, 0.0, 2.0, 1.0, 1
549 },
550 {
551 {
552 "GlossLimit", N_("Gloss Level"), "Color=Yes,Category=Output Level Adjustment",
553 N_("Adjust the gloss level"),
554 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
555 STP_PARAMETER_LEVEL_ADVANCED, 0, 1, 6, 1, 0
556 }, 0.0, 2.0, 1.0, 1
557 },
558 {
559 {
560 "DropSize1", N_("Drop Size Small"), "Color=Yes,Category=Advanced Ink Adjustment",
561 N_("Drop Size 1 (small)"),
562 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
563 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
564 }, 0.0, 1.0, 1.0, 1
565 },
566 {
567 {
568 "DropSize2", N_("Drop Size Medium"), "Color=Yes,Category=Advanced Ink Adjustment",
569 N_("Drop Size 2 (medium)"),
570 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
571 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
572 }, 0.0, 1.0, 0.0, 1
573 },
574 {
575 {
576 "DropSize3", N_("Drop Size Large"), "Color=Yes,Category=Advanced Ink Adjustment",
577 N_("Drop Size 3 (large)"),
578 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
579 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
580 }, 0.0, 1.0, 0.0, 1
581 },
582 {
583 {
584 "LightCyanValue", N_("Light Cyan Value"), "Color=Yes,Category=Advanced Ink Adjustment",
585 N_("Light Cyan Value"),
586 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
587 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
588 }, 0.0, 5.0, 1.0, 1
589 },
590 {
591 {
592 "LightCyanTrans", N_("Light Cyan Transition"), "Color=Yes,Category=Advanced Ink Adjustment",
593 N_("Light Cyan Transition"),
594 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
595 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
596 }, 0.0, 5.0, 1.0, 1
597 },
598 {
599 {
600 "LightCyanScale", N_("Light Cyan Density Scale"), "Color=Yes,Category=Advanced Ink Adjustment",
601 N_("Light Cyan Density Scale"),
602 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
603 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
604 }, 0.0, 5.0, 1.0, 1
605 },
606 {
607 {
608 "LightMagentaValue", N_("Light Magenta Value"), "Color=Yes,Category=Advanced Ink Adjustment",
609 N_("Light Magenta Value"),
610 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
611 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
612 }, 0.0, 5.0, 1.0, 1
613 },
614 {
615 {
616 "LightMagentaScale", N_("Light Magenta Density Scale"), "Color=Yes,Category=Advanced Ink Adjustment",
617 N_("Light Magenta Density Scale"),
618 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
619 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
620 }, 0.0, 5.0, 1.0, 1
621 },
622 {
623 {
624 "LightMagentaTrans", N_("Light Magenta Transition"), "Color=Yes,Category=Advanced Ink Adjustment",
625 N_("Light Magenta Transition"),
626 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
627 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
628 }, 0.0, 5.0, 1.0, 1
629 },
630 {
631 {
632 "DarkYellowValue", N_("Dark Yellow Value"), "Color=Yes,Category=Advanced Ink Adjustment",
633 N_("Dark Yellow Value"),
634 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
635 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
636 }, 0.0, 5.0, 1.0, 1
637 },
638 {
639 {
640 "DarkYellowTrans", N_("Dark Yellow Transition"), "Color=Yes,Category=Advanced Ink Adjustment",
641 N_("Dark Yellow Transition"),
642 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
643 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
644 }, 0.0, 5.0, 1.0, 1
645 },
646 {
647 {
648 "DarkYellowScale", N_("Dark Yellow Density Scale"), "Color=Yes,Category=Advanced Ink Adjustment",
649 N_("Dark Yellow Density Scale"),
650 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
651 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
652 }, 0.0, 5.0, 1.0, 1
653 },
654 {
655 {
656 "GrayValue", N_("Gray Value"), "Color=Yes,Category=Advanced Ink Adjustment",
657 N_("Gray Value"),
658 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
659 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
660 }, 0.0, 5.0, 1.0, 1
661 },
662 {
663 {
664 "GrayTrans", N_("Gray Transition"), "Color=Yes,Category=Advanced Ink Adjustment",
665 N_("Gray Transition"),
666 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
667 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
668 }, 0.0, 5.0, 1.0, 1
669 },
670 {
671 {
672 "GrayScale", N_("Gray Density Scale"), "Color=Yes,Category=Advanced Ink Adjustment",
673 N_("Gray Density Scale"),
674 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
675 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
676 }, 0.0, 5.0, 1.0, 1
677 },
678 {
679 {
680 "DarkGrayValue", N_("Gray Value"), "Color=Yes,Category=Advanced Ink Adjustment",
681 N_("Gray Value"),
682 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
683 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
684 }, 0.0, 5.0, 1.0, 1
685 },
686 {
687 {
688 "DarkGrayTrans", N_("Gray Transition"), "Color=Yes,Category=Advanced Ink Adjustment",
689 N_("Gray Transition"),
690 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
691 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
692 }, 0.0, 5.0, 1.0, 1
693 },
694 {
695 {
696 "DarkGrayScale", N_("Gray Density Scale"), "Color=Yes,Category=Advanced Ink Adjustment",
697 N_("Gray Density Scale"),
698 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
699 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
700 }, 0.0, 5.0, 1.0, 1
701 },
702 {
703 {
704 "LightGrayValue", N_("Light Gray Value"), "Color=Yes,Category=Advanced Ink Adjustment",
705 N_("Light Gray Value"),
706 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
707 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
708 }, 0.0, 5.0, 1.0, 1
709 },
710 {
711 {
712 "LightGrayTrans", N_("Light Gray Transition"), "Color=Yes,Category=Advanced Ink Adjustment",
713 N_("Light Gray Transition"),
714 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
715 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
716 }, 0.0, 5.0, 1.0, 1
717 },
718 {
719 {
720 "LightGrayScale", N_("Light Gray Density Scale"), "Color=Yes,Category=Advanced Ink Adjustment",
721 N_("Light Gray Density Scale"),
722 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
723 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
724 }, 0.0, 5.0, 1.0, 1
725 },
726 {
727 {
728 "Gray3Value", N_("Dark Gray Value"), "Color=Yes,Category=Advanced Ink Adjustment",
729 N_("Dark Gray Value"),
730 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
731 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
732 }, 0.0, 5.0, 1.0, 1
733 },
734 {
735 {
736 "Gray3Trans", N_("Dark Gray Transition"), "Color=Yes,Category=Advanced Ink Adjustment",
737 N_("Dark Gray Transition"),
738 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
739 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
740 }, 0.0, 5.0, 1.0, 1
741 },
742 {
743 {
744 "Gray3Scale", N_("Dark Gray Density Scale"), "Color=Yes,Category=Advanced Ink Adjustment",
745 N_("Dark Gray Density Scale"),
746 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
747 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
748 }, 0.0, 5.0, 1.0, 1
749 },
750 {
751 {
752 "Gray2Value", N_("Mid Gray Value"), "Color=Yes,Category=Advanced Ink Adjustment",
753 N_("Medium Gray Value"),
754 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
755 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
756 }, 0.0, 5.0, 1.0, 1
757 },
758 {
759 {
760 "Gray2Trans", N_("Mid Gray Transition"), "Color=Yes,Category=Advanced Ink Adjustment",
761 N_("Medium Gray Transition"),
762 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
763 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
764 }, 0.0, 5.0, 1.0, 1
765 },
766 {
767 {
768 "Gray2Scale", N_("Mid Gray Density Scale"), "Color=Yes,Category=Advanced Ink Adjustment",
769 N_("Medium Gray Density Scale"),
770 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
771 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
772 }, 0.0, 5.0, 1.0, 1
773 },
774 {
775 {
776 "Gray1Value", N_("Light Gray Value"), "Color=Yes,Category=Advanced Ink Adjustment",
777 N_("Light Gray Value"),
778 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
779 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
780 }, 0.0, 5.0, 1.0, 1
781 },
782 {
783 {
784 "Gray1Trans", N_("Light Gray Transition"), "Color=Yes,Category=Advanced Ink Adjustment",
785 N_("Light Gray Transition"),
786 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
787 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
788 }, 0.0, 5.0, 1.0, 1
789 },
790 {
791 {
792 "Gray1Scale", N_("Light Gray Density Scale"), "Color=Yes,Category=Advanced Ink Adjustment",
793 N_("Light Gray Density Scale"),
794 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
795 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
796 }, 0.0, 5.0, 1.0, 1
797 },
798 {
799 {
800 "HGray5Value", N_("Hextone Gray 5 Value"), "Color=Yes,Category=Advanced Ink Adjustment",
801 N_("Hextone Gray 5 (Darkest) Value"),
802 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
803 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
804 }, 0.0, 5.0, 1.0, 1
805 },
806 {
807 {
808 "HGray5Trans", N_("Hextone Gray 5 Transition"), "Color=Yes,Category=Advanced Ink Adjustment",
809 N_("Hextone Gray 5 (Darkest) Transition"),
810 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
811 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
812 }, 0.0, 5.0, 1.0, 1
813 },
814 {
815 {
816 "HGray5Scale", N_("Hextone Gray 5 Density Scale"), "Color=Yes,Category=Advanced Ink Adjustment",
817 N_("Hextone Gray 5 (Darkest) Density Scale"),
818 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
819 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
820 }, 0.0, 5.0, 1.0, 1
821 },
822 {
823 {
824 "HGray4Value", N_("Hextone Gray 4 Value"), "Color=Yes,Category=Advanced Ink Adjustment",
825 N_("Hextone Gray 4 Value"),
826 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
827 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
828 }, 0.0, 5.0, 1.0, 1
829 },
830 {
831 {
832 "HGray4Trans", N_("Hextone Gray 4 Transition"), "Color=Yes,Category=Advanced Ink Adjustment",
833 N_("Hextone Gray 4 Transition"),
834 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
835 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
836 }, 0.0, 5.0, 1.0, 1
837 },
838 {
839 {
840 "HGray4Scale", N_("Hextone Gray 4 Density Scale"), "Color=Yes,Category=Advanced Ink Adjustment",
841 N_("Hextone Gray 4 Density Scale"),
842 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
843 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
844 }, 0.0, 5.0, 1.0, 1
845 },
846 {
847 {
848 "HGray3Value", N_("Hextone Gray 3 Value"), "Color=Yes,Category=Advanced Ink Adjustment",
849 N_("Hextone Gray 3 Value"),
850 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
851 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
852 }, 0.0, 5.0, 1.0, 1
853 },
854 {
855 {
856 "HGray3Trans", N_("Hextone Gray 3 Transition"), "Color=Yes,Category=Advanced Ink Adjustment",
857 N_("Hextone Gray 3 Transition"),
858 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
859 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
860 }, 0.0, 5.0, 1.0, 1
861 },
862 {
863 {
864 "HGray3Scale", N_("Hextone Gray 3 Density Scale"), "Color=Yes,Category=Advanced Ink Adjustment",
865 N_("Hextone Gray 3 Density Scale"),
866 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
867 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
868 }, 0.0, 5.0, 1.0, 1
869 },
870 {
871 {
872 "HGray2Value", N_("Hextone Gray 2 Value"), "Color=Yes,Category=Advanced Ink Adjustment",
873 N_("Hextone Gray 2 Value"),
874 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
875 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
876 }, 0.0, 5.0, 1.0, 1
877 },
878 {
879 {
880 "HGray2Trans", N_("Hextone Gray 2 Transition"), "Color=Yes,Category=Advanced Ink Adjustment",
881 N_("Hextone Gray 2 Transition"),
882 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
883 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
884 }, 0.0, 5.0, 1.0, 1
885 },
886 {
887 {
888 "HGray2Scale", N_("Hextone Gray 2 Density Scale"), "Color=Yes,Category=Advanced Ink Adjustment",
889 N_("Hextone Gray 2 Density Scale"),
890 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
891 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
892 }, 0.0, 5.0, 1.0, 1
893 },
894 {
895 {
896 "HGray1Value", N_("Hextone Gray 1 Value"), "Color=Yes,Category=Advanced Ink Adjustment",
897 N_("Hextone Gray 1 (Lightest) Value"),
898 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
899 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
900 }, 0.0, 5.0, 1.0, 1
901 },
902 {
903 {
904 "HGray1Trans", N_("Hextone Gray 1 Transition"), "Color=Yes,Category=Advanced Ink Adjustment",
905 N_("Hextone Gray 1 (Lightest) Transition"),
906 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
907 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
908 }, 0.0, 5.0, 1.0, 1
909 },
910 {
911 {
912 "HGray1Scale", N_("Hextone Gray 1 Density Scale"), "Color=Yes,Category=Advanced Ink Adjustment",
913 N_("Hextone Gray 1 (Lightest) Density Scale"),
914 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
915 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0
916 }, 0.0, 5.0, 1.0, 1
917 },
918 {
919 {
920 "BlackTrans", N_("GCR Transition"), "Color=Yes,Category=Advanced Output Control",
921 N_("Adjust the gray component transition rate"),
922 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
923 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, 0, 1, 0
924 }, 0.0, 1.0, 1.0, 1
925 },
926 {
927 {
928 "GCRLower", N_("GCR Lower Bound"), "Color=Yes,Category=Advanced Output Control",
929 N_("Lower bound of gray component reduction"),
930 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
931 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, 0, 1, 0
932 }, 0.0, 1.0, 0.2, 1
933 },
934 {
935 {
936 "GCRUpper", N_("GCR Upper Bound"), "Color=Yes,Category=Advanced Output Control",
937 N_("Upper bound of gray component reduction"),
938 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
939 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, 0, 1, 0
940 }, 0.0, 5.0, 0.5, 1
941 },
942 {
943 {
944 "SubchannelCutoff", N_("Subchannel Cutoff"), "Color=Yes,Category=Advanced Output Control",
945 N_("Upper limit for using light ink"),
946 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT,
947 STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, 0, 1, 0
948 }, 0.0, 1.0, 1.0, 1
949 },
950 {
951 {
952 "PageDryTime", N_("Drying Time Per Page"), "Color=No,Category=Advanced Printer Functionality",
953 N_("Set drying time per page"),
954 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_FEATURE,
955 STP_PARAMETER_LEVEL_ADVANCED3, 0, 1, STP_CHANNEL_NONE, 1, 0
956 }, 0, 60.0, 0.0, 1
957 },
958 {
959 {
960 "ScanDryTime", N_("Drying Time Per Scan"), "Color=No,Category=Advanced Printer Functionality",
961 N_("Set drying time per scan"),
962 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_FEATURE,
963 STP_PARAMETER_LEVEL_ADVANCED3, 0, 1, STP_CHANNEL_NONE, 1, 0
964 }, 0, 10.0, 0.0, 1
965 },
966 {
967 {
968 "ScanMinDryTime", N_("Minimum Drying Time Per Scan"), "Color=No,Category=Advanced Printer Functionality",
969 N_("Set minimum drying time per scan"),
970 STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_FEATURE,
971 STP_PARAMETER_LEVEL_ADVANCED3, 0, 1, STP_CHANNEL_NONE, 1, 0
972 }, 0, 10.0, 0.0, 1
973 },
974 };
975
976 static const unsigned int float_parameter_count =
977 sizeof(float_parameters) / sizeof(const float_param_t);
978
979 static const int_param_t int_parameters[] =
980 {
981 {
982 {
983 "BandEnhancement", N_("Quality Enhancement"), "Color=No,Category=Advanced Printer Functionality",
984 N_("Enhance print quality by additional passes"),
985 STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE,
986 STP_PARAMETER_LEVEL_ADVANCED2, 0, 1, STP_CHANNEL_NONE, 1, 0
987 }, 0, 4, 0
988 },
989 {
990 {
991 "PaperThickness", N_("Paper Thickness"), "Color=No,Category=Advanced Printer Functionality",
992 N_("Set printer paper thickness"),
993 STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE,
994 STP_PARAMETER_LEVEL_ADVANCED3, 0, 1, STP_CHANNEL_NONE, 1, 0
995 }, 0, 255, 0
996 },
997 {
998 {
999 "VacuumIntensity", N_("Vacuum Intensity"), "Color=No,Category=Advanced Printer Functionality",
1000 N_("Set vacuum intensity (printer-specific)"),
1001 STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE,
1002 STP_PARAMETER_LEVEL_ADVANCED3, 0, 1, STP_CHANNEL_NONE, 1, 0
1003 }, 0, 255, 0
1004 },
1005 {
1006 {
1007 "FeedSequence", N_("Feed Sequence"), "Color=No,Category=Advanced Printer Functionality",
1008 N_("Set paper feed sequence (printer-specific)"),
1009 STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE,
1010 STP_PARAMETER_LEVEL_ADVANCED3, 0, 1, STP_CHANNEL_NONE, 1, 0
1011 }, 0, 255, 0
1012 },
1013 {
1014 {
1015 "PrintMethod", N_("Print Method"), "Color=No,Category=Advanced Printer Functionality",
1016 N_("Set print method (printer-specific)"),
1017 STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE,
1018 STP_PARAMETER_LEVEL_ADVANCED3, 0, 1, STP_CHANNEL_NONE, 1, 0
1019 }, 0, 255, 0
1020 },
1021 {
1022 {
1023 "PlatenGap", N_("Platen Gap"), "Color=No,Category=Advanced Printer Functionality",
1024 N_("Set platen gap (printer-specific)"),
1025 STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE,
1026 STP_PARAMETER_LEVEL_ADVANCED3, 0, 1, STP_CHANNEL_NONE, 1, 0
1027 }, 0, 255, 0
1028 },
1029 {
1030 {
1031 "FeedAdjustment", N_("Feed Adjustment"), "Color=No,Category=Advanced Printer Functionality",
1032 /* xgettext:no-c-format */
1033 N_("Set paper feed adjustment (0.01% units)"),
1034 STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE,
1035 STP_PARAMETER_LEVEL_ADVANCED3, 0, 1, STP_CHANNEL_NONE, 1, 0
1036 }, 0, 255, 0
1037 },
1038 };
1039
1040 static const unsigned int int_parameter_count =
1041 sizeof(int_parameters) / sizeof(const int_param_t);
1042
1043 static escp2_privdata_t *
1044 get_privdata(const stp_vars_t *v)
1045 {
1046 return (escp2_privdata_t *) stp_get_component_data(v, "Driver");
1047 }
1048
1049 #define DEF_SIMPLE_ACCESSOR(f, t) \
1050 static t \
1051 escp2_##f(const stp_vars_t *v) \
1052 { \
1053 if (stp_check_int_parameter(v, "escp2_" #f, STP_PARAMETER_ACTIVE)) \
1054 return stp_get_int_parameter(v, "escp2_" #f); \
1055 else \
1056 { \
1057 stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v); \
1058 return printdef->f; \
1059 } \
1060 }
1061
1062 #define DEF_DIMENSION_ACCESSOR(f) \
1063 static stp_dimension_t \
1064 escp2_##f(const stp_vars_t *v) \
1065 { \
1066 if (stp_check_dimension_parameter(v, "escp2_" #f, STP_PARAMETER_ACTIVE)) \
1067 return stp_get_dimension_parameter(v, "escp2_" #f); \
1068 else \
1069 { \
1070 stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v); \
1071 return (stp_dimension_t) printdef->f; \
1072 } \
1073 }
1074
1075 #define DEF_RAW_ACCESSOR(f, t) \
1076 static t \
1077 escp2_##f(const stp_vars_t *v) \
1078 { \
1079 if (stp_check_raw_parameter(v, "escp2_" #f, STP_PARAMETER_ACTIVE)) \
1080 return stp_get_raw_parameter(v, "escp2_" #f); \
1081 else \
1082 { \
1083 stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v); \
1084 return printdef->f; \
1085 } \
1086 }
1087
1088 #define DEF_ROLL_ACCESSOR(f) \
1089 static stp_dimension_t \
1090 escp2_##f(const stp_vars_t *v, int rollfeed) \
1091 { \
1092 if (stp_check_dimension_parameter(v, "escp2_" #f, STP_PARAMETER_ACTIVE)) \
1093 return stp_get_dimension_parameter(v, "escp2_" #f); \
1094 else \
1095 { \
1096 stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v); \
1097 const res_t *res = stpi_escp2_find_resolution(v); \
1098 if (res && res->command) \
1099 { \
1100 if (rollfeed) \
1101 return (printdef->m_roll_##f); \
1102 else \
1103 return (printdef->m_##f); \
1104 } \
1105 else \
1106 { \
1107 if (rollfeed) \
1108 return (printdef->roll_##f); \
1109 else \
1110 return (printdef->f); \
1111 } \
1112 } \
1113 }
1114
1115 DEF_SIMPLE_ACCESSOR(max_hres, unsigned int)
1116 DEF_SIMPLE_ACCESSOR(max_vres, unsigned int)
1117 DEF_SIMPLE_ACCESSOR(min_hres, unsigned int)
1118 DEF_SIMPLE_ACCESSOR(min_vres, unsigned int)
1119 DEF_SIMPLE_ACCESSOR(nozzles, unsigned)
1120 DEF_SIMPLE_ACCESSOR(black_nozzles, unsigned)
1121 DEF_SIMPLE_ACCESSOR(fast_nozzles, unsigned)
1122 DEF_SIMPLE_ACCESSOR(min_nozzles, unsigned)
1123 DEF_SIMPLE_ACCESSOR(min_black_nozzles, unsigned)
1124 DEF_SIMPLE_ACCESSOR(min_fast_nozzles, unsigned)
1125 DEF_SIMPLE_ACCESSOR(nozzle_start, int)
1126 DEF_SIMPLE_ACCESSOR(black_nozzle_start, int)
1127 DEF_SIMPLE_ACCESSOR(fast_nozzle_start, int)
1128 DEF_SIMPLE_ACCESSOR(nozzle_separation, unsigned)
1129 DEF_SIMPLE_ACCESSOR(black_nozzle_separation, unsigned)
1130 DEF_SIMPLE_ACCESSOR(fast_nozzle_separation, unsigned)
1131 DEF_SIMPLE_ACCESSOR(separation_rows, unsigned)
1132 DEF_SIMPLE_ACCESSOR(paper_extra_bottom, int)
1133 DEF_SIMPLE_ACCESSOR(extra_feed, unsigned)
1134 DEF_SIMPLE_ACCESSOR(pseudo_separation_rows, int)
1135 DEF_SIMPLE_ACCESSOR(base_separation, int)
1136 DEF_SIMPLE_ACCESSOR(resolution_scale, int)
1137 DEF_SIMPLE_ACCESSOR(initial_vertical_offset, int)
1138 DEF_SIMPLE_ACCESSOR(black_initial_vertical_offset, int)
1139 DEF_SIMPLE_ACCESSOR(printing_initial_vertical_offset, int)
1140 DEF_SIMPLE_ACCESSOR(max_black_resolution, int)
1141 DEF_SIMPLE_ACCESSOR(zero_margin_offset, int)
1142 DEF_SIMPLE_ACCESSOR(extra_720dpi_separation, int)
1143 DEF_SIMPLE_ACCESSOR(micro_left_margin, int)
1144 DEF_SIMPLE_ACCESSOR(min_horizontal_position_alignment, unsigned)
1145 DEF_SIMPLE_ACCESSOR(base_horizontal_position_alignment, unsigned)
1146 DEF_SIMPLE_ACCESSOR(bidirectional_upper_limit, int)
1147 DEF_SIMPLE_ACCESSOR(physical_channels, int)
1148 DEF_SIMPLE_ACCESSOR(alignment_passes, int)
1149 DEF_SIMPLE_ACCESSOR(alignment_choices, int)
1150 DEF_SIMPLE_ACCESSOR(alternate_alignment_passes, int)
1151 DEF_SIMPLE_ACCESSOR(alternate_alignment_choices, int)
1152
1153 DEF_DIMENSION_ACCESSOR(max_paper_width)
1154 DEF_DIMENSION_ACCESSOR(max_paper_height)
1155 DEF_DIMENSION_ACCESSOR(min_paper_width)
1156 DEF_DIMENSION_ACCESSOR(min_paper_height)
1157 DEF_DIMENSION_ACCESSOR(max_imageable_width)
1158 DEF_DIMENSION_ACCESSOR(max_imageable_height)
1159 DEF_DIMENSION_ACCESSOR(cd_page_width)
1160 DEF_DIMENSION_ACCESSOR(cd_page_height)
1161
1162 DEF_DIMENSION_ACCESSOR(cd_x_offset)
1163 DEF_DIMENSION_ACCESSOR(cd_y_offset)
1164
1165 DEF_ROLL_ACCESSOR(left_margin)
1166 DEF_ROLL_ACCESSOR(right_margin)
1167 DEF_ROLL_ACCESSOR(top_margin)
1168 DEF_ROLL_ACCESSOR(bottom_margin)
1169
1170 DEF_RAW_ACCESSOR(preinit_sequence, const stp_raw_t *)
1171 DEF_RAW_ACCESSOR(preinit_remote_sequence, const stp_raw_t *)
1172 DEF_RAW_ACCESSOR(postinit_remote_sequence, const stp_raw_t *)
1173
1174 DEF_RAW_ACCESSOR(vertical_borderless_sequence, const stp_raw_t *)
1175
1176 /* froundto( 500.5 points, 180 dpi, 72 points/inch) */
1177 static double
1178 froundto(double value, double numerator, double denominator)
1179 {
1180 double multiplier = (double) ((int) ((numerator + (denominator / 2)) / denominator));
1181 return ((double) ((int) ((value * multiplier) + .5))) / multiplier;
1182 }
1183
1184 static const resolution_list_t *
1185 escp2_reslist(const stp_vars_t *v)
1186 {
1187 stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v);
1188 return printdef->resolutions;
1189 }
1190
1191 static inline const printer_weave_list_t *
1192 escp2_printer_weaves(const stp_vars_t *v)
1193 {
1194 stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v);
1195 return printdef->printer_weaves;
1196 }
1197
1198 static inline const stp_string_list_t *
1199 escp2_channel_names(const stp_vars_t *v)
1200 {
1201 stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v);
1202 return (printdef->channel_names);
1203 }
1204
1205 static inline const inkgroup_t *
1206 escp2_inkgroup(const stp_vars_t *v)
1207 {
1208 stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v);
1209 return (printdef->inkgroup);
1210 }
1211
1212 static inline const quality_list_t *
1213 escp2_quality_list(const stp_vars_t *v)
1214 {
1215 stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v);
1216 return printdef->quality_list;
1217 }
1218
1219 static short
1220 escp2_duplex_left_margin(const stp_vars_t *v)
1221 {
1222 stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v);
1223 return printdef->duplex_left_margin;
1224 }
1225
1226 static short
1227 escp2_duplex_right_margin(const stp_vars_t *v)
1228 {
1229 stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v);
1230 return printdef->duplex_right_margin;
1231 }
1232
1233 static short
1234 escp2_duplex_top_margin(const stp_vars_t *v)
1235 {
1236 stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v);
1237 return printdef->duplex_top_margin;
1238 }
1239
1240 static short
1241 escp2_duplex_bottom_margin(const stp_vars_t *v)
1242 {
1243 stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v);
1244 return printdef->duplex_bottom_margin;
1245 }
1246
1247 static const channel_count_t *
1248 get_channel_count_by_name(const char *name)
1249 {
1250 int i;
1251 for (i = 0; i < escp2_channel_counts_count; i++)
1252 if (strcmp(name, escp2_channel_counts[i].name) == 0)
1253 return &(escp2_channel_counts[i]);
1254 return NULL;
1255 }
1256
1257 static const channel_count_t *
1258 get_channel_count_by_number(unsigned count)
1259 {
1260 int i;
1261 for (i = 0; i < escp2_channel_counts_count; i++)
1262 if (count == escp2_channel_counts[i].count)
1263 return &(escp2_channel_counts[i]);
1264 return NULL;
1265 }
1266
1267 static int
1268 escp2_res_param(const stp_vars_t *v, const char *param, const res_t *res)
1269 {
1270 if (res)
1271 {
1272 if (res->v &&
1273 stp_check_int_parameter(res->v, param, STP_PARAMETER_ACTIVE))
1274 return stp_get_int_parameter(res->v, param);
1275 else
1276 return -1;
1277 }
1278 if (stp_check_int_parameter(v, param, STP_PARAMETER_ACTIVE))
1279 return stp_get_int_parameter(v, param);
1280 else
1281 {
1282 const res_t *res1 = stpi_escp2_find_resolution(v);
1283 if (res1->v &&
1284 stp_check_int_parameter(res1->v, param, STP_PARAMETER_ACTIVE))
1285 return stp_get_int_parameter(res1->v, param);
1286 }
1287 return -1;
1288 }
1289
1290 static int
1291 escp2_ink_type(const stp_vars_t *v)
1292 {
1293 return escp2_res_param(v, "escp2_ink_type", NULL);
1294 }
1295
1296 static double
1297 escp2_density(const stp_vars_t *v)
1298 {
1299 if (stp_check_float_parameter(v, "escp2_density", STP_PARAMETER_ACTIVE))
1300 return stp_get_float_parameter(v, "escp2_density");
1301 else
1302 {
1303 const res_t *res1 = stpi_escp2_find_resolution(v);
1304 if (res1->v &&
1305 stp_check_float_parameter(res1->v, "escp2_density", STP_PARAMETER_ACTIVE))
1306 return stp_get_float_parameter(res1->v, "escp2_density");
1307 }
1308 return 0;
1309 }
1310
1311 static inline int
1312 escp2_bits(const stp_vars_t *v)
1313 {
1314 return escp2_res_param(v, "escp2_bits", NULL);
1315 }
1316
1317 static inline int
1318 escp2_base_res(const stp_vars_t *v)
1319 {
1320 return escp2_res_param(v, "escp2_base_res", NULL);
1321 }
1322
1323 static inline int
1324 escp2_ink_type_by_res(const stp_vars_t *v, const res_t *res)
1325 {
1326 return escp2_res_param(v, "escp2_ink_type", res);
1327 }
1328
1329 static inline double
1330 escp2_density_by_res(const stp_vars_t *v, const res_t *res)
1331 {
1332 (void)v;
1333 if (res)
1334 {
1335 if (res->v &&
1336 stp_check_float_parameter(res->v, "escp2_density", STP_PARAMETER_ACTIVE))
1337 return stp_get_float_parameter(res->v, "escp2_density");
1338 }
1339 return 0.0;
1340 }
1341
1342 static inline int
1343 escp2_bits_by_res(const stp_vars_t *v, const res_t *res)
1344 {
1345 return escp2_res_param(v, "escp2_bits", res);
1346 }
1347
1348 static inline int
1349 escp2_base_res_by_res(const stp_vars_t *v, const res_t *res)
1350 {
1351 return escp2_res_param(v, "escp2_base_res", res);
1352 }
1353
1354 static escp2_dropsize_t *
1355 escp2_copy_dropsizes(const stp_vars_t *v)
1356 {
1357 const res_t *res = stpi_escp2_find_resolution(v);
1358 escp2_dropsize_t *ndrops;
1359 if (!res || !(res->v))
1360 return NULL;
1361 ndrops = stp_zalloc(sizeof(escp2_dropsize_t));
1362 if (! ndrops)
1363 return NULL;
1364 if (stp_check_float_parameter(res->v, "DropSize1", STP_PARAMETER_ACTIVE))
1365 {
1366 ndrops->numdropsizes = 1;
1367 ndrops->dropsizes[0] = stp_get_float_parameter(res->v, "DropSize1");
1368 }
1369 if (stp_check_float_parameter(res->v, "DropSize2", STP_PARAMETER_ACTIVE))
1370 {
1371 ndrops->numdropsizes = 2;
1372 ndrops->dropsizes[1] = stp_get_float_parameter(res->v, "DropSize2");
1373 }
1374 if (stp_check_float_parameter(res->v, "DropSize3", STP_PARAMETER_ACTIVE))
1375 {
1376 ndrops->numdropsizes = 3;
1377 ndrops->dropsizes[2] = stp_get_float_parameter(res->v, "DropSize3");
1378 }
1379 return ndrops;
1380 }
1381
1382 static void
1383 escp2_free_dropsizes(escp2_dropsize_t *drops)
1384 {
1385 if (drops)
1386 stp_free(drops);
1387 }
1388
1389 const inklist_t *
1390 stpi_escp2_inklist(const stp_vars_t *v)
1391 {
1392 int i;
1393 const char *ink_list_name = NULL;
1394 const inkgroup_t *inkgroup = escp2_inkgroup(v);
1395
1396 if (stp_check_string_parameter(v, "InkSet", STP_PARAMETER_ACTIVE))
1397 ink_list_name = stp_get_string_parameter(v, "InkSet");
1398 if (ink_list_name)
1399 {
1400 for (i = 0; i < inkgroup->n_inklists; i++)
1401 {
1402 if (strcmp(ink_list_name, inkgroup->inklists[i].name) == 0)
1403 return &(inkgroup->inklists[i]);
1404 }
1405 }
1406 STPI_ASSERT(inkgroup, v);
1407 return &(inkgroup->inklists[0]);
1408 }
1409
1410 static const shade_t *
1411 escp2_shades(const stp_vars_t *v, int channel)
1412 {
1413 const inklist_t *inklist = stpi_escp2_inklist(v);
1414 return &(inklist->shades[channel]);
1415 }
1416
1417 static shade_t *
1418 escp2_copy_shades(const stp_vars_t *v, int channel)
1419 {
1420 unsigned int i;
1421 shade_t *nshades;
1422 const inklist_t *inklist = stpi_escp2_inklist(v);
1423 if (!inklist)
1424 return NULL;
1425 nshades = stp_zalloc(sizeof(shade_t));
1426 nshades->n_shades = inklist->shades[channel].n_shades;
1427 nshades->shades = stp_zalloc(sizeof(double) * inklist->shades[channel].n_shades);
1428 for (i = 0; i < inklist->shades[channel].n_shades; i++)
1429 nshades->shades[i] = inklist->shades[channel].shades[i];
1430 return nshades;
1431 }
1432
1433 static void
1434 escp2_free_shades(shade_t *shades)
1435 {
1436 if (shades)
1437 {
1438 if (shades->shades)
1439 stp_free(shades->shades);
1440 stp_free(shades);
1441 }
1442 }
1443
1444 static const stp_string_list_t *
1445 escp2_paperlist(const stp_vars_t *v)
1446 {
1447 stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v);
1448 return printdef->papers;
1449 }
1450
1451 static const stp_string_list_t *
1452 escp2_slotlist(const stp_vars_t *v)
1453 {
1454 stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v);
1455 return printdef->input_slots;
1456 }
1457
1458 static int
1459 supports_borderless(const stp_vars_t *v)
1460 {
1461 return (stpi_escp2_has_cap(v, MODEL_ZEROMARGIN, MODEL_ZEROMARGIN_YES) ||
1462 stpi_escp2_has_cap(v, MODEL_ZEROMARGIN, MODEL_ZEROMARGIN_FULL) ||
1463 stpi_escp2_has_cap(v, MODEL_ZEROMARGIN, MODEL_ZEROMARGIN_H_ONLY) ||
1464 stpi_escp2_has_cap(v, MODEL_ZEROMARGIN, MODEL_ZEROMARGIN_RESTR));
1465 }
1466
1467 static int
1468 max_nozzle_span(const stp_vars_t *v)
1469 {
1470 int nozzle_count = escp2_nozzles(v);
1471 int nozzle_separation = escp2_nozzle_separation(v);
1472 int black_nozzle_count = escp2_black_nozzles(v);
1473 int black_nozzle_separation = escp2_black_nozzle_separation(v);
1474 int nozzle_span = nozzle_count * nozzle_separation;
1475 int black_nozzle_span = black_nozzle_count * black_nozzle_separation;
1476 if (black_nozzle_span > nozzle_span)
1477 return black_nozzle_span;
1478 else
1479 return nozzle_span;
1480 }
1481
1482 static const stp_raw_t *
1483 get_printer_weave(const stp_vars_t *v)
1484 {
1485 int i;
1486 const res_t *res = stpi_escp2_find_resolution(v);
1487 const printer_weave_list_t *p = escp2_printer_weaves(v);
1488 if (p)
1489 {
1490 const char *name = stp_get_string_parameter(v, "Weave");
1491 int printer_weave_count = p->n_printer_weaves;
1492 if (name)
1493 {
1494 for (i = 0; i < printer_weave_count; i++)
1495 {
1496 if (!strcmp(name, p->printer_weaves[i].name))
1497 return p->printer_weaves[i].command;
1498 }
1499 }
1500 }
1501 if (res)
1502 return res->command;
1503 return NULL;
1504 }
1505
1506 static int
1507 use_printer_weave(const stp_vars_t *v)
1508 {
1509 const res_t *res = stpi_escp2_find_resolution(v);
1510 return (!res || res->command);
1511 }
1512
1513 static void
1514 get_resolution_bounds_by_paper_type(const stp_vars_t *v,
1515 unsigned *max_x, unsigned *max_y,
1516 unsigned *min_x, unsigned *min_y)
1517 {
1518 const paper_t *paper = stpi_escp2_get_media_type(v, 1);
1519 *min_x = 0;
1520 *min_y = 0;
1521 *max_x = 0;
1522 *max_y = 0;
1523 if (paper)
1524 {
1525 switch (paper->paper_class)
1526 {
1527 case PAPER_PLAIN:
1528 *min_x = 0;
1529 *min_y = 0;
1530 *max_x = escp2_base_separation(v) * 4;
1531 *max_y = escp2_base_separation(v) * 2;
1532 break;
1533 case PAPER_GOOD:
1534 *min_x = escp2_base_separation(v);
1535 *min_y = escp2_base_separation(v);
1536 *max_x = escp2_base_separation(v) * 4;
1537 *max_y = escp2_base_separation(v) * 4;
1538 break;
1539 case PAPER_PHOTO:
1540 *min_x = escp2_base_separation(v) * 2;
1541 *min_y = escp2_base_separation(v);
1542 *max_x = 2880;
1543 *max_y = escp2_base_separation(v) * 4;
1544 if (*min_x >= escp2_max_hres(v))
1545 *min_x = escp2_max_hres(v);
1546 break;
1547 case PAPER_PREMIUM_PHOTO:
1548 *min_x = escp2_base_separation(v) * 2;
1549 *min_y = escp2_base_separation(v) * 2;
1550 *max_x = 0;
1551 *max_y = 0;
1552 if (*min_x >= escp2_max_hres(v))
1553 *min_x = escp2_max_hres(v);
1554 break;
1555 case PAPER_TRANSPARENCY:
1556 *min_x = escp2_base_separation(v);
1557 *min_y = escp2_base_separation(v);
1558 *max_x = escp2_base_separation(v) * 2;
1559 *max_y = escp2_base_separation(v) * 2;
1560 break;
1561 }
1562 stp_dprintf(STP_DBG_ESCP2, v,
1563 "Paper %s class %d: min_x %d min_y %d max_x %d max_y %d\n",
1564 paper->text, paper->paper_class, *min_x, *min_y,
1565 *max_x, *max_y);
1566 }
1567 }
1568
1569 static int
1570 verify_resolution_by_paper_type(const stp_vars_t *v, const res_t *res)
1571 {
1572 unsigned min_x = 0;
1573 unsigned min_y = 0;
1574 unsigned max_x = 0;
1575 unsigned max_y = 0;
1576 get_resolution_bounds_by_paper_type(v, &max_x, &max_y, &min_x, &min_y);
1577 if ((max_x == 0 || res->printed_hres <= max_x) &&
1578 (max_y == 0 || res->printed_vres <= max_y) &&
1579 (min_x == 0 || res->printed_hres >= min_x) &&
1580 (min_y == 0 || res->printed_vres >= min_y))
1581 {
1582 stp_dprintf(STP_DBG_ESCP2, v,
1583 "Resolution %s (%d, %d) GOOD (%d, %d, %d, %d)\n",
1584 res->name, res->printed_hres, res->printed_vres,
1585 min_x, min_y, max_x, max_y);
1586 return 1;
1587 }
1588 else
1589 {
1590 stp_dprintf(STP_DBG_ESCP2, v,
1591 "Resolution %s (%d, %d) BAD (%d, %d, %d, %d)\n",
1592 res->name, res->printed_hres, res->printed_vres,
1593 min_x, min_y, max_x, max_y);
1594 return 0;
1595 }
1596 }
1597
1598 static int
1599 verify_resolution(const stp_vars_t *v, const res_t *res)
1600 {
1601 int nozzle_width =
1602 (escp2_base_separation(v) / escp2_nozzle_separation(v));
1603 int nozzles = escp2_nozzles(v);
1604 if (escp2_ink_type_by_res(v, res) != -1 &&
1605 res->vres <= escp2_max_vres(v) &&
1606 res->hres <= escp2_max_hres(v) &&
1607 res->vres >= escp2_min_vres(v) &&
1608 res->hres >= escp2_min_hres(v) &&
1609 (nozzles == 1 ||
1610 ((res->vres / nozzle_width) * nozzle_width) == res->vres))
1611 {
1612 int xdpi = res->hres;
1613 int physical_xdpi = escp2_base_res_by_res(v, res);
1614 int horizontal_passes, oversample;
1615 if (physical_xdpi > xdpi)
1616 physical_xdpi = xdpi;
1617 horizontal_passes = xdpi / physical_xdpi;
1618 oversample = horizontal_passes * res->vertical_passes;
1619 if (horizontal_passes < 1)
1620 horizontal_passes = 1;
1621 if (oversample < 1)
1622 oversample = 1;
1623 if (((horizontal_passes * res->vertical_passes) <= STP_MAX_WEAVE) &&
1624 (res->command || (nozzles > 1 && nozzles > oversample)))
1625 return 1;
1626 }
1627 return 0;
1628 }
1629
1630 static void
1631 get_printer_resolution_bounds(const stp_vars_t *v,
1632 unsigned *max_x, unsigned *max_y,
1633 unsigned *min_x, unsigned *min_y)
1634 {
1635 unsigned int i = 0;
1636 const resolution_list_t *resolutions = escp2_reslist(v);
1637 *max_x = 0;
1638 *max_y = 0;
1639 *min_x = 0;
1640 *min_y = 0;
1641 for (i = 0; i < resolutions->n_resolutions; i++)
1642 {
1643 res_t *res = &(resolutions->resolutions[i]);
1644 if (verify_resolution(v, res))
1645 {
1646 if (res->printed_hres * res->vertical_passes > *max_x)
1647 *max_x = res->printed_hres * res->vertical_passes;
1648 if (res->printed_vres > *max_y)
1649 *max_y = res->printed_vres;
1650 if (*min_x == 0 ||
1651 res->printed_hres * res->vertical_passes < *min_x)
1652 *min_x = res->printed_hres * res->vertical_passes;
1653 if (*min_y == 0 || res->printed_vres < *min_y)
1654 *min_y = res->printed_vres;
1655 }
1656 }
1657 stp_dprintf(STP_DBG_ESCP2, v,
1658 "Printer bounds: %d %d %d %d\n", *min_x, *min_y, *max_x, *max_y);
1659 }
1660
1661 static int
1662 verify_papersize(const stp_vars_t *v, const stp_papersize_t *pt)
1663 {
1664 stp_dimension_t height_limit, width_limit;
1665 stp_dimension_t min_height_limit, min_width_limit;
1666 unsigned int envelope_landscape =
1667 stpi_escp2_has_cap(v, MODEL_ENVELOPE_LANDSCAPE, MODEL_ENVELOPE_LANDSCAPE_YES);
1668 width_limit = escp2_max_paper_width(v);
1669 height_limit = escp2_max_paper_height(v);
1670 min_width_limit = escp2_min_paper_width(v);
1671 min_height_limit = escp2_min_paper_height(v);
1672
1673 if (pt->paper_size_type != PAPERSIZE_TYPE_STANDARD &&
1674 pt->paper_size_type != PAPERSIZE_TYPE_ENVELOPE)
1675 return 0;
1676
1677 if (strlen(pt->name) > 0 &&
1678 (pt->paper_size_type != PAPERSIZE_TYPE_ENVELOPE ||
1679 envelope_landscape || pt->height > pt->width) &&
1680 pt->width <= width_limit && pt->height <= height_limit &&
1681 (pt->height >= min_height_limit || pt->height == 0) &&
1682 (pt->width >= min_width_limit || pt->width == 0) &&
1683 (pt->width == 0 || pt->height > 0 ||
1684 stpi_escp2_printer_supports_rollfeed(v)))
1685 return 1;
1686 else
1687 return 0;
1688 }
1689
1690 static int
1691 verify_inktype(const stp_vars_t *v, const inkname_t *inks)
1692 {
1693 (void)v;
1694 if (inks->inkset == INKSET_EXTENDED)
1695 return 0;
1696 else
1697 return 1;
1698 }
1699
1700 static const char *
1701 get_default_inktype(const stp_vars_t *v)
1702 {
1703 const inklist_t *ink_list = stpi_escp2_inklist(v);
1704 const paper_t *paper_type;
1705 if (!ink_list)
1706 return NULL;
1707 paper_type = stpi_escp2_get_media_type(v, 0);
1708 if (!paper_type)
1709 paper_type = stpi_escp2_get_default_media_type(v);
1710 if (paper_type && paper_type->preferred_ink_type)
1711 return paper_type->preferred_ink_type;
1712 else if (stpi_escp2_has_cap(v, MODEL_FAST_360, MODEL_FAST_360_YES) &&
1713 stp_check_string_parameter(v, "Resolution", STP_PARAMETER_ACTIVE))
1714 {
1715 const res_t *res = stpi_escp2_find_resolution(v);
1716 if (res)
1717 {
1718 /* Hard-coded value for old printers */
1719 if (res->vres == 360 && res->hres == escp2_base_res(v))
1720 {
1721 int i;
1722 for (i = 0; i < ink_list->n_inks; i++)
1723 if (strcmp(ink_list->inknames[i].name, "CMYK") == 0)
1724 return ink_list->inknames[i].name;
1725 }
1726 }
1727 }
1728 return ink_list->inknames[0].name;
1729 }
1730
1731
1732 static const inkname_t *
1733 get_inktype(const stp_vars_t *v)
1734 {
1735 const char *ink_type = stp_get_string_parameter(v, "InkType");
1736 const inklist_t *ink_list = stpi_escp2_inklist(v);
1737 int i;
1738
1739 if (!ink_type || strcmp(ink_type, "None") == 0 ||
1740 (ink_list && ink_list->n_inks == 1))
1741 ink_type = get_default_inktype(v);
1742
1743 if (ink_type && ink_list)
1744 {
1745 for (i = 0; i < ink_list->n_inks; i++)
1746 {
1747 if (strcmp(ink_type, ink_list->inknames[i].name) == 0)
1748 return &(ink_list->inknames[i]);
1749 }
1750 }
1751 /*
1752 * If we couldn't find anything, try again with the default ink type.
1753 * This may mean duplicate work, but that's cheap enough.
1754 */
1755 ink_type = get_default_inktype(v);
1756 if (ink_type && ink_list)
1757 {
1758 for (i = 0; i < ink_list->n_inks; i++)
1759 {
1760 if (strcmp(ink_type, ink_list->inknames[i].name) == 0)
1761 return &(ink_list->inknames[i]);
1762 }
1763 }
1764 /*
1765 * If even *that* doesn't work, try using the first ink type on the list.
1766 */
1767 return (ink_list) ? &(ink_list->inknames[0]) : NULL;
1768 }
1769
1770 static const inkname_t *
1771 get_inktype_only(const stp_vars_t *v)
1772 {
1773 const char *ink_type = stp_get_string_parameter(v, "InkType");
1774
1775 if (!ink_type)
1776 return NULL;
1777 else
1778 return get_inktype(v);
1779 }
1780
1781 static int
1782 printer_supports_inkset(const stp_vars_t *v, inkset_id_t inkset)
1783 {
1784 const inkgroup_t *ink_group = escp2_inkgroup(v);
1785 int i;
1786 for (i = 0; i < ink_group->n_inklists; i++)
1787 {
1788 const inklist_t *ink_list = &(ink_group->inklists[i]);
1789 if (ink_list)
1790 {
1791 int j;
1792 for (j = 0; j < ink_list->n_inks; j++)
1793 {
1794 if (ink_list->inknames[j].inkset == inkset)
1795 {
1796 return 1;
1797 }
1798 }
1799 }
1800 }
1801 return 0;
1802 }
1803
1804 static const stp_vars_t *
1805 get_media_adjustment(const stp_vars_t *v)
1806 {
1807 const paper_t *pt = stpi_escp2_get_media_type(v, 0);
1808 if (pt)
1809 return pt->v;
1810 else
1811 return NULL;
1812 }
1813
1814 /*
1815 * 'escp2_parameters()' - Return the parameter values for the given parameter.
1816 */
1817
1818 static stp_parameter_list_t
1819 escp2_list_parameters(const stp_vars_t *v)
1820 {
1821 stp_parameter_list_t *ret = stp_parameter_list_create();
1822 stp_parameter_list_t *tmp_list;
1823
1824 unsigned int i;
1825
1826 /* Set up dithering */
1827 tmp_list = stp_dither_list_parameters(v);
1828 stp_parameter_list_append(ret, tmp_list);
1829 stp_parameter_list_destroy(tmp_list);
1830
1831 for (i = 0; i < the_parameter_count; i++)
1832 stp_parameter_list_add_param(ret, &(the_parameters[i]));
1833 for (i = 0; i < float_parameter_count; i++)
1834 stp_parameter_list_add_param(ret, &(float_parameters[i].param));
1835 for (i = 0; i < int_parameter_count; i++)
1836 stp_parameter_list_add_param(ret, &(int_parameters[i].param));
1837 return ret;
1838 }
1839
1840 static void
1841 set_density_parameter(const stp_vars_t *v,
1842 stp_parameter_t *description,
1843 const char *name)
1844 {
1845 const inkname_t *ink_name = get_inktype(v);
1846 description->is_active = 0;
1847 if (ink_name && stp_get_string_parameter(v, "PrintingMode") &&
1848 strcmp(stp_get_string_parameter(v, "PrintingMode"), "BW") != 0)
1849 {
1850 int i, j;
1851 for (i = 0; i < ink_name->channel_count; i++)
1852 {
1853 ink_channel_t *ich = &(ink_name->channels[i]);
1854 if (ich)
1855 {
1856 for (j = 0; j < ich->n_subchannels; j++)
1857 {
1858 physical_subchannel_t *sch = &(ich->subchannels[j]);
1859 if (sch && sch->channel_density &&
1860 !strcmp(name, sch->channel_density))
1861 {
1862 description->is_active = 1;
1863 description->bounds.dbl.lower = 0;
1864 description->bounds.dbl.upper = 2.0;
1865 description->deflt.dbl = 1.0;
1866 }
1867 }
1868 }
1869 }
1870 }
1871 }
1872
1873 static void
1874 set_hue_map_parameter(const stp_vars_t *v,
1875 stp_parameter_t *description,
1876 const char *name)
1877 {
1878 const inkname_t *ink_name = get_inktype(v);
1879 description->is_active = 0;
1880 description->deflt.curve = hue_curve_bounds;
1881 description->bounds.curve = stp_curve_create_copy(hue_curve_bounds);
1882 if (ink_name && stp_get_string_parameter(v, "PrintingMode") &&
1883 strcmp(stp_get_string_parameter(v, "PrintingMode"), "BW") != 0)
1884 {
1885 int i;
1886 for (i = 0; i < ink_name->channel_count; i++)
1887 {
1888 ink_channel_t *ich = &(ink_name->channels[i]);
1889 if (ich && ich->hue_curve && !strcmp(name, ich->hue_curve_name))
1890 {
1891 description->deflt.curve = ich->hue_curve;
1892 description->is_active = 1;
1893 }
1894 }
1895 }
1896 }
1897
1898 static void
1899 fill_value_parameters(const stp_vars_t *v,
1900 stp_parameter_t *description,
1901 int color)
1902 {
1903 const shade_t *shades = escp2_shades(v, color);
1904 const inkname_t *ink_name = get_inktype(v);
1905 description->is_active = 1;
1906 description->bounds.dbl.lower = 0;
1907 description->bounds.dbl.upper = 1.0;
1908 description->deflt.dbl = 1.0;
1909 if (shades && ink_name)
1910 {
1911 const ink_channel_t *channel = &(ink_name->channels[color]);
1912 int i;
1913 for (i = 0; i < channel->n_subchannels; i++)
1914 {
1915 if (channel->subchannels[i].subchannel_value &&
1916 strcmp(description->name,
1917 channel->subchannels[i].subchannel_value) == 0)
1918 {
1919 description->deflt.dbl = shades->shades[i];
1920 return;
1921 }
1922 }
1923 }
1924 }
1925
1926 static void
1927 set_color_value_parameter(const stp_vars_t *v,
1928 stp_parameter_t *description,
1929 int color)
1930 {
1931 description->is_active = 0;
1932 if (stp_get_string_parameter(v, "PrintingMode") &&
1933 strcmp(stp_get_string_parameter(v, "PrintingMode"), "BW") != 0)
1934 {
1935 const inkname_t *ink_name = get_inktype(v);
1936 if (ink_name &&
1937 ink_name->channel_count == 4 &&
1938 ink_name->channels[color].n_subchannels == 2)
1939 fill_value_parameters(v, description, color);
1940 }
1941 }
1942
1943 static void
1944 set_gray_value_parameter(const stp_vars_t *v,
1945 stp_parameter_t *description,
1946 int expected_channels)
1947 {
1948 const inkname_t *ink_name = get_inktype_only(v);
1949 description->is_active = 0;
1950 if (!ink_name &&
1951 ((expected_channels == 4 && printer_supports_inkset(v, INKSET_QUADTONE)) ||
1952 (expected_channels == 6 && printer_supports_inkset(v, INKSET_HEXTONE))))
1953 fill_value_parameters(v, description, STP_ECOLOR_K);
1954 else if (ink_name &&
1955 (ink_name->channels[STP_ECOLOR_K].n_subchannels ==
1956 expected_channels))
1957 fill_value_parameters(v, description, STP_ECOLOR_K);
1958 else
1959 set_color_value_parameter(v, description, STP_ECOLOR_K);
1960 }
1961
1962 static void
1963 fill_transition_parameters(const stp_vars_t *v,
1964 stp_parameter_t *description,
1965 int color)
1966 {
1967 const stp_vars_t *paper_adj = get_media_adjustment(v);
1968 (void)v;
1969 (void)color;
1970
1971 description->is_active = 1;
1972 description->bounds.dbl.lower = 0;
1973 description->bounds.dbl.upper = 1.0;
1974 if (paper_adj && stp_check_float_parameter(paper_adj, "SubchannelCutoff", STP_PARAMETER_ACTIVE))
1975 description->deflt.dbl = stp_get_float_parameter(paper_adj, "SubchannelCutoff");
1976 else
1977 description->deflt.dbl = 1.0;
1978 }
1979
1980 static void
1981 set_color_transition_parameter(const stp_vars_t *v,
1982 stp_parameter_t *description,
1983 int color)
1984 {
1985 description->is_active = 0;
1986 if (stp_get_string_parameter(v, "PrintingMode") &&
1987 strcmp(stp_get_string_parameter(v, "PrintingMode"), "BW") != 0)
1988 {
1989 const inkname_t *ink_name = get_inktype(v);
1990 if (ink_name &&
1991 ink_name->channel_count == 4 &&
1992 ink_name->channels[color].n_subchannels == 2)
1993 fill_transition_parameters(v, description, color);
1994 }
1995 }
1996
1997 static void
1998 set_gray_transition_parameter(const stp_vars_t *v,
1999 stp_parameter_t *description,
2000 int expected_channels)
2001 {
2002 const inkname_t *ink_name = get_inktype_only(v);
2003 description->is_active = 0;
2004 if (!ink_name &&
2005 ((expected_channels == 4 && printer_supports_inkset(v, INKSET_QUADTONE)) ||
2006 (expected_channels == 6 && printer_supports_inkset(v, INKSET_HEXTONE))))
2007 fill_transition_parameters(v, description, STP_ECOLOR_K);
2008 if (ink_name &&
2009 (ink_name->channels[STP_ECOLOR_K].n_subchannels ==
2010 expected_channels))
2011 fill_transition_parameters(v, description, STP_ECOLOR_K);
2012 else
2013 set_color_transition_parameter(v, description, STP_ECOLOR_K);
2014 }
2015
2016 static void
2017 fill_scale_parameters(stp_parameter_t *description)
2018 {
2019 description->is_active = 1;
2020 description->bounds.dbl.lower = 0;
2021 description->bounds.dbl.upper = 5.0;
2022 description->deflt.dbl = 1.0;
2023 }
2024
2025 static void
2026 set_color_scale_parameter(const stp_vars_t *v,
2027 stp_parameter_t *description,
2028 int color)
2029 {
2030 description->is_active = 0;
2031 if (stp_get_string_parameter(v, "PrintingMode") &&
2032 strcmp(stp_get_string_parameter(v, "PrintingMode"), "BW") != 0)
2033 {
2034 const inkname_t *ink_name = get_inktype(v);
2035 if (ink_name &&
2036 ink_name->channel_count == 4 &&
2037 ink_name->channels[color].n_subchannels == 2)
2038 fill_scale_parameters(description);
2039 }
2040 }
2041
2042 static void
2043 set_gray_scale_parameter(const stp_vars_t *v,
2044 stp_parameter_t *description,
2045 int expected_channels)
2046 {
2047 const inkname_t *ink_name = get_inktype_only(v);
2048 description->is_active = 0;
2049 if (!ink_name &&
2050 ((expected_channels == 4 && printer_supports_inkset(v, INKSET_QUADTONE)) ||
2051 (expected_channels == 6 && printer_supports_inkset(v, INKSET_HEXTONE))))
2052 fill_transition_parameters(v, description, STP_ECOLOR_K);
2053 if (ink_name &&
2054 (ink_name->channels[STP_ECOLOR_K].n_subchannels ==
2055 expected_channels))
2056 fill_scale_parameters(description);
2057 else
2058 set_color_scale_parameter(v, description, STP_ECOLOR_K);
2059 }
2060
2061 static const res_t *
2062 find_default_resolution(const stp_vars_t *v, const quality_t *q, int strict)
2063 {
2064 const resolution_list_t *resolutions = escp2_reslist(v);
2065 unsigned int i = 0;
2066 stp_dprintf(STP_DBG_ESCP2, v, "Quality %s: min %d %d max %d %d, des %d %d\n",
2067 q->name, q->min_hres, q->min_vres, q->max_hres, q->max_vres,
2068 q->desired_hres, q->desired_vres);
2069 if (q->desired_hres < 0 || q->desired_vres < 0)
2070 {
2071 for (i = resolutions->n_resolutions; i > 0; i--)
2072 {
2073 const res_t *res = &(resolutions->resolutions[i-1]);
2074 stp_dprintf(STP_DBG_ESCP2, v, " Checking resolution %s %d...\n",
2075 res->name, i);
2076 if ((q->max_hres <= 0 || res->printed_hres <= q->max_hres) &&
2077 (q->max_vres <= 0 || res->printed_vres <= q->max_vres) &&
2078 q->min_hres <= res->printed_hres &&
2079 q->min_vres <= res->printed_vres &&
2080 verify_resolution(v, res) &&
2081 verify_resolution_by_paper_type(v, res))
2082 return res;
2083 }
2084 }
2085 if (!strict)
2086 {
2087 unsigned max_x, max_y, min_x, min_y;
2088 unsigned desired_hres = q->desired_hres;
2089 unsigned desired_vres = q->desired_vres;
2090 get_resolution_bounds_by_paper_type(v, &max_x, &max_y, &min_x, &min_y);
2091 stp_dprintf(STP_DBG_ESCP2, v, " Comparing hres %d to %d, %d\n",
2092 desired_hres, min_x, max_x);
2093 stp_dprintf(STP_DBG_ESCP2, v, " Comparing vres %d to %d, %d\n",
2094 desired_vres, min_y, max_y);
2095 if (max_x > 0 && desired_hres > max_x)
2096 {
2097 stp_dprintf(STP_DBG_ESCP2, v, " Decreasing hres from %d to %d\n",
2098 desired_hres, max_x);
2099 desired_hres = max_x;
2100 }
2101 else if (desired_hres < min_x)
2102 {
2103 stp_dprintf(STP_DBG_ESCP2, v, " Increasing hres from %d to %d\n",
2104 desired_hres, min_x);
2105 desired_hres = min_x;
2106 }
2107 if (max_y > 0 && desired_vres > max_y)
2108 {
2109 stp_dprintf(STP_DBG_ESCP2, v, " Decreasing vres from %d to %d\n",
2110 desired_vres, max_y);
2111 desired_vres = max_y;
2112 }
2113 else if (desired_vres < min_y)
2114 {
2115 stp_dprintf(STP_DBG_ESCP2, v, " Increasing vres from %d to %d\n",
2116 desired_vres, min_y);
2117 desired_vres = min_y;
2118 }
2119 for (i = 0; i < resolutions->n_resolutions; i++)
2120 {
2121 res_t *res = &(resolutions->resolutions[i]);
2122 if (verify_resolution(v, res) &&
2123 res->printed_vres == desired_vres &&
2124 res->printed_hres == desired_hres)
2125 {
2126 stp_dprintf(STP_DBG_ESCP2, v,
2127 " Found desired resolution w/o oversample: %s %d: %d * %d, %d\n",
2128 res->name, i, res->printed_hres,
2129 res->vertical_passes, res->printed_vres);
2130 return res;
2131 }
2132 }
2133 for (i = 0; i < resolutions->n_resolutions; i++)
2134 {
2135 res_t *res = &(resolutions->resolutions[i]);
2136 if (verify_resolution(v, res) &&
2137 res->printed_vres == desired_vres &&
2138 res->printed_hres * res->vertical_passes == desired_hres)
2139 {
2140 stp_dprintf(STP_DBG_ESCP2, v,
2141 " Found desired resolution: %s %d: %d * %d, %d\n",
2142 res->name, i, res->printed_hres,
2143 res->vertical_passes, res->printed_vres);
2144 return res;
2145 }
2146 }
2147 for (i = 0; i < resolutions->n_resolutions; i++)
2148 {
2149 res_t *res = &(resolutions->resolutions[i]);
2150 if (verify_resolution(v, res) &&
2151 (q->min_vres == 0 || res->printed_vres >= q->min_vres) &&
2152 (q->max_vres == 0 || res->printed_vres <= q->max_vres) &&
2153 (q->min_hres == 0 ||
2154 res->printed_hres * res->vertical_passes >=q->min_hres) &&
2155 (q->max_hres == 0 ||
2156 res->printed_hres * res->vertical_passes <= q->max_hres))
2157 {
2158 stp_dprintf(STP_DBG_ESCP2, v,
2159 " Found acceptable resolution: %s %d: %d * %d, %d\n",
2160 res->name, i, res->printed_hres,
2161 res->vertical_passes, res->printed_vres);
2162 return res;
2163 }
2164 }
2165 }
2166 #if 0
2167 if (!strict) /* Try again to find a match */
2168 {
2169 for (i = 0; i < resolutions->n_resolutions; i++)
2170 {
2171 res_t *res = &(resolutions->resolutions[i]);
2172 if (verify_resolution(v, res) &&
2173 res->printed_vres >= desired_vres &&
2174 res->printed_hres * res->vertical_passes >= desired_hres &&
2175 res->printed_vres <= 2 * desired_vres &&
2176 res->printed_hres * res->vertical_passes <= 2 * desired_hres)
2177 return res;
2178 }
2179 }
2180 #endif
2181 return NULL;
2182 }
2183
2184 static int
2185 verify_quality(const stp_vars_t *v, const quality_t *q)
2186 {
2187 unsigned max_x, max_y, min_x, min_y;
2188 get_printer_resolution_bounds(v, &max_x, &max_y, &min_x, &min_y);
2189 if ((q->max_vres == 0 || min_y <= q->max_vres) &&
2190 (q->min_vres == 0 || max_y >= q->min_vres) &&
2191 (q->max_hres == 0 || min_x <= q->max_hres) &&
2192 (q->min_hres == 0 || max_x >= q->min_hres))
2193 {
2194 stp_dprintf(STP_DBG_ESCP2, v, "Quality %s OK: %d %d %d %d\n",
2195 q->text, q->min_hres, q->min_vres, q->max_hres, q->max_vres);
2196 return 1;
2197 }
2198 else
2199 {
2200 stp_dprintf(STP_DBG_ESCP2, v, "Quality %s not OK: %d %d %d %d\n",
2201 q->text, q->min_hres, q->min_vres, q->max_hres, q->max_vres);
2202 return 0;
2203 }
2204 }
2205
2206 static const res_t *
2207 find_resolution_from_quality(const stp_vars_t *v, const char *quality,
2208 int strict)
2209 {
2210 unsigned int i;
2211 const quality_list_t *quals = escp2_quality_list(v);
2212 /* This is a rather gross hack... */
2213 if (strcmp(quality, "None") == 0)
2214 quality = "Standard";
2215 for (i = 0; i < quals->n_quals; i++)
2216 {
2217 const quality_t *q = &(quals->qualities[i]);
2218 if (strcmp(quality, q->name) == 0 && verify_quality(v, q))
2219 return find_default_resolution(v, q, strict);
2220 }
2221 return NULL;
2222 }
2223
2224 static const inkname_t *
2225 get_raw_inktype(const stp_vars_t *v)
2226 {
2227 if (strcmp(stp_get_string_parameter(v, "InputImageType"), "Raw") == 0)
2228 {
2229 const inklist_t *inks = stpi_escp2_inklist(v);
2230 unsigned int ninktypes = inks->n_inks;
2231 unsigned int i;
2232 const char *channel_name = stp_get_string_parameter(v, "RawChannels");
2233 const channel_count_t *count;
2234 if (!channel_name)
2235 goto none;
2236 count = get_channel_count_by_name(channel_name);
2237 if (!count)
2238 goto none;
2239 for (i = 0; i < ninktypes; i++)
2240 if (inks->inknames[i].inkset == INKSET_EXTENDED &&
2241 (inks->inknames[i].channel_count == count->count))
2242 return &(inks->inknames[i]);
2243 }
2244 none:
2245 return get_inktype(v);
2246 }
2247
2248 static void
2249 escp2_parameters(const stp_vars_t *v, const char *name,
2250 stp_parameter_t *description)
2251 {
2252 unsigned int i;
2253 description->p_type = STP_PARAMETER_TYPE_INVALID;
2254 int found = 0;
2255 if (name == NULL)
2256 return;
2257
2258 memset(&description->deflt, 0, sizeof(description->deflt));
2259
2260 for (i = 0; i < float_parameter_count; i++)
2261 if (strcmp(name, float_parameters[i].param.name) == 0)
2262 {
2263 stp_fill_parameter_settings(description,
2264 &(float_parameters[i].param));
2265 description->deflt.dbl = float_parameters[i].defval;
2266 description->bounds.dbl.upper = float_parameters[i].max;
2267 description->bounds.dbl.lower = float_parameters[i].min;
2268 found = 1;
2269 break;
2270 }
2271 if (!found)
2272 {
2273 for (i = 0; i < int_parameter_count; i++)
2274 if (strcmp(name, int_parameters[i].param.name) == 0)
2275 {
2276 stp_fill_parameter_settings(description,
2277 &(int_parameters[i].param));
2278 description->deflt.integer = int_parameters[i].defval;
2279 description->bounds.integer.upper = int_parameters[i].max;
2280 description->bounds.integer.lower = int_parameters[i].min;
2281 found = 1;
2282 break;
2283 }
2284 }
2285
2286 if (!found)
2287 {
2288 for (i = 0; i < the_parameter_count; i++)
2289 if (strcmp(name, the_parameters[i].name) == 0)
2290 {
2291 stp_fill_parameter_settings(description, &(the_parameters[i]));
2292 if (description->p_type == STP_PARAMETER_TYPE_INT)
2293 {
2294 description->deflt.integer = 0;
2295 description->bounds.integer.upper = INT_MAX;
2296 description->bounds.integer.lower = INT_MIN;
2297 }
2298 break;
2299 }
2300 }
2301
2302 if (strcmp(name, "AutoMode") == 0)
2303 {
2304 description->bounds.str = stp_string_list_create();
2305 stp_string_list_add_string(description->bounds.str, "None",
2306 _("Full Manual Control"));
2307 stp_string_list_add_string(description->bounds.str, "Auto",
2308 _("Automatic Setting Control"));
2309 description->deflt.str = "None"; /* so CUPS doesn't break */
2310 }
2311 else if (strcmp(name, "PageSize") == 0)
2312 {
2313 const input_slot_t *slot = stpi_escp2_get_input_slot(v);
2314 description->bounds.str = stp_string_list_create();
2315 if (slot && slot->is_cd &&
2316 !stp_get_boolean_parameter(v, "CDAllowOtherMedia"))
2317 {
2318 stp_string_list_add_string
2319 (description->bounds.str, "CD5Inch", _("CD - 5 inch"));
2320 stp_string_list_add_string
2321 (description->bounds.str, "CD3Inch", _("CD - 3 inch"));
2322 stp_string_list_add_string
2323 (description->bounds.str, "CDCustom", _("CD - Custom"));
2324 }
2325 else
2326 {
2327 const stp_papersize_list_t *paper_sizes =
2328 stpi_get_standard_papersize_list();
2329 const stp_papersize_list_item_t *ptli =
2330 stpi_papersize_list_get_start(paper_sizes);
2331 while (ptli)
2332 {
2333 const stp_papersize_t *pt = stpi_paperlist_item_get_data(ptli);
2334 if (verify_papersize(v, pt))
2335 stp_string_list_add_string(description->bounds.str,
2336 pt->name, gettext(pt->text));
2337 ptli = stpi_paperlist_item_next(ptli);
2338 }
2339 }
2340 description->deflt.str =
2341 stp_string_list_param(description->bounds.str, 0)->name;
2342 }
2343 else if (strcmp(name, "CDAllowOtherMedia") == 0)
2344 {
2345 const input_slot_t *slot = stpi_escp2_get_input_slot(v);
2346 if (stpi_escp2_printer_supports_print_to_cd(v) &&
2347 (!slot || slot->is_cd))
2348 description->is_active = 1;
2349 else
2350 description->is_active = 0;
2351 }
2352 else if (strcmp(name, "CDInnerRadius") == 0 )
2353 {
2354 const input_slot_t *slot = stpi_escp2_get_input_slot(v);
2355 description->bounds.str = stp_string_list_create();
2356 if (stpi_escp2_printer_supports_print_to_cd(v) &&
2357 (!slot || slot->is_cd) &&
2358 (!stp_get_string_parameter(v, "PageSize") ||
2359 strcmp(stp_get_string_parameter(v, "PageSize"), "CDCustom") != 0))
2360 {
2361 stp_string_list_add_string
2362 (description->bounds.str, "None", _("Normal"));
2363 stp_string_list_add_string
2364 (description->bounds.str, "Small", _("Print To Hub"));
2365 description->deflt.str =
2366 stp_string_list_param(description->bounds.str, 0)->name;
2367 }
2368 else
2369 description->is_active = 0;
2370 }
2371 else if (strcmp(name, "CDInnerDiameter") == 0 )
2372 {
2373 const input_slot_t *slot = stpi_escp2_get_input_slot(v);
2374 description->bounds.dimension.lower = 16 * 10 * 72 / 254;
2375 description->bounds.dimension.upper = 43 * 10 * 72 / 254;
2376 description->deflt.dimension = 43 * 10 * 72 / 254;
2377 if (stpi_escp2_printer_supports_print_to_cd(v) &&
2378 (!slot || slot->is_cd) &&
2379 (!stp_get_string_parameter(v, "PageSize") ||
2380 strcmp(stp_get_string_parameter(v, "PageSize"), "CDCustom") == 0))
2381 description->is_active = 1;
2382 else
2383 description->is_active = 0;
2384 }
2385 else if (strcmp(name, "CDOuterDiameter") == 0 )
2386 {
2387 const input_slot_t *slot = stpi_escp2_get_input_slot(v);
2388 description->bounds.dimension.lower = 65 * 10 * 72 / 254;
2389 description->bounds.dimension.upper = 120 * 10 * 72 / 254;
2390 description->deflt.dimension = 329;
2391 if (stpi_escp2_printer_supports_print_to_cd(v) &&
2392 (!slot || slot->is_cd) &&
2393 (!stp_get_string_parameter(v, "PageSize") ||
2394 strcmp(stp_get_string_parameter(v, "PageSize"), "CDCustom") == 0))
2395 description->is_active = 1;
2396 else
2397 description->is_active = 0;
2398 }
2399 else if (strcmp(name, "CDXAdjustment") == 0 ||
2400 strcmp(name, "CDYAdjustment") == 0)
2401 {
2402 const input_slot_t *slot = stpi_escp2_get_input_slot(v);
2403 description->bounds.dimension.lower = -30;
2404 description->bounds.dimension.upper = 30;
2405 description->deflt.dimension = 0;
2406 if (stpi_escp2_printer_supports_print_to_cd(v) && (!slot || slot->is_cd))
2407 description->is_active = 1;
2408 else
2409 description->is_active = 0;
2410 }
2411 else if (strcmp(name, "Quality") == 0)
2412 {
2413 const quality_list_t *quals = escp2_quality_list(v);
2414 int has_standard_quality = 0;
2415 description->bounds.str = stp_string_list_create();
2416 stp_string_list_add_string(description->bounds.str, "None",
2417 _("Manual Control"));
2418 for (i = 0; i < quals->n_quals; i++)
2419 {
2420 const quality_t *q = &(quals->qualities[i]);
2421 if (verify_quality(v, q))
2422 stp_string_list_add_string(description->bounds.str, q->name,
2423 gettext(q->text));
2424 if (strcmp(q->name, "Standard") == 0)
2425 has_standard_quality = 1;
2426 }
2427 if (has_standard_quality)
2428 description->deflt.str = "Standard";
2429 else
2430 description->deflt.str = "None";
2431 }
2432 else if (strcmp(name, "Resolution") == 0)
2433 {
2434 const resolution_list_t *resolutions = escp2_reslist(v);
2435 description->bounds.str = stp_string_list_create();
2436 stp_string_list_add_string(description->bounds.str, "None",
2437 _("Default"));
2438 description->deflt.str = "None";
2439 for (i = 0; i < resolutions->n_resolutions; i++)
2440 {
2441 res_t *res = &(resolutions->resolutions[i]);
2442 if (verify_resolution(v, res))
2443 stp_string_list_add_string(description->bounds.str,
2444 res->name, gettext(res->text));
2445 }
2446 }
2447 else if (strcmp(name, "InkType") == 0)
2448 {
2449 const inklist_t *inks = stpi_escp2_inklist(v);
2450 unsigned int ninktypes = inks->n_inks;
2451 int verified_inktypes = 0;
2452 for (i = 0; i < ninktypes; i++)
2453 if (verify_inktype(v, &(inks->inknames[i])))
2454 verified_inktypes++;
2455 description->bounds.str = stp_string_list_create();
2456 if (verified_inktypes > 1)
2457 {
2458 stp_string_list_add_string(description->bounds.str, "None",
2459 _("Standard"));
2460 for (i = 0; i < ninktypes; i++)
2461 if (verify_inktype(v, &(inks->inknames[i])))
2462 stp_string_list_add_string(description->bounds.str,
2463 inks->inknames[i].name,
2464 gettext(inks->inknames[i].text));
2465 description->deflt.str = "None";
2466 }
2467 else
2468 description->is_active = 0;
2469 }
2470 else if (strcmp(name, "InkSet") == 0)
2471 {
2472 const inkgroup_t *inks = escp2_inkgroup(v);
2473 unsigned int ninklists = inks->n_inklists;
2474 description->bounds.str = stp_string_list_create();
2475 if (ninklists > 1)
2476 {
2477 for (i = 0; i < ninklists; i++)
2478 {
2479 stp_string_list_add_string(description->bounds.str,
2480 inks->inklists[i].name,
2481 gettext(inks->inklists[i].text));
2482 }
2483 description->deflt.str =
2484 stp_string_list_param(description->bounds.str, 0)->name;
2485 }
2486 else
2487 description->is_active = 0;
2488 }
2489 else if (strcmp(name, "MediaType") == 0)
2490 {
2491 const stp_string_list_t *p = escp2_paperlist(v);
2492 description->is_active = 0;
2493 if (p)
2494 {
2495 unsigned int nmediatypes = stp_string_list_count(p);
2496 description->bounds.str = stp_string_list_create();
2497 if (nmediatypes)
2498 {
2499 description->is_active = 1;
2500 for (i = 0; i < nmediatypes; i++)
2501 stp_string_list_add_string(description->bounds.str,
2502 stp_string_list_param(p, i)->name,
2503 gettext(stp_string_list_param(p, i)->text));
2504 description->deflt.str =
2505 stp_string_list_param(description->bounds.str, 0)->name;
2506 }
2507 }
2508 }
2509 else if (strcmp(name, "InputSlot") == 0)
2510 {
2511 const stp_string_list_t *p = escp2_slotlist(v);
2512 description->is_active = 0;
2513 if (p)
2514 {
2515 unsigned int nslots = stp_string_list_count(p);
2516 description->bounds.str = stp_string_list_create();
2517 if (nslots)
2518 {
2519 description->is_active = 1;
2520 for (i = 0; i < nslots; i++)
2521 stp_string_list_add_string(description->bounds.str,
2522 stp_string_list_param(p, i)->name,
2523 gettext(stp_string_list_param(p, i)->text));
2524 description->deflt.str =
2525 stp_string_list_param(description->bounds.str, 0)->name;
2526 }
2527 }
2528 }
2529 else if (strcmp(name, "PrintingDirection") == 0)
2530 {
2531 description->bounds.str = stp_string_list_create();
2532 stp_string_list_add_string
2533 (description->bounds.str, "None", _("Automatic"));
2534 stp_string_list_add_string
2535 (description->bounds.str, "Bidirectional", _("Bidirectional"));
2536 stp_string_list_add_string
2537 (description->bounds.str, "Unidirectional", _("Unidirectional"));
2538 description->deflt.str =
2539 stp_string_list_param(description->bounds.str, 0)->name;
2540 }
2541 else if (strcmp(name, "Weave") == 0)
2542 {
2543 description->bounds.str = stp_string_list_create();
2544 if (stpi_escp2_has_cap(v, MODEL_COMMAND, MODEL_COMMAND_PRO))
2545 {
2546 const res_t *res = stpi_escp2_find_resolution(v);
2547 const printer_weave_list_t *printer_weaves = escp2_printer_weaves(v);
2548 unsigned int nprinter_weaves = 0;
2549 if (printer_weaves && use_printer_weave(v) && (!res || res->command))
2550 nprinter_weaves = printer_weaves->n_printer_weaves;
2551 if (nprinter_weaves)
2552 {
2553 stp_string_list_add_string(description->bounds.str, "None",
2554 _("Standard"));
2555 for (i = 0; i < nprinter_weaves; i++)
2556 stp_string_list_add_string(description->bounds.str,
2557 printer_weaves->printer_weaves[i].name,
2558 gettext(printer_weaves->printer_weaves[i].text));
2559 }
2560 else
2561 description->is_active = 0;
2562 }
2563 else
2564 {
2565 stp_string_list_add_string
2566 (description->bounds.str, "None", _("Standard"));
2567 stp_string_list_add_string
2568 (description->bounds.str, "Alternate", _("Alternate Fill"));
2569 stp_string_list_add_string
2570 (description->bounds.str, "Ascending", _("Ascending Fill"));
2571 stp_string_list_add_string
2572 (description->bounds.str, "Descending", _("Descending Fill"));
2573 stp_string_list_add_string
2574 (description->bounds.str, "Ascending2X", _("Ascending Double"));
2575 stp_string_list_add_string
2576 (description->bounds.str, "Staggered", _("Nearest Neighbor Avoidance"));
2577 }
2578 if (description->is_active)
2579 description->deflt.str =
2580 stp_string_list_param(description->bounds.str, 0)->name;
2581 }
2582 else if (strcmp(name, "OutputOrder") == 0)
2583 {
2584 description->bounds.str = stp_string_list_create();
2585 description->deflt.str = "Reverse";
2586 }
2587 else if (strcmp(name, "FullBleed") == 0)
2588 {
2589 const input_slot_t *slot = stpi_escp2_get_input_slot(v);
2590 if (slot && slot->is_cd)
2591 description->is_active = 0;
2592 else if (supports_borderless(v))
2593 description->deflt.boolean = 0;
2594 else
2595 description->is_active = 0;
2596 }
2597 else if (strcmp(name, "Duplex") == 0)
2598 {
2599 if (stpi_escp2_printer_supports_duplex(v))
2600 {
2601 const input_slot_t *slot = stpi_escp2_get_input_slot(v);
2602 if (slot && !slot->duplex)
2603 description->is_active = 0;
2604 else
2605 {
2606 description->bounds.str = stp_string_list_create();
2607 stp_string_list_add_string
2608 (description->bounds.str, "None", _("Off"));
2609 stp_string_list_add_string
2610 (description->bounds.str, "DuplexNoTumble", _("Long Edge (Standard)"));
2611 stp_string_list_add_string
2612 (description->bounds.str, "DuplexTumble", _("Short Edge(Flip)"));
2613 description->deflt.str = "None";
2614 }
2615 }
2616 else
2617 description->is_active = 0;
2618 }
2619 else if (strcmp(name, "CyanDensity") == 0 ||
2620 strcmp(name, "MagentaDensity") == 0 ||
2621 strcmp(name, "YellowDensity") == 0 ||
2622 strcmp(name, "BlackDensity") == 0 ||
2623 strcmp(name, "RedDensity") == 0 ||
2624 strcmp(name, "BlueDensity") == 0 ||
2625 strcmp(name, "GreenDensity") == 0 ||
2626 strcmp(name, "OrangeDensity") == 0)
2627 set_density_parameter(v, description, name);
2628 else if (strcmp(name, "CyanHueCurve") == 0 ||
2629 strcmp(name, "MagentaHueCurve") == 0 ||
2630 strcmp(name, "YellowHueCurve") == 0 ||
2631 strcmp(name, "RedHueCurve") == 0 ||
2632 strcmp(name, "BlueHueCurve") == 0 ||
2633 strcmp(name, "GreenHueCurve") == 0 ||
2634 strcmp(name, "OrangeHueCurve") == 0)
2635 set_hue_map_parameter(v, description, name);
2636 else if (strcmp(name, "UseGloss") == 0)
2637 {
2638 const inkname_t *ink_name = get_inktype(v);
2639 if (ink_name && ink_name->aux_channel_count > 0)
2640 description->is_active = 1;
2641 else
2642 description->is_active = 0;
2643 }
2644 else if (strcmp(name, "GlossLimit") == 0)
2645 {
2646 const inkname_t *ink_name = get_inktype(v);
2647 if (ink_name && ink_name->aux_channel_count > 0)
2648 description->is_active = 1;
2649 else
2650 description->is_active = 0;
2651 }
2652 else if (strcmp(name, "DropSize1") == 0 ||
2653 strcmp(name, "DropSize2") == 0 ||
2654 strcmp(name, "DropSize3") == 0)
2655 {
2656 if (stpi_escp2_has_cap(v, MODEL_VARIABLE_DOT, MODEL_VARIABLE_YES))
2657 {
2658 const res_t *res = stpi_escp2_find_resolution(v);
2659 if (res && res->v &&
2660 stp_check_float_parameter(v, name, STP_PARAMETER_ACTIVE))
2661 description->deflt.dbl = stp_get_float_parameter(v, name);
2662 description->is_active = 1;
2663 }
2664 else
2665 description->is_active = 0;
2666 }
2667 else if (strcmp(name, "BlackTrans") == 0 ||
2668 strcmp(name, "GCRLower") == 0 ||
2669 strcmp(name, "GCRUpper") == 0)
2670 {
2671 const stp_vars_t *paper_adj = get_media_adjustment(v);
2672 if (paper_adj &&
2673 stp_get_string_parameter(v, "PrintingMode") &&
2674 strcmp(stp_get_string_parameter(v, "PrintingMode"), "BW") != 0)
2675 {
2676 if (paper_adj && stp_check_float_parameter(paper_adj, name, STP_PARAMETER_ACTIVE))
2677 description->deflt.dbl = stp_get_float_parameter(paper_adj, name);
2678 else
2679 description->p_type = STP_PARAMETER_TYPE_INVALID;
2680 }
2681 else
2682 description->p_type = STP_PARAMETER_TYPE_INVALID;
2683 }
2684 else if (strcmp(name, "GrayValue") == 0)
2685 set_gray_value_parameter(v, description, 2);
2686 else if (strcmp(name, "DarkGrayValue") == 0 ||
2687 strcmp(name, "LightGrayValue") == 0)
2688 set_gray_value_parameter(v, description, 3);
2689 else if (strcmp(name, "Gray1Value") == 0 ||
2690 strcmp(name, "Gray2Value") == 0 ||
2691 strcmp(name, "Gray3Value") == 0)
2692 set_gray_value_parameter(v, description, 4);
2693 else if (strcmp(name, "LightCyanValue") == 0)
2694 set_color_value_parameter(v, description, STP_ECOLOR_C);
2695 else if (strcmp(name, "LightMagentaValue") == 0)
2696 set_color_value_parameter(v, description, STP_ECOLOR_M);
2697 else if (strcmp(name, "DarkYellowValue") == 0)
2698 set_color_value_parameter(v, description, STP_ECOLOR_Y);
2699 else if (strcmp(name, "GrayTrans") == 0)
2700 set_gray_transition_parameter(v, description, 2);
2701 else if (strcmp(name, "DarkGrayTrans") == 0 ||
2702 strcmp(name, "LightGrayTrans") == 0)
2703 set_gray_transition_parameter(v, description, 3);
2704 else if (strcmp(name, "Gray1Trans") == 0 ||
2705 strcmp(name, "Gray2Trans") == 0 ||
2706 strcmp(name, "Gray3Trans") == 0)
2707 set_gray_transition_parameter(v, description, 4);
2708 else if (strcmp(name, "LightCyanTrans") == 0)
2709 set_color_transition_parameter(v, description, STP_ECOLOR_C);
2710 else if (strcmp(name, "LightMagentaTrans") == 0)
2711 set_color_transition_parameter(v, description, STP_ECOLOR_M);
2712 else if (strcmp(name, "DarkYellowTrans") == 0)
2713 set_color_transition_parameter(v, description, STP_ECOLOR_Y);
2714 else if (strcmp(name, "GrayScale") == 0)
2715 set_gray_scale_parameter(v, description, 2);
2716 else if (strcmp(name, "DarkGrayScale") == 0 ||
2717 strcmp(name, "LightGrayScale") == 0)
2718 set_gray_scale_parameter(v, description, 3);
2719 else if (strcmp(name, "Gray1Scale") == 0 ||
2720 strcmp(name, "Gray2Scale") == 0 ||
2721 strcmp(name, "Gray3Scale") == 0)
2722 set_gray_scale_parameter(v, description, 4);
2723 else if (strcmp(name, "LightCyanScale") == 0)
2724 set_color_scale_parameter(v, description, STP_ECOLOR_C);
2725 else if (strcmp(name, "LightMagentaScale") == 0)
2726 set_color_scale_parameter(v, description, STP_ECOLOR_M);
2727 else if (strcmp(name, "DarkYellowScale") == 0)
2728 set_color_scale_parameter(v, description, STP_ECOLOR_Y);
2729 else if (strcmp(name, "AlignmentPasses") == 0)
2730 {
2731 description->deflt.integer = escp2_alignment_passes(v);
2732 }
2733 else if (strcmp(name, "AlignmentChoices") == 0)
2734 {
2735 description->deflt.integer = escp2_alignment_choices(v);
2736 }
2737 else if (strcmp(name, "SupportsInkChange") == 0)
2738 {
2739 description->deflt.integer =
2740 stpi_escp2_has_cap(v, MODEL_SUPPORTS_INK_CHANGE,
2741 MODEL_SUPPORTS_INK_CHANGE_YES);
2742 }
2743 else if (strcmp(name, "AlternateAlignmentPasses") == 0)
2744 {
2745 description->deflt.integer = escp2_alternate_alignment_passes(v);
2746 }
2747 else if (strcmp(name, "AlternateAlignmentChoices") == 0)
2748 {
2749 description->deflt.integer = escp2_alternate_alignment_choices(v);
2750 }
2751 else if (strcmp(name, "InkChannels") == 0)
2752 {
2753 description->deflt.integer = escp2_physical_channels(v);
2754 }
2755 else if (strcmp(name, "ChannelNames") == 0)
2756 {
2757 const stp_string_list_t *channel_names = escp2_channel_names(v);
2758 if (channel_names)
2759 {
2760 description->bounds.str = stp_string_list_create_copy(channel_names);
2761 description->deflt.str =
2762 stp_string_list_param(description->bounds.str, 0)->name;
2763 }
2764 else
2765 description->p_type = STP_PARAMETER_TYPE_INVALID;
2766 }
2767 else if (strcmp(name, "SupportsPacketMode") == 0)
2768 {
2769 description->deflt.boolean =
2770 stpi_escp2_has_cap(v, MODEL_PACKET_MODE, MODEL_PACKET_MODE_YES);
2771 }
2772 else if (strcmp(name, "PrintingMode") == 0)
2773 {
2774 description->bounds.str = stp_string_list_create();
2775 stp_string_list_add_string
2776 (description->bounds.str, "Color", _("Color"));
2777 stp_string_list_add_string
2778 (description->bounds.str, "BW", _("Black and White"));
2779 description->deflt.str =
2780 stp_string_list_param(description->bounds.str, 0)->name;
2781 }
2782 else if (strcmp(name, "RawChannels") == 0)
2783 {
2784 const inklist_t *inks = stpi_escp2_inklist(v);
2785 unsigned int ninktypes = inks->n_inks;
2786 description->bounds.str = stp_string_list_create();
2787 if (ninktypes >= 1)
2788 {
2789 stp_string_list_add_string(description->bounds.str, "None", "None");
2790 for (i = 0; i < ninktypes; i++)
2791 if (inks->inknames[i].inkset == INKSET_EXTENDED)
2792 {
2793 const channel_count_t *ch =
2794 (get_channel_count_by_number
2795 (inks->inknames[i].channel_count));
2796 stp_string_list_add_string(description->bounds.str,
2797 ch->name, ch->name);
2798 }
2799 description->deflt.str =
2800 stp_string_list_param(description->bounds.str, 0)->name;
2801 }
2802 else
2803 description->is_active = 0;
2804 }
2805 else if (strcmp(name, "RawChannelNames") == 0)
2806 {
2807 const inkname_t *ink_name = get_raw_inktype(v);
2808 if (ink_name)
2809 {
2810 description->bounds.str = stp_string_list_create();
2811 for (i = 0; i < ink_name->channel_count; i++)
2812 {
2813 int j;
2814 const ink_channel_t *ic = &(ink_name->channels[i]);
2815 if (ic)
2816 for (j = 0; j < ic->n_subchannels; j++)
2817 if (ic->subchannels[j].name)
2818 stp_string_list_add_string(description->bounds.str,
2819 ic->subchannels[j].name,
2820 gettext(ic->subchannels[j].text));
2821 }
2822 for (i = 0; i < ink_name->aux_channel_count; i++)
2823 {
2824 int j;
2825 const ink_channel_t *ic = &(ink_name->aux_channels[i]);
2826 if (ic)
2827 for (j = 0; j < ic->n_subchannels; j++)
2828 if (ic->subchannels[j].name)
2829 stp_string_list_add_string(description->bounds.str,
2830 ic->subchannels[j].name,
2831 gettext(ic->subchannels[j].text));
2832 }
2833 description->deflt.str =
2834 stp_string_list_param(description->bounds.str, 0)->name;
2835 }
2836 }
2837 else if (strcmp(name, "CommandFilterName") == 0)
2838 {
2839 description->bounds.str = stp_string_list_create();
2840 stp_string_list_add_string(description->bounds.str,
2841 "commandtoepson", _("commandtoepson"));
2842 description->is_active = 1;
2843 }
2844 else if (strcmp(name, "CommandFilterCommands") == 0)
2845 {
2846 description->bounds.str = stp_string_list_create();
2847 stp_string_list_add_string(description->bounds.str,
2848 "Clean", _("Clean"));
2849 stp_string_list_add_string(description->bounds.str,
2850 "PrintSelfTestPage", _("Print self-test page"));
2851 /* Not yet */
2852 // stp_string_list_add_string(description->bounds.str,
2853 // "ReportLevels", _("Report levels"));
2854 // stp_string_list_add_string(description->bounds.str,
2855 // "AutoConfigure", _("Auto Configure"));
2856 description->is_active = 1;
2857 }
2858 else if (strcmp(name, "MultiChannelLimit") == 0)
2859 {
2860 description->is_active = 0;
2861 if (stp_get_string_parameter(v, "PrintingMode") &&
2862 strcmp(stp_get_string_parameter(v, "PrintingMode"), "BW") != 0)
2863 {
2864 const inkname_t *ink_name = get_inktype(v);
2865 if (ink_name && ink_name->inkset == INKSET_OTHER)
2866 description->is_active = 1;
2867 }
2868 }
2869 else if (strcmp(name, "PageDryTime") == 0 ||
2870 strcmp(name, "ScanDryTime") == 0 ||
2871 strcmp(name, "ScanMinDryTime") == 0 ||
2872 strcmp(name, "FeedAdjustment") == 0 ||
2873 strcmp(name, "PaperThickness") == 0 ||
2874 strcmp(name, "VacuumIntensity") == 0 ||
2875 strcmp(name, "FeedSequence") == 0 ||
2876 strcmp(name, "PrintMethod") == 0 ||
2877 strcmp(name, "PaperMedia") == 0 ||
2878 strcmp(name, "PaperMediaSize") == 0 ||
2879 strcmp(name, "PlatenGap") == 0)
2880 {
2881 description->is_active = stpi_escp2_has_media_feature(v, name);
2882 }
2883 else if (strcmp(name, "BandEnhancement") == 0)
2884 {
2885 description->is_active = 1;
2886 }
2887 }
2888
2889 const res_t *
2890 stpi_escp2_find_resolution(const stp_vars_t *v)
2891 {
2892 const char *resolution = stp_get_string_parameter(v, "Resolution");
2893 if (resolution)
2894 {
2895 const resolution_list_t *resolutions = escp2_reslist(v);
2896 unsigned int i;
2897 for (i = 0; i < resolutions->n_resolutions; i++)
2898 {
2899 const res_t *res = &(resolutions->resolutions[i]);
2900 if (!strcmp(resolution, res->name))
2901 return res;
2902 else if (!strcmp(res->name, ""))
2903 return NULL;
2904 }
2905 }
2906 if (stp_check_string_parameter(v, "Quality", STP_PARAMETER_ACTIVE))
2907 {
2908 const res_t *default_res =
2909 find_resolution_from_quality(v, stp_get_string_parameter(v, "Quality"),
2910 0);
2911 if (default_res)
2912 {
2913 stp_dprintf(STP_DBG_ESCP2, v,
2914 "Setting resolution to %s from quality %s\n",
2915 default_res->name,
2916 stp_get_string_parameter(v, "Quality"));
2917 return default_res;
2918 }
2919 else
2920 stp_dprintf(STP_DBG_ESCP2, v, "Unable to map quality %s\n",
2921 stp_get_string_parameter(v, "Quality"));
2922 }
2923 return NULL;
2924 }
2925
2926 static inline int
2927 smax(stp_dimension_t a, stp_dimension_t b)
2928 {
2929 if (a > b)
2930 return a;
2931 else
2932 return b;
2933 }
2934
2935 static void
2936 escp2_media_size(const stp_vars_t *v, /* I */
2937 stp_dimension_t *width, /* O - Width in points */
2938 stp_dimension_t *height) /* O - Height in points */
2939 {
2940 if (stp_get_page_width(v) > 0 && stp_get_page_height(v) > 0)
2941 {
2942 *width = stp_get_page_width(v);
2943 *height = stp_get_page_height(v);
2944 }
2945 else
2946 {
2947 const char *page_size = stp_get_string_parameter(v, "PageSize");
2948 const stp_papersize_t *papersize = NULL;
2949 if (page_size)
2950 papersize = stp_describe_papersize(v, page_size);
2951 if (!papersize)
2952 {
2953 *width = 1;
2954 *height = 1;
2955 }
2956 else
2957 {
2958 *width = papersize->width;
2959 *height = papersize->height;
2960 }
2961 if (*width == 0 || *height == 0)
2962 {
2963 const input_slot_t *slot = stpi_escp2_get_input_slot(v);
2964 if (slot && slot->is_cd)
2965 {
2966 papersize = stp_describe_papersize(v, "CDCustom");
2967 if (papersize)
2968 {
2969 if (*width == 0)
2970 *width = papersize->width;
2971 if (*height == 0)
2972 *height = papersize->height;
2973 }
2974 }
2975 else
2976 {
2977 const stp_papersize_list_t *paper_sizes =
2978 stpi_get_standard_papersize_list();
2979 const stp_papersize_list_item_t *ptli =
2980 stpi_papersize_list_get_start(paper_sizes);
2981 while (ptli)
2982 {
2983 papersize = stpi_paperlist_item_get_data(ptli);
2984 if (verify_papersize(v, papersize))
2985 {
2986 if (*width == 0)
2987 *width = papersize->width;
2988 if (*height == 0)
2989 *height = papersize->height;
2990 break;
2991 }
2992 ptli = stpi_paperlist_item_next(ptli);
2993 }
2994 }
2995 }
2996 /* FIXME When we support A4/letter */
2997 if (*width == 0)
2998 *width = 612;
2999 if (*height == 0)
3000 *height = 792;
3001 }
3002 }
3003
3004 static void
3005 internal_imageable_area(const stp_vars_t *v, int use_paper_margins,
3006 int use_maximum_area,
3007 stp_dimension_t *left, stp_dimension_t *right,
3008 stp_dimension_t *bottom, stp_dimension_t *top)
3009 {
3010 stp_dimension_t width, height; /* Size of page */
3011 int rollfeed = 0; /* Roll feed selected */
3012 int cd = 0; /* CD selected */
3013 const char *media_size = stp_get_string_parameter(v, "PageSize");
3014 const char *duplex = stp_get_string_parameter(v, "Duplex");
3015 stp_dimension_t left_margin = 0;
3016 stp_dimension_t right_margin = 0;
3017 stp_dimension_t bottom_margin = 0;
3018 stp_dimension_t top_margin = 0;
3019 const stp_papersize_t *pt = NULL;
3020 const input_slot_t *input_slot = NULL;
3021
3022 if (media_size)
3023 pt = stp_describe_papersize(v, media_size);
3024
3025 input_slot = stpi_escp2_get_input_slot(v);
3026 if (input_slot)
3027 {
3028 cd = input_slot->is_cd;
3029 rollfeed = input_slot->is_roll_feed;
3030 }
3031
3032 escp2_media_size(v, &width, &height);
3033 if (cd)
3034 {
3035 if (pt)
3036 {
3037 left_margin = pt->left;
3038 right_margin = pt->right;
3039 bottom_margin = pt->bottom;
3040 top_margin = pt->top;
3041 }
3042 else
3043 {
3044 left_margin = 0;
3045 right_margin = 0;
3046 bottom_margin = 0;
3047 top_margin = 0;
3048 }
3049 }
3050 else
3051 {
3052 if (pt && use_paper_margins)
3053 {
3054 left_margin = pt->left;
3055 right_margin = pt->right;
3056 bottom_margin = pt->bottom;
3057 top_margin = pt->top;
3058 }
3059
3060 left_margin = smax(left_margin, escp2_left_margin(v, rollfeed));
3061 right_margin = smax(right_margin, escp2_right_margin(v, rollfeed));
3062 bottom_margin = smax(bottom_margin, escp2_bottom_margin(v, rollfeed));
3063 top_margin = smax(top_margin, escp2_top_margin(v, rollfeed));
3064 }
3065 if (supports_borderless(v) &&
3066 (use_maximum_area ||
3067 (!cd && stp_get_boolean_parameter(v, "FullBleed"))))
3068 {
3069 if (pt)
3070 {
3071 if (pt->left <= 0 && pt->right <= 0 && pt->top <= 0 &&
3072 pt->bottom <= 0)
3073 {
3074 if (use_paper_margins)
3075 {
3076 stp_dimension_t width_limit = escp2_max_paper_width(v);
3077 stp_dimension_t offset = escp2_zero_margin_offset(v);
3078 stp_dimension_t margin = escp2_micro_left_margin(v);
3079 stp_dimension_t sep = escp2_base_separation(v);
3080 stp_dimension_t delta = -((offset - margin) * 72.0 / sep);
3081 left_margin = delta; /* Allow some overlap if paper isn't */
3082 right_margin = delta; /* positioned correctly */
3083 if (width - right_margin - 3 > width_limit)
3084 right_margin = width - width_limit - 3;
3085 if (! stpi_escp2_has_cap(v, MODEL_ZEROMARGIN,
3086 MODEL_ZEROMARGIN_H_ONLY))
3087 {
3088 top_margin = -7;
3089 bottom_margin = -7;
3090 }
3091 }
3092 else
3093 {
3094 left_margin = 0;
3095 right_margin = 0;
3096 if (! stpi_escp2_has_cap(v, MODEL_ZEROMARGIN,
3097 MODEL_ZEROMARGIN_H_ONLY))
3098 {
3099 top_margin = 0;
3100 bottom_margin = 0;
3101 }
3102 }
3103 }
3104 }
3105 }
3106 if (!use_maximum_area && duplex && strcmp(duplex, "None") != 0)
3107 {
3108 left_margin = smax(left_margin, escp2_duplex_left_margin(v));
3109 right_margin = smax(right_margin, escp2_duplex_right_margin(v));
3110 bottom_margin = smax(bottom_margin, escp2_duplex_bottom_margin(v));
3111 top_margin = smax(top_margin, escp2_duplex_top_margin(v));
3112 }
3113
3114 if (width > escp2_max_imageable_width(v))
3115 width = escp2_max_imageable_width(v);
3116 if (height > escp2_max_imageable_height(v))
3117 height = escp2_max_imageable_height(v);
3118 *left = left_margin;
3119 *right = width - right_margin;
3120 *top = top_margin;
3121 *bottom = height - bottom_margin;
3122 }
3123
3124 /*
3125 * 'escp2_imageable_area()' - Return the imageable area of the page.
3126 */
3127
3128 static void
3129 escp2_imageable_area(const stp_vars_t *v, /* I */
3130 stp_dimension_t *left, /* O - Left position in points */
3131 stp_dimension_t *right, /* O - Right position in points */
3132 stp_dimension_t *bottom, /* O - Bottom position in points */
3133 stp_dimension_t *top) /* O - Top position in points */
3134 {
3135 internal_imageable_area(v, 1, 0, left, right, bottom, top);
3136 }
3137
3138 static void
3139 escp2_maximum_imageable_area(const stp_vars_t *v, /* I */
3140 stp_dimension_t *left, /* O - Left position in points */
3141 stp_dimension_t *right, /* O - Right position in points */
3142 stp_dimension_t *bottom, /* O - Bottom position in points */
3143 stp_dimension_t *top) /* O - Top position in points */
3144 {
3145 internal_imageable_area(v, 1, 1, left, right, bottom, top);
3146 }
3147
3148 static void
3149 escp2_limit(const stp_vars_t *v, /* I */
3150 stp_dimension_t *width, stp_dimension_t *height,
3151 stp_dimension_t *min_width, stp_dimension_t *min_height)
3152 {
3153 *width = escp2_max_paper_width(v);
3154 *height = escp2_max_paper_height(v);
3155 *min_width = escp2_min_paper_width(v);
3156 *min_height = escp2_min_paper_height(v);
3157 }
3158
3159 static void
3160 escp2_describe_resolution(const stp_vars_t *v, stp_resolution_t *x, stp_resolution_t *y)
3161 {
3162 const res_t *res = stpi_escp2_find_resolution(v);
3163 if (res && verify_resolution(v, res))
3164 {
3165 *x = res->printed_hres;
3166 *y = res->printed_vres;
3167 return;
3168 }
3169 *x = -1;
3170 *y = -1;
3171 }
3172
3173 static const char *
3174 escp2_describe_output(const stp_vars_t *v)
3175 {
3176 const char *printing_mode = stp_get_string_parameter(v, "PrintingMode");
3177 const char *input_image_type = stp_get_string_parameter(v, "InputImageType");
3178 if (input_image_type && strcmp(input_image_type, "Raw") == 0)
3179 return "Raw";
3180 else if (printing_mode && strcmp(printing_mode, "BW") == 0)
3181 return "Grayscale";
3182 else
3183 {
3184 const inkname_t *ink_type = get_inktype(v);
3185 if (ink_type)
3186 {
3187 switch (ink_type->inkset)
3188 {
3189 case INKSET_QUADTONE:
3190 case INKSET_HEXTONE:
3191 return "Grayscale";
3192 case INKSET_OTHER:
3193 case INKSET_CMYK:
3194 case INKSET_CcMmYK:
3195 case INKSET_CcMmYyK:
3196 case INKSET_CcMmYKk:
3197 default:
3198 if (ink_type->channels[0].n_subchannels > 0)
3199 return "KCMY";
3200 else
3201 return "CMY";
3202 break;
3203 }
3204 }
3205 else
3206 return "CMYK";
3207 }
3208 }
3209
3210 static int
3211 escp2_has_advanced_command_set(const stp_vars_t *v)
3212 {
3213 return (stpi_escp2_has_cap(v, MODEL_COMMAND, MODEL_COMMAND_PRO) ||
3214 stpi_escp2_has_cap(v, MODEL_COMMAND, MODEL_COMMAND_1999) ||
3215 stpi_escp2_has_cap(v, MODEL_COMMAND, MODEL_COMMAND_2000));
3216 }
3217
3218 static int
3219 escp2_use_extended_commands(const stp_vars_t *v, int use_softweave)
3220 {
3221 return (stpi_escp2_has_cap(v, MODEL_COMMAND, MODEL_COMMAND_PRO) ||
3222 (stpi_escp2_has_cap(v, MODEL_VARIABLE_DOT, MODEL_VARIABLE_YES) &&
3223 use_softweave));
3224 }
3225
3226 static int
3227 set_raw_ink_type(stp_vars_t *v)
3228 {
3229 const inklist_t *inks = stpi_escp2_inklist(v);
3230 int ninktypes = inks->n_inks;
3231 int i;
3232 const char *channel_name = stp_get_string_parameter(v, "RawChannels");
3233 const channel_count_t *count;
3234 if (!channel_name)
3235 return 0;
3236 count = get_channel_count_by_name(channel_name);
3237 if (!count)
3238 return 0;
3239
3240 /*
3241 * If we're using raw printer output, we dummy up the appropriate inkset.
3242 */
3243 for (i = 0; i < ninktypes; i++)
3244 if (inks->inknames[i].inkset == INKSET_EXTENDED &&
3245 (inks->inknames[i].channel_count == count->count))
3246 {
3247 stp_dprintf(STP_DBG_INK, v, "Changing ink type from %s to %s\n",
3248 stp_get_string_parameter(v, "InkType") ?
3249 stp_get_string_parameter(v, "InkType") : "NULL",
3250 inks->inknames[i].name);
3251 stp_set_string_parameter(v, "InkType", inks->inknames[i].name);
3252 stp_set_int_parameter(v, "STPIRawChannels", count->count);
3253 return 1;
3254 }
3255 stp_eprintf
3256 (v, _("This printer does not support raw printer output at depth %d\n"),
3257 count->count);
3258 return 0;
3259 }
3260
3261 static void
3262 adjust_density_and_ink_type(stp_vars_t *v)
3263 {
3264 escp2_privdata_t *pd = get_privdata(v);
3265 const stp_vars_t *pv = pd->paper_type->v;
3266 double paper_density = .8;
3267
3268 if (pv && stp_check_float_parameter(pv, "Density", STP_PARAMETER_ACTIVE))
3269 paper_density = stp_get_float_parameter(pv, "Density");
3270
3271 if (!stp_check_float_parameter(v, "Density", STP_PARAMETER_DEFAULTED))
3272 {
3273 stp_set_float_parameter_active(v, "Density", STP_PARAMETER_ACTIVE);
3274 stp_set_float_parameter(v, "Density", 1.0);
3275 }
3276 stp_scale_float_parameter(v, "Density", paper_density * escp2_density(v));
3277 pd->drop_size = escp2_ink_type(v);
3278
3279 if (stp_get_float_parameter(v, "Density") > 1.0)
3280 stp_set_float_parameter(v, "Density", 1.0);
3281 }
3282
3283 static void
3284 adjust_print_quality(stp_vars_t *v)
3285 {
3286 escp2_privdata_t *pd = get_privdata(v);
3287 const stp_vars_t *pv = pd->paper_type->v;
3288 double k_upper = 1.0;
3289 double k_lower = 0;
3290 double k_transition = 1.0;
3291
3292 /*
3293 * Compute the LUT. For now, it's 8 bit, but that may eventually
3294 * sometimes change.
3295 */
3296
3297 if (pv)
3298 {
3299 int i;
3300 stp_string_list_t *slist;
3301 stp_set_default_float_parameter(v, "BlackDensity", 1.0);
3302 stp_set_default_float_parameter(v, "Saturation", 1.0);
3303 stp_set_default_float_parameter(v, "Gamma", 1.0);
3304 slist = stp_list_parameters(pv, STP_PARAMETER_TYPE_STRING_LIST);
3305 if (slist)
3306 {
3307 int len = stp_string_list_count(slist);
3308 for (i = 0; i < len; i++)
3309 {
3310 const char *name = stp_string_list_param(slist, i)->name;
3311 if (!stp_check_string_parameter(v, name, STP_PARAMETER_ACTIVE))
3312 stp_set_string_parameter(v, name,
3313 stp_get_string_parameter(pv, name));
3314 }
3315 stp_string_list_destroy(slist);
3316 }
3317 slist = stp_list_parameters(pv, STP_PARAMETER_TYPE_FILE);
3318 if (slist)
3319 {
3320 int len = stp_string_list_count(slist);
3321 for (i = 0; i < len; i++)
3322 {
3323 const char *name = stp_string_list_param(slist, i)->name;
3324 if (!stp_check_file_parameter(v, name, STP_PARAMETER_ACTIVE))
3325 stp_set_file_parameter(v, name,
3326 stp_get_file_parameter(pv, name));
3327 }
3328 stp_string_list_destroy(slist);
3329 }
3330 slist = stp_list_parameters(pv, STP_PARAMETER_TYPE_INT);
3331 if (slist)
3332 {
3333 int len = stp_string_list_count(slist);
3334 for (i = 0; i < len; i++)
3335 {
3336 const char *name = stp_string_list_param(slist, i)->name;
3337 if (!stp_check_int_parameter(v, name, STP_PARAMETER_ACTIVE))
3338 stp_set_int_parameter(v, name,
3339 stp_get_int_parameter(pv, name));
3340 }
3341 stp_string_list_destroy(slist);
3342 }
3343 slist = stp_list_parameters(pv, STP_PARAMETER_TYPE_DIMENSION);
3344 if (slist)
3345 {
3346 int len = stp_string_list_count(slist);
3347 for (i = 0; i < len; i++)
3348 {
3349 const char *name = stp_string_list_param(slist, i)->name;
3350 if (!stp_check_dimension_parameter(v, name, STP_PARAMETER_ACTIVE))
3351 stp_set_dimension_parameter(v, name,
3352 stp_get_dimension_parameter(pv, name));
3353 }
3354 stp_string_list_destroy(slist);
3355 }
3356 slist = stp_list_parameters(pv, STP_PARAMETER_TYPE_BOOLEAN);
3357 if (slist)
3358 {
3359 int len = stp_string_list_count(slist);
3360 for (i = 0; i < len; i++)
3361 {
3362 const char *name = stp_string_list_param(slist, i)->name;
3363 if (!stp_check_boolean_parameter(v, name, STP_PARAMETER_ACTIVE))
3364 stp_set_boolean_parameter(v, name,
3365 stp_get_boolean_parameter(pv, name));
3366 }
3367 stp_string_list_destroy(slist);
3368 }
3369 slist = stp_list_parameters(pv, STP_PARAMETER_TYPE_CURVE);
3370 if (slist)
3371 {
3372 int len = stp_string_list_count(slist);
3373 for (i = 0; i < len; i++)
3374 {
3375 const char *name = stp_string_list_param(slist, i)->name;
3376 if (!stp_check_curve_parameter(v, name, STP_PARAMETER_ACTIVE))
3377 stp_set_curve_parameter(v, name,
3378 stp_get_curve_parameter(pv, name));
3379 }
3380 stp_string_list_destroy(slist);
3381 }
3382 slist = stp_list_parameters(pv, STP_PARAMETER_TYPE_ARRAY);
3383 if (slist)
3384 {
3385 int len = stp_string_list_count(slist);
3386 for (i = 0; i < len; i++)
3387 {
3388 const char *name = stp_string_list_param(slist, i)->name;
3389 if (!stp_check_array_parameter(v, name, STP_PARAMETER_ACTIVE))
3390 stp_set_array_parameter(v, name,
3391 stp_get_array_parameter(pv, name));
3392 }
3393 stp_string_list_destroy(slist);
3394 }
3395 slist = stp_list_parameters(pv, STP_PARAMETER_TYPE_RAW);
3396 if (slist)
3397 {
3398 int len = stp_string_list_count(slist);
3399 for (i = 0; i < len; i++)
3400 {
3401 const char *name = stp_string_list_param(slist, i)->name;
3402 if (!stp_check_raw_parameter(v, name, STP_PARAMETER_ACTIVE))
3403 {
3404 const stp_raw_t *r = stp_get_raw_parameter(pv, name);
3405 stp_set_raw_parameter(v, name, r->data, r->bytes);
3406 }
3407 }
3408 stp_string_list_destroy(slist);
3409 }
3410 slist = stp_list_parameters(pv, STP_PARAMETER_TYPE_DOUBLE);
3411 if (slist)
3412 {
3413 int len = stp_string_list_count(slist);
3414 for (i = 0; i < len; i++)
3415 {
3416 const char *name = stp_string_list_param(slist, i)->name;
3417 if (strcmp(name, "BlackDensity") == 0 ||
3418 strcmp(name, "Saturation") == 0 ||
3419 strcmp(name, "Gamma") == 0)
3420 stp_scale_float_parameter(v, name,
3421 stp_get_float_parameter(pv, name));
3422 else if (strcmp(name, "GCRLower") == 0)
3423 k_lower = stp_get_float_parameter(pv, "GCRLower");
3424 else if (strcmp(name, "GCRUpper") == 0)
3425 k_upper = stp_get_float_parameter(pv, "GCRUpper");
3426 else if (strcmp(name, "BlackTrans") == 0)
3427 k_transition = stp_get_float_parameter(pv, "BlackTrans");
3428 else if (!stp_check_float_parameter(v, name, STP_PARAMETER_ACTIVE))
3429 stp_set_float_parameter(v, name,
3430 stp_get_float_parameter(pv, name));
3431 }
3432 stp_string_list_destroy(slist);
3433 }
3434 }
3435
3436 if (!stp_check_float_parameter(v, "GCRLower", STP_PARAMETER_ACTIVE))
3437 stp_set_default_float_parameter(v, "GCRLower", k_lower);
3438 if (!stp_check_float_parameter(v, "GCRUpper", STP_PARAMETER_ACTIVE))
3439 stp_set_default_float_parameter(v, "GCRUpper", k_upper);
3440 if (!stp_check_float_parameter(v, "BlackTrans", STP_PARAMETER_ACTIVE))
3441 stp_set_default_float_parameter(v, "BlackTrans", k_transition);
3442
3443
3444 }
3445
3446 static int
3447 count_channels(const inkname_t *inks, int use_aux_channels)
3448 {
3449 int answer = 0;
3450 int i;
3451 for (i = 0; i < inks->channel_count; i++)
3452 if (inks->channels[i].n_subchannels > 0)
3453 answer += inks->channels[i].n_subchannels;
3454 if (use_aux_channels)
3455 for (i = 0; i < inks->aux_channel_count; i++)
3456 if (inks->aux_channels[i].n_subchannels > 0)
3457 answer += inks->aux_channels[i].n_subchannels;
3458 return answer;
3459 }
3460
3461 static int
3462 compute_channel_count(const inkname_t *ink_type, int channel_limit,
3463 int use_aux_channels)
3464 {
3465 int i;
3466 int physical_channels = 0;
3467 for (i = 0; i < channel_limit; i++)
3468 {
3469 const ink_channel_t *channel = &(ink_type->channels[i]);
3470 if (channel)
3471 physical_channels += channel->n_subchannels;
3472 }
3473 if (use_aux_channels)
3474 for (i = 0; i < ink_type->aux_channel_count; i++)
3475 if (ink_type->aux_channels[i].n_subchannels > 0)
3476 physical_channels += ink_type->aux_channels[i].n_subchannels;
3477 return physical_channels;
3478 }
3479
3480 static double
3481 get_double_param(const stp_vars_t *v, const char *param)
3482 {
3483 if (param && stp_check_float_parameter(v, param, STP_PARAMETER_ACTIVE))
3484 return stp_get_float_parameter(v, param);
3485 else
3486 return 1.0;
3487 }
3488
3489 static void
3490 setup_inks(stp_vars_t *v)
3491 {
3492 escp2_privdata_t *pd = get_privdata(v);
3493 int i, j;
3494 escp2_dropsize_t *drops;
3495 const inkname_t *ink_type = pd->inkname;
3496 const stp_vars_t *pv = pd->paper_type->v;
3497 double gloss_scale = get_double_param(v, "Density");
3498
3499 drops = escp2_copy_dropsizes(v);
3500 stp_init_debug_messages(v);
3501 if (stp_check_float_parameter(v, "DropSize1", STP_PARAMETER_ACTIVE))
3502 {
3503 drops->dropsizes[0] = stp_get_float_parameter(v, "DropSize1");
3504 if (drops->dropsizes[0] > 0 && drops->numdropsizes < 1)
3505 drops->numdropsizes = 1;
3506 }
3507 if (stp_check_float_parameter(v, "DropSize2", STP_PARAMETER_ACTIVE))
3508 {
3509 drops->dropsizes[1] = stp_get_float_parameter(v, "DropSize2");
3510 if (drops->dropsizes[1] > 0 && drops->numdropsizes < 2)
3511 drops->numdropsizes = 2;
3512 }
3513 if (stp_check_float_parameter(v, "DropSize3", STP_PARAMETER_ACTIVE))
3514 {
3515 drops->dropsizes[2] = stp_get_float_parameter(v, "DropSize3");
3516 if (drops->dropsizes[2] > 0 && drops->numdropsizes < 3)
3517 drops->numdropsizes = 3;
3518 }
3519 STPI_ASSERT(drops->numdropsizes < (1 << escp2_bits(v)), v);
3520 for (i = drops->numdropsizes - 1; i >= 0; i--)
3521 {
3522 if (drops->dropsizes[i] > 0)
3523 break;
3524 drops->numdropsizes--;
3525 }
3526 for (i = 0; i < pd->logical_channels; i++)
3527 {
3528 const ink_channel_t *channel = &(ink_type->channels[i]);
3529 if (channel && channel->n_subchannels > 0)
3530 {
3531 int hue_curve_found = 0;
3532 const char *param = channel->subchannels[0].channel_density;
3533 shade_t *shades = escp2_copy_shades(v, i);
3534 double userval = get_double_param(v, param);
3535 STPI_ASSERT(shades->n_shades >= channel->n_subchannels, v);
3536 if (ink_type->inkset != INKSET_EXTENDED)
3537 {
3538 if (strcmp(param, "BlackDensity") == 0)
3539 stp_channel_set_black_channel(v, i);
3540 else if (strcmp(param, "GlossDensity") == 0)
3541 {
3542 gloss_scale *= get_double_param(v, param);
3543 }
3544 }
3545 for (j = 0; j < channel->n_subchannels; j++)
3546 {
3547 const char *subparam =
3548 channel->subchannels[j].subchannel_value;
3549 if (subparam &&
3550 stp_check_float_parameter(v, subparam, STP_PARAMETER_ACTIVE))
3551 shades->shades[j] = stp_get_float_parameter(v, subparam);
3552 }
3553 stp_dither_set_inks(v, i, 1.0, ink_darknesses[i % 8],
3554 channel->n_subchannels, shades->shades,
3555 drops->numdropsizes, drops->dropsizes);
3556 for (j = 0; j < channel->n_subchannels; j++)
3557 {
3558 const char *subparam =
3559 channel->subchannels[j].subchannel_scale;
3560 double scale = userval * get_double_param(v, subparam);
3561 scale *= get_double_param(v, "Density");
3562 stp_channel_set_density_adjustment(v, i, j, scale);
3563 subparam =
3564 channel->subchannels[j].subchannel_transition;
3565 if (subparam &&
3566 stp_check_float_parameter(v, subparam, STP_PARAMETER_ACTIVE))
3567 stp_channel_set_cutoff_adjustment
3568 (v, i, j, stp_get_float_parameter(v, subparam));
3569 else if (pv)
3570 {
3571 if (subparam &&
3572 stp_check_float_parameter(pv, subparam, STP_PARAMETER_ACTIVE))
3573 stp_channel_set_cutoff_adjustment
3574 (v, i, j, stp_get_float_parameter(pv, subparam));
3575 else if (stp_check_float_parameter(pv, "SubchannelCutoff", STP_PARAMETER_ACTIVE))
3576 stp_channel_set_cutoff_adjustment
3577 (v, i, j, stp_get_float_parameter(pv, "SubchannelCutoff"));
3578 }
3579 }
3580 if (ink_type->inkset != INKSET_EXTENDED)
3581 {
3582 if (channel->hue_curve_name)
3583 {
3584 const stp_curve_t *curve = NULL;
3585 curve = stp_get_curve_parameter(v, channel->hue_curve_name);
3586 if (curve)
3587 {
3588 stp_channel_set_curve(v, i, curve);
3589 hue_curve_found = 1;
3590 }
3591 }
3592 if (channel->hue_curve && !hue_curve_found)
3593 stp_channel_set_curve(v, i, channel->hue_curve);
3594 }
3595 escp2_free_shades(shades);
3596 }
3597 }
3598 if (pd->use_aux_channels)
3599 {
3600 int base_count = pd->logical_channels;
3601 for (i = 0; i < ink_type->aux_channel_count; i++)
3602 {
3603 const ink_channel_t *channel = &(ink_type->aux_channels[i]);
3604 if (channel && channel->n_subchannels > 0)
3605 {
3606 int ch = i + base_count;
3607 const char *param = channel->subchannels[0].channel_density;
3608 shade_t *shades = escp2_copy_shades(v, ch);
3609 double userval = get_double_param(v, param);
3610 STPI_ASSERT(shades->n_shades >= channel->n_subchannels, v);
3611 if (strcmp(param, "GlossDensity") == 0)
3612 {
3613 gloss_scale *= get_double_param(v, param);
3614 stp_channel_set_gloss_channel(v, ch);
3615 stp_channel_set_gloss_limit(v, gloss_scale);
3616 }
3617 for (j = 0; j < channel->n_subchannels; j++)
3618 {
3619 const char *subparam =
3620 channel->subchannels[j].subchannel_value;
3621 if (subparam &&
3622 stp_check_float_parameter(v, subparam, STP_PARAMETER_ACTIVE))
3623 shades->shades[j] = stp_get_float_parameter(v, subparam);
3624 }
3625 stp_dither_set_inks(v, ch, 1.0, ink_darknesses[ch % 8],
3626 channel->n_subchannels, shades->shades,
3627 drops->numdropsizes, drops->dropsizes);
3628 for (j = 0; j < channel->n_subchannels; j++)
3629 {
3630 const char *subparam =
3631 channel->subchannels[j].subchannel_scale;
3632 double scale = userval * get_double_param(v, subparam);
3633 scale *= get_double_param(v, "Density");
3634 stp_channel_set_density_adjustment(v, ch, j, scale);
3635 subparam =
3636 channel->subchannels[j].subchannel_transition;
3637 if (subparam &&
3638 stp_check_float_parameter(v, subparam, STP_PARAMETER_ACTIVE))
3639 stp_channel_set_cutoff_adjustment
3640 (v, ch, j, stp_get_float_parameter(v, subparam));
3641 else if (pv)
3642 {
3643 if (subparam &&
3644 stp_check_float_parameter(pv, subparam, STP_PARAMETER_ACTIVE))
3645 stp_channel_set_cutoff_adjustment
3646 (v, ch, j, stp_get_float_parameter(pv, subparam));
3647 else if (stp_check_float_parameter(pv, "SubchannelCutoff", STP_PARAMETER_ACTIVE))
3648 stp_channel_set_cutoff_adjustment
3649 (v, ch, j, stp_get_float_parameter(pv, "SubchannelCutoff"));
3650 }
3651 }
3652 if (channel->hue_curve)
3653 {
3654 stp_curve_t *curve_tmp =
3655 stp_curve_create_copy(channel->hue_curve);
3656 (void) stp_curve_rescale(curve_tmp,
3657 sqrt(1.0 / stp_get_float_parameter(v, "Gamma")),
3658 STP_CURVE_COMPOSE_EXPONENTIATE,
3659 STP_CURVE_BOUNDS_RESCALE);
3660 stp_channel_set_curve(v, ch, curve_tmp);
3661 stp_curve_destroy(curve_tmp);
3662 }
3663 escp2_free_shades(shades);
3664 }
3665 }
3666 }
3667 escp2_free_dropsizes(drops);
3668 stp_flush_debug_messages(v);
3669 }
3670
3671 static void
3672 setup_head_offset(stp_vars_t *v)
3673 {
3674 escp2_privdata_t *pd = get_privdata(v);
3675 int i;
3676 int channel_id = 0;
3677 int channel_limit = pd->logical_channels;
3678 const inkname_t *ink_type = pd->inkname;
3679 if (pd->channels_in_use > pd->logical_channels)
3680 channel_limit = pd->channels_in_use;
3681 pd->head_offset = stp_zalloc(sizeof(int) * channel_limit);
3682 for (i = 0; i < pd->logical_channels; i++)
3683 {
3684 const ink_channel_t *channel = &(ink_type->channels[i]);
3685 if (channel)
3686 {
3687 int j;
3688 for (j = 0; j < channel->n_subchannels; j++)
3689 {
3690 pd->head_offset[channel_id] =
3691 channel->subchannels[j].head_offset;
3692 channel_id++;
3693 }
3694 }
3695 }
3696 if (pd->use_aux_channels)
3697 {
3698 for (i = 0; i < ink_type->aux_channel_count; i++)
3699 {
3700 const ink_channel_t *channel = &(ink_type->aux_channels[i]);
3701 if (channel)
3702 {
3703 int j;
3704 for (j = 0; j < channel->n_subchannels; j++)
3705 {
3706 pd->head_offset[channel_id] =
3707 channel->subchannels[j].head_offset;
3708 channel_id++;
3709 }
3710 }
3711 }
3712 }
3713 if (pd->physical_channels == 1)
3714 pd->head_offset[0] = 0;
3715 pd->max_head_offset = 0;
3716 if (pd->physical_channels > 1)
3717 for (i = 0; i < pd->channels_in_use; i++)
3718 {
3719 pd->head_offset[i] = pd->head_offset[i] * pd->res->vres /
3720 escp2_base_separation(v);
3721 if (pd->head_offset[i] > pd->max_head_offset)
3722 pd->max_head_offset = pd->head_offset[i];
3723 }
3724 }
3725
3726 static int
3727 supports_split_channels(stp_vars_t *v)
3728 {
3729 escp2_privdata_t *pd = get_privdata(v);
3730 int i;
3731 int split_channel_count = -1;
3732 for (i = 0; i < pd->logical_channels; i++)
3733 {
3734 int j;
3735 if (pd->inkname->channels[i].n_subchannels > 0)
3736 {
3737 for (j = 0; j < pd->inkname->channels[i].n_subchannels; j++)
3738 {
3739 int split_count = pd->inkname->channels[i].subchannels[j].split_channel_count;
3740 if (split_count == 0)
3741 return 0;
3742 else if (split_channel_count >= 0 && split_count != split_channel_count)
3743 return 0;
3744 else
3745 split_channel_count = split_count;
3746 }
3747 }
3748 }
3749 if (split_channel_count > 0)
3750 return split_channel_count;
3751 else
3752 return 0;
3753 }
3754
3755
3756 static void
3757 setup_split_channels(stp_vars_t *v)
3758 {
3759 escp2_privdata_t *pd = get_privdata(v);
3760 /*
3761 * Set up the output channels
3762 */
3763 pd->split_channel_count = supports_split_channels(v);
3764 if (pd->split_channel_count)
3765 {
3766 if (pd->res->vres <
3767 (escp2_base_separation(v) / escp2_black_nozzle_separation(v)))
3768 {
3769 int incr =
3770 (escp2_base_separation(v) / escp2_black_nozzle_separation(v)) /
3771 pd->res->vres;
3772 pd->split_channel_count /= incr;
3773 pd->nozzle_separation *= incr;
3774 pd->nozzles /= incr;
3775 pd->min_nozzles /= incr;
3776 }
3777 }
3778 }
3779
3780 static void
3781 setup_basic(stp_vars_t *v)
3782 {
3783 escp2_privdata_t *pd = get_privdata(v);
3784 pd->advanced_command_set = escp2_has_advanced_command_set(v);
3785 pd->command_set = stpi_escp2_get_cap(v, MODEL_COMMAND);
3786 pd->variable_dots = stpi_escp2_has_cap(v, MODEL_VARIABLE_DOT, MODEL_VARIABLE_YES);
3787 pd->has_graymode = stpi_escp2_has_cap(v, MODEL_GRAYMODE, MODEL_GRAYMODE_YES);
3788 pd->roll_only = stpi_escp2_has_cap(v, MODEL_ROLL_ONLY, MODEL_ROLL_ONLY_YES);
3789 pd->preinit_sequence = escp2_preinit_sequence(v);
3790 pd->preinit_remote_sequence = escp2_preinit_remote_sequence(v);
3791 pd->deinit_remote_sequence = escp2_postinit_remote_sequence(v);
3792 pd->borderless_sequence = escp2_vertical_borderless_sequence(v);
3793 pd->base_separation = escp2_base_separation(v);
3794 pd->resolution_scale = escp2_resolution_scale(v);
3795 }
3796
3797 static void
3798 setup_misc(stp_vars_t *v)
3799 {
3800 escp2_privdata_t *pd = get_privdata(v);
3801 pd->input_slot = stpi_escp2_get_input_slot(v);
3802 pd->paper_type = stpi_escp2_get_media_type(v, 0);
3803 pd->ink_group = escp2_inkgroup(v);
3804 pd->media_settings = stp_vars_create_copy(pd->paper_type->v);
3805 stpi_escp2_set_media_size(pd->media_settings, v);
3806 if (stp_check_float_parameter(v, "PageDryTime", STP_PARAMETER_ACTIVE))
3807 stp_set_float_parameter(pd->media_settings, "PageDryTime",
3808 stp_get_float_parameter(v, "PageDryTime"));
3809 if (stp_check_float_parameter(v, "ScanDryTime", STP_PARAMETER_ACTIVE))
3810 stp_set_float_parameter(pd->media_settings, "ScanDryTime",
3811 stp_get_float_parameter(v, "ScanDryTime"));
3812 if (stp_check_float_parameter(v, "ScanMinDryTime", STP_PARAMETER_ACTIVE))
3813 stp_set_float_parameter(pd->media_settings, "ScanMinDryTime",
3814 stp_get_float_parameter(v, "ScanMinDryTime"));
3815 if (stp_check_int_parameter(v, "FeedAdjustment", STP_PARAMETER_ACTIVE))
3816 stp_set_int_parameter(pd->media_settings, "FeedAdjustment",
3817 stp_get_int_parameter(v, "FeedAdjustment"));
3818 if (stp_check_int_parameter(v, "PaperThickness", STP_PARAMETER_ACTIVE))
3819 stp_set_int_parameter(pd->media_settings, "PaperThickness",
3820 stp_get_int_parameter(v, "PaperThickness"));
3821 if (stp_check_int_parameter(v, "VacuumIntensity", STP_PARAMETER_ACTIVE))
3822 stp_set_int_parameter(pd->media_settings, "VacuumIntensity",
3823 stp_get_int_parameter(v, "VacuumIntensity"));
3824 if (stp_check_int_parameter(v, "FeedSequence", STP_PARAMETER_ACTIVE))
3825 stp_set_int_parameter(pd->media_settings, "FeedSequence",
3826 stp_get_int_parameter(v, "FeedSequence"));
3827 if (stp_check_int_parameter(v, "PrintMethod", STP_PARAMETER_ACTIVE))
3828 stp_set_int_parameter(pd->media_settings, "PrintMethod",
3829 stp_get_int_parameter(v, "PrintMethod"));
3830 if (stp_check_int_parameter(v, "PlatenGap", STP_PARAMETER_ACTIVE))
3831 stp_set_int_parameter(pd->media_settings, "PlatenGap",
3832 stp_get_int_parameter(v, "PlatenGap"));
3833 }
3834
3835 static void
3836 allocate_channels(stp_vars_t *v, int line_length)
3837 {
3838 escp2_privdata_t *pd = get_privdata(v);
3839 const inkname_t *ink_type = pd->inkname;
3840 int i, j, k;
3841 int channel_id = 0;
3842 int split_id = 0;
3843
3844 pd->cols = stp_zalloc(sizeof(unsigned char *) * pd->channels_in_use);
3845 pd->channels =
3846 stp_zalloc(sizeof(physical_subchannel_t *) * pd->channels_in_use);
3847 if (pd->split_channel_count)
3848 pd->split_channels = stp_zalloc(sizeof(short) * pd->channels_in_use *
3849 pd->split_channel_count);
3850
3851 for (i = 0; i < pd->logical_channels; i++)
3852 {
3853 const ink_channel_t *channel = &(ink_type->channels[i]);
3854 if (channel)
3855 {
3856 for (j = 0; j < channel->n_subchannels; j++)
3857 {
3858 const physical_subchannel_t *sc = &(channel->subchannels[j]);
3859 pd->cols[channel_id] = stp_zalloc(line_length);
3860 pd->channels[channel_id] = sc;
3861 stp_dither_add_channel(v, pd->cols[channel_id], i, j);
3862 if (pd->split_channel_count)
3863 {
3864 for (k = 0; k < pd->split_channel_count; k++)
3865 pd->split_channels[split_id++] = sc->split_channels[k];
3866 }
3867 channel_id++;
3868 }
3869 }
3870 }
3871 if (pd->use_aux_channels && ink_type->aux_channel_count > 0)
3872 {
3873 for (i = 0; i < ink_type->aux_channel_count; i++)
3874 {
3875 const ink_channel_t *channel = &(ink_type->aux_channels[i]);
3876 for (j = 0; j < channel->n_subchannels; j++)
3877 {
3878 const physical_subchannel_t *sc = &(channel->subchannels[j]);
3879 pd->cols[channel_id] = stp_zalloc(line_length);
3880 pd->channels[channel_id] = sc;
3881 stp_dither_add_channel(v, pd->cols[channel_id],
3882 i + pd->logical_channels, j);
3883 if (pd->split_channel_count)
3884 {
3885 for (k = 0; k < pd->split_channel_count; k++)
3886 pd->split_channels[split_id++] = sc->split_channels[k];
3887 }
3888 channel_id++;
3889 }
3890 }
3891 }
3892 stp_set_string_parameter(v, "STPIOutputType", escp2_describe_output(v));
3893 }
3894
3895 static unsigned
3896 gcd(unsigned a, unsigned b)
3897 {
3898 unsigned tmp;
3899 if (b > a)
3900 {
3901 tmp = a;
3902 a = b;
3903 b = tmp;
3904 }
3905 while (1)
3906 {
3907 tmp = a % b;
3908 if (tmp == 0)
3909 return b;
3910 a = b;
3911 b = tmp;
3912 }
3913 }
3914
3915 static unsigned
3916 lcm(unsigned a, unsigned b)
3917 {
3918 if (a == b)
3919 return a;
3920 else
3921 return a * b / gcd(a, b);
3922 }
3923
3924 /* XXX -- How do we handle 300 DPI base? */
3925 static int
3926 adjusted_vertical_resolution(const stp_vars_t *v, const res_t *res)
3927 {
3928 escp2_privdata_t *pd = get_privdata(v);
3929
3930 if (res->vres >= escp2_base_separation(v) * 2)
3931 return res->vres;
3932 else if (!pd->roll_only && res->hres >= escp2_base_separation(v) * 2) /* Special case 720x360 */
3933 /* Note that we want to bypass this for the roll_only models like the D700. This needs
3934 to be revisited as it's likely applicable for many more models! */
3935 return escp2_base_separation(v) * 2;
3936 else if (res->vres % 90 == 0)
3937 return res->vres;
3938 else
3939 return lcm(res->hres, res->vres); /* E. g. 360x240 => 720 */
3940 }
3941
3942 static int
3943 adjusted_horizontal_resolution(const stp_vars_t *v, const res_t *res)
3944 {
3945 (void)v;
3946 /* XXX -- How do we handle 300 DPI base? */
3947 if (res->vres % 90 == 0)
3948 return res->hres;
3949 else
3950 return lcm(res->hres, res->vres); /* E. g. 360x240 => 720 */
3951 }
3952
3953 static void
3954 setup_resolution(stp_vars_t *v)
3955 {
3956 escp2_privdata_t *pd = get_privdata(v);
3957 const res_t *res = stpi_escp2_find_resolution(v);
3958
3959 int vertical = adjusted_vertical_resolution(v, res);
3960 int horizontal = adjusted_horizontal_resolution(v, res);
3961
3962 pd->res = res;
3963 pd->use_extended_commands =
3964 escp2_use_extended_commands(v, !(pd->res->command));
3965 pd->physical_xdpi = escp2_base_res(v);
3966 if (pd->physical_xdpi > pd->res->hres)
3967 pd->physical_xdpi = pd->res->hres;
3968
3969 if (pd->use_extended_commands)
3970 {
3971 pd->unit_scale = MAX(escp2_max_hres(v), escp2_max_vres(v));
3972 pd->horizontal_units = horizontal;
3973 pd->micro_units = horizontal;
3974 }
3975 else
3976 {
3977 /* Hard-coded values for older printers */
3978 pd->unit_scale = 3600;
3979 if (pd->res->hres <= 720)
3980 pd->micro_units = vertical;
3981 else
3982 pd->micro_units = horizontal;
3983 pd->horizontal_units = vertical;
3984 }
3985 /* Note hard-coded 1440 -- from Epson manuals */
3986 if (stpi_escp2_has_cap(v, MODEL_COMMAND, MODEL_COMMAND_1999) &&
3987 stpi_escp2_has_cap(v, MODEL_VARIABLE_DOT, MODEL_VARIABLE_NO))
3988 pd->micro_units = 1440;
3989 pd->vertical_units = vertical;
3990 pd->page_management_units = vertical;
3991 }
3992
3993 static void
3994 setup_softweave_parameters(stp_vars_t *v)
3995 {
3996 escp2_privdata_t *pd = get_privdata(v);
3997 pd->horizontal_passes = pd->res->printed_hres / pd->physical_xdpi;
3998 if (pd->physical_channels == 1 &&
3999 (pd->inkname->channels[0].subchannels->split_channel_count > 1 ||
4000 (pd->res->vres >=
4001 (escp2_base_separation(v) / escp2_black_nozzle_separation(v)))) &&
4002 (escp2_max_black_resolution(v) < 0 ||
4003 pd->res->vres <= escp2_max_black_resolution(v)) &&
4004 escp2_black_nozzles(v))
4005 pd->use_black_parameters = 1;
4006 else
4007 pd->use_black_parameters = 0;
4008 if (pd->use_fast_360)
4009 {
4010 pd->nozzles = escp2_fast_nozzles(v);
4011 pd->nozzle_separation = escp2_fast_nozzle_separation(v);
4012 pd->nozzle_start = escp2_fast_nozzle_start(v);
4013 pd->min_nozzles = escp2_min_fast_nozzles(v);
4014 }
4015 else if (pd->use_black_parameters)
4016 {
4017 pd->nozzles = escp2_black_nozzles(v);
4018 pd->nozzle_separation = escp2_black_nozzle_separation(v);
4019 pd->nozzle_start = escp2_black_nozzle_start(v);
4020 pd->min_nozzles = escp2_min_black_nozzles(v);
4021 }
4022 else
4023 {
4024 pd->nozzles = escp2_nozzles(v);
4025 pd->nozzle_separation = escp2_nozzle_separation(v);
4026 pd->nozzle_start = escp2_nozzle_start(v);
4027 pd->min_nozzles = escp2_min_nozzles(v);
4028 }
4029 }
4030
4031 static void
4032 setup_printer_weave_parameters(stp_vars_t *v)
4033 {
4034 escp2_privdata_t *pd = get_privdata(v);
4035 pd->horizontal_passes = 1;
4036 pd->nozzles = 1;
4037 pd->nozzle_separation = 1;
4038 pd->nozzle_start = 0;
4039 pd->min_nozzles = 1;
4040 if (pd->physical_channels == 1)
4041 pd->use_black_parameters = 1;
4042 else
4043 pd->use_black_parameters = 0;
4044 pd->extra_vertical_passes = 1;
4045 }
4046
4047 static void
4048 setup_head_parameters(stp_vars_t *v)
4049 {
4050 escp2_privdata_t *pd = get_privdata(v);
4051 /*
4052 * Set up the output channels
4053 */
4054 if (strcmp(stp_get_string_parameter(v, "PrintingMode"), "BW") == 0)
4055 pd->logical_channels = 1;
4056 else
4057 pd->logical_channels = pd->inkname->channel_count;
4058
4059 pd->physical_channels =
4060 compute_channel_count(pd->inkname, pd->logical_channels,
4061 pd->use_aux_channels);
4062 if (pd->physical_channels == 0)
4063 {
4064 pd->inkname = stpi_escp2_get_default_black_inkset();
4065 pd->physical_channels =
4066 compute_channel_count(pd->inkname, pd->logical_channels,
4067 pd->use_aux_channels);
4068 }
4069
4070 pd->printer_weave = get_printer_weave(v);
4071
4072 pd->extra_vertical_passes = 1;
4073 if (stp_check_int_parameter(v, "BandEnhancement", STP_PARAMETER_ACTIVE))
4074 pd->extra_vertical_passes =
4075 1 << stp_get_int_parameter(v, "BandEnhancement");
4076 if (stpi_escp2_has_cap(v, MODEL_FAST_360, MODEL_FAST_360_YES) &&
4077 (pd->inkname->inkset == INKSET_CMYK || pd->physical_channels == 1) &&
4078 pd->res->hres == pd->physical_xdpi && pd->res->vres == 360)
4079 pd->use_fast_360 = 1;
4080 else
4081 pd->use_fast_360 = 0;
4082
4083 /*
4084 * Set up the printer-specific parameters (weaving)
4085 */
4086 pd->use_printer_weave = use_printer_weave(v);
4087 if (pd->use_printer_weave)
4088 setup_printer_weave_parameters(v);
4089 else
4090 setup_softweave_parameters(v);
4091 pd->separation_rows = escp2_separation_rows(v);
4092 pd->pseudo_separation_rows = escp2_pseudo_separation_rows(v);
4093 pd->extra_720dpi_separation = escp2_extra_720dpi_separation(v);
4094 pd->bidirectional_upper_limit = escp2_bidirectional_upper_limit(v);
4095
4096 if (pd->horizontal_passes == 0)
4097 pd->horizontal_passes = 1;
4098
4099 setup_head_offset(v);
4100 setup_split_channels(v);
4101
4102 if (stp_check_string_parameter(v, "Duplex", STP_PARAMETER_ACTIVE))
4103 {
4104 const char *duplex = stp_get_string_parameter(v, "Duplex");
4105 if (strcmp(duplex, "DuplexTumble") == 0)
4106 pd->duplex = DUPLEX_TUMBLE;
4107 else if (strcmp(duplex, "DuplexNoTumble") == 0)
4108 pd->duplex = DUPLEX_NO_TUMBLE;
4109 else
4110 pd->duplex = 0;
4111 }
4112 if (pd->duplex)
4113 pd->extra_vertical_feed = 0;
4114 else
4115 pd->extra_vertical_feed = escp2_extra_feed(v);
4116
4117 if (strcmp(stp_get_string_parameter(v, "PrintingMode"), "BW") == 0 &&
4118 pd->physical_channels == 1)
4119 {
4120 if (pd->use_black_parameters)
4121 pd->initial_vertical_offset =
4122 (escp2_black_initial_vertical_offset(v) -
4123 (escp2_black_nozzle_start(v) * (int) escp2_black_nozzle_separation(v))) *
4124 pd->page_management_units /
4125 escp2_base_separation(v);
4126 else
4127 pd->initial_vertical_offset = pd->head_offset[0] +
4128 ((escp2_initial_vertical_offset(v) -
4129 (escp2_nozzle_start(v) * (int) escp2_nozzle_separation(v))) *
4130 pd->page_management_units / escp2_base_separation(v));
4131 }
4132 else
4133 pd->initial_vertical_offset =
4134 (escp2_initial_vertical_offset(v) -
4135 (escp2_nozzle_start(v) * (int) escp2_nozzle_separation(v))) *
4136 pd->page_management_units /
4137 escp2_base_separation(v);
4138
4139 pd->printing_initial_vertical_offset = escp2_printing_initial_vertical_offset(v) *
4140 pd->page_management_units / escp2_base_separation(v);
4141
4142 pd->bitwidth = escp2_bits(v);
4143 }
4144
4145 static void
4146 setup_page(stp_vars_t *v)
4147 {
4148 escp2_privdata_t *pd = get_privdata(v);
4149 const input_slot_t *input_slot = stpi_escp2_get_input_slot(v);
4150 stp_dimension_t extra_left = 0;
4151 stp_dimension_t extra_top = 0;
4152 stp_dimension_t hub_size = 0;
4153 int min_horizontal_alignment = escp2_min_horizontal_position_alignment(v);
4154 int base_horizontal_alignment =
4155 pd->res->hres / escp2_base_horizontal_position_alignment(v);
4156 int required_horizontal_alignment =
4157 MAX(min_horizontal_alignment, base_horizontal_alignment);
4158
4159 const char *cd_type = stp_get_string_parameter(v, "PageSize");
4160 if (cd_type && (strcmp(cd_type, "CDCustom") == 0 ))
4161 {
4162 stp_dimension_t outer_diameter =
4163 stp_get_dimension_parameter(v, "CDOuterDiameter");
4164 stp_set_page_width(v, outer_diameter);
4165 stp_set_page_height(v, outer_diameter);
4166 stp_set_width(v, outer_diameter);
4167 stp_set_height(v, outer_diameter);
4168 hub_size = stp_get_dimension_parameter(v, "CDInnerDiameter");
4169 }
4170 else
4171 {
4172 const char *inner_radius_name = stp_get_string_parameter(v, "CDInnerRadius");
4173 hub_size = 43.0 * 10.0 * 72.0 / 254.0; /* 43 mm standard CD hub */
4174
4175 if (inner_radius_name && strcmp(inner_radius_name, "Small") == 0)
4176 hub_size = 16.0 * 10.0 * 72.0 / 254.0; /* 15 mm prints to the hole -
4177 play safe and print 16 mm */
4178 }
4179
4180 escp2_media_size(v, &(pd->page_true_width), &(pd->page_true_height));
4181 /* Don't use full bleed mode if the paper itself has a margin */
4182 if (pd->page_left > 0 || pd->page_top > 0)
4183 stp_set_boolean_parameter(v, "FullBleed", 0);
4184 if (stpi_escp2_has_cap(v, MODEL_ZEROMARGIN, MODEL_ZEROMARGIN_FULL) &&
4185 ((!input_slot || !(input_slot->is_cd))))
4186 {
4187 pd->page_extra_height =
4188 max_nozzle_span(v) * pd->page_management_units /
4189 escp2_base_separation(v);
4190 if (stp_get_boolean_parameter(v, "FullBleed"))
4191 pd->paper_extra_bottom = 0;
4192 else
4193 pd->paper_extra_bottom = escp2_paper_extra_bottom(v);
4194 }
4195 else if (stpi_escp2_has_cap(v, MODEL_ZEROMARGIN, MODEL_ZEROMARGIN_YES) &&
4196 (stp_get_boolean_parameter(v, "FullBleed")) &&
4197 ((!input_slot || !(input_slot->is_cd))))
4198 {
4199 pd->paper_extra_bottom = 0;
4200 pd->page_extra_height =
4201 escp2_zero_margin_offset(v) * pd->page_management_units /
4202 escp2_base_separation(v);
4203 }
4204 else if (stpi_escp2_has_cap(v, MODEL_ZEROMARGIN, MODEL_ZEROMARGIN_RESTR) &&
4205 (stp_get_boolean_parameter(v, "FullBleed")) &&
4206 ((!input_slot || !(input_slot->is_cd))))
4207 {
4208 pd->paper_extra_bottom = 0;
4209 pd->page_extra_height = 0;
4210 }
4211 else if (stpi_escp2_printer_supports_duplex(v) && !pd->duplex)
4212 {
4213 pd->paper_extra_bottom = escp2_paper_extra_bottom(v);
4214 pd->page_extra_height =
4215 max_nozzle_span(v) * pd->page_management_units /
4216 escp2_base_separation(v);
4217 }
4218 else
4219 {
4220 if (input_slot)
4221 pd->page_extra_height = input_slot->extra_height *
4222 pd->page_management_units / escp2_base_separation(v);
4223 else
4224 pd->page_extra_height = 0;
4225 if (pd->duplex)
4226 pd->paper_extra_bottom = 0;
4227 else
4228 pd->paper_extra_bottom = escp2_paper_extra_bottom(v);
4229 }
4230 internal_imageable_area(v, 0, 0, &pd->page_left, &pd->page_right,
4231 &pd->page_bottom, &pd->page_top);
4232
4233 stp_set_left(v, froundto(stp_get_left(v), pd->res->hres, 72));
4234 stp_set_width(v, froundto(stp_get_width(v), pd->res->hres, 72));
4235 stp_set_top(v, froundto(stp_get_top(v), pd->res->hres, 72));
4236 stp_set_height(v, froundto(stp_get_height(v), pd->res->hres, 72));
4237
4238 if (input_slot && input_slot->is_cd && escp2_cd_x_offset(v) > 0)
4239 {
4240 stp_dimension_t left_center = escp2_cd_x_offset(v) +
4241 stp_get_dimension_parameter(v, "CDXAdjustment");
4242 stp_dimension_t top_center = escp2_cd_y_offset(v) +
4243 stp_get_dimension_parameter(v, "CDYAdjustment");
4244 pd->page_true_height = pd->page_bottom - pd->page_top;
4245 pd->page_true_width = pd->page_right - pd->page_left;
4246 pd->paper_extra_bottom = 0;
4247 pd->page_extra_height = 0;
4248 stp_set_left(v, stp_get_left(v) - pd->page_left);
4249 stp_set_top(v, stp_get_top(v) - pd->page_top);
4250 pd->page_right -= pd->page_left;
4251 pd->page_bottom -= pd->page_top;
4252 pd->page_top = 0;
4253 pd->page_left = 0;
4254 extra_top = top_center - (pd->page_bottom / 2.0);
4255 extra_left = left_center - (pd->page_right / 2.0);
4256 pd->cd_inner_radius = hub_size * pd->micro_units / 72.0 / 2.0;
4257 pd->cd_outer_radius = pd->page_right * pd->micro_units / 72.0 / 2.0;
4258 pd->cd_x_offset =
4259 ((pd->page_right / 2.0) - stp_get_left(v)) * pd->micro_units / 72.0;
4260 pd->cd_y_offset = stp_get_top(v) * pd->res->printed_vres / 72.0;
4261 if (escp2_cd_page_height(v))
4262 {
4263 pd->page_right = escp2_cd_page_width(v);
4264 pd->page_bottom = escp2_cd_page_height(v);
4265 pd->page_true_height = escp2_cd_page_height(v);
4266 pd->page_true_width = escp2_cd_page_width(v);
4267 }
4268 }
4269
4270 pd->page_right += extra_left + 1;
4271 pd->page_width = pd->page_right - pd->page_left;
4272 pd->image_left = stp_get_left(v) - pd->page_left + extra_left;
4273 pd->image_width = stp_get_width(v);
4274 pd->image_scaled_width = pd->image_width * pd->res->hres / 72;
4275 pd->image_printed_width = pd->image_width * pd->res->printed_hres / 72;
4276 if (pd->split_channel_count >= 1)
4277 {
4278 pd->split_channel_width =
4279 ((pd->image_printed_width + pd->horizontal_passes - 1) /
4280 pd->horizontal_passes);
4281 pd->split_channel_width = (pd->split_channel_width + 7) / 8;
4282 pd->split_channel_width *= pd->bitwidth;
4283 if (!(stp_get_debug_level() & STP_DBG_NO_COMPRESSION))
4284 {
4285 pd->comp_buf =
4286 stp_malloc(stp_compute_tiff_linewidth(v, pd->split_channel_width));
4287 }
4288 }
4289 pd->image_left_position = pd->image_left * pd->micro_units / 72;
4290 pd->zero_margin_offset = escp2_zero_margin_offset(v);
4291 if (supports_borderless(v) &&
4292 pd->advanced_command_set &&
4293 ((!input_slot || !(input_slot->is_cd)) &&
4294 stp_get_boolean_parameter(v, "FullBleed")))
4295 {
4296 int margin = escp2_micro_left_margin(v);
4297 int sep = escp2_base_separation(v);
4298 pd->image_left_position +=
4299 (pd->zero_margin_offset - margin) * pd->micro_units / sep;
4300 }
4301 /*
4302 * Many printers print extremely slowly if the starting position
4303 * is not aligned to 1/180"
4304 */
4305 if (required_horizontal_alignment > 1)
4306 pd->image_left_position =
4307 (pd->image_left_position / required_horizontal_alignment) *
4308 required_horizontal_alignment;
4309
4310
4311 pd->page_bottom += extra_top + 1;
4312 pd->page_height = pd->page_bottom - pd->page_top;
4313 pd->image_top = stp_get_top(v) - pd->page_top + extra_top;
4314 pd->image_height = stp_get_height(v);
4315 pd->image_scaled_height = pd->image_height * pd->res->vres / 72;
4316 pd->image_printed_height = pd->image_height * pd->res->printed_vres / 72;
4317
4318 if (input_slot && input_slot->roll_feed_cut_flags)
4319 {
4320 pd->page_true_height += 4; /* Empirically-determined constants */
4321 pd->page_top += 2;
4322 pd->page_bottom += 2;
4323 pd->image_top += 2;
4324 pd->page_height += 2;
4325 }
4326 }
4327
4328 static void
4329 set_mask(unsigned char *cd_mask, int x_center, int scaled_x_where,
4330 int limit, int expansion, int invert)
4331 {
4332 int clear_val = invert ? 255 : 0;
4333 int set_val = invert ? 0 : 255;
4334 int bytesize = 8 / expansion;
4335 int byteextra = bytesize - 1;
4336 int first_x_on = x_center - scaled_x_where;
4337 int first_x_off = x_center + scaled_x_where;
4338 if (first_x_on < 0)
4339 first_x_on = 0;
4340 if (first_x_on > limit)
4341 first_x_on = limit;
4342 if (first_x_off < 0)
4343 first_x_off = 0;
4344 if (first_x_off > limit)
4345 first_x_off = limit;
4346 first_x_on += byteextra;
4347 if (first_x_off > (first_x_on - byteextra))
4348 {
4349 int first_x_on_byte = first_x_on / bytesize;
4350 int first_x_on_mod = expansion * (byteextra - (first_x_on % bytesize));
4351 int first_x_on_extra = ((1 << first_x_on_mod) - 1) ^ clear_val;
4352 int first_x_off_byte = first_x_off / bytesize;
4353 int first_x_off_mod = expansion * (byteextra - (first_x_off % bytesize));
4354 int first_x_off_extra = ((1 << 8) - (1 << first_x_off_mod)) ^ clear_val;
4355 if (first_x_off_byte < first_x_on_byte)
4356 {
4357 /* This can happen, if 6 or fewer points are turned on */
4358 cd_mask[first_x_on_byte] = first_x_on_extra & first_x_off_extra;
4359 }
4360 else
4361 {
4362 if (first_x_on_extra != clear_val)
4363 cd_mask[first_x_on_byte - 1] = first_x_on_extra;
4364 if (first_x_off_byte > first_x_on_byte)
4365 memset(cd_mask + first_x_on_byte, set_val,
4366 first_x_off_byte - first_x_on_byte);
4367 if (first_x_off_extra != clear_val)
4368 cd_mask[first_x_off_byte] = first_x_off_extra;
4369 }
4370 }
4371 }
4372
4373 static int
4374 escp2_print_data(stp_vars_t *v, stp_image_t *image)
4375 {
4376 escp2_privdata_t *pd = get_privdata(v);
4377 int errdiv = stp_image_height(image) / pd->image_printed_height;
4378 int errmod = stp_image_height(image) % pd->image_printed_height;
4379 int errval = 0;
4380 int errlast = -1;
4381 int errline = 0;
4382 int y;
4383 stp_dimension_t outer_r_sq = 0;
4384 stp_dimension_t inner_r_sq = 0;
4385 int x_center = pd->cd_x_offset * pd->res->printed_hres / pd->micro_units;
4386 unsigned char *cd_mask = NULL;
4387 if (pd->cd_outer_radius > 0)
4388 {
4389 cd_mask = stp_malloc(1 + (pd->image_printed_width + 7) / 8);
4390 outer_r_sq = pd->cd_outer_radius * pd->cd_outer_radius;
4391 inner_r_sq = pd->cd_inner_radius * pd->cd_inner_radius;
4392 }
4393
4394 for (y = 0; y < pd->image_printed_height; y ++)
4395 {
4396 int duplicate_line = 1;
4397 unsigned zero_mask = 0;
4398
4399 if (errline != errlast)
4400 {
4401 errlast = errline;
4402 duplicate_line = 0;
4403 if (stp_color_get_row(v, image, errline, &zero_mask))
4404 return 2;
4405 }
4406
4407 if (cd_mask)
4408 {
4409 stp_dimension_t y_distance_from_center =
4410 pd->cd_outer_radius -
4411 ((y + pd->cd_y_offset) * pd->micro_units / pd->res->printed_vres);
4412 if (y_distance_from_center < 0)
4413 y_distance_from_center = -y_distance_from_center;
4414 memset(cd_mask, 0, (pd->image_printed_width + 7) / 8);
4415 if (y_distance_from_center < pd->cd_outer_radius)
4416 {
4417 stp_dimension_t y_sq = y_distance_from_center * y_distance_from_center;
4418 stp_dimension_t x_where = sqrt(outer_r_sq - y_sq);
4419 int scaled_x_where = x_where * pd->res->printed_hres / pd->micro_units;
4420 set_mask(cd_mask, x_center, scaled_x_where,
4421 pd->image_printed_width, 1, 0);
4422 if (y_distance_from_center < pd->cd_inner_radius)
4423 {
4424 x_where = sqrt(inner_r_sq - y_sq);
4425 scaled_x_where = x_where * pd->res->printed_hres / pd->micro_units;
4426 set_mask(cd_mask, x_center, scaled_x_where,
4427 pd->image_printed_width, 1, 1);
4428 }
4429 }
4430 }
4431
4432 stp_dither(v, y, duplicate_line, zero_mask, cd_mask);
4433
4434 stp_write_weave(v, pd->cols);
4435 errval += errmod;
4436 errline += errdiv;
4437 if (errval >= pd->image_printed_height)
4438 {
4439 errval -= pd->image_printed_height;
4440 errline ++;
4441 }
4442 }
4443 if (cd_mask)
4444 stp_free(cd_mask);
4445 return 1;
4446 }
4447
4448 static int
4449 escp2_print_page(stp_vars_t *v, stp_image_t *image)
4450 {
4451 int status;
4452 escp2_privdata_t *pd = get_privdata(v);
4453 int line_width = (pd->image_printed_width + 7) / 8 * pd->bitwidth;
4454 int weave_pattern = STP_WEAVE_ZIGZAG;
4455 if (stp_check_string_parameter(v, "Weave", STP_PARAMETER_ACTIVE))
4456 {
4457 const char *weave = stp_get_string_parameter(v, "Weave");
4458 if (strcmp(weave, "Alternate") == 0)
4459 weave_pattern = STP_WEAVE_ZIGZAG;
4460 else if (strcmp(weave, "Ascending") == 0)
4461 weave_pattern = STP_WEAVE_ASCENDING;
4462 else if (strcmp(weave, "Descending") == 0)
4463 weave_pattern = STP_WEAVE_DESCENDING;
4464 else if (strcmp(weave, "Ascending2X") == 0)
4465 weave_pattern = STP_WEAVE_ASCENDING_2X;
4466 else if (strcmp(weave, "Staggered") == 0)
4467 weave_pattern = STP_WEAVE_STAGGERED;
4468 }
4469
4470 stp_initialize_weave
4471 (v,
4472 pd->nozzles,
4473 pd->nozzle_separation * pd->res->vres / escp2_base_separation(v),
4474 pd->horizontal_passes,
4475 pd->res->vertical_passes * pd->extra_vertical_passes,
4476 1,
4477 pd->channels_in_use,
4478 pd->bitwidth,
4479 pd->image_printed_width,
4480 pd->image_printed_height,
4481 ((pd->page_extra_height * pd->res->vres / pd->vertical_units) +
4482 (pd->image_top * pd->res->vres / 72)),
4483 (pd->page_extra_height +
4484 (pd->page_height + pd->extra_vertical_feed) * pd->res->vres / 72),
4485 pd->head_offset,
4486 weave_pattern,
4487 stpi_escp2_flush_pass,
4488 (((stp_get_debug_level() & STP_DBG_NO_COMPRESSION) ||
4489 pd->split_channel_count > 0) ?
4490 stp_fill_uncompressed : stp_fill_tiff),
4491 (((stp_get_debug_level() & STP_DBG_NO_COMPRESSION) ||
4492 pd->split_channel_count > 0) ?
4493 stp_pack_uncompressed : stp_pack_tiff),
4494 (((stp_get_debug_level() & STP_DBG_NO_COMPRESSION) ||
4495 pd->split_channel_count > 0) ?
4496 stp_compute_uncompressed_linewidth : stp_compute_tiff_linewidth));
4497
4498 stp_dither_init(v, image, pd->image_printed_width, pd->res->printed_hres,
4499 pd->res->printed_vres);
4500 allocate_channels(v, line_width);
4501 adjust_print_quality(v);
4502 (void) stp_color_init(v, image, 65536);
4503
4504 /* stpi_dither_set_expansion(v, pd->res->hres / pd->res->printed_hres); */
4505
4506 setup_inks(v);
4507
4508 status = escp2_print_data(v, image);
4509 stp_flush_all(v);
4510 stpi_escp2_terminate_page(v);
4511 return status;
4512 }
4513
4514 /*
4515 * 'escp2_print()' - Print an image to an EPSON printer.
4516 */
4517 static int
4518 escp2_do_print(stp_vars_t *v, stp_image_t *image, int print_op)
4519 {
4520 int status = 1;
4521 int i;
4522
4523 escp2_privdata_t *pd;
4524
4525 if (strcmp(stp_get_string_parameter(v, "PrintingMode"), "BW") == 0 &&
4526 (stp_get_string_parameter(v, "InkType") &&
4527 (strcmp(stp_get_string_parameter(v, "InkType"), "RGB") == 0 ||
4528 strcmp(stp_get_string_parameter(v, "InkType"), "CMY") == 0 ||
4529 strcmp(stp_get_string_parameter(v, "InkType"), "CMYRB") == 0 ||
4530 strcmp(stp_get_string_parameter(v, "InkType"), "CMYRBG") == 0 ||
4531 strcmp(stp_get_string_parameter(v, "InkType"), "CMYRO") == 0 ||
4532 strcmp(stp_get_string_parameter(v, "InkType"), "CMYROG") == 0 ||
4533 strcmp(stp_get_string_parameter(v, "InkType"), "PhotoCMY") == 0 ||
4534 strcmp(stp_get_string_parameter(v, "InkType"), "RGBG") == 0)))
4535 {
4536 stp_eprintf(v, "Warning: Inkset %s not available in BW\n",
4537 stp_get_string_parameter(v, "InkType"));
4538 stp_set_string_parameter(v, "InkType", "CMYK");
4539 }
4540
4541 if (!stp_verify(v))
4542 {
4543 stp_eprintf(v, _("Print options not verified; cannot print.\n"));
4544 return 0;
4545 }
4546
4547 if (strcmp(stp_get_string_parameter(v, "InputImageType"), "Raw") == 0 &&
4548 !set_raw_ink_type(v))
4549 return 0;
4550 int page_number = stp_get_int_parameter(v, "PageNumber");
4551
4552 pd = (escp2_privdata_t *) stp_zalloc(sizeof(escp2_privdata_t));
4553
4554 pd->printed_something = 0;
4555 pd->last_color = -1;
4556 pd->last_pass_offset = 0;
4557 pd->last_pass = -1;
4558 pd->send_zero_pass_advance =
4559 stpi_escp2_has_cap(v, MODEL_SEND_ZERO_ADVANCE, MODEL_SEND_ZERO_ADVANCE_YES);
4560 stp_allocate_component_data(v, "Driver", NULL, NULL, pd);
4561
4562 pd->inkname = get_inktype(v);
4563 if (pd->inkname && pd->inkname->inkset != INKSET_EXTENDED &&
4564 stp_check_boolean_parameter(v, "UseGloss", STP_PARAMETER_ACTIVE) &&
4565 stp_get_boolean_parameter(v, "UseGloss"))
4566 pd->use_aux_channels = 1;
4567 else
4568 pd->use_aux_channels = 0;
4569 if (pd->inkname && pd->inkname->inkset == INKSET_QUADTONE &&
4570 strcmp(stp_get_string_parameter(v, "PrintingMode"), "BW") != 0)
4571 {
4572 stp_eprintf(v, "Warning: Quadtone inkset only available in MONO\n");
4573 stp_set_string_parameter(v, "PrintingMode", "BW");
4574 }
4575 if (pd->inkname && pd->inkname->inkset == INKSET_HEXTONE &&
4576 strcmp(stp_get_string_parameter(v, "PrintingMode"), "BW") != 0)
4577 {
4578 stp_eprintf(v, "Warning: Hextone inkset only available in MONO\n");
4579 stp_set_string_parameter(v, "PrintingMode", "BW");
4580 }
4581 pd->channels_in_use = count_channels(pd->inkname, pd->use_aux_channels);
4582
4583 setup_basic(v);
4584 setup_resolution(v);
4585 setup_head_parameters(v);
4586 setup_page(v);
4587 setup_misc(v);
4588
4589 adjust_density_and_ink_type(v);
4590 if (print_op & OP_JOB_START)
4591 stpi_escp2_init_printer(v);
4592 if (print_op & OP_JOB_PRINT)
4593 {
4594 stp_image_init(image);
4595 if ((page_number & 1) && pd->duplex &&
4596 ((pd->duplex & pd->input_slot->duplex) == 0))
4597 /* If the hardware can't do the duplex operation, we need to
4598 emulate it in software */
4599 image = stpi_buffer_image(image, BUFFER_FLAG_FLIP_X | BUFFER_FLAG_FLIP_Y);
4600 status = escp2_print_page(v, image);
4601 stp_image_conclude(image);
4602 }
4603 if (print_op & OP_JOB_END)
4604 stpi_escp2_deinit_printer(v);
4605
4606 if (pd->head_offset)
4607 stp_free(pd->head_offset);
4608
4609 /*
4610 * Cleanup...
4611 */
4612 if (pd->cols)
4613 {
4614 for (i = 0; i < pd->channels_in_use; i++)
4615 if (pd->cols[i])
4616 stp_free(pd->cols[i]);
4617 stp_free(pd->cols);
4618 }
4619 if (pd->media_settings)
4620 stp_vars_destroy(pd->media_settings);
4621 if (pd->channels)
4622 stp_free(pd->channels);
4623 if (pd->split_channels)
4624 stp_free(pd->split_channels);
4625 if (pd->comp_buf)
4626 stp_free(pd->comp_buf);
4627 stp_free(pd);
4628
4629 return status;
4630 }
4631
4632 static int
4633 escp2_print(const stp_vars_t *v, stp_image_t *image)
4634 {
4635 stp_vars_t *nv = stp_vars_create_copy(v);
4636 int op = OP_JOB_PRINT;
4637 int status;
4638
4639 if (!stp_get_string_parameter(v, "JobMode") ||
4640 strcmp(stp_get_string_parameter(v, "JobMode"), "Page") == 0)
4641 op = OP_JOB_START | OP_JOB_PRINT | OP_JOB_END;
4642
4643 status = escp2_do_print(nv, image, op);
4644 stp_vars_destroy(nv);
4645 return status;
4646 }
4647
4648 static int
4649 escp2_job_start(const stp_vars_t *v, stp_image_t *image)
4650 {
4651 stp_vars_t *nv = stp_vars_create_copy(v);
4652 int status;
4653 status = escp2_do_print(nv, image, OP_JOB_START);
4654 stp_vars_destroy(nv);
4655 return status;
4656 }
4657
4658 static int
4659 escp2_job_end(const stp_vars_t *v, stp_image_t *image)
4660 {
4661 stp_vars_t *nv = stp_vars_create_copy(v);
4662 int status;
4663 status = escp2_do_print(nv, image, OP_JOB_END);
4664 stp_vars_destroy(nv);
4665 return status;
4666 }
4667
4668 static const stp_printfuncs_t print_escp2_printfuncs =
4669 {
4670 escp2_list_parameters,
4671 escp2_parameters,
4672 escp2_media_size,
4673 escp2_imageable_area,
4674 escp2_maximum_imageable_area,
4675 escp2_limit,
4676 escp2_print,
4677 escp2_describe_resolution,
4678 escp2_describe_output,
4679 stp_verify_printer_params,
4680 escp2_job_start,
4681 escp2_job_end,
4682 NULL,
4683 stpi_standard_describe_papersize
4684 };
4685
4686 static stp_family_t print_escp2_module_data =
4687 {
4688 &print_escp2_printfuncs,
4689 NULL
4690 };
4691
4692
4693 static int
4694 print_escp2_module_init(void)
4695 {
4696 hue_curve_bounds = stp_curve_create_from_string
4697 ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
4698 "<gutenprint>\n"
4699 "<curve wrap=\"wrap\" type=\"linear\" gamma=\"0\">\n"
4700 "<sequence count=\"2\" lower-bound=\"0\" upper-bound=\"1\">\n"
4701 "1 1\n"
4702 "</sequence>\n"
4703 "</curve>\n"
4704 "</gutenprint>");
4705 return stpi_family_register(print_escp2_module_data.printer_list);
4706 }
4707
4708
4709 static int
4710 print_escp2_module_exit(void)
4711 {
4712 return stpi_family_unregister(print_escp2_module_data.printer_list);
4713 }
4714
4715
4716 /* Module header */
4717 #define stp_module_version print_escp2_LTX_stp_module_version
4718 #define stp_module_data print_escp2_LTX_stp_module_data
4719
4720 stp_module_version_t stp_module_version = {0, 0};
4721
4722 stp_module_t stp_module_data =
4723 {
4724 "escp2",
4725 VERSION,
4726 "Epson family driver",
4727 STP_MODULE_CLASS_FAMILY,
4728 NULL,
4729 print_escp2_module_init,
4730 print_escp2_module_exit,
4731 (void *) &print_escp2_module_data
4732 };