diff options
author | Didier Raboud <odyx@debian.org> | 2017-10-25 12:30:55 +0200 |
---|---|---|
committer | Didier Raboud <odyx@debian.org> | 2017-10-25 12:30:55 +0200 |
commit | 9dd97a029bf391c42b1dc76f2f7c5e386bb8f466 (patch) | |
tree | ec2b3262b629dd03af9924906ec3bdbd6c54ef83 /src/main | |
parent | 337ffefc0bdf252749c81ebb9255556d54c3e632 (diff) |
New upstream version 5.3.0~pre1
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/canon-printers.h | 12 | ||||
-rw-r--r-- | src/main/escp2-driver.c | 44 | ||||
-rw-r--r-- | src/main/mxml-file.c | 5 | ||||
-rw-r--r-- | src/main/mxml-node.c | 11 | ||||
-rw-r--r-- | src/main/print-canon.c | 77 | ||||
-rw-r--r-- | src/main/print-dpl.c | 49 | ||||
-rw-r--r-- | src/main/print-escp2-data.c | 24 | ||||
-rw-r--r-- | src/main/print-escp2.c | 217 | ||||
-rw-r--r-- | src/main/print-escp2.h | 94 | ||||
-rw-r--r-- | src/main/print-lexmark.c | 64 | ||||
-rw-r--r-- | src/main/print-olympus.c | 111 | ||||
-rw-r--r-- | src/main/print-papers.c | 26 | ||||
-rw-r--r-- | src/main/print-pcl.c | 70 | ||||
-rw-r--r-- | src/main/print-ps.c | 108 | ||||
-rw-r--r-- | src/main/print-raw.c | 15 | ||||
-rw-r--r-- | src/main/print-vars.c | 70 | ||||
-rw-r--r-- | src/main/printers.c | 39 | ||||
-rw-r--r-- | src/main/xml.c | 12 |
18 files changed, 577 insertions, 471 deletions
diff --git a/src/main/canon-printers.h b/src/main/canon-printers.h index fec7df1..6345443 100644 --- a/src/main/canon-printers.h +++ b/src/main/canon-printers.h @@ -37,12 +37,12 @@ typedef struct canon_caps { const char* name; /* model name */ int model_id; /* model ID code for use in commands */ - int max_width; /* maximum printable paper size */ - int max_height; - int border_left; /* left margin, points */ - int border_right; /* right margin, points */ - int border_top; /* absolute top margin, points */ - int border_bottom; /* absolute bottom margin, points */ + stp_dimension_t max_width; /* maximum printable paper size */ + stp_dimension_t max_height; + stp_dimension_t border_left; /* left margin, points */ + stp_dimension_t border_right; /* right margin, points */ + stp_dimension_t border_top; /* absolute top margin, points */ + stp_dimension_t border_bottom; /* absolute bottom margin, points */ /* int raster_lines_per_block; */ /* number of raster lines in every F) command */ const canon_slotlist_t* slotlist; /*available paperslots */ diff --git a/src/main/escp2-driver.c b/src/main/escp2-driver.c index c49f41b..f3c8d51 100644 --- a/src/main/escp2-driver.c +++ b/src/main/escp2-driver.c @@ -83,6 +83,12 @@ print_remote_float_param(stp_vars_t *v, const char *param, double value) } static void +print_remote_dim_param(stp_vars_t *v, const char *param, double value) +{ + print_remote_float_param(v, param, value); +} + +static void print_debug_params(stp_vars_t *v) { escp2_privdata_t *pd = get_privdata(v); @@ -93,10 +99,10 @@ print_debug_params(stp_vars_t *v) print_remote_param(v, "Version", VERSION); print_remote_param(v, "Release Date", RELEASE_DATE); print_remote_param(v, "Driver", stp_get_driver(v)); - print_remote_int_param(v, "Left", stp_get_left(v)); - print_remote_int_param(v, "Top", stp_get_top(v)); - print_remote_int_param(v, "Page Width", stp_get_page_width(v)); - print_remote_int_param(v, "Page Height", stp_get_page_height(v)); + print_remote_dim_param(v, "Left", stp_get_left(v)); + print_remote_dim_param(v, "Top", stp_get_top(v)); + print_remote_dim_param(v, "Page Width", stp_get_page_width(v)); + print_remote_dim_param(v, "Page Height", stp_get_page_height(v)); print_remote_int_param(v, "Model", stp_get_model_id(v)); print_remote_int_param(v, "Ydpi", pd->res->vres); print_remote_int_param(v, "Xdpi", pd->res->hres); @@ -108,19 +114,23 @@ print_debug_params(stp_vars_t *v) */ print_remote_int_param(v, "Use_printer_weave", pd->use_printer_weave); print_remote_int_param(v, "Duplex", pd->duplex); - print_remote_int_param(v, "Page_left", pd->page_left); - print_remote_int_param(v, "Page_right", pd->page_right); - print_remote_int_param(v, "Page_top", pd->page_top); - print_remote_int_param(v, "Page_bottom", pd->page_bottom); - print_remote_int_param(v, "Page_width", pd->page_width); - print_remote_int_param(v, "Page_height", pd->page_height); - print_remote_int_param(v, "Page_true_height", pd->page_true_height); - print_remote_int_param(v, "Page_extra_height", pd->page_extra_height); - print_remote_int_param(v, "Paper_extra_bottom", pd->paper_extra_bottom); - print_remote_int_param(v, "Image_left", pd->image_left); - print_remote_int_param(v, "Image_top", pd->image_top); - print_remote_int_param(v, "Image_width", pd->image_width); - print_remote_int_param(v, "Image_height", pd->image_height); + print_remote_dim_param(v, "Page_left", pd->page_left); + print_remote_dim_param(v, "Page_right", pd->page_right); + print_remote_dim_param(v, "Page_top", pd->page_top); + print_remote_dim_param(v, "Page_bottom", pd->page_bottom); + print_remote_dim_param(v, "Page_width", pd->page_width); + print_remote_dim_param(v, "Page_height", pd->page_height); + print_remote_dim_param(v, "Page_true_height", pd->page_true_height); + print_remote_dim_param(v, "Page_extra_height", pd->page_extra_height); + print_remote_dim_param(v, "Paper_extra_bottom", pd->paper_extra_bottom); + print_remote_dim_param(v, "Image_left", pd->image_left); + print_remote_dim_param(v, "Image_top", pd->image_top); + print_remote_dim_param(v, "Image_width", pd->image_width); + print_remote_dim_param(v, "Image_height", pd->image_height); + print_remote_dim_param(v, "CD_X_offset", pd->cd_x_offset); + print_remote_dim_param(v, "CD_Y_offset", pd->cd_y_offset); + print_remote_dim_param(v, "CD_inner_radius", pd->cd_inner_radius); + print_remote_dim_param(v, "CD_outer_radius", pd->cd_outer_radius); print_remote_int_param(v, "Image_scaled_width", pd->image_scaled_width); print_remote_int_param(v, "Image_scaled_height", pd->image_scaled_height); print_remote_int_param(v, "Image_printed_width", pd->image_printed_width); diff --git a/src/main/mxml-file.c b/src/main/mxml-file.c index 8f8ff46..4ee1328 100644 --- a/src/main/mxml-file.c +++ b/src/main/mxml-file.c @@ -429,6 +429,10 @@ mxml_load_data(stp_mxml_node_t *top, /* I - Top node */ node = stp_mxmlNewReal(parent, strtod(buffer, &bufptr)); break; + case STP_MXML_DIMENSION : + node = stp_mxmlNewDimension(parent, strtod(buffer, &bufptr)); + break; + case STP_MXML_TEXT : node = stp_mxmlNewText(parent, whitespace, buffer); break; @@ -1242,6 +1246,7 @@ mxml_write_node(stp_mxml_node_t *node, /* I - Node to write */ break; case STP_MXML_REAL : + case STP_MXML_DIMENSION : if (node->prev) { if (col > STP_MXML_WRAP) diff --git a/src/main/mxml-node.c b/src/main/mxml-node.c index afecf68..b050fe2 100644 --- a/src/main/mxml-node.c +++ b/src/main/mxml-node.c @@ -21,6 +21,7 @@ * stp_mxmlNewInteger() - Create a new integer node. * stp_mxmlNewOpaque() - Create a new opaque string. * stp_mxmlNewReal() - Create a new real number node. + * stp_mxmlNewDimension() - Create a new dimension node. * stp_mxmlNewText() - Create a new text fragment node. * stp_mxmlRemove() - Remove a node from its parent. * mxml_new() - Create a new node. @@ -223,6 +224,9 @@ stp_mxmlDelete(stp_mxml_node_t *node) /* I - Node to delete */ case STP_MXML_REAL : /* Nothing to do */ break; + case STP_MXML_DIMENSION : + /* Nothing to do */ + break; case STP_MXML_TEXT : if (node->value.text.string) free(node->value.text.string); @@ -369,6 +373,13 @@ stp_mxmlNewReal(stp_mxml_node_t *parent, /* I - Parent node or STP_MXML_NO_PAREN return (node); } +stp_mxml_node_t * /* O - New node */ +stp_mxmlNewDimension(stp_mxml_node_t *parent, /* I - Parent node or STP_MXML_NO_PARENT */ + stp_dimension_t dimension) /* I - Dimension value */ +{ + return stp_mxmlNewReal(parent, (double) dimension); +} + /* * 'stp_mxmlNewText()' - Create a new text fragment node. diff --git a/src/main/print-canon.c b/src/main/print-canon.c index 7b1b1cc..4405fae 100644 --- a/src/main/print-canon.c +++ b/src/main/print-canon.c @@ -2666,7 +2666,7 @@ canon_size_type(const stp_vars_t *v, const canon_cap_t * caps) stp_deprintf(STP_DBG_CANON,"canon: Unknown paper size '%s' - using custom\n",name); } else { - stp_deprintf(STP_DBG_CANON,"canon: Couldn't look up paper size %dx%d - " + stp_deprintf(STP_DBG_CANON,"canon: Couldn't look up paper size %fx%f - " "using custom\n",stp_get_page_height(v), stp_get_page_width(v)); } return 0; @@ -2763,7 +2763,7 @@ static void fix_papersize(unsigned char arg_ESCP_1, int *paper_width, int *paper } static void -canon_describe_resolution(const stp_vars_t *v, int *x, int *y) +canon_describe_resolution(const stp_vars_t *v, stp_resolution_t *x, stp_resolution_t *y) { const canon_mode_t* mode = NULL; const canon_cap_t * caps = canon_get_model_capabilities(v); @@ -3292,18 +3292,18 @@ static void internal_imageable_area(const stp_vars_t *v, /* I */ int use_paper_margins, int use_maximum_area, - int *left, /* O - Left position in points */ - int *right, /* O - Right position in points */ - int *bottom, /* O - Bottom position in points */ - int *top) /* O - Top position in points */ + stp_dimension_t *left, /* O - Left position in points */ + stp_dimension_t *right, /* O - Right position in points */ + stp_dimension_t *bottom, /* O - Bottom position in points */ + stp_dimension_t *top) /* O - Top position in points */ { - int width, length; /* Size of page */ + stp_dimension_t width, length; /* Size of page */ int cd = 0; /* CD selected */ const char *media_size = stp_get_string_parameter(v, "PageSize"); - int left_margin = 0; - int right_margin = 0; - int bottom_margin = 0; - int top_margin = 0; + stp_dimension_t left_margin = 0; + stp_dimension_t right_margin = 0; + stp_dimension_t bottom_margin = 0; + stp_dimension_t top_margin = 0; const stp_papersize_t *pt = NULL; const char* input_slot = stp_get_string_parameter(v, "InputSlot"); @@ -3387,49 +3387,49 @@ internal_imageable_area(const stp_vars_t *v, /* I */ } } - stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: left_margin %d\n",left_margin); - stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: right_margin %d\n",right_margin); - stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: top_margin %d\n",top_margin); - stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: bottom_margin %d\n",bottom_margin); + stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: left_margin %f\n",left_margin); + stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: right_margin %f\n",right_margin); + stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: top_margin %f\n",top_margin); + stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: bottom_margin %f\n",bottom_margin); *left = left_margin; *right = width - right_margin; *top = top_margin; *bottom = length - bottom_margin; - stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: page_left %d\n",*left); - stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: page_right %d\n",*right); - stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: page_top %d\n",*top); - stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: page_bottom %d\n",*bottom); + stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: page_left %f\n",*left); + stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: page_right %f\n",*right); + stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: page_top %f\n",*top); + stp_dprintf(STP_DBG_CANON, v,"internal_imageable_area: page_bottom %f\n",*bottom); } static void canon_imageable_area(const stp_vars_t *v, /* I */ - int *left, /* O - Left position in points */ - int *right, /* O - Right position in points */ - int *bottom, /* O - Bottom position in points */ - int *top) /* O - Top position in points */ + stp_dimension_t *left, /* O - Left position in points */ + stp_dimension_t *right, /* O - Right position in points */ + stp_dimension_t *bottom, /* O - Bottom position in points */ + stp_dimension_t *top) /* O - Top position in points */ { internal_imageable_area(v, 1, 0, left, right, bottom, top); } static void canon_maximum_imageable_area(const stp_vars_t *v, /* I */ - int *left, /* O - Left position in points */ - int *right, /* O - Right position in points */ - int *bottom, /* O - Bottom position in points */ - int *top) /* O - Top position in points */ + stp_dimension_t *left, /* O - Left position in points */ + stp_dimension_t *right, /* O - Right position in points */ + stp_dimension_t *bottom, /* O - Bottom position in points */ + stp_dimension_t *top) /* O - Top position in points */ { internal_imageable_area(v, 1, 1, left, right, bottom, top); } static void canon_limit(const stp_vars_t *v, /* I */ - int *width, - int *height, - int *min_width, - int *min_height) + stp_dimension_t *width, + stp_dimension_t *height, + stp_dimension_t *min_width, + stp_dimension_t *min_height) { const canon_cap_t * caps= canon_get_model_capabilities(v); @@ -4409,7 +4409,7 @@ canon_init_setESC_P(const stp_vars_t *v, const canon_privdata_t *init) { unsigned char arg_ESCP_1, arg_ESCP_2, arg_ESCP_5, arg_ESCP_6, arg_ESCP_7, arg_ESCP_9; - int width, length; + stp_dimension_t width, length; /* const char *media_size = stp_get_string_parameter(v, "PageSize"); const stp_papersize_t *pt = NULL; */ const char* orientation_type = stp_get_string_parameter(v, "Orientation"); @@ -5697,7 +5697,10 @@ static void setup_page(stp_vars_t* v,canon_privdata_t* privdata){ const char *media_source = stp_get_string_parameter(v, "InputSlot"); const char *cd_type = stp_get_string_parameter(v, "PageSize"); int print_cd = (media_source && (!strcmp(media_source, "CD"))); - int page_left, page_top, page_right, page_bottom; + stp_dimension_t page_left, + page_top, + page_right, + page_bottom; int hub_size = 0; #if 0 @@ -5765,10 +5768,10 @@ static void setup_page(stp_vars_t* v,canon_privdata_t* privdata){ privdata->page_height = page_bottom - page_top; /* checked in Epson: matches */ } - stp_dprintf(STP_DBG_CANON, v, "setup_page page_top = %i\n",page_top); - stp_dprintf(STP_DBG_CANON, v, "setup_page page_bottom = %i\n",page_bottom); - stp_dprintf(STP_DBG_CANON, v, "setup_page page_left = %i\n",page_left); - stp_dprintf(STP_DBG_CANON, v, "setup_page page_right = %i\n",page_right); + stp_dprintf(STP_DBG_CANON, v, "setup_page page_top = %f\n",page_top); + stp_dprintf(STP_DBG_CANON, v, "setup_page page_bottom = %f\n",page_bottom); + stp_dprintf(STP_DBG_CANON, v, "setup_page page_left = %f\n",page_left); + stp_dprintf(STP_DBG_CANON, v, "setup_page page_right = %f\n",page_right); stp_dprintf(STP_DBG_CANON, v, "setup_page top = %i\n",privdata->top); stp_dprintf(STP_DBG_CANON, v, "setup_page left = %i\n",privdata->left); stp_dprintf(STP_DBG_CANON, v, "setup_page out_height = %i\n",privdata->out_height); diff --git a/src/main/print-dpl.c b/src/main/print-dpl.c index 23f825b..e8f27e8 100644 --- a/src/main/print-dpl.c +++ b/src/main/print-dpl.c @@ -645,7 +645,7 @@ dpl_get_model_capabilities (int model) /* I: Model */ */ static void -dpl_describe_resolution (const stp_vars_t * v, int *x, int *y) +dpl_describe_resolution (const stp_vars_t * v, stp_resolution_t *x, stp_resolution_t *y) { int i; const char *resolution = stp_get_string_parameter (v, "Resolution"); @@ -675,7 +675,8 @@ dpl_describe_resolution (const stp_vars_t * v, int *x, int *y) int dpl_get_multiplier (const stp_vars_t * v) { - int x, y, multiplier; + stp_resolution_t x, y; + int multiplier; int i; int max_dpi; int model = stp_get_model_id (v); @@ -935,12 +936,12 @@ dpl_parameters (const stp_vars_t * v, const char *name, */ static void internal_imageable_area (const stp_vars_t * v, /* I */ - int *left, /* O - Left position in points */ - int *right, /* O - Right position in points */ - int *bottom, /* O - Bottom position in points */ - int *top) /* O - Top position in points */ + stp_dimension_t *left, /* O - Left position in points */ + stp_dimension_t *right, /* O - Right position in points */ + stp_dimension_t *bottom, /* O - Bottom position in points */ + stp_dimension_t *top) /* O - Top position in points */ { - int width, height; /* Size of page */ + stp_dimension_t width, height; /* Size of page */ stp_default_media_size (v, &width, &height); @@ -952,17 +953,17 @@ internal_imageable_area (const stp_vars_t * v, /* I */ static void dpl_imageable_area (const stp_vars_t * v, /* I */ - int *left, /* O - Left position in points */ - int *right, /* O - Right position in points */ - int *bottom, /* O - Bottom position in points */ - int *top) /* O - Top position in points */ + stp_dimension_t *left, /* O - Left position in points */ + stp_dimension_t *right, /* O - Right position in points */ + stp_dimension_t *bottom, /* O - Bottom position in points */ + stp_dimension_t *top) /* O - Top position in points */ { internal_imageable_area (v, left, right, bottom, top); } static void dpl_limit (const stp_vars_t * v, /* I */ - int *width, int *height, int *min_width, int *min_height) + stp_dimension_t *width, stp_dimension_t *height, stp_dimension_t *min_width, stp_dimension_t *min_height) { const dpl_cap_t *caps = dpl_get_model_capabilities (stp_get_model_id (v)); *width = caps->custom_max_width; @@ -985,11 +986,11 @@ pcx_header (stp_vars_t * v, stp_image_t * image) unsigned short top; /* y = 0 is at bottom */ unsigned short bytes; short xdpi; - int i_xdpi; - int *xdpi_p = (&i_xdpi); + stp_resolution_t r_xdpi; + stp_resolution_t *xdpi_p = (&r_xdpi); short ydpi; - int i_ydpi; - int *ydpi_p = (&i_ydpi); + stp_resolution_t r_ydpi; + stp_resolution_t *ydpi_p = (&r_ydpi); int n; const short zero = 0; @@ -1001,8 +1002,8 @@ pcx_header (stp_vars_t * v, stp_image_t * image) /* Get resolutions */ dpl_describe_resolution (v, xdpi_p, ydpi_p); - xdpi = (short) i_xdpi; - ydpi = (short) i_ydpi; + xdpi = (short) r_xdpi; + ydpi = (short) r_ydpi; bytes = (xdpi * 4 + 7 ) / 8; /* must be an even number */ if (bytes != (bytes & 0xfffe)) @@ -1085,7 +1086,7 @@ dpl_do_print (stp_vars_t * v, stp_image_t * image) double v_offset = get_double_param (v, "VertOffset"); double present = get_double_param (v, "Present"); int y; /* Looping vars */ - int xdpi, ydpi; /* Resolution */ + stp_resolution_t xdpi, ydpi; /* Resolution */ int multiplier; unsigned char *black; /* Black bitmap data */ unsigned zero_mask; @@ -1119,7 +1120,7 @@ dpl_do_print (stp_vars_t * v, stp_image_t * image) dpl_describe_resolution (v, &xdpi, &ydpi); - stp_deprintf (STP_DBG_DPL, "dpl: resolution=%dx%d\n", xdpi, ydpi); + stp_deprintf (STP_DBG_DPL, "dpl: resolution=%dx%d\n", (int) xdpi, (int) ydpi); if (xdpi <= 0 || ydpi <= 0) { stp_eprintf (v, "No resolution found; cannot print.\n"); @@ -1221,7 +1222,7 @@ dpl_do_print (stp_vars_t * v, stp_image_t * image) if (image_height / ydpi > 4) { stp_zprintf (v, "\002M%04i\r", - 300 * image_height / ydpi + (3 * privdata.v_offset)); + 300 * image_height / ((int) ydpi) + (3 * privdata.v_offset)); } else { @@ -1229,7 +1230,7 @@ dpl_do_print (stp_vars_t * v, stp_image_t * image) } /* set Label Width */ stp_zprintf (v, "\002KcLW%04i\r", - 100 * image_width / xdpi + privdata.h_offset); + 100 * image_width / ((int) xdpi) + privdata.h_offset); if (0 != privdata.label_separator) { if (1 == privdata.label_separator) @@ -1243,7 +1244,7 @@ dpl_do_print (stp_vars_t * v, stp_image_t * image) else { stp_zprintf (v, "\002c%04i\r", 100 * /* Continuous mode */ - image_height / ydpi + privdata.v_offset); + image_height / ((int) ydpi) + privdata.v_offset); } } if (privdata.darkness > -1) @@ -1364,7 +1365,7 @@ dpl_pcx (stp_vars_t * v, /* I - Print file or command */ int count = 0; int in = 0; int out = 0; - int xdpi, ydpi; + stp_resolution_t xdpi, ydpi; int model = stp_get_model_id (v); const dpl_cap_t *caps = dpl_get_model_capabilities (model); int i; diff --git a/src/main/print-escp2-data.c b/src/main/print-escp2-data.c index 259204a..870ec40 100644 --- a/src/main/print-escp2-data.c +++ b/src/main/print-escp2-data.c @@ -212,7 +212,7 @@ load_model_from_file(const stp_vars_t *v, stp_mxml_node_t *xmod, int model) while (child && i < 4) { if (child->type == STP_MXML_TEXT) - data[i++] = stp_xmlstrtoul(child->value.text.string); + data[i++] = stp_xmlstrtodim(child->value.text.string); child = child->next; } if (dtype && !strcmp(dtype, "duplex")) @@ -299,36 +299,36 @@ load_model_from_file(const stp_vars_t *v, stp_mxml_node_t *xmod, int model) p->bidirectional_upper_limit = stp_xmlstrtoul(val); else if (!strcmp(name, "minimumMediaSize")) { - p->min_paper_width = stp_xmlstrtoul(child->value.text.string); + p->min_paper_width = stp_xmlstrtodim(child->value.text.string); child = child->next; - p->min_paper_height = stp_xmlstrtoul(child->value.text.string); + p->min_paper_height = stp_xmlstrtodim(child->value.text.string); } else if (!strcmp(name, "maximumMediaSize")) { - p->max_paper_width = stp_xmlstrtoul(child->value.text.string); + p->max_paper_width = stp_xmlstrtodim(child->value.text.string); child = child->next; - p->max_paper_height = stp_xmlstrtoul(child->value.text.string); + p->max_paper_height = stp_xmlstrtodim(child->value.text.string); } else if (!strcmp(name, "maximumImageableArea")) { - p->max_imageable_width = stp_xmlstrtoul(child->value.text.string); + p->max_imageable_width = stp_xmlstrtodim(child->value.text.string); child = child->next; - p->max_imageable_height = stp_xmlstrtoul(child->value.text.string); + p->max_imageable_height = stp_xmlstrtodim(child->value.text.string); } else if (!strcmp(name, "CDOffset")) { - p->cd_x_offset = stp_xmlstrtoul(child->value.text.string); + p->cd_x_offset = stp_xmlstrtodim(child->value.text.string); child = child->next; - p->cd_y_offset = stp_xmlstrtoul(child->value.text.string); + p->cd_y_offset = stp_xmlstrtodim(child->value.text.string); } else if (!strcmp(name, "CDMediaSize")) { - p->cd_page_width = stp_xmlstrtoul(child->value.text.string); + p->cd_page_width = stp_xmlstrtodim(child->value.text.string); child = child->next; - p->cd_page_height = stp_xmlstrtoul(child->value.text.string); + p->cd_page_height = stp_xmlstrtodim(child->value.text.string); } else if (!strcmp(name, "extraBottom")) - p->paper_extra_bottom = stp_xmlstrtoul(val); + p->paper_extra_bottom = stp_xmlstrtodim(val); else if (!strcmp(name, "AlignmentChoices")) { p->alignment_passes = diff --git a/src/main/print-escp2.c b/src/main/print-escp2.c index d666d1c..f4e90f1 100644 --- a/src/main/print-escp2.c +++ b/src/main/print-escp2.c @@ -117,6 +117,14 @@ static const double ink_darknesses[] = STP_PARAMETER_LEVEL_INTERNAL, 0, 1, STP_CHANNEL_NONE, 1, 0 \ } +#define PARAMETER_DIMENSION(s) \ +{ \ + "escp2_" #s, "escp2_" #s, \ + "Color=Yes,Category=Advanced Printer Functionality", NULL, \ + STP_PARAMETER_TYPE_DIMENSION, STP_PARAMETER_CLASS_FEATURE, \ + STP_PARAMETER_LEVEL_INTERNAL, 0, 1, STP_CHANNEL_NONE, 1, 0 \ +} + #define PARAMETER_INT_RO(s) \ { \ "escp2_" #s, "escp2_" #s, \ @@ -415,12 +423,12 @@ static const stp_parameter_t the_parameters[] = PARAMETER_INT(black_nozzle_separation), PARAMETER_INT(fast_nozzle_separation), PARAMETER_INT(separation_rows), - PARAMETER_INT(max_paper_width), - PARAMETER_INT(max_paper_height), - PARAMETER_INT(min_paper_width), - PARAMETER_INT(min_paper_height), - PARAMETER_INT(max_imageable_width), - PARAMETER_INT(max_imageable_height), + PARAMETER_DIMENSION(max_paper_width), + PARAMETER_DIMENSION(max_paper_height), + PARAMETER_DIMENSION(min_paper_width), + PARAMETER_DIMENSION(min_paper_height), + PARAMETER_DIMENSION(max_imageable_width), + PARAMETER_DIMENSION(max_imageable_height), PARAMETER_INT(extra_feed), PARAMETER_INT(pseudo_separation_rows), PARAMETER_INT(base_separation), @@ -435,10 +443,10 @@ static const stp_parameter_t the_parameters[] = PARAMETER_INT(base_horizontal_position_alignment), PARAMETER_INT(bidirectional_upper_limit), PARAMETER_INT(physical_channels), - PARAMETER_INT(left_margin), - PARAMETER_INT(right_margin), - PARAMETER_INT(top_margin), - PARAMETER_INT(bottom_margin), + PARAMETER_DIMENSION(left_margin), + PARAMETER_DIMENSION(right_margin), + PARAMETER_DIMENSION(top_margin), + PARAMETER_DIMENSION(bottom_margin), PARAMETER_INT(ink_type), PARAMETER_INT(bits), PARAMETER_INT(base_res), @@ -446,10 +454,10 @@ static const stp_parameter_t the_parameters[] = PARAMETER_INT_RO(alignment_choices), PARAMETER_INT_RO(alternate_alignment_passes), PARAMETER_INT_RO(alternate_alignment_choices), - PARAMETER_INT(cd_x_offset), - PARAMETER_INT(cd_y_offset), - PARAMETER_INT(cd_page_width), - PARAMETER_INT(cd_page_height), + PARAMETER_DIMENSION(cd_page_width), + PARAMETER_DIMENSION(cd_page_height), + PARAMETER_DIMENSION(cd_x_offset), + PARAMETER_DIMENSION(cd_y_offset), PARAMETER_INT(paper_extra_bottom), PARAMETER_RAW(preinit_sequence), PARAMETER_RAW(preinit_remote_sequence), @@ -1040,6 +1048,19 @@ escp2_##f(const stp_vars_t *v) \ } \ } +#define DEF_DIMENSION_ACCESSOR(f) \ +static stp_dimension_t \ +escp2_##f(const stp_vars_t *v) \ +{ \ + if (stp_check_dimension_parameter(v, "escp2_" #f, STP_PARAMETER_ACTIVE)) \ + return stp_get_dimension_parameter(v, "escp2_" #f); \ + else \ + { \ + stpi_escp2_printer_t *printdef = stp_escp2_get_printer(v); \ + return (stp_dimension_t) printdef->f; \ + } \ +} + #define DEF_RAW_ACCESSOR(f, t) \ static t \ escp2_##f(const stp_vars_t *v) \ @@ -1053,12 +1074,12 @@ escp2_##f(const stp_vars_t *v) \ } \ } -#define DEF_ROLL_ACCESSOR(f, t) \ -static t \ +#define DEF_ROLL_ACCESSOR(f) \ +static stp_dimension_t \ escp2_##f(const stp_vars_t *v, int rollfeed) \ { \ - if (stp_check_int_parameter(v, "escp2_" #f, STP_PARAMETER_ACTIVE)) \ - return stp_get_int_parameter(v, "escp2_" #f); \ + if (stp_check_dimension_parameter(v, "escp2_" #f, STP_PARAMETER_ACTIVE)) \ + return stp_get_dimension_parameter(v, "escp2_" #f); \ else \ { \ stpi_escp2_printer_t *printdef = stp_escp2_get_printer(v); \ @@ -1117,22 +1138,22 @@ DEF_SIMPLE_ACCESSOR(alignment_choices, int) DEF_SIMPLE_ACCESSOR(alternate_alignment_passes, int) DEF_SIMPLE_ACCESSOR(alternate_alignment_choices, int) -DEF_SIMPLE_ACCESSOR(max_paper_width, unsigned) -DEF_SIMPLE_ACCESSOR(max_paper_height, unsigned) -DEF_SIMPLE_ACCESSOR(min_paper_width, unsigned) -DEF_SIMPLE_ACCESSOR(min_paper_height, unsigned) -DEF_SIMPLE_ACCESSOR(max_imageable_width, unsigned) -DEF_SIMPLE_ACCESSOR(max_imageable_height, unsigned) -DEF_SIMPLE_ACCESSOR(cd_page_width, int) -DEF_SIMPLE_ACCESSOR(cd_page_height, int) +DEF_DIMENSION_ACCESSOR(max_paper_width) +DEF_DIMENSION_ACCESSOR(max_paper_height) +DEF_DIMENSION_ACCESSOR(min_paper_width) +DEF_DIMENSION_ACCESSOR(min_paper_height) +DEF_DIMENSION_ACCESSOR(max_imageable_width) +DEF_DIMENSION_ACCESSOR(max_imageable_height) +DEF_DIMENSION_ACCESSOR(cd_page_width) +DEF_DIMENSION_ACCESSOR(cd_page_height) -DEF_SIMPLE_ACCESSOR(cd_x_offset, int) -DEF_SIMPLE_ACCESSOR(cd_y_offset, int) +DEF_DIMENSION_ACCESSOR(cd_x_offset) +DEF_DIMENSION_ACCESSOR(cd_y_offset) -DEF_ROLL_ACCESSOR(left_margin, unsigned) -DEF_ROLL_ACCESSOR(right_margin, unsigned) -DEF_ROLL_ACCESSOR(top_margin, unsigned) -DEF_ROLL_ACCESSOR(bottom_margin, unsigned) +DEF_ROLL_ACCESSOR(left_margin) +DEF_ROLL_ACCESSOR(right_margin) +DEF_ROLL_ACCESSOR(top_margin) +DEF_ROLL_ACCESSOR(bottom_margin) DEF_RAW_ACCESSOR(preinit_sequence, const stp_raw_t *) DEF_RAW_ACCESSOR(preinit_remote_sequence, const stp_raw_t *) @@ -1140,6 +1161,14 @@ DEF_RAW_ACCESSOR(postinit_remote_sequence, const stp_raw_t *) DEF_RAW_ACCESSOR(vertical_borderless_sequence, const stp_raw_t *) +/* froundto( 500.5 points, 180 dpi, 72 points/inch) */ +static double +froundto(double value, double numerator, double denominator) +{ + double multiplier = (double) ((int) ((numerator + (denominator / 2)) / denominator)); + return ((double) ((int) ((value * multiplier) + .5))) / multiplier; +} + static const resolution_list_t * escp2_reslist(const stp_vars_t *v) { @@ -1619,8 +1648,8 @@ get_printer_resolution_bounds(const stp_vars_t *v, static int verify_papersize(const stp_vars_t *v, const stp_papersize_t *pt) { - unsigned int height_limit, width_limit; - unsigned int min_height_limit, min_width_limit; + stp_dimension_t height_limit, width_limit; + stp_dimension_t min_height_limit, min_width_limit; unsigned int envelope_landscape = stp_escp2_has_cap(v, MODEL_ENVELOPE_LANDSCAPE, MODEL_ENVELOPE_LANDSCAPE_YES); width_limit = escp2_max_paper_width(v); @@ -2845,7 +2874,7 @@ stp_escp2_find_resolution(const stp_vars_t *v) } static inline int -imax(int a, int b) +smax(stp_dimension_t a, stp_dimension_t b) { if (a > b) return a; @@ -2855,8 +2884,8 @@ imax(int a, int b) static void escp2_media_size(const stp_vars_t *v, /* I */ - int *width, /* O - Width in points */ - int *height) /* O - Height in points */ + stp_dimension_t *width, /* O - Width in points */ + stp_dimension_t *height) /* O - Height in points */ { if (stp_get_page_width(v) > 0 && stp_get_page_height(v) > 0) { @@ -2921,17 +2950,18 @@ escp2_media_size(const stp_vars_t *v, /* I */ static void internal_imageable_area(const stp_vars_t *v, int use_paper_margins, int use_maximum_area, - int *left, int *right, int *bottom, int *top) + stp_dimension_t *left, stp_dimension_t *right, + stp_dimension_t *bottom, stp_dimension_t *top) { - int width, height; /* Size of page */ + stp_dimension_t width, height; /* Size of page */ int rollfeed = 0; /* Roll feed selected */ int cd = 0; /* CD selected */ const char *media_size = stp_get_string_parameter(v, "PageSize"); const char *duplex = stp_get_string_parameter(v, "Duplex"); - int left_margin = 0; - int right_margin = 0; - int bottom_margin = 0; - int top_margin = 0; + stp_dimension_t left_margin = 0; + stp_dimension_t right_margin = 0; + stp_dimension_t bottom_margin = 0; + stp_dimension_t top_margin = 0; const stp_papersize_t *pt = NULL; const input_slot_t *input_slot = NULL; @@ -2973,10 +3003,10 @@ internal_imageable_area(const stp_vars_t *v, int use_paper_margins, top_margin = pt->top; } - left_margin = imax(left_margin, escp2_left_margin(v, rollfeed)); - right_margin = imax(right_margin, escp2_right_margin(v, rollfeed)); - bottom_margin = imax(bottom_margin, escp2_bottom_margin(v, rollfeed)); - top_margin = imax(top_margin, escp2_top_margin(v, rollfeed)); + left_margin = smax(left_margin, escp2_left_margin(v, rollfeed)); + right_margin = smax(right_margin, escp2_right_margin(v, rollfeed)); + bottom_margin = smax(bottom_margin, escp2_bottom_margin(v, rollfeed)); + top_margin = smax(top_margin, escp2_top_margin(v, rollfeed)); } if (supports_borderless(v) && (use_maximum_area || @@ -2989,11 +3019,11 @@ internal_imageable_area(const stp_vars_t *v, int use_paper_margins, { if (use_paper_margins) { - unsigned width_limit = escp2_max_paper_width(v); - int offset = escp2_zero_margin_offset(v); - int margin = escp2_micro_left_margin(v); - int sep = escp2_base_separation(v); - int delta = -((offset - margin) * 72 / sep); + stp_dimension_t width_limit = escp2_max_paper_width(v); + stp_dimension_t offset = escp2_zero_margin_offset(v); + stp_dimension_t margin = escp2_micro_left_margin(v); + stp_dimension_t sep = escp2_base_separation(v); + stp_dimension_t delta = -((offset - margin) * 72.0 / sep); left_margin = delta; /* Allow some overlap if paper isn't */ right_margin = delta; /* positioned correctly */ if (width - right_margin - 3 > width_limit) @@ -3021,10 +3051,10 @@ internal_imageable_area(const stp_vars_t *v, int use_paper_margins, } if (!use_maximum_area && duplex && strcmp(duplex, "None") != 0) { - left_margin = imax(left_margin, escp2_duplex_left_margin(v)); - right_margin = imax(right_margin, escp2_duplex_right_margin(v)); - bottom_margin = imax(bottom_margin, escp2_duplex_bottom_margin(v)); - top_margin = imax(top_margin, escp2_duplex_top_margin(v)); + left_margin = smax(left_margin, escp2_duplex_left_margin(v)); + right_margin = smax(right_margin, escp2_duplex_right_margin(v)); + bottom_margin = smax(bottom_margin, escp2_duplex_bottom_margin(v)); + top_margin = smax(top_margin, escp2_duplex_top_margin(v)); } if (width > escp2_max_imageable_width(v)) @@ -3043,28 +3073,28 @@ internal_imageable_area(const stp_vars_t *v, int use_paper_margins, static void escp2_imageable_area(const stp_vars_t *v, /* I */ - int *left, /* O - Left position in points */ - int *right, /* O - Right position in points */ - int *bottom, /* O - Bottom position in points */ - int *top) /* O - Top position in points */ + stp_dimension_t *left, /* O - Left position in points */ + stp_dimension_t *right, /* O - Right position in points */ + stp_dimension_t *bottom, /* O - Bottom position in points */ + stp_dimension_t *top) /* O - Top position in points */ { internal_imageable_area(v, 1, 0, left, right, bottom, top); } static void escp2_maximum_imageable_area(const stp_vars_t *v, /* I */ - int *left, /* O - Left position in points */ - int *right, /* O - Right position in points */ - int *bottom, /* O - Bottom position in points */ - int *top) /* O - Top position in points */ + stp_dimension_t *left, /* O - Left position in points */ + stp_dimension_t *right, /* O - Right position in points */ + stp_dimension_t *bottom, /* O - Bottom position in points */ + stp_dimension_t *top) /* O - Top position in points */ { internal_imageable_area(v, 1, 1, left, right, bottom, top); } static void escp2_limit(const stp_vars_t *v, /* I */ - int *width, int *height, - int *min_width, int *min_height) + stp_dimension_t *width, stp_dimension_t *height, + stp_dimension_t *min_width, stp_dimension_t *min_height) { *width = escp2_max_paper_width(v); *height = escp2_max_paper_height(v); @@ -3073,7 +3103,7 @@ escp2_limit(const stp_vars_t *v, /* I */ } static void -escp2_describe_resolution(const stp_vars_t *v, int *x, int *y) +escp2_describe_resolution(const stp_vars_t *v, stp_resolution_t *x, stp_resolution_t *y) { const res_t *res = stp_escp2_find_resolution(v); if (res && verify_resolution(v, res)) @@ -4052,9 +4082,9 @@ setup_page(stp_vars_t *v) { escp2_privdata_t *pd = get_privdata(v); const input_slot_t *input_slot = stp_escp2_get_input_slot(v); - int extra_left = 0; - int extra_top = 0; - int hub_size = 0; + stp_dimension_t extra_left = 0; + stp_dimension_t extra_top = 0; + stp_dimension_t hub_size = 0; int min_horizontal_alignment = escp2_min_horizontal_position_alignment(v); int base_horizontal_alignment = pd->res->hres / escp2_base_horizontal_position_alignment(v); @@ -4064,7 +4094,8 @@ setup_page(stp_vars_t *v) const char *cd_type = stp_get_string_parameter(v, "PageSize"); if (cd_type && (strcmp(cd_type, "CDCustom") == 0 )) { - int outer_diameter = stp_get_dimension_parameter(v, "CDOuterDiameter"); + stp_dimension_t outer_diameter = + stp_get_dimension_parameter(v, "CDOuterDiameter"); stp_set_page_width(v, outer_diameter); stp_set_page_height(v, outer_diameter); stp_set_width(v, outer_diameter); @@ -4074,11 +4105,11 @@ setup_page(stp_vars_t *v) else { const char *inner_radius_name = stp_get_string_parameter(v, "CDInnerRadius"); - hub_size = 43 * 10 * 72 / 254; /* 43 mm standard CD hub */ + hub_size = 43.0 * 10.0 * 72.0 / 254.0; /* 43 mm standard CD hub */ if (inner_radius_name && strcmp(inner_radius_name, "Small") == 0) - hub_size = 16 * 10 * 72 / 254; /* 15 mm prints to the hole - play it - safe and print 16 mm */ + hub_size = 16.0 * 10.0 * 72.0 / 254.0; /* 15 mm prints to the hole - + play safe and print 16 mm */ } escp2_media_size(v, &(pd->page_true_width), &(pd->page_true_height)); @@ -4134,11 +4165,16 @@ setup_page(stp_vars_t *v) internal_imageable_area(v, 0, 0, &pd->page_left, &pd->page_right, &pd->page_bottom, &pd->page_top); + stp_set_left(v, froundto(stp_get_left(v), pd->res->hres, 72)); + stp_set_width(v, froundto(stp_get_width(v), pd->res->hres, 72)); + stp_set_top(v, froundto(stp_get_top(v), pd->res->hres, 72)); + stp_set_height(v, froundto(stp_get_height(v), pd->res->hres, 72)); + if (input_slot && input_slot->is_cd && escp2_cd_x_offset(v) > 0) { - int left_center = escp2_cd_x_offset(v) + + stp_dimension_t left_center = escp2_cd_x_offset(v) + stp_get_dimension_parameter(v, "CDXAdjustment"); - int top_center = escp2_cd_y_offset(v) + + stp_dimension_t top_center = escp2_cd_y_offset(v) + stp_get_dimension_parameter(v, "CDYAdjustment"); pd->page_true_height = pd->page_bottom - pd->page_top; pd->page_true_width = pd->page_right - pd->page_left; @@ -4150,13 +4186,13 @@ setup_page(stp_vars_t *v) pd->page_bottom -= pd->page_top; pd->page_top = 0; pd->page_left = 0; - extra_top = top_center - (pd->page_bottom / 2); - extra_left = left_center - (pd->page_right / 2); - pd->cd_inner_radius = hub_size * pd->micro_units / 72 / 2; - pd->cd_outer_radius = pd->page_right * pd->micro_units / 72 / 2; + extra_top = top_center - (pd->page_bottom / 2.0); + extra_left = left_center - (pd->page_right / 2.0); + pd->cd_inner_radius = hub_size * pd->micro_units / 72.0 / 2.0; + pd->cd_outer_radius = pd->page_right * pd->micro_units / 72.0 / 2.0; pd->cd_x_offset = - ((pd->page_right / 2) - stp_get_left(v)) * pd->micro_units / 72; - pd->cd_y_offset = stp_get_top(v) * pd->res->printed_vres / 72; + ((pd->page_right / 2.0) - stp_get_left(v)) * pd->micro_units / 72.0; + pd->cd_y_offset = stp_get_top(v) * pd->res->printed_vres / 72.0; if (escp2_cd_page_height(v)) { pd->page_right = escp2_cd_page_width(v); @@ -4279,15 +4315,15 @@ escp2_print_data(stp_vars_t *v, stp_image_t *image) int errlast = -1; int errline = 0; int y; - double outer_r_sq = 0; - double inner_r_sq = 0; + stp_dimension_t outer_r_sq = 0; + stp_dimension_t inner_r_sq = 0; int x_center = pd->cd_x_offset * pd->res->printed_hres / pd->micro_units; unsigned char *cd_mask = NULL; if (pd->cd_outer_radius > 0) { cd_mask = stp_malloc(1 + (pd->image_printed_width + 7) / 8); - outer_r_sq = (double) pd->cd_outer_radius * (double) pd->cd_outer_radius; - inner_r_sq = (double) pd->cd_inner_radius * (double) pd->cd_inner_radius; + outer_r_sq = pd->cd_outer_radius * pd->cd_outer_radius; + inner_r_sq = pd->cd_inner_radius * pd->cd_inner_radius; } for (y = 0; y < pd->image_printed_height; y ++) @@ -4305,7 +4341,7 @@ escp2_print_data(stp_vars_t *v, stp_image_t *image) if (cd_mask) { - int y_distance_from_center = + stp_dimension_t y_distance_from_center = pd->cd_outer_radius - ((y + pd->cd_y_offset) * pd->micro_units / pd->res->printed_vres); if (y_distance_from_center < 0) @@ -4313,15 +4349,14 @@ escp2_print_data(stp_vars_t *v, stp_image_t *image) memset(cd_mask, 0, (pd->image_printed_width + 7) / 8); if (y_distance_from_center < pd->cd_outer_radius) { - double y_sq = (double) y_distance_from_center * - (double) y_distance_from_center; - int x_where = sqrt(outer_r_sq - y_sq) + .5; + stp_dimension_t y_sq = y_distance_from_center * y_distance_from_center; + stp_dimension_t x_where = sqrt(outer_r_sq - y_sq); int scaled_x_where = x_where * pd->res->printed_hres / pd->micro_units; set_mask(cd_mask, x_center, scaled_x_where, pd->image_printed_width, 1, 0); if (y_distance_from_center < pd->cd_inner_radius) { - x_where = sqrt(inner_r_sq - y_sq) + .5; + x_where = sqrt(inner_r_sq - y_sq); scaled_x_where = x_where * pd->res->printed_hres / pd->micro_units; set_mask(cd_mask, x_center, scaled_x_where, pd->image_printed_width, 1, 1); diff --git a/src/main/print-escp2.h b/src/main/print-escp2.h index 600083a..3f4bfa9 100644 --- a/src/main/print-escp2.h +++ b/src/main/print-escp2.h @@ -378,48 +378,48 @@ typedef struct escp2_printer /* in auto mode */ /*****************************************************************************/ /* Paper size limits */ - int max_paper_width; /* Maximum paper width, in points */ - int max_paper_height; /* Maximum paper height, in points */ - int min_paper_width; /* Maximum paper width, in points */ - int min_paper_height; /* Maximum paper height, in points */ - int max_imageable_width; /* Maximum imageable area, in points */ - int max_imageable_height; /* Maximum imageable area, in points */ + stp_dimension_t max_paper_width; /* Maximum paper width, in points */ + stp_dimension_t max_paper_height; /* Maximum paper height, in points */ + stp_dimension_t min_paper_width; /* Maximum paper width, in points */ + stp_dimension_t min_paper_height; /* Maximum paper height, in points */ + stp_dimension_t max_imageable_width; /* Maximum imageable area, in points */ + stp_dimension_t max_imageable_height; /* Maximum imageable area, in points */ /*****************************************************************************/ /* Borders */ /* SHEET FED: */ /* Softweave: */ - short left_margin; /* Left margin, points */ - short right_margin; /* Right margin, points */ - short top_margin; /* Absolute top margin, points */ - short bottom_margin; /* Absolute bottom margin, points */ + stp_dimension_t left_margin; /* Left margin, points */ + stp_dimension_t right_margin; /* Right margin, points */ + stp_dimension_t top_margin; /* Absolute top margin, points */ + stp_dimension_t bottom_margin; /* Absolute bottom margin, points */ /* Printer weave: */ - short m_left_margin; /* Left margin, points */ - short m_right_margin; /* Right margin, points */ - short m_top_margin; /* Absolute top margin, points */ - short m_bottom_margin; /* Absolute bottom margin, points */ + stp_dimension_t m_left_margin; /* Left margin, points */ + stp_dimension_t m_right_margin; /* Right margin, points */ + stp_dimension_t m_top_margin; /* Absolute top margin, points */ + stp_dimension_t m_bottom_margin; /* Absolute bottom margin, points */ /* ROLL FEED: */ /* Softweave: */ - short roll_left_margin; /* Left margin, points */ - short roll_right_margin; /* Right margin, points */ - short roll_top_margin; /* Absolute top margin, points */ - short roll_bottom_margin; /* Absolute bottom margin, points */ + stp_dimension_t roll_left_margin; /* Left margin, points */ + stp_dimension_t roll_right_margin; /* Right margin, points */ + stp_dimension_t roll_top_margin; /* Absolute top margin, points */ + stp_dimension_t roll_bottom_margin; /* Absolute bottom margin, points */ /* Printer weave: */ - short m_roll_left_margin; /* Left margin, points */ - short m_roll_right_margin; /* Right margin, points */ - short m_roll_top_margin; /* Absolute top margin, points */ - short m_roll_bottom_margin; /* Absolute bottom margin, points */ + stp_dimension_t m_roll_left_margin; /* Left margin, points */ + stp_dimension_t m_roll_right_margin; /* Right margin, points */ + stp_dimension_t m_roll_top_margin; /* Absolute top margin, points */ + stp_dimension_t m_roll_bottom_margin; /* Absolute bottom margin, points */ /* Duplex margin limit (SHRT_MIN = no limit): */ - short duplex_left_margin; /* Left margin, points */ - short duplex_right_margin; /* Right margin, points */ - short duplex_top_margin; /* Absolute top margin, points */ - short duplex_bottom_margin; /* Absolute bottom margin, points */ + stp_dimension_t duplex_left_margin; /* Left margin, points */ + stp_dimension_t duplex_right_margin; /* Right margin, points */ + stp_dimension_t duplex_top_margin; /* Absolute top margin, points */ + stp_dimension_t duplex_bottom_margin; /* Absolute bottom margin, points */ /* Print directly to CD */ - short cd_x_offset; /* Center of CD (horizontal offset) */ - short cd_y_offset; /* Center of CD (vertical offset) */ - short cd_page_width; /* Width of "page" when printing to CD */ - short cd_page_height; /* Height of "page" when printing to CD */ + stp_dimension_t cd_x_offset; /* Center of CD (horizontal offset) */ + stp_dimension_t cd_y_offset; /* Center of CD (vertical offset) */ + stp_dimension_t cd_page_width; /* Width of "page" when printing to CD */ + stp_dimension_t cd_page_height; /* Height of "page" when printing to CD */ /* Extra height for form factor command */ - short paper_extra_bottom; /* Extra space on the bottom of the page */ + stp_dimension_t paper_extra_bottom; /* Extra space on the bottom of the page */ /*****************************************************************************/ /* Parameters for escputil */ short alignment_passes; @@ -565,26 +565,26 @@ typedef struct int extra_vertical_passes; /* Quality enhancement */ /* page parameters */ /* Indexed from top left */ - int page_left; /* Left edge of page (points) */ - int page_right; /* Right edge of page (points) */ - int page_top; /* Top edge of page (points) */ - int page_bottom; /* Bottom edge of page (points) */ - int page_width; /* Page width (points) */ - int page_height; /* Page height (points) */ - int page_true_height; /* Physical page height (points) */ - int page_true_width; /* Physical page height (points) */ - int cd_x_offset; /* CD X offset (micro units) */ - int cd_y_offset; /* CD Y offset (micro units) */ - int cd_outer_radius; /* CD radius (micro units) */ - int cd_inner_radius; /* CD radius (micro units) */ + stp_dimension_t page_left; /* Left edge of page (points) */ + stp_dimension_t page_right; /* Right edge of page (points) */ + stp_dimension_t page_top; /* Top edge of page (points) */ + stp_dimension_t page_bottom; /* Bottom edge of page (points) */ + stp_dimension_t page_width; /* Page width (points) */ + stp_dimension_t page_height; /* Page height (points) */ + stp_dimension_t page_true_height; /* Physical page height (points) */ + stp_dimension_t page_true_width; /* Physical page height (points) */ + stp_dimension_t cd_x_offset; /* CD X offset (micro units) */ + stp_dimension_t cd_y_offset; /* CD Y offset (micro units) */ + stp_dimension_t cd_outer_radius; /* CD radius (micro units) */ + stp_dimension_t cd_inner_radius; /* CD radius (micro units) */ int page_extra_height; /* Extra height for set_form_factor (rows) */ int paper_extra_bottom; /* Extra bottom for set_page_size (rows) */ /* Image parameters */ /* Indexed from top left */ - int image_height; /* Height of printed region (points) */ - int image_width; /* Width of printed region (points) */ - int image_top; /* First printed row (points) */ - int image_left; /* Left edge of image (points) */ + stp_dimension_t image_height; /* Height of printed region (points) */ + stp_dimension_t image_width; /* Width of printed region (points) */ + stp_dimension_t image_top; /* First printed row (points) */ + stp_dimension_t image_left; /* Left edge of image (points) */ int image_scaled_width; /* Width of physical printed region (dots) */ int image_printed_width; /* Width of printed region (dots) */ int image_scaled_height; /* Height of physical printed region (dots) */ diff --git a/src/main/print-lexmark.c b/src/main/print-lexmark.c index 9c7bf97..6c9df76 100644 --- a/src/main/print-lexmark.c +++ b/src/main/print-lexmark.c @@ -1094,7 +1094,8 @@ lexmark_sat_adjustment(const lexmark_cap_t * caps, const stp_vars_t *v) static void -lexmark_describe_resolution(const stp_vars_t *v, int *x, int *y) +lexmark_describe_resolution(const stp_vars_t *v, + stp_resolution_t *x, stp_resolution_t *y) { const char *resolution = stp_get_string_parameter(v, "Resolution"); const lexmark_res_t *res = @@ -1307,16 +1308,16 @@ lexmark_parameters(const stp_vars_t *v, const char *name, static void internal_imageable_area(const stp_vars_t *v, /* I */ int use_paper_margins, - int *left, /* O - Left position in points */ - int *right, /* O - Right position in points */ - int *bottom, /* O - Bottom position in points */ - int *top) /* O - Top position in points */ + stp_dimension_t *left, /* O - Left position in points */ + stp_dimension_t *right, /* O - Right position in points */ + stp_dimension_t *bottom, /* O - Bottom position in points */ + stp_dimension_t *top) /* O - Top position in points */ { - int width, length; /* Size of page */ - int left_margin = 0; - int right_margin = 0; - int bottom_margin = 0; - int top_margin = 0; + stp_dimension_t width, length; /* Size of page */ + stp_dimension_t left_margin = 0; + stp_dimension_t right_margin = 0; + stp_dimension_t bottom_margin = 0; + stp_dimension_t top_margin = 0; const char *media_size = stp_get_string_parameter(v, "PageSize"); const stp_papersize_t *pt = NULL; const lexmark_cap_t *caps = @@ -1347,20 +1348,20 @@ internal_imageable_area(const stp_vars_t *v, /* I */ static void lexmark_imageable_area(const stp_vars_t *v, /* I */ - int *left, /* O - Left position in points */ - int *right, /* O - Right position in points */ - int *bottom, /* O - Bottom position in points */ - int *top) /* O - Top position in points */ + stp_dimension_t *left, /* O - Left position in points */ + stp_dimension_t *right, /* O - Right position in points */ + stp_dimension_t *bottom, /* O - Bottom position in points */ + stp_dimension_t *top) /* O - Top position in points */ { internal_imageable_area(v, 1, left, right, bottom, top); } static void lexmark_limit(const stp_vars_t *v, /* I */ - int *width, - int *height, - int *min_width, - int *min_height) + stp_dimension_t *width, + stp_dimension_t *height, + stp_dimension_t *min_width, + stp_dimension_t *min_height) { const lexmark_cap_t * caps= lexmark_get_model_capabilities(stp_get_model_id(v)); *width = caps->max_paper_width; @@ -1597,15 +1598,16 @@ lexmark_do_print(stp_vars_t *v, stp_image_t *image) { int status = 1; int y; /* Looping vars */ - int xdpi, ydpi; /* Resolution */ - int n; /* Output number */ - int page_width, /* Width of page */ + stp_resolution_t xdpi, ydpi; /* Resolution */ + stp_dimension_t page_width, /* Width of page */ page_height, /* Length of page */ page_left, page_top, page_right, page_bottom, - page_true_height, /* True length of page */ + page_true_width, /* True length of page */ + page_true_height; /* True length of page */ + int out_width, /* Width of image on page in pixels */ out_height, /* Length of image on page */ length, /* Length of raster data in bytes*/ @@ -1652,8 +1654,8 @@ lexmark_do_print(stp_vars_t *v, stp_image_t *image) const char *print_mode = stp_get_string_parameter(v, "PrintingMode"); int printing_color = 0; const char *ink_type = stp_get_string_parameter(v, "InkType"); - int top = stp_get_top(v); - int left = stp_get_left(v); + stp_dimension_t top = stp_get_top(v); + stp_dimension_t left = stp_get_left(v); const lexmark_cap_t * caps= lexmark_get_model_capabilities(model); const lexmark_res_t *res_para_ptr = @@ -1712,7 +1714,7 @@ lexmark_do_print(stp_vars_t *v, stp_image_t *image) */ stp_describe_resolution(v, &xdpi, &ydpi); - stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: resolution=%dx%d\n",xdpi,ydpi); + stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: resolution=%dx%d\n",(int)xdpi,(int)ydpi); switch (res_para_ptr->resid) { case DPI300: @@ -1750,8 +1752,8 @@ densityDivisor /= 1.2; nozzle_separation = ydpi / physical_ydpi; horizontal_passes = xdpi / physical_xdpi; - stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: horizontal_passes %i, xdpi %i, physical_xdpi %i\n", - horizontal_passes, xdpi, physical_xdpi); + stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: horizontal_passes %i, xdpi %d, physical_xdpi %i\n", + horizontal_passes, (int)xdpi, physical_xdpi); @@ -1776,11 +1778,11 @@ densityDivisor /= 1.2; page_width = page_right - page_left; page_height = page_bottom - page_top; - stp_dprintf(STP_DBG_LEXMARK, v, "page_right %d, page_left %d, page_top %d, page_bottom %d, left %d, top %d\n",page_right, page_left, page_top, page_bottom,left, top); + stp_dprintf(STP_DBG_LEXMARK, v, "page_right %f, page_left %f, page_top %f, page_bottom %f, left %f, top %f\n",page_right, page_left, page_top, page_bottom,left, top); image_height = stp_image_height(image); - stp_default_media_size(v, &n, &page_true_height); + stp_default_media_size(v, &page_true_width, &page_true_height); lxm3200_linetoeject = (page_true_height * 1200) / 72; @@ -1798,11 +1800,11 @@ densityDivisor /= 1.2; out_height = ydpi * out_height / 72; - stp_dprintf(STP_DBG_LEXMARK, v, "border: left %d, x_raster_res %d, offset_left %d\n", left, caps->x_raster_res, caps->offset_left_border); + stp_dprintf(STP_DBG_LEXMARK, v, "border: left %f, x_raster_res %d, offset_left %d\n", left, caps->x_raster_res, caps->offset_left_border); left = ((caps->x_raster_res * left) / 72) + caps->offset_left_border; - stp_dprintf(STP_DBG_LEXMARK, v, "border: left %d\n", left); + stp_dprintf(STP_DBG_LEXMARK, v, "border: left %f\n", left); diff --git a/src/main/print-olympus.c b/src/main/print-olympus.c index acfc1d1..26ce9c8 100644 --- a/src/main/print-olympus.c +++ b/src/main/print-olympus.c @@ -73,9 +73,9 @@ #ifndef MAX # define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif /* !MAX */ -#define PX(pt,dpi) ((pt) * (dpi) / 72) -#define PT(px,dpi) ((px) * 72 / (dpi)) -#define PT1(px,dpi) (((px) * 72 / (dpi))+1) +#define PX(pt,dpi) (int)(((stp_dimension_t)(pt) * (stp_resolution_t)(dpi) / (stp_resolution_t)72) + 0.5f) +#define PT(px,dpi) ((stp_resolution_t)(px) * (stp_resolution_t)72 / (stp_dimension_t)(dpi)) +#define PT1 PT #define LIST(list_t, list_name, items_t, items_name) \ static const list_t list_name = \ { \ @@ -110,8 +110,8 @@ typedef struct { typedef struct { const char* name; - int w_dpi; - int h_dpi; + stp_resolution_t w_dpi; + stp_resolution_t h_dpi; } dyesub_resolution_t; typedef struct { @@ -122,12 +122,12 @@ typedef struct { typedef struct { const char* name; const char* text; - int width_pt; - int height_pt; - int border_pt_left; - int border_pt_right; - int border_pt_top; - int border_pt_bottom; + stp_dimension_t width_pt; + stp_dimension_t height_pt; + stp_dimension_t border_pt_left; + stp_dimension_t border_pt_right; + stp_dimension_t border_pt_top; + stp_dimension_t border_pt_bottom; int print_mode; } dyesub_pagesize_t; @@ -237,8 +237,8 @@ typedef struct /* Private data for dyesub driver as a whole */ typedef struct { - int w_dpi, h_dpi; - int w_size, h_size; + stp_resolution_t w_dpi, h_dpi; + stp_dimension_t w_size, h_size; char plane; int block_min_w, block_min_h; int block_max_w, block_max_h; @@ -5127,6 +5127,11 @@ static const dyesub_printsize_t fuji_ask300_printsize[] = LIST(dyesub_printsize_list_t, fuji_ask300_printsize_list, dyesub_printsize_t, fuji_ask300_printsize); +static void fuji_ask300_printer_init(stp_vars_t *v) +{ + mitsu_cpd70k60_printer_init(v, 0x80); +} + /* Shinko CHC-S9045 (experimental) */ static const dyesub_pagesize_t shinko_chcs9045_page[] = { @@ -7708,12 +7713,12 @@ static const dyesub_cap_t dyesub_model_capabilities[] = SHRT_MAX, #ifdef MITSU70X_8BPP DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT | DYESUB_FEATURE_PLANE_LEFTTORIGHT, - &mitsu_cpd70x_printer_init, NULL, + &fuji_ask300_printer_init, NULL, #else DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT | DYESUB_FEATURE_PLANE_INTERLACE | DYESUB_FEATURE_16BPP | DYESUB_FEATURE_BIGENDIAN, - &mitsu_cpd70x_printer_init, &mitsu_cpd70x_printer_end, + &fuji_ask300_printer_init, &mitsu_cpd70x_printer_end, #endif NULL, &mitsu_cpd70x_plane_end, NULL, NULL, /* No block funcs */ @@ -8477,8 +8482,8 @@ dyesub_current_pagesize(const stp_vars_t *v) static void dyesub_media_size(const stp_vars_t *v, - int *width, - int *height) + stp_dimension_t *width, + stp_dimension_t *height) { const dyesub_pagesize_t *p = dyesub_current_pagesize(v); stp_default_media_size(v, width, height); @@ -8492,13 +8497,13 @@ dyesub_media_size(const stp_vars_t *v, static void dyesub_imageable_area_internal(const stp_vars_t *v, int use_maximum_area, - int *left, - int *right, - int *bottom, - int *top, + stp_dimension_t *left, + stp_dimension_t *right, + stp_dimension_t *bottom, + stp_dimension_t *top, int *print_mode) { - int width, height; + stp_dimension_t width, height; const dyesub_pagesize_t *p = dyesub_current_pagesize(v); const dyesub_cap_t *caps = dyesub_get_model_capabilities( stp_get_model_id(v)); @@ -8529,10 +8534,10 @@ dyesub_imageable_area_internal(const stp_vars_t *v, static void dyesub_imageable_area(const stp_vars_t *v, - int *left, - int *right, - int *bottom, - int *top) + stp_dimension_t *left, + stp_dimension_t *right, + stp_dimension_t *bottom, + stp_dimension_t *top) { int not_used; dyesub_imageable_area_internal(v, 0, left, right, bottom, top, ¬_used); @@ -8540,10 +8545,10 @@ dyesub_imageable_area(const stp_vars_t *v, static void dyesub_maximum_imageable_area(const stp_vars_t *v, - int *left, - int *right, - int *bottom, - int *top) + stp_dimension_t *left, + stp_dimension_t *right, + stp_dimension_t *bottom, + stp_dimension_t *top) { int not_used; const int model = stp_get_model_id(v); @@ -8562,8 +8567,8 @@ dyesub_maximum_imageable_area(const stp_vars_t *v, static void dyesub_limit(const stp_vars_t *v, /* I */ - int *width, int *height, - int *min_width, int *min_height) + stp_dimension_t *width, stp_dimension_t *height, + stp_dimension_t *min_width, stp_dimension_t *min_height) { *width = SHRT_MAX; *height = SHRT_MAX; @@ -8572,7 +8577,8 @@ dyesub_limit(const stp_vars_t *v, /* I */ } static void -dyesub_describe_resolution(const stp_vars_t *v, int *x, int *y) +dyesub_describe_resolution(const stp_vars_t *v, + stp_resolution_t *x, stp_resolution_t *y) { const char *resolution = stp_get_string_parameter(v, "Resolution"); const dyesub_cap_t *caps = dyesub_get_model_capabilities( @@ -9001,22 +9007,23 @@ dyesub_do_print(stp_vars_t *v, stp_image_t *image) const dyesub_cap_t *caps = dyesub_get_model_capabilities(model); int max_print_px_width = 0; int max_print_px_height = 0; - int w_dpi, h_dpi; /* Resolution */ + int w_dpi, h_dpi; + stp_resolution_t wr_dpi, hr_dpi; /* Resolution */ /* output in 1/72" */ - int out_pt_width = stp_get_width(v); - int out_pt_height = stp_get_height(v); - int out_pt_left = stp_get_left(v); - int out_pt_top = stp_get_top(v); + stp_dimension_t out_pt_width = stp_get_width(v); + stp_dimension_t out_pt_height = stp_get_height(v); + stp_dimension_t out_pt_left = stp_get_left(v); + stp_dimension_t out_pt_top = stp_get_top(v); /* page in 1/72" */ - int page_pt_width = stp_get_page_width(v); - int page_pt_height = stp_get_page_height(v); - int page_pt_left = 0; - int page_pt_right = 0; - int page_pt_top = 0; - int page_pt_bottom = 0; - int page_mode; + stp_dimension_t page_pt_width = stp_get_page_width(v); + stp_dimension_t page_pt_height = stp_get_page_height(v); + stp_dimension_t page_pt_left = 0; + stp_dimension_t page_pt_right = 0; + stp_dimension_t page_pt_top = 0; + stp_dimension_t page_pt_bottom = 0; + int page_mode; int pl; @@ -9042,7 +9049,9 @@ dyesub_do_print(stp_vars_t *v, stp_image_t *image) pv.imgw_px = stp_image_width(image); pv.imgh_px = stp_image_height(image); - stp_describe_resolution(v, &w_dpi, &h_dpi); + stp_describe_resolution(v, &wr_dpi, &hr_dpi); + w_dpi = (int) wr_dpi; + h_dpi = (int) hr_dpi; dyesub_printsize(v, &max_print_px_width, &max_print_px_height); /* Duplex processing -- Rotate even pages for DuplexNoTumble */ @@ -9102,14 +9111,14 @@ dyesub_do_print(stp_vars_t *v, stp_image_t *image) dyesub_swap_ints(&w_dpi, &h_dpi); stp_deprintf(STP_DBG_DYESUB, - "paper (pt) %d x %d\n" + "paper (pt) %f x %f\n" "image (px) %d x %d\n" - "image (pt) %d x %d\n" - "* out (pt) %d x %d\n" + "image (pt) %f x %f\n" + "* out (pt) %f x %f\n" "* out (px) %d x %d\n" - "* left x top (pt) %d x %d\n" + "* left x top (pt) %f x %f\n" "* left x top (px) %d x %d\n" - "border (pt) (%d - %d) = %d x (%d - %d) = %d\n" + "border (pt) (%f - %f) = %f x (%f - %f) = %f\n" "printable pixels (px) %d x %d\n" "res (dpi) %d x %d\n", page_pt_width, page_pt_height, diff --git a/src/main/print-papers.c b/src/main/print-papers.c index 7ce254d..b5fb1e7 100644 --- a/src/main/print-papers.c +++ b/src/main/print-papers.c @@ -160,15 +160,15 @@ stp_get_papersize_by_index(int idx) } static int -paper_size_mismatch(int l, int w, const stp_papersize_t *val) +paper_size_mismatch(stp_dimension_t l, stp_dimension_t w, const stp_papersize_t *val) { - int hdiff = abs(l - (int) val->height); - int vdiff = abs(w - (int) val->width); + stp_dimension_t hdiff = abs(l - (stp_dimension_t) val->height); + stp_dimension_t vdiff = abs(w - (stp_dimension_t) val->width); return hdiff > vdiff ? hdiff : vdiff; } const stp_papersize_t * -stp_get_papersize_by_size(int l, int w) +stp_get_papersize_by_size(stp_dimension_t l, stp_dimension_t w) { int score = INT_MAX; const stp_papersize_t *ref = NULL; @@ -201,7 +201,7 @@ stp_get_papersize_by_size(int l, int w) } const stp_papersize_t * -stp_get_papersize_by_size_exact(int l, int w) +stp_get_papersize_by_size_exact(stp_dimension_t l, stp_dimension_t w) { const stp_papersize_t *ref = NULL; const stp_papersize_t *val = NULL; @@ -225,8 +225,8 @@ stp_get_papersize_by_size_exact(int l, int w) void stp_default_media_size(const stp_vars_t *v, /* I */ - int *width, /* O - Width in points */ - int *height) /* O - Height in points */ + stp_dimension_t *width, /* O - Width in points */ + stp_dimension_t *height) /* O - Height in points */ { if (stp_get_page_width(v) > 0 && stp_get_page_height(v) > 0) { @@ -326,7 +326,7 @@ stp_xml_process_paper(stp_mxml_node_t *paper) /* The paper node */ stmp = stp_mxmlElementGetAttr(prop, "value"); if (stmp) { - outpaper->width = stp_xmlstrtoul(stmp); + outpaper->width = stp_xmlstrtodim(stmp); width = 1; } } @@ -335,29 +335,29 @@ stp_xml_process_paper(stp_mxml_node_t *paper) /* The paper node */ stmp = stp_mxmlElementGetAttr(prop, "value"); if (stmp) { - outpaper->height = stp_xmlstrtoul(stmp); + outpaper->height = stp_xmlstrtodim(stmp); height = 1; } } if (!strcmp(prop_name, "left")) { stmp = stp_mxmlElementGetAttr(prop, "value"); - outpaper->left = stp_xmlstrtoul(stmp); + outpaper->left = stp_xmlstrtodim(stmp); } if (!strcmp(prop_name, "right")) { stmp = stp_mxmlElementGetAttr(prop, "value"); - outpaper->right = stp_xmlstrtoul(stmp); + outpaper->right = stp_xmlstrtodim(stmp); } if (!strcmp(prop_name, "bottom")) { stmp = stp_mxmlElementGetAttr(prop, "value"); - outpaper->bottom = stp_xmlstrtoul(stmp); + outpaper->bottom = stp_xmlstrtodim(stmp); } if (!strcmp(prop_name, "top")) { stmp = stp_mxmlElementGetAttr(prop, "value"); - outpaper->top = stp_xmlstrtoul(stmp); + outpaper->top = stp_xmlstrtodim(stmp); } if (!strcmp(prop_name, "unit")) { diff --git a/src/main/print-pcl.c b/src/main/print-pcl.c index 5ef206e..8752e58 100644 --- a/src/main/print-pcl.c +++ b/src/main/print-pcl.c @@ -1727,7 +1727,7 @@ pcl_get_model_capabilities(int model) /* I: Model */ */ static void -pcl_describe_resolution(const stp_vars_t *v, int *x, int *y) +pcl_describe_resolution(const stp_vars_t *v, stp_resolution_t *x, stp_resolution_t *y) { int i; int model = stp_get_model_id(v); @@ -1757,8 +1757,8 @@ pcl_describe_resolution(const stp_vars_t *v, int *x, int *y) if ((caps->resolutions & pcl_qualities[i].pcl_code) && !strcmp(quality, pcl_qualities[i].pcl_name)) { - *x = pcl_qualities[i].p0; - *y = pcl_qualities[i].p1; + *x = (stp_dimension_t) pcl_qualities[i].p0; + *y = (stp_dimension_t) pcl_qualities[i].p1; return; } } @@ -2272,20 +2272,20 @@ pcl_parameters(const stp_vars_t *v, const char *name, static void internal_imageable_area(const stp_vars_t *v, /* I */ int use_paper_margins, - int *left, /* O - Left position in points */ - int *right, /* O - Right position in points */ - int *bottom, /* O - Bottom position in points */ - int *top) /* O - Top position in points */ + stp_dimension_t *left, /* O - Left position in points */ + stp_dimension_t *right, /* O - Right position in points */ + stp_dimension_t *bottom, /* O - Bottom position in points */ + stp_dimension_t *top) /* O - Top position in points */ { - int width, height; /* Size of page */ + stp_dimension_t width, height; /* Size of page */ const pcl_cap_t *caps; /* Printer caps */ int pcl_media_size; /* Converted media size */ const char *media_size = stp_get_string_parameter(v, "PageSize"); const stp_papersize_t *pp = NULL; - int left_margin = 0; - int right_margin = 0; - int bottom_margin = 0; - int top_margin = 0; + stp_dimension_t left_margin = 0; + stp_dimension_t right_margin = 0; + stp_dimension_t bottom_margin = 0; + stp_dimension_t top_margin = 0; caps = pcl_get_model_capabilities(stp_get_model_id(v)); @@ -2339,20 +2339,20 @@ internal_imageable_area(const stp_vars_t *v, /* I */ static void pcl_imageable_area(const stp_vars_t *v, /* I */ - int *left, /* O - Left position in points */ - int *right, /* O - Right position in points */ - int *bottom, /* O - Bottom position in points */ - int *top) /* O - Top position in points */ + stp_dimension_t *left, /* O - Left position in points */ + stp_dimension_t *right, /* O - Right position in points */ + stp_dimension_t *bottom, /* O - Bottom position in points */ + stp_dimension_t *top) /* O - Top position in points */ { internal_imageable_area(v, 1, left, right, bottom, top); } static void pcl_limit(const stp_vars_t *v, /* I */ - int *width, - int *height, - int *min_width, - int *min_height) + stp_dimension_t *width, + stp_dimension_t *height, + stp_dimension_t *min_width, + stp_dimension_t *min_height) { const pcl_cap_t *caps= pcl_get_model_capabilities(stp_get_model_id(v)); *width = caps->custom_max_width; @@ -2368,7 +2368,7 @@ pcl_describe_output(const stp_vars_t *v) int model = stp_get_model_id(v); const pcl_cap_t *caps = pcl_get_model_capabilities(model); const char *print_mode = stp_get_string_parameter(v, "PrintingMode"); - int xdpi, ydpi; + stp_resolution_t xdpi, ydpi; pcl_describe_resolution(v, &xdpi, &ydpi); if (!print_mode || strcmp(print_mode, "Color") == 0) @@ -2531,21 +2531,21 @@ pcl_do_print(stp_vars_t *v, stp_image_t *image) double v_offset = get_double_param(v, "VertOffset"); int page_number = stp_get_int_parameter(v, "PageNumber"); int printing_color = 0; - int top = stp_get_top(v); - int left = stp_get_left(v); + int top = (int) stp_get_top(v) + .5; + int left = (int) stp_get_left(v) + .5; int y; /* Looping vars */ - int xdpi, ydpi; /* Resolution */ + stp_resolution_t xdpi, ydpi; /* Resolution */ unsigned char *black, /* Black bitmap data */ *cyan, /* Cyan bitmap data */ *magenta, /* Magenta bitmap data */ *yellow, /* Yellow bitmap data */ *lcyan, /* Light Cyan bitmap data */ *lmagenta; /* Light Magenta bitmap data */ - int page_left, - page_top, - page_right, - page_bottom, - out_width, /* Width of image on page */ + stp_dimension_t page_left, + page_top, + page_right, + page_bottom; + int out_width, /* Width of image on page */ out_height, /* Height of image on page */ errdiv, /* Error dividend */ errmod, /* Error modulus */ @@ -2589,7 +2589,7 @@ pcl_do_print(stp_vars_t *v, stp_image_t *image) pcl_describe_resolution(v, &xdpi, &ydpi); - stp_deprintf(STP_DBG_PCL,"pcl: resolution=%dx%d\n",xdpi,ydpi); + stp_deprintf(STP_DBG_PCL,"pcl: resolution=%dx%d\n",(int)xdpi,(int)ydpi); if (xdpi <= 0 || ydpi <= 0) { stp_eprintf(v, "No resolution found; cannot print.\n"); @@ -2633,8 +2633,8 @@ pcl_do_print(stp_vars_t *v, stp_image_t *image) * Compute the output size... */ - out_width = stp_get_width(v); - out_height = stp_get_height(v); + out_width = (int) stp_get_width(v) + .5; + out_height = (int) stp_get_height(v) + .5; internal_imageable_area(v, 0, &page_left, &page_right, &page_bottom, &page_top); @@ -2770,7 +2770,7 @@ pcl_do_print(stp_vars_t *v, stp_image_t *image) "@PJL SET PAPERLENGTH=%d\n" "@PJL SET VERTICALOFFSET=%d\n" "@PJL SET HORIZONTALOFFSET=%d\n" - "@PJL ENTER LANGUAGE=PCL\n", xdpi, out_width*10, + "@PJL ENTER LANGUAGE=PCL\n", (int) xdpi, out_width*10, out_height*10, privdata.v_offset, privdata.h_offset); if ( privdata.label_separator != 0) { @@ -2800,7 +2800,7 @@ pcl_do_print(stp_vars_t *v, stp_image_t *image) stp_zprintf(v, "\033&l%dA", pcl_media_size); /* Set media size we calculated above */ } - stp_zprintf(v, "\033&l%dP", stp_get_page_height(v) / 12); + stp_zprintf(v, "\033&l%dP", ((int) stp_get_page_height(v)) / 12); /* Length of "forms" in "lines" */ stp_puts("\033&l0L", v); /* Turn off perforation skip */ if (! label) { @@ -2978,7 +2978,7 @@ pcl_do_print(stp_vars_t *v, stp_image_t *image) } else { - stp_zprintf(v, "\033*t%dR", xdpi); /* Simple resolution */ + stp_zprintf(v, "\033*t%dR", (int) xdpi); /* Simple resolution */ if (printing_color) { if ((caps->color_type & PCL_COLOR_CMY) == PCL_COLOR_CMY) diff --git a/src/main/print-ps.c b/src/main/print-ps.c index 557f3a8..5a8ab9c 100644 --- a/src/main/print-ps.c +++ b/src/main/print-ps.c @@ -137,9 +137,9 @@ ps_option_to_param(stp_parameter_t *param, stp_mxml_node_t *option) break; case STP_PARAMETER_TYPE_DIMENSION: param->deflt.dimension = atoi(default_value); - param->bounds.dimension.upper = (int) upper_bound; - param->bounds.dimension.lower = (int) lower_bound; - stp_deprintf(STP_DBG_PS, " %d %d %d\n", + param->bounds.dimension.upper = (stp_dimension_t) upper_bound; + param->bounds.dimension.lower = (stp_dimension_t) lower_bound; + stp_deprintf(STP_DBG_PS, " %f %f %f\n", param->deflt.dimension, param->bounds.dimension.upper, param->bounds.dimension.lower); break; @@ -436,8 +436,8 @@ ps_parameters(const stp_vars_t *v, const char *name, static void ps_media_size_internal(const stp_vars_t *v, /* I */ - int *width, /* O - Width in points */ - int *height) /* O - Height in points */ + stp_dimension_t *width, /* O - Width in points */ + stp_dimension_t *height) /* O - Height in points */ { const char *pagesize = stp_get_string_parameter(v, "PageSize"); int status = check_ppd_file(v); @@ -466,12 +466,12 @@ ps_media_size_internal(const stp_vars_t *v, /* I */ } } - stp_dprintf(STP_DBG_PS, v, "dimensions %d %d\n", *width, *height); + stp_dprintf(STP_DBG_PS, v, "dimensions %f %f\n", *width, *height); return; } static void -ps_media_size(const stp_vars_t *v, int *width, int *height) +ps_media_size(const stp_vars_t *v, stp_dimension_t *width, stp_dimension_t *height) { #ifdef HAVE_LOCALE_H char *locale = stp_strdup(setlocale(LC_ALL, NULL)); @@ -491,12 +491,12 @@ ps_media_size(const stp_vars_t *v, int *width, int *height) static void ps_imageable_area_internal(const stp_vars_t *v, /* I */ int use_max_area, /* I - Use maximum area */ - int *left, /* O - Left position in points */ - int *right, /* O - Right position in points */ - int *bottom, /* O - Bottom position in points */ - int *top) /* O - Top position in points */ + stp_dimension_t *left, /* O - Left position in points */ + stp_dimension_t *right, /* O - Right position in points */ + stp_dimension_t *bottom, /* O - Bottom position in points */ + stp_dimension_t *top) /* O - Top position in points */ { - int width, height; + stp_dimension_t width, height; const char *pagesize = stp_get_string_parameter(v, "PageSize"); if (!pagesize) pagesize = ""; @@ -517,13 +517,13 @@ ps_imageable_area_internal(const stp_vars_t *v, /* I */ double pright = atoi(stp_mxmlElementGetAttr(paper, "right")); double ptop = atoi(stp_mxmlElementGetAttr(paper, "top")); double pbottom = atoi(stp_mxmlElementGetAttr(paper, "bottom")); - stp_dprintf(STP_DBG_PS, v, "size=l %f r %f b %f t %f h %d w %d\n", + stp_dprintf(STP_DBG_PS, v, "size=l %f r %f b %f t %f h %f w %f\n", pleft, pright, pbottom, ptop, height, width); - *left = (int) pleft; - *right = (int) pright; - *top = height - (int) ptop; - *bottom = height - (int) pbottom; - stp_dprintf(STP_DBG_PS, v, ">>>> l %d r %d b %d t %d h %d w %d\n", + *left = (stp_dimension_t) pleft; + *right = (stp_dimension_t) pright; + *top = height - (stp_dimension_t) ptop; + *bottom = height - (stp_dimension_t) pbottom; + stp_dprintf(STP_DBG_PS, v, ">>>> l %f r %f b %f t %f h %f w %f\n", *left, *right, *bottom, *top, height, width); } } @@ -540,7 +540,7 @@ ps_imageable_area_internal(const stp_vars_t *v, /* I */ *bottom = height; } - stp_dprintf(STP_DBG_PS, v, "pagesize %s max_area=%d l %d r %d b %d t %d h %d w %d\n", + stp_dprintf(STP_DBG_PS, v, "pagesize %s max_area=%d l %f r %f b %f t %f h %f w %f\n", pagesize ? pagesize : "(null)", use_max_area, *left, *right, *bottom, *top, width, height); @@ -549,10 +549,10 @@ ps_imageable_area_internal(const stp_vars_t *v, /* I */ static void ps_imageable_area(const stp_vars_t *v, /* I */ - int *left, /* O - Left position in points */ - int *right, /* O - Right position in points */ - int *bottom, /* O - Bottom position in points */ - int *top) /* O - Top position in points */ + stp_dimension_t *left, /* O - Left position in points */ + stp_dimension_t *right, /* O - Right position in points */ + stp_dimension_t *bottom, /* O - Bottom position in points */ + stp_dimension_t *top) /* O - Top position in points */ { #ifdef HAVE_LOCALE_H char *locale = stp_strdup(setlocale(LC_ALL, NULL)); @@ -567,10 +567,10 @@ ps_imageable_area(const stp_vars_t *v, /* I */ static void ps_maximum_imageable_area(const stp_vars_t *v, /* I */ - int *left, /* O - Left position in points */ - int *right, /* O - Right position in points */ - int *bottom, /* O - Bottom position in points */ - int *top) /* O - Top position in points */ + stp_dimension_t *left, /* O - Left position in points */ + stp_dimension_t *right, /* O - Right position in points */ + stp_dimension_t *bottom, /* O - Bottom position in points */ + stp_dimension_t *top) /* O - Top position in points */ { #ifdef HAVE_LOCALE_H char *locale = stp_strdup(setlocale(LC_ALL, NULL)); @@ -585,13 +585,13 @@ ps_maximum_imageable_area(const stp_vars_t *v, /* I */ static void ps_limit(const stp_vars_t *v, /* I */ - int *width, - int *height, - int *min_width, - int *min_height) + stp_dimension_t *width, + stp_dimension_t *height, + stp_dimension_t *min_width, + stp_dimension_t *min_height) { - *width = INT_MAX; - *height = INT_MAX; + *width = (stp_dimension_t) INT_MAX; + *height = (stp_dimension_t) INT_MAX; *min_width = 1; *min_height = 1; } @@ -600,18 +600,24 @@ ps_limit(const stp_vars_t *v, /* I */ * This is really bogus... */ static void -ps_describe_resolution_internal(const stp_vars_t *v, int *x, int *y) +ps_describe_resolution_internal(const stp_vars_t *v, stp_resolution_t *x, stp_resolution_t *y) { const char *resolution = stp_get_string_parameter(v, "Resolution"); *x = -1; *y = -1; if (resolution) - sscanf(resolution, "%dx%d", x, y); + { + int tx = -1; + int ty = -1; + sscanf(resolution, "%dx%d", &tx, &ty); + *x = (stp_resolution_t) tx; + *y = (stp_resolution_t) ty; + } return; } static void -ps_describe_resolution(const stp_vars_t *v, int *x, int *y) +ps_describe_resolution(const stp_vars_t *v, stp_resolution_t *x, stp_resolution_t *y) { #ifdef HAVE_LOCALE_H char *locale = stp_strdup(setlocale(LC_ALL, NULL)); @@ -744,11 +750,11 @@ ps_external_options(const stp_vars_t *v) if (stp_get_dimension_parameter(v, desc.name) != desc.deflt.dimension) { - stp_dprintf(STP_DBG_PS, v, "Adding dimension parameter %s (%s): %d %d\n", + stp_dprintf(STP_DBG_PS, v, "Adding dimension parameter %s (%s): %f %f\n", desc.name, ppd_name ? ppd_name : "(null)", stp_get_dimension_parameter(v, desc.name), desc.deflt.dimension); - stp_asprintf(&tmp, "%d", + stp_asprintf(&tmp, "%f", stp_get_dimension_parameter(v, desc.name)); stp_string_list_add_string(answer, ppd_name ? ppd_name : desc.name, @@ -870,7 +876,7 @@ ps_print_device_settings(stp_vars_t *v) if(stp_get_dimension_parameter(v,desc.name)!=desc.deflt.dimension) { stp_puts("[{\n", v); - stp_zprintf(v, "%%%%IncludeFeature: *%s %d\n", desc.name, + stp_zprintf(v, "%%%%IncludeFeature: *%s %f\n", desc.name, stp_get_dimension_parameter(v, desc.name)); stp_puts("} stopped cleartomark\n", v); } @@ -897,18 +903,18 @@ ps_print_internal(stp_vars_t *v, stp_image_t *image) const char *print_mode = stp_get_string_parameter(v, "PrintingMode"); const char *input_image_type = stp_get_string_parameter(v, "InputImageType"); unsigned short *out = NULL; - int top = stp_get_top(v); - int left = stp_get_left(v); + stp_dimension_t top = stp_get_top(v); + stp_dimension_t left = stp_get_left(v); int y; /* Looping vars */ - int page_left, /* Left margin of page */ + stp_dimension_t page_left, /* Left margin of page */ page_right, /* Right margin of page */ page_top, /* Top of page */ page_bottom, /* Bottom of page */ page_width, /* Width of page */ page_height, /* Height of page */ - paper_width, /* Width of physical page */ - paper_height, /* Height of physical page */ - out_width, /* Width of image on page */ + paper_width, /* Width of physical page */ + paper_height; /* Height of physical page */ + int out_width, /* Width of image on page */ out_height, /* Height of image on page */ out_channels, /* Output bytes per pixel */ out_ps_height, /* Output height (Level 2 output) */ @@ -955,13 +961,13 @@ ps_print_internal(stp_vars_t *v, stp_image_t *image) stp_dprintf(STP_DBG_PS, v, "out_width = %d, out_height = %d\n", out_width, out_height); stp_dprintf(STP_DBG_PS, v, - "page_left = %d, page_right = %d, page_bottom = %d, page_top = %d\n", + "page_left = %f, page_right = %f, page_bottom = %f, page_top = %f\n", page_left, page_right, page_bottom, page_top); - stp_dprintf(STP_DBG_PS, v, "left = %d, top = %d\n", left, top); - stp_dprintf(STP_DBG_PS, v, "page_width = %d, page_height = %d\n", + stp_dprintf(STP_DBG_PS, v, "left = %f, top = %f\n", left, top); + stp_dprintf(STP_DBG_PS, v, "page_width = %f, page_height = %f\n", page_width, page_height); - stp_dprintf(STP_DBG_PS, v, "bounding box l %d b %d r %d t %d\n", + stp_dprintf(STP_DBG_PS, v, "bounding box l %f b %f r %f t %f\n", page_left, paper_height - page_bottom, page_right, paper_height - page_top); @@ -973,7 +979,7 @@ ps_print_internal(stp_vars_t *v, stp_image_t *image) stp_zprintf(v, "%%%%Creator: %s/Gutenprint\n", stp_image_get_appname(image)); #endif stp_zprintf(v, "%%%%CreationDate: %s", ctime(&curtime)); - stp_zprintf(v, "%%%%BoundingBox: %d %d %d %d\n", + stp_zprintf(v, "%%%%BoundingBox: %f %f %f %f\n", page_left, paper_height - page_bottom, page_right, paper_height - page_top); stp_puts("%%DocumentData: Clean7Bit\n", v); @@ -991,7 +997,7 @@ ps_print_internal(stp_vars_t *v, stp_image_t *image) stp_puts("%%Page: 1 1\n", v); stp_puts("gsave\n", v); - stp_zprintf(v, "%d %d translate\n", left, top); + stp_zprintf(v, "%f %f translate\n", left, top); /* Force locale to "C", because decimal numbers in Postscript must always be printed with a decimal point rather than the diff --git a/src/main/print-raw.c b/src/main/print-raw.c index 766aa9f..131d095 100644 --- a/src/main/print-raw.c +++ b/src/main/print-raw.c @@ -175,10 +175,10 @@ raw_parameters(const stp_vars_t *v, const char *name, static void raw_imageable_area(const stp_vars_t *v, - int *left, - int *right, - int *bottom, - int *top) + stp_dimension_t *left, + stp_dimension_t *right, + stp_dimension_t *bottom, + stp_dimension_t *top) { *left = 0; *top = 0; @@ -188,8 +188,8 @@ raw_imageable_area(const stp_vars_t *v, static void raw_limit(const stp_vars_t *v, /* I */ - int *width, int *height, - int *min_width, int *min_height) + stp_dimension_t *width, stp_dimension_t *height, + stp_dimension_t *min_width, stp_dimension_t *min_height) { *width = 65535; *height = 65535; @@ -198,7 +198,8 @@ raw_limit(const stp_vars_t *v, /* I */ } static void -raw_describe_resolution(const stp_vars_t *v, int *x, int *y) +raw_describe_resolution(const stp_vars_t *v, + stp_resolution_t *x, stp_resolution_t *y) { *x = 72; *y = 72; diff --git a/src/main/print-vars.c b/src/main/print-vars.c index 515cb76..4526f71 100644 --- a/src/main/print-vars.c +++ b/src/main/print-vars.c @@ -48,6 +48,7 @@ typedef struct int ival; int bval; double dval; + stp_dimension_t sval; stp_curve_t *cval; stp_array_t *aval; stp_raw_t rval; @@ -66,12 +67,12 @@ struct stp_vars /* Plug-in variables */ { char *driver; /* Name of printer "driver" */ char *color_conversion; /* Color module in use */ - int left; /* Offset from left-upper corner, points */ - int top; /* ... */ - int width; /* Width of the image, points */ - int height; /* ... */ - int page_width; /* Width of page in points */ - int page_height; /* Height of page in points */ + stp_dimension_t left; /* Offset from left-upper corner, points */ + stp_dimension_t top; /* ... */ + stp_dimension_t width; /* Width of the image, points */ + stp_dimension_t height; /* ... */ + stp_dimension_t page_width; /* Width of page in points */ + stp_dimension_t page_height; /* Height of page in points */ stp_list_t *params[STP_PARAMETER_TYPE_INVALID]; stp_list_t *internal_data; void (*outfunc)(void *data, const char *buffer, size_t bytes); @@ -190,8 +191,10 @@ value_copy(const void *item) case STP_PARAMETER_TYPE_RAW: copy_to_raw(&(ret->value.rval), v->value.rval.data, v->value.rval.bytes); break; - case STP_PARAMETER_TYPE_INT: case STP_PARAMETER_TYPE_DIMENSION: + ret->value.sval = v->value.sval; + break; + case STP_PARAMETER_TYPE_INT: case STP_PARAMETER_TYPE_BOOLEAN: ret->value.ival = v->value.ival; break; @@ -411,12 +414,12 @@ pre##_get_##s(const stp_vars_t *v) \ DEF_STRING_FUNCS(driver, stp) DEF_STRING_FUNCS(color_conversion, stp) -DEF_FUNCS(left, int, stp) -DEF_FUNCS(top, int, stp) -DEF_FUNCS(width, int, stp) -DEF_FUNCS(height, int, stp) -DEF_FUNCS(page_width, int, stp) -DEF_FUNCS(page_height, int, stp) +DEF_FUNCS(left, stp_dimension_t, stp) +DEF_FUNCS(top, stp_dimension_t, stp) +DEF_FUNCS(width, stp_dimension_t, stp) +DEF_FUNCS(height, stp_dimension_t, stp) +DEF_FUNCS(page_width, stp_dimension_t, stp) +DEF_FUNCS(page_height, stp_dimension_t, stp) DEF_FUNCS(outdata, void *, stp) DEF_FUNCS(errdata, void *, stp) DEF_FUNCS(outfunc, stp_outfunc_t, stp) @@ -1012,13 +1015,13 @@ stp_get_boolean_parameter(const stp_vars_t *v, const char *parameter) } void -stp_set_dimension_parameter(stp_vars_t *v, const char *parameter, int ival) +stp_set_dimension_parameter(stp_vars_t *v, const char *parameter, stp_dimension_t sval) { stp_list_t *list = v->params[STP_PARAMETER_TYPE_DIMENSION]; value_t *val; stp_list_item_t *item = stp_list_get_item_by_name(list, parameter); - stp_deprintf(STP_DBG_VARS, "stp_set_dimension_parameter(0x%p, %s, %d)\n", - (const void *) v, parameter, ival); + stp_deprintf(STP_DBG_VARS, "stp_set_dimension_parameter(0x%p, %s, %f)\n", + (const void *) v, parameter, sval); if (item) { val = (value_t *) stp_list_item_get_data(item); @@ -1033,18 +1036,19 @@ stp_set_dimension_parameter(stp_vars_t *v, const char *parameter, int ival) val->active = STP_PARAMETER_ACTIVE; stp_list_item_create(list, NULL, val); } - val->value.ival = ival; + val->value.sval = sval; stp_set_verified(v, 0); } void -stp_set_default_dimension_parameter(stp_vars_t *v, const char *parameter, int ival) +stp_set_default_dimension_parameter(stp_vars_t *v, const char *parameter, + stp_dimension_t sval) { stp_list_t *list = v->params[STP_PARAMETER_TYPE_DIMENSION]; value_t *val; stp_list_item_t *item = stp_list_get_item_by_name(list, parameter); - stp_deprintf(STP_DBG_VARS, "stp_set_default_dimension_parameter(0x%p, %s, %d)\n", - (const void *) v, parameter, ival); + stp_deprintf(STP_DBG_VARS, "stp_set_default_dimension_parameter(0x%p, %s, %f)\n", + (const void *) v, parameter, sval); if (!item) { val = stp_malloc(sizeof(value_t)); @@ -1052,7 +1056,7 @@ stp_set_default_dimension_parameter(stp_vars_t *v, const char *parameter, int iv val->typ = STP_PARAMETER_TYPE_DIMENSION; val->active = STP_PARAMETER_DEFAULTED; stp_list_item_create(list, NULL, val); - val->value.ival = ival; + val->value.sval = sval; } stp_set_verified(v, 0); } @@ -1069,7 +1073,7 @@ stp_clear_dimension_parameter(stp_vars_t *v, const char *parameter) stp_set_verified(v, 0); } -int +stp_dimension_t stp_get_dimension_parameter(const stp_vars_t *v, const char *parameter) { const stp_list_t *list = v->params[STP_PARAMETER_TYPE_DIMENSION]; @@ -1077,7 +1081,7 @@ stp_get_dimension_parameter(const stp_vars_t *v, const char *parameter) if (item) { const value_t *val = (const value_t *) stp_list_item_get_data(item); - return val->value.ival; + return val->value.sval; } else { @@ -1085,7 +1089,7 @@ stp_get_dimension_parameter(const stp_vars_t *v, const char *parameter) stp_describe_parameter(v, parameter, &desc); if (desc.p_type == STP_PARAMETER_TYPE_DIMENSION) { - int intval = desc.deflt.integer; + stp_dimension_t intval = desc.deflt.dimension; stp_parameter_description_destroy(&desc); return intval; } @@ -1471,9 +1475,9 @@ stpi_vars_print_error(const stp_vars_t *v, const char *prefix) }; stp_erprintf("%s: Gutenprint: === BEGIN GUTENPRINT SETTINGS ===\n", prefix); stp_erprintf("%s: Gutenprint: Driver: %s\n", prefix, stp_get_driver(v)); - stp_erprintf("%s: Gutenprint: L: %d T: %d W: %d H: %d\n", prefix, stp_get_left(v), + stp_erprintf("%s: Gutenprint: L: %f T: %f W: %f H: %f\n", prefix, stp_get_left(v), stp_get_top(v), stp_get_width(v), stp_get_height(v)); - stp_erprintf("%s: Gutenprint: Page: %dx%d\n", prefix, stp_get_page_width(v), + stp_erprintf("%s: Gutenprint: Page: %fx%f\n", prefix, stp_get_page_width(v), stp_get_page_height(v)); stp_erprintf("%s: Gutenprint: Conversion: %s\n", prefix, stp_get_color_conversion(v)); for (i = 0; i < STP_PARAMETER_TYPE_INVALID; i++) @@ -1513,8 +1517,12 @@ stpi_vars_print_error(const stp_vars_t *v, const char *prefix) if (crep) stp_free(crep); break; - case STP_PARAMETER_TYPE_INT: case STP_PARAMETER_TYPE_DIMENSION: + stp_erprintf("%s: Gutenprint: (%s) (%i) (%s) [%f]\n", prefix, + val->name, val->active, data_types[val->typ], + val->value.sval); + break; + case STP_PARAMETER_TYPE_INT: case STP_PARAMETER_TYPE_BOOLEAN: stp_erprintf("%s: Gutenprint: (%s) (%i) (%s) [%d]\n", prefix, val->name, val->active, data_types[val->typ], @@ -1634,7 +1642,7 @@ debug_print_parameter_description(const stp_parameter_t *desc, const char *who, break; case STP_PARAMETER_TYPE_DIMENSION: stp_deprintf(STP_DBG_VARS, - " Dimension default: %d Bounds: %d %d\n", + " Dimension default: %f Bounds: %f %f\n", desc->deflt.dimension, desc->bounds.dimension.lower, desc->bounds.dimension.upper); break; @@ -2002,10 +2010,10 @@ fill_vars_from_xmltree(stp_mxml_node_t *prop, stp_mxml_node_t *root, if (cnode->type == STP_MXML_TEXT) { stp_set_dimension_parameter - (v, p_name, (int) stp_xmlstrtol(cnode->value.text.string)); + (v, p_name, (int) stp_xmlstrtodim(cnode->value.text.string)); type = STP_PARAMETER_TYPE_DOUBLE; if (stp_get_debug_level() & STP_DBG_XML) - stp_deprintf(STP_DBG_XML, " Set dimension '%s' to '%s' (%d)\n", + stp_deprintf(STP_DBG_XML, " Set dimension '%s' to '%s' (%f)\n", p_name, cnode->value.text.string, stp_get_dimension_parameter(v, p_name)); } @@ -2276,7 +2284,7 @@ stp_xmltree_create_from_vars(const stp_vars_t *v) break; case STP_PARAMETER_TYPE_DIMENSION: stp_mxmlElementSetAttr(node, "type", "dimension"); - stp_mxmlNewInteger(node, stp_get_dimension_parameter(v, name)); + stp_mxmlNewDimension(node, stp_get_dimension_parameter(v, name)); break; default: stp_mxmlElementSetAttr(node, "type", "INVALID!"); diff --git a/src/main/printers.c b/src/main/printers.c index 9722bd4..d9fb458 100644 --- a/src/main/printers.c +++ b/src/main/printers.c @@ -452,7 +452,7 @@ stp_printer_get_defaults(const stp_printer_t *printer) } void -stp_get_media_size(const stp_vars_t *v, int *width, int *height) +stp_get_media_size(const stp_vars_t *v, stp_dimension_t *width, stp_dimension_t *height) { const stp_printfuncs_t *printfuncs = stpi_get_printfuncs(stp_get_printer(v)); @@ -461,7 +461,8 @@ stp_get_media_size(const stp_vars_t *v, int *width, int *height) void stp_get_imageable_area(const stp_vars_t *v, - int *left, int *right, int *bottom, int *top) + stp_dimension_t *left, stp_dimension_t *right, + stp_dimension_t *bottom, stp_dimension_t *top) { const stp_printfuncs_t *printfuncs = stpi_get_printfuncs(stp_get_printer(v)); @@ -470,7 +471,8 @@ stp_get_imageable_area(const stp_vars_t *v, void stp_get_maximum_imageable_area(const stp_vars_t *v, - int *left, int *right, int *bottom, int *top) + stp_dimension_t *left, stp_dimension_t *right, + stp_dimension_t *bottom, stp_dimension_t *top) { const stp_printfuncs_t *printfuncs = stpi_get_printfuncs(stp_get_printer(v)); @@ -478,8 +480,9 @@ stp_get_maximum_imageable_area(const stp_vars_t *v, } void -stp_get_size_limit(const stp_vars_t *v, int *max_width, int *max_height, - int *min_width, int *min_height) +stp_get_size_limit(const stp_vars_t *v, + stp_dimension_t *max_width, stp_dimension_t *max_height, + stp_dimension_t *min_width, stp_dimension_t *min_height) { const stp_printfuncs_t *printfuncs = stpi_get_printfuncs(stp_get_printer(v)); @@ -487,7 +490,7 @@ stp_get_size_limit(const stp_vars_t *v, int *max_width, int *max_height, } void -stp_describe_resolution(const stp_vars_t *v, int *x, int *y) +stp_describe_resolution(const stp_vars_t *v, stp_resolution_t *x, stp_resolution_t *y) { const stp_printfuncs_t *printfuncs = stpi_get_printfuncs(stp_get_printer(v)); @@ -660,18 +663,18 @@ verify_int_param(const stp_vars_t *v, const char *parameter, static int verify_dimension_param(const stp_vars_t *v, const char *parameter, - stp_parameter_t *desc, int quiet) + stp_parameter_t *desc, int quiet) { stp_dprintf(STP_DBG_VARS, v, " Verifying dimension %s\n", parameter); if (desc->is_mandatory || stp_check_dimension_parameter(v, parameter, STP_PARAMETER_ACTIVE)) { - int checkval = stp_get_dimension_parameter(v, parameter); + stp_dimension_t checkval = stp_get_dimension_parameter(v, parameter); if (checkval < desc->bounds.dimension.lower || checkval > desc->bounds.dimension.upper) { if (!quiet) - stp_eprintf(v, _("%s must be between %d and %d (is %d)\n"), + stp_eprintf(v, _("%s must be between %f and %f (is %f)\n"), parameter, desc->bounds.dimension.lower, desc->bounds.dimension.upper, checkval); stp_parameter_description_destroy(desc); @@ -816,7 +819,7 @@ stp_verify_printer_params(stp_vars_t *v) int nparams; int i; int answer = 1; - int left, top, bottom, right; + stp_dimension_t left, top, bottom, right; const char *pagesize = stp_get_string_parameter(v, "PageSize"); stp_dprintf(STP_DBG_VARS, v, "** Entering stp_verify_printer_params(0x%p)\n", @@ -835,7 +838,7 @@ stp_verify_printer_params(stp_vars_t *v) } else { - int width, height, min_height, min_width; + stp_dimension_t width, height, min_height, min_width; stp_get_size_limit(v, &width, &height, &min_width, &min_height); if (stp_get_page_height(v) <= min_height || stp_get_page_height(v) > height || @@ -845,7 +848,7 @@ stp_verify_printer_params(stp_vars_t *v) stp_eprintf(v, _("Page size is not valid\n")); } stp_dprintf(STP_DBG_PAPER, v, - "page size max %d %d min %d %d actual %d %d\n", + "page size max %f %f min %f %f actual %f %f\n", width, height, min_width, min_height, stp_get_page_width(v), stp_get_page_height(v)); } @@ -853,23 +856,23 @@ stp_verify_printer_params(stp_vars_t *v) stp_get_imageable_area(v, &left, &right, &bottom, &top); stp_dprintf(STP_DBG_PAPER, v, - "page left %d top %d right %d bottom %d\n", + "page left %f top %f right %f bottom %f\n", left, top, right, bottom); stp_dprintf(STP_DBG_PAPER, v, - "requested left %d top %d width %d height %d\n", + "requested left %f top %f width %f height %f\n", stp_get_left(v), stp_get_top(v), stp_get_width(v), stp_get_height(v)); if (stp_get_top(v) < top) { answer = 0; - stp_eprintf(v, _("Top margin must not be less than %d\n"), top); + stp_eprintf(v, _("Top margin must not be less than %f\n"), top); } if (stp_get_left(v) < left) { answer = 0; - stp_eprintf(v, _("Left margin must not be less than %d\n"), left); + stp_eprintf(v, _("Left margin must not be less than %f\n"), left); } if (stp_get_height(v) <= 0) @@ -887,14 +890,14 @@ stp_verify_printer_params(stp_vars_t *v) if (stp_get_left(v) + stp_get_width(v) > right) { answer = 0; - stp_eprintf(v, _("Image is too wide for the page: left margin is %d, width %d, right edge is %d\n"), + stp_eprintf(v, _("Image is too wide for the page: left margin is %f, width %f, right edge is %f\n"), stp_get_left(v), stp_get_width(v), right); } if (stp_get_top(v) + stp_get_height(v) > bottom) { answer = 0; - stp_eprintf(v, _("Image is too long for the page: top margin is %d, height %d, bottom edge is %d\n"), + stp_eprintf(v, _("Image is too long for the page: top margin is %f, height %f, bottom edge is %f\n"), stp_get_top(v), stp_get_height(v), bottom); } diff --git a/src/main/xml.c b/src/main/xml.c index a630902..c4c92f4 100644 --- a/src/main/xml.c +++ b/src/main/xml.c @@ -336,6 +336,18 @@ stp_xmlstrtod(const char *textval) } /* + * Convert a text string into a dimension. + */ +stp_dimension_t +stp_xmlstrtodim(const char *textval) +{ + double val; /* The value to return */ + val = (stp_dimension_t) strtod(textval, (char **)NULL); + + return val; +} + +/* * Convert an encoded text string into a raw. */ stp_raw_t * |