00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifdef HAVE_CONFIG_H
00030 #include <config.h>
00031 #endif
00032 #include <gimp-print/gimp-print.h>
00033 #include <gimp-print/gimp-print-intl-internal.h>
00034 #include "gimp-print-internal.h"
00035 #include <string.h>
00036 #include "print-escp2.h"
00037
00038 #ifdef __GNUC__
00039 #define inline __inline__
00040 #endif
00041
00042 static escp2_privdata_t *
00043 get_privdata(stp_vars_t *v)
00044 {
00045 return (escp2_privdata_t *) stp_get_component_data(v, "Driver");
00046 }
00047
00048 static void
00049 escp2_reset_printer(stp_vars_t *v)
00050 {
00051 escp2_privdata_t *pd = get_privdata(v);
00052
00053
00054
00055
00056 if (pd->init_sequence)
00057 stp_zfwrite(pd->init_sequence->data, pd->init_sequence->bytes, 1, v);
00058
00059 stp_send_command(v, "\033@", "");
00060 }
00061
00062 static void
00063 print_remote_param(stp_vars_t *v, const char *param, const char *value)
00064 {
00065 stp_send_command(v, "\033(R", "bcscs", '\0', param, ':',
00066 value ? value : "NULL");
00067 stp_send_command(v, "\033", "ccc", 0, 0, 0);
00068 }
00069
00070 static void
00071 print_remote_int_param(stp_vars_t *v, const char *param, int value)
00072 {
00073 char buf[64];
00074 (void) snprintf(buf, 64, "%d", value);
00075 print_remote_param(v, param, buf);
00076 }
00077
00078 static void
00079 print_remote_float_param(stp_vars_t *v, const char *param, double value)
00080 {
00081 char buf[64];
00082 (void) snprintf(buf, 64, "%f", value);
00083 print_remote_param(v, param, buf);
00084 }
00085
00086 static void
00087 print_debug_params(stp_vars_t *v)
00088 {
00089 escp2_privdata_t *pd = get_privdata(v);
00090 stp_parameter_list_t params = stp_get_parameter_list(v);
00091 int count = stp_parameter_list_count(params);
00092 int i;
00093 print_remote_param(v, "Package", PACKAGE);
00094 print_remote_param(v, "Version", VERSION);
00095 print_remote_param(v, "Release Date", RELEASE_DATE);
00096 print_remote_param(v, "Driver", stp_get_driver(v));
00097 print_remote_int_param(v, "Left", stp_get_left(v));
00098 print_remote_int_param(v, "Top", stp_get_top(v));
00099 print_remote_int_param(v, "Page Width", stp_get_page_width(v));
00100 print_remote_int_param(v, "Page Height", stp_get_page_height(v));
00101 print_remote_int_param(v, "Model", stp_get_model_id(v));
00102 print_remote_int_param(v, "Ydpi", pd->res->vres);
00103 print_remote_int_param(v, "Xdpi", pd->res->hres);
00104 print_remote_int_param(v, "Use_softweave", pd->res->softweave);
00105 print_remote_int_param(v, "Use_printer_weave", pd->res->printer_weave);
00106 print_remote_int_param(v, "Use_printer_weave", pd->use_printer_weave);
00107 print_remote_int_param(v, "Page_left", pd->page_left);
00108 print_remote_int_param(v, "Page_right", pd->page_right);
00109 print_remote_int_param(v, "Page_top", pd->page_top);
00110 print_remote_int_param(v, "Page_bottom", pd->page_bottom);
00111 print_remote_int_param(v, "Page_width", pd->page_width);
00112 print_remote_int_param(v, "Page_height", pd->page_height);
00113 print_remote_int_param(v, "Page_true_height", pd->page_true_height);
00114 print_remote_int_param(v, "Image_left", pd->image_left);
00115 print_remote_int_param(v, "Image_top", pd->image_top);
00116 print_remote_int_param(v, "Image_width", pd->image_width);
00117 print_remote_int_param(v, "Image_height", pd->image_height);
00118 print_remote_int_param(v, "Image_scaled_width", pd->image_scaled_width);
00119 print_remote_int_param(v, "Image_scaled_height", pd->image_scaled_height);
00120 print_remote_int_param(v, "Image_printed_width", pd->image_printed_width);
00121 print_remote_int_param(v, "Image_printed_height", pd->image_printed_height);
00122 print_remote_int_param(v, "Image_left_position", pd->image_left_position);
00123 print_remote_int_param(v, "Nozzles", pd->nozzles);
00124 print_remote_int_param(v, "Nozzle_separation", pd->nozzle_separation);
00125 print_remote_int_param(v, "Horizontal_passes", pd->horizontal_passes);
00126 print_remote_int_param(v, "Vertical_passes", pd->res->vertical_passes);
00127 print_remote_int_param(v, "Physical_xdpi", pd->physical_xdpi);
00128 print_remote_int_param(v, "Page_management_units", pd->page_management_units);
00129 print_remote_int_param(v, "Vertical_units", pd->vertical_units);
00130 print_remote_int_param(v, "Horizontal_units", pd->horizontal_units);
00131 print_remote_int_param(v, "Micro_units", pd->micro_units);
00132 print_remote_int_param(v, "Unit_scale", pd->unit_scale);
00133 print_remote_int_param(v, "Zero_advance", pd->send_zero_pass_advance);
00134 print_remote_int_param(v, "Bits", pd->bitwidth);
00135 print_remote_int_param(v, "Resid", pd->ink_resid);
00136 print_remote_int_param(v, "Drop Size", pd->drop_size);
00137 print_remote_int_param(v, "Initial_vertical_offset", pd->initial_vertical_offset);
00138 print_remote_int_param(v, "Channels_in_use", pd->channels_in_use);
00139 print_remote_int_param(v, "Logical_channels", pd->logical_channels);
00140 print_remote_int_param(v, "Physical_channels", pd->physical_channels);
00141 print_remote_int_param(v, "Use_black_parameters", pd->use_black_parameters);
00142 print_remote_int_param(v, "Use_fast_360", pd->use_fast_360);
00143 print_remote_int_param(v, "Command_set", pd->command_set);
00144 print_remote_int_param(v, "Variable_dots", pd->variable_dots);
00145 print_remote_int_param(v, "Has_vacuum", pd->has_vacuum);
00146 print_remote_int_param(v, "Has_graymode", pd->has_graymode);
00147 print_remote_int_param(v, "Base_separation", pd->base_separation);
00148 print_remote_int_param(v, "Resolution_scale", pd->resolution_scale);
00149 print_remote_int_param(v, "Printing_resolution", pd->printing_resolution);
00150 print_remote_int_param(v, "Separation_rows", pd->separation_rows);
00151 print_remote_int_param(v, "Pseudo_separation_rows", pd->pseudo_separation_rows);
00152 print_remote_int_param(v, "Extra_720dpi_separation", pd->extra_720dpi_separation);
00153 print_remote_param(v, "Ink name", pd->inkname->name);
00154 print_remote_int_param(v, " channels", pd->inkname->channel_set->channel_count);
00155 print_remote_int_param(v, " inkset", pd->inkname->inkset);
00156 for (i = 0; i < count; i++)
00157 {
00158 const stp_parameter_t *p = stp_parameter_list_param(params, i);
00159 switch (p->p_type)
00160 {
00161 case STP_PARAMETER_TYPE_DOUBLE:
00162 if (stp_check_float_parameter(v, p->name, STP_PARAMETER_DEFAULTED))
00163 print_remote_float_param(v, p->name,
00164 stp_get_float_parameter(v, p->name));
00165 break;
00166 case STP_PARAMETER_TYPE_INT:
00167 if (stp_check_int_parameter(v, p->name, STP_PARAMETER_DEFAULTED))
00168 print_remote_int_param(v, p->name,
00169 stp_get_int_parameter(v, p->name));
00170 break;
00171 case STP_PARAMETER_TYPE_BOOLEAN:
00172 if (stp_check_boolean_parameter(v, p->name, STP_PARAMETER_DEFAULTED))
00173 print_remote_int_param(v, p->name,
00174 stp_get_boolean_parameter(v, p->name));
00175 break;
00176 case STP_PARAMETER_TYPE_STRING_LIST:
00177 if (stp_check_string_parameter(v, p->name, STP_PARAMETER_DEFAULTED))
00178 print_remote_param(v, p->name,
00179 stp_get_string_parameter(v, p->name));
00180 break;
00181 case STP_PARAMETER_TYPE_CURVE:
00182 if (stp_check_curve_parameter(v, p->name, STP_PARAMETER_DEFAULTED))
00183 {
00184 char *curve =
00185 stp_curve_write_string(stp_get_curve_parameter(v, p->name));
00186 print_remote_param(v, p->name, curve);
00187 stp_free(curve);
00188 }
00189 break;
00190 default:
00191 break;
00192 }
00193 }
00194 stp_parameter_list_destroy(params);
00195 stp_send_command(v, "\033", "ccc", 0, 0, 0);
00196 }
00197
00198 static void
00199 escp2_set_remote_sequence(stp_vars_t *v)
00200 {
00201
00202 escp2_privdata_t *pd = get_privdata(v);
00203
00204 if (stp_get_debug_level() & STP_DBG_MARK_FILE)
00205 print_debug_params(v);
00206 if (pd->advanced_command_set || pd->input_slot)
00207 {
00208 int feed_sequence = 0;
00209
00210 stp_send_command(v, "\033(R", "bcs", 0, "REMOTE1");
00211 if (pd->command_set == MODEL_COMMAND_PRO)
00212 {
00213 if (pd->paper_type)
00214 {
00215 stp_send_command(v, "PH", "bcc", 0,
00216 pd->paper_type->paper_thickness);
00217 if (pd->has_vacuum)
00218 stp_send_command(v, "SN", "bccc", 0, 5,
00219 pd->paper_type->vacuum_intensity);
00220 stp_send_command(v, "SN", "bccc", 0, 4,
00221 pd->paper_type->feed_adjustment);
00222 }
00223 }
00224 else if (pd->advanced_command_set)
00225 {
00226 if (pd->paper_type)
00227 feed_sequence = pd->paper_type->paper_feed_sequence;
00228
00229 stp_send_command(v, "PM", "bh", 0);
00230
00231 stp_send_command(v, "SN", "bccc", 0, 0, feed_sequence);
00232 if (stp_get_boolean_parameter(v, "FullBleed"))
00233 stp_send_command(v, "FP", "bch", 0, 0xffb0);
00234 }
00235 if (pd->input_slot)
00236 {
00237 int divisor = pd->base_separation / 360;
00238 int height = pd->page_true_height * 5 / divisor;
00239 if (pd->input_slot->init_sequence.bytes)
00240 stp_zfwrite(pd->input_slot->init_sequence.data,
00241 pd->input_slot->init_sequence.bytes, 1, v);
00242 switch (pd->input_slot->roll_feed_cut_flags)
00243 {
00244 case ROLL_FEED_CUT_ALL:
00245 stp_send_command(v, "JS", "bh", 0);
00246 stp_send_command(v, "CO", "bccccl", 0, 0, 1, 0, 0);
00247 stp_send_command(v, "CO", "bccccl", 0, 0, 0, 0, height);
00248 break;
00249 case ROLL_FEED_CUT_LAST:
00250 stp_send_command(v, "CO", "bccccl", 0, 0, 1, 0, 0);
00251 stp_send_command(v, "CO", "bccccl", 0, 0, 2, 0, height);
00252 break;
00253 default:
00254 break;
00255 }
00256 }
00257
00258
00259
00260 stp_send_command(v, "\033", "ccc", 0, 0, 0);
00261 }
00262 }
00263
00264 static void
00265 escp2_set_graphics_mode(stp_vars_t *v)
00266 {
00267 stp_send_command(v, "\033(G", "bc", 1);
00268 }
00269
00270 static void
00271 escp2_set_resolution(stp_vars_t *v)
00272 {
00273 escp2_privdata_t *pd = get_privdata(v);
00274 if (pd->use_extended_commands)
00275 stp_send_command(v, "\033(U", "bccch",
00276 pd->unit_scale / pd->page_management_units,
00277 pd->unit_scale / pd->vertical_units,
00278 pd->unit_scale / pd->horizontal_units,
00279 pd->unit_scale);
00280 else
00281 stp_send_command(v, "\033(U", "bc",
00282 pd->unit_scale / pd->page_management_units);
00283 }
00284
00285 static void
00286 escp2_set_color(stp_vars_t *v)
00287 {
00288 escp2_privdata_t *pd = get_privdata(v);
00289 if (pd->use_fast_360)
00290 stp_send_command(v, "\033(K", "bcc", 0, 3);
00291 else if (pd->has_graymode)
00292 stp_send_command(v, "\033(K", "bcc", 0,
00293 (pd->use_black_parameters ? 1 : 2));
00294 }
00295
00296 static void
00297 escp2_set_printer_weave(stp_vars_t *v)
00298 {
00299 escp2_privdata_t *pd = get_privdata(v);
00300 int printer_weave_parm = 0;
00301 if (pd->printer_weave)
00302 printer_weave_parm = pd->printer_weave->value;
00303 else if (pd->res->printer_weave)
00304 printer_weave_parm = pd->res->printer_weave;
00305 stp_send_command(v, "\033(i", "bc", printer_weave_parm);
00306 }
00307
00308 static void
00309 escp2_set_printhead_speed(stp_vars_t *v)
00310 {
00311 escp2_privdata_t *pd = get_privdata(v);
00312 const char *direction = stp_get_string_parameter(v, "PrintingDirection");
00313 int unidirectional;
00314 if (direction && strcmp(direction, "Unidirectional") == 0)
00315 unidirectional = 1;
00316 else if (direction && strcmp(direction, "Bidirectional") == 0)
00317 unidirectional = 0;
00318 else if (pd->res->hres >= 720 && pd->res->vres >= 720)
00319 unidirectional = 1;
00320 else
00321 unidirectional = 0;
00322 if (unidirectional)
00323 {
00324 stp_send_command(v, "\033U", "c", 1);
00325 if (pd->res->hres > pd->printing_resolution)
00326 stp_send_command(v, "\033(s", "bc", 2);
00327 }
00328 else
00329 stp_send_command(v, "\033U", "c", 0);
00330 }
00331
00332 static void
00333 escp2_set_dot_size(stp_vars_t *v)
00334 {
00335 escp2_privdata_t *pd = get_privdata(v);
00336
00337 if (pd->drop_size >= 0)
00338 stp_send_command(v, "\033(e", "bcc", 0, pd->drop_size);
00339 }
00340
00341 static void
00342 escp2_set_page_height(stp_vars_t *v)
00343 {
00344 escp2_privdata_t *pd = get_privdata(v);
00345 int l = pd->page_management_units * pd->page_true_height / 72;
00346 if (pd->use_extended_commands)
00347 stp_send_command(v, "\033(C", "bl", l);
00348 else
00349 stp_send_command(v, "\033(C", "bh", l);
00350 }
00351
00352 static void
00353 escp2_set_margins(stp_vars_t *v)
00354 {
00355 escp2_privdata_t *pd = get_privdata(v);
00356 int bot = pd->page_management_units * pd->page_bottom / 72;
00357 int top = pd->page_management_units * pd->page_top / 72;
00358
00359 top += pd->initial_vertical_offset;
00360 if (pd->use_extended_commands &&
00361 (pd->command_set == MODEL_COMMAND_2000 ||
00362 pd->command_set == MODEL_COMMAND_PRO))
00363 stp_send_command(v, "\033(c", "bll", top, bot);
00364 else
00365 stp_send_command(v, "\033(c", "bhh", top, bot);
00366 }
00367
00368 static void
00369 escp2_set_form_factor(stp_vars_t *v)
00370 {
00371 escp2_privdata_t *pd = get_privdata(v);
00372 if (pd->advanced_command_set)
00373 {
00374 int w = pd->page_width * pd->page_management_units / 72;
00375 int h = pd->page_true_height * pd->page_management_units / 72;
00376
00377 if (stp_get_boolean_parameter(v, "FullBleed"))
00378
00379
00380
00381 w += 320 * pd->page_management_units / 720;
00382
00383 stp_send_command(v, "\033(S", "bll", w, h);
00384 }
00385 }
00386
00387 static void
00388 escp2_set_printhead_resolution(stp_vars_t *v)
00389 {
00390 escp2_privdata_t *pd = get_privdata(v);
00391 if (pd->use_extended_commands)
00392 {
00393 int xres;
00394 int yres = pd->resolution_scale;
00395
00396 xres = pd->resolution_scale / pd->physical_xdpi;
00397
00398 if (pd->command_set == MODEL_COMMAND_PRO && !pd->res->softweave)
00399 yres = yres / pd->res->vres;
00400 else
00401 yres = yres * pd->nozzle_separation / pd->base_separation;
00402
00403
00404 stp_send_command(v, "\033(D", "bhcc", pd->resolution_scale, yres, xres);
00405 }
00406 }
00407
00408 static void
00409 set_vertical_position(stp_vars_t *v, stp_pass_t *pass)
00410 {
00411 escp2_privdata_t *pd = get_privdata(v);
00412 int advance = pass->logicalpassstart - pd->last_pass_offset -
00413 (pd->separation_rows - 1);
00414 advance = advance * pd->vertical_units / pd->res->vres;
00415 if (pass->logicalpassstart > pd->last_pass_offset ||
00416 (pd->send_zero_pass_advance && pass->pass > pd->last_pass) ||
00417 pd->printing_initial_vertical_offset != 0)
00418 {
00419 advance += pd->printing_initial_vertical_offset;
00420 pd->printing_initial_vertical_offset = 0;
00421 if (pd->use_extended_commands)
00422 stp_send_command(v, "\033(v", "bl", advance);
00423 else
00424 stp_send_command(v, "\033(v", "bh", advance);
00425 pd->last_pass_offset = pass->logicalpassstart;
00426 pd->last_pass = pass->pass;
00427 }
00428 }
00429
00430 static void
00431 set_color(stp_vars_t *v, stp_pass_t *pass, int color)
00432 {
00433 escp2_privdata_t *pd = get_privdata(v);
00434 if (pd->last_color != color && ! pd->use_extended_commands)
00435 {
00436 int ncolor = pd->channels[color]->color;
00437 int subchannel = pd->channels[color]->subchannel;
00438 if (subchannel >= 0)
00439 stp_send_command(v, "\033(r", "bcc", subchannel, ncolor);
00440 else
00441 stp_send_command(v, "\033r", "c", ncolor);
00442 pd->last_color = color;
00443 }
00444 }
00445
00446 static void
00447 set_horizontal_position(stp_vars_t *v, stp_pass_t *pass, int vertical_subpass)
00448 {
00449 escp2_privdata_t *pd = get_privdata(v);
00450 int microoffset = (vertical_subpass & (pd->horizontal_passes - 1)) *
00451 pd->image_scaled_width / pd->image_printed_width;
00452 int pos = pd->image_left_position + microoffset;
00453
00454 if (pos != 0)
00455 {
00456
00457 if (pd->command_set == MODEL_COMMAND_PRO || pd->variable_dots)
00458 stp_send_command(v, "\033($", "bl", pos);
00459 else if (pd->advanced_command_set || pd->res->hres > 720)
00460 stp_send_command(v, "\033(\\", "bhh", pd->micro_units, pos);
00461 else
00462 stp_send_command(v, "\033\\", "h", pos);
00463 }
00464 }
00465
00466 static void
00467 send_print_command(stp_vars_t *v, stp_pass_t *pass, int color, int nlines)
00468 {
00469 escp2_privdata_t *pd = get_privdata(v);
00470 int lwidth = (pd->image_printed_width + (pd->horizontal_passes - 1)) /
00471 pd->horizontal_passes;
00472 if (pd->command_set == MODEL_COMMAND_PRO || pd->variable_dots)
00473 {
00474 int ncolor = pd->channels[color]->color;
00475 int subchannel = pd->channels[color]->subchannel;
00476 int nwidth = pd->bitwidth * ((lwidth + 7) / 8);
00477 if (subchannel >= 0)
00478 ncolor |= (subchannel << 4);
00479 stp_send_command(v, "\033i", "ccchh", ncolor, COMPRESSION,
00480 pd->bitwidth, nwidth, nlines);
00481 }
00482 else
00483 {
00484 int ygap = 3600 / pd->vertical_units;
00485 int xgap = 3600 / pd->physical_xdpi;
00486 if (pd->nozzles == 1)
00487 {
00488 if (pd->vertical_units == 720 && pd->extra_720dpi_separation)
00489 ygap *= pd->extra_720dpi_separation;
00490 }
00491 else if (pd->extra_720dpi_separation)
00492 ygap *= pd->extra_720dpi_separation;
00493 else if (pd->pseudo_separation_rows > 0)
00494 ygap *= pd->pseudo_separation_rows;
00495 else
00496 ygap *= pd->separation_rows;
00497 stp_send_command(v, "\033.", "cccch", COMPRESSION, ygap, xgap, nlines,
00498 lwidth);
00499 }
00500 }
00501
00502 static void
00503 send_extra_data(stp_vars_t *v, int extralines)
00504 {
00505 escp2_privdata_t *pd = get_privdata(v);
00506 int lwidth = (pd->image_printed_width + (pd->horizontal_passes - 1)) /
00507 pd->horizontal_passes;
00508 #if TEST_UNCOMPRESSED
00509 int i;
00510 for (i = 0; i < pd->bitwidth * (lwidth + 7) / 8; i++)
00511 stp_putc(0, v);
00512 #else
00513 int k, l;
00514 int bytes_to_fill = pd->bitwidth * ((lwidth + 7) / 8);
00515 int full_blocks = bytes_to_fill / 128;
00516 int leftover = bytes_to_fill % 128;
00517 int total_bytes = extralines * (full_blocks + 1) * 2;
00518 unsigned char *buf = stp_malloc(total_bytes);
00519 total_bytes = 0;
00520 for (k = 0; k < extralines; k++)
00521 {
00522 for (l = 0; l < full_blocks; l++)
00523 {
00524 buf[total_bytes++] = 129;
00525 buf[total_bytes++] = 0;
00526 }
00527 if (leftover == 1)
00528 {
00529 buf[total_bytes++] = 1;
00530 buf[total_bytes++] = 0;
00531 }
00532 else if (leftover > 0)
00533 {
00534 buf[total_bytes++] = 257 - leftover;
00535 buf[total_bytes++] = 0;
00536 }
00537 }
00538 stp_zfwrite((const char *) buf, total_bytes, 1, v);
00539 stp_free(buf);
00540 #endif
00541 }
00542
00543 void
00544 stpi_escp2_init_printer(stp_vars_t *v)
00545 {
00546 escp2_reset_printer(v);
00547 escp2_set_remote_sequence(v);
00548 escp2_set_graphics_mode(v);
00549 escp2_set_resolution(v);
00550 escp2_set_color(v);
00551 escp2_set_printer_weave(v);
00552 escp2_set_printhead_speed(v);
00553 escp2_set_dot_size(v);
00554 escp2_set_printhead_resolution(v);
00555 escp2_set_page_height(v);
00556 escp2_set_margins(v);
00557 escp2_set_form_factor(v);
00558 }
00559
00560 void
00561 stpi_escp2_deinit_printer(stp_vars_t *v)
00562 {
00563 escp2_privdata_t *pd = get_privdata(v);
00564 stp_puts("\033@", v);
00565 if (pd->advanced_command_set || pd->input_slot)
00566 {
00567 stp_send_command(v, "\033(R", "bcs", 0, "REMOTE1");
00568 if (pd->input_slot && pd->input_slot->deinit_sequence.bytes)
00569 stp_zfwrite(pd->input_slot->deinit_sequence.data,
00570 pd->input_slot->deinit_sequence.bytes, 1, v);
00571
00572 stp_send_command(v, "LD", "b");
00573
00574
00575 if (pd->deinit_sequence)
00576 stp_zfwrite(pd->deinit_sequence->data, pd->deinit_sequence->bytes,
00577 1, v);
00578
00579 stp_send_command(v, "\033", "ccc", 0, 0, 0);
00580 }
00581 }
00582
00583 void
00584 stpi_escp2_flush_pass(stp_vars_t *v, int passno, int vertical_subpass)
00585 {
00586 int j;
00587 escp2_privdata_t *pd = get_privdata(v);
00588 stp_lineoff_t *lineoffs = stp_get_lineoffsets_by_pass(v, passno);
00589 stp_lineactive_t *lineactive = stp_get_lineactive_by_pass(v, passno);
00590 const stp_linebufs_t *bufs = stp_get_linebases_by_pass(v, passno);
00591 stp_pass_t *pass = stp_get_pass_by_pass(v, passno);
00592 stp_linecount_t *linecount = stp_get_linecount_by_pass(v, passno);
00593 int minlines = pd->min_nozzles;
00594
00595 for (j = 0; j < pd->channels_in_use; j++)
00596 {
00597 if (lineactive[0].v[j] > 0)
00598 {
00599 int nlines = linecount[0].v[j];
00600 int extralines = 0;
00601 if (nlines < minlines)
00602 {
00603 extralines = minlines - nlines;
00604 nlines = minlines;
00605 }
00606 set_vertical_position(v, pass);
00607 set_color(v, pass, j);
00608 set_horizontal_position(v, pass, vertical_subpass);
00609 send_print_command(v, pass, j, nlines);
00610
00611
00612
00613
00614 stp_zfwrite((const char *)bufs[0].v[j], lineoffs[0].v[j], 1, v);
00615 if (extralines)
00616 send_extra_data(v, extralines);
00617 stp_send_command(v, "\r", "");
00618 pd->printed_something = 1;
00619 }
00620 lineoffs[0].v[j] = 0;
00621 linecount[0].v[j] = 0;
00622 }
00623 }
00624
00625 void
00626 stpi_escp2_terminate_page(stp_vars_t *v)
00627 {
00628 escp2_privdata_t *pd = get_privdata(v);
00629 if (!pd->input_slot ||
00630 pd->input_slot->roll_feed_cut_flags != ROLL_FEED_DONT_EJECT)
00631 {
00632 if (!pd->printed_something)
00633 stp_send_command(v, "\n", "");
00634 stp_send_command(v, "\f", "");
00635 }
00636 }