From 960d46981a03e44added629cde4a89b5669de6b8 Mon Sep 17 00:00:00 2001 From: hooper114 Date: Sat, 20 Dec 2008 15:21:04 +0000 Subject: [PATCH] Added scale value to change size of output image --- backend/library.c | 1 + backend/png.c | 128 +++++++++++++++++----------------- backend/ps.c | 171 +++++++++++++++++++++++----------------------- backend/zint.h | 1 + 4 files changed, 153 insertions(+), 148 deletions(-) diff --git a/backend/library.c b/backend/library.c index 858d6083..1b77297f 100644 --- a/backend/library.c +++ b/backend/library.c @@ -42,6 +42,7 @@ struct zint_symbol *ZBarcode_Create() strcpy(symbol->fgcolour, "000000"); strcpy(symbol->bgcolour, "ffffff"); strcpy(symbol->outfile, "out.png"); + symbol->scale = 1.0; symbol->option_1 = -1; symbol->option_2 = 0; symbol->option_3 = 928; // PDF_MAX diff --git a/backend/png.c b/backend/png.c index d2fc801d..d35d25fb 100644 --- a/backend/png.c +++ b/backend/png.c @@ -114,6 +114,7 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c strcpy(symbol->errtxt, "Can't open output file [B5]"); return ERROR_FILE_ACCESS; } + /* graphic->outfile = stdout; */ /* Set up error handling routine as proc() above */ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, graphic, @@ -276,12 +277,12 @@ void draw_bar(char *pixelbuf, int xpos, int xlen, int ypos, int ylen, int image_ /* Draw a rectangle */ int i, j, png_ypos; - png_ypos = (image_height / 2) - ypos - ylen; + png_ypos = image_height - ypos - ylen; /* This fudge is needed because EPS measures height from the bottom up but PNG measures y position from the top down */ - for(i = (xpos * 2); i < (2 * (xpos + xlen)); i++) { - for( j = (png_ypos * 2); j < (2 * (png_ypos + ylen)); j++) { + for(i = (xpos); i < (xpos + xlen); i++) { + for( j = (png_ypos); j < (png_ypos + ylen); j++) { *(pixelbuf + (image_width * j) + i) = '1'; } } @@ -418,6 +419,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle) int this_row, block_width, plot_height, plot_yposn, textpos; float row_height, row_posn; int error_number; + int scaler = (int)(2 * symbol->scale); textdone = 0; main_width = symbol->width; @@ -499,8 +501,8 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle) } xoffset = symbol->border_width + symbol->whitespace_width; yoffset = symbol->border_width; - image_width = 2 * (symbol->width + xoffset + xoffset); - image_height = 2 * (symbol->height + textoffset + yoffset + yoffset); + image_width = scaler * (symbol->width + xoffset + xoffset); + image_height = scaler * (symbol->height + textoffset + yoffset + yoffset); if (!(pixelbuf = (char *) malloc(image_width * image_height))) { printf("Insifficient memory for pixel buffer [BA]"); @@ -552,7 +554,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle) } if(latch == 1) { /* a bar */ - draw_bar(pixelbuf, (i + xoffset), block_width, plot_yposn, plot_height, image_width, image_height); + draw_bar(pixelbuf, (i + xoffset) * scaler, block_width * scaler, plot_yposn * scaler, plot_height * scaler, image_width, image_height); latch = 0; } else { /* a space */ @@ -571,33 +573,33 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle) case 8: /* EAN-8 */ case 11: case 14: - draw_bar(pixelbuf, (0 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); - draw_bar(pixelbuf, (2 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); - draw_bar(pixelbuf, (32 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); - draw_bar(pixelbuf, (34 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); - draw_bar(pixelbuf, (64 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); - draw_bar(pixelbuf, (66 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); + draw_bar(pixelbuf, (0 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); + draw_bar(pixelbuf, (2 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); + draw_bar(pixelbuf, (32 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); + draw_bar(pixelbuf, (34 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); + draw_bar(pixelbuf, (64 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); + draw_bar(pixelbuf, (66 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); for(i = 0; i < 4; i++) { textpart[i] = symbol->text[i]; } textpart[4] = '\0'; - textpos = 2 * (17 + xoffset); + textpos = scaler * (17 + xoffset); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); for(i = 0; i < 4; i++) { textpart[i] = symbol->text[i + 4]; } textpart[4] = '\0'; - textpos = 2 * (50 + xoffset); + textpos = scaler * (50 + xoffset); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); textdone = 1; switch(strlen(addon)) { case 2: - textpos = 2 * (symbol->width + xoffset - 10); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); + textpos = scaler * (symbol->width + xoffset - 10); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height); break; case 5: - textpos = 2 * (symbol->width + xoffset - 23); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); + textpos = scaler * (symbol->width + xoffset - 23); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height); break; } @@ -605,38 +607,38 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle) case 13: /* EAN 13 */ case 16: case 19: - draw_bar(pixelbuf, (0 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); - draw_bar(pixelbuf, (2 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); - draw_bar(pixelbuf, (46 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); - draw_bar(pixelbuf, (48 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); - draw_bar(pixelbuf, (92 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); - draw_bar(pixelbuf, (94 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); + draw_bar(pixelbuf, (0 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); + draw_bar(pixelbuf, (2 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); + draw_bar(pixelbuf, (46 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); + draw_bar(pixelbuf, (48 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); + draw_bar(pixelbuf, (92 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); + draw_bar(pixelbuf, (94 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); textpart[0] = symbol->text[0]; textpart[1] = '\0'; - textpos = 2 * (-7 + xoffset); + textpos = scaler * (-7 + xoffset); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); for(i = 0; i < 6; i++) { textpart[i] = symbol->text[i + 1]; } textpart[6] = '\0'; - textpos = 2 * (24 + xoffset); + textpos = scaler * (24 + xoffset); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); for(i = 0; i < 6; i++) { textpart[i] = symbol->text[i + 7]; } textpart[6] = '\0'; - textpos = 2 * (71 + xoffset); + textpos = scaler * (71 + xoffset); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); textdone = 1; switch(strlen(addon)) { case 2: - textpos = 2 * (symbol->width + xoffset - 10); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); + textpos = scaler * (symbol->width + xoffset - 10); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height); break; case 5: - textpos = 2 * (symbol->width + xoffset - 23); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); + textpos = scaler * (symbol->width + xoffset - 23); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height); break; } break; @@ -656,7 +658,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle) } while (symbol->encoded_data[symbol->rows - 1][i + block_width] == symbol->encoded_data[symbol->rows - 1][i]); if(latch == 1) { /* a bar */ - draw_bar(pixelbuf, (i + xoffset - comp_offset), block_width, (4 + (int)yoffset), 5, image_width, image_height); + draw_bar(pixelbuf, (i + xoffset - comp_offset) * scaler, block_width * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); latch = 0; } else { /* a space */ @@ -664,8 +666,8 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle) } i += block_width; } while (i < 11 + comp_offset); - draw_bar(pixelbuf, (46 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); - draw_bar(pixelbuf, (48 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); + draw_bar(pixelbuf, (46 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); + draw_bar(pixelbuf, (48 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); latch = 1; i = 85 + comp_offset; do { @@ -675,7 +677,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle) } while (symbol->encoded_data[symbol->rows - 1][i + block_width] == symbol->encoded_data[symbol->rows - 1][i]); if(latch == 1) { /* a bar */ - draw_bar(pixelbuf, (i + xoffset - comp_offset), block_width, (4 + (int)yoffset), 5, image_width, image_height); + draw_bar(pixelbuf, (i + xoffset - comp_offset) * scaler, block_width * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); latch = 0; } else { /* a space */ @@ -685,33 +687,33 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle) } while (i < 96 + comp_offset); textpart[0] = symbol->text[0]; textpart[1] = '\0'; - textpos = 2 * (-5 + xoffset); + textpos = scaler * (-5 + xoffset); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); for(i = 0; i < 5; i++) { textpart[i] = symbol->text[i + 1]; } textpart[5] = '\0'; - textpos = 2 * (27 + xoffset); + textpos = scaler * (27 + xoffset); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); for(i = 0; i < 5; i++) { textpart[i] = symbol->text[i + 6]; } textpart[6] = '\0'; - textpos = 2 * (68 + xoffset); + textpos = scaler * (68 + xoffset); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); textpart[0] = symbol->text[11]; textpart[1] = '\0'; - textpos = 2 * (100 + xoffset); + textpos = scaler * (100 + xoffset); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); textdone = 1; switch(strlen(addon)) { case 2: - textpos = 2 * (symbol->width + xoffset - 10); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); + textpos = scaler * (symbol->width + xoffset - 10); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height); break; case 5: - textpos = 2 * (symbol->width + xoffset - 23); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); + textpos = scaler * (symbol->width + xoffset - 23); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height); break; } @@ -719,35 +721,35 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle) if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) { /* guard bar extensions and text formatting for UPCE */ - draw_bar(pixelbuf, (0 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); - draw_bar(pixelbuf, (2 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); - draw_bar(pixelbuf, (46 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); - draw_bar(pixelbuf, (48 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); - draw_bar(pixelbuf, (50 + xoffset), 1, (4 + (int)yoffset), 5, image_width, image_height); + draw_bar(pixelbuf, (0 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); + draw_bar(pixelbuf, (2 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); + draw_bar(pixelbuf, (46 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); + draw_bar(pixelbuf, (48 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); + draw_bar(pixelbuf, (50 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height); textpart[0] = symbol->text[0]; textpart[1] = '\0'; - textpos = 2 * (-5 + xoffset); + textpos = scaler * (-5 + xoffset); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); for(i = 0; i < 6; i++) { textpart[i] = symbol->text[i + 1]; } textpart[6] = '\0'; - textpos = 2 * (24 + xoffset); + textpos = scaler * (24 + xoffset); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); textpart[0] = symbol->text[7]; textpart[1] = '\0'; - textpos = 2 * (55 + xoffset); + textpos = scaler * (55 + xoffset); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); textdone = 1; switch(strlen(addon)) { case 2: - textpos = 2 * (symbol->width + xoffset - 10); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); + textpos = scaler * (symbol->width + xoffset - 10); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height); break; case 5: - textpos = 2 * (symbol->width + xoffset - 23); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); + textpos = scaler * (symbol->width + xoffset - 23); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height); break; } @@ -759,22 +761,22 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle) if ((symbol->output_options == BARCODE_BOX) || (symbol->output_options == BARCODE_BIND)) { if(symbol->symbology != BARCODE_CODABLOCKF) { /* boundary bars */ - draw_bar(pixelbuf, 0, (symbol->width + xoffset + xoffset), textoffset, symbol->border_width, image_width, image_height); - draw_bar(pixelbuf, 0, (symbol->width + xoffset + xoffset), (textoffset + symbol->height + symbol->border_width), symbol->border_width, image_width, image_height); + draw_bar(pixelbuf, 0, (symbol->width + xoffset + xoffset) * scaler, textoffset * scaler, symbol->border_width * scaler, image_width, image_height); + draw_bar(pixelbuf, 0, (symbol->width + xoffset + xoffset) * scaler, (textoffset + symbol->height + symbol->border_width) * scaler, symbol->border_width * scaler, image_width, image_height); if(symbol->rows > 1) { /* row binding */ for(r = 1; r < symbol->rows; r++) { - draw_bar(pixelbuf, xoffset, symbol->width, ((r * row_height) + textoffset + yoffset - 1), 2, image_width, image_height); + draw_bar(pixelbuf, xoffset * scaler, symbol->width * scaler, ((r * row_height) + textoffset + yoffset - 1) * scaler, 2 * scaler, image_width, image_height); } } } else { /* boundary bars */ - draw_bar(pixelbuf, xoffset, symbol->width, textoffset, symbol->border_width, image_width, image_height); - draw_bar(pixelbuf, xoffset, symbol->width, (textoffset + symbol->height + symbol->border_width), symbol->border_width, image_width, image_height); + draw_bar(pixelbuf, xoffset * scaler, symbol->width * scaler, textoffset * scaler, symbol->border_width * scaler, image_width, image_height); + draw_bar(pixelbuf, xoffset * scaler, symbol->width * scaler, (textoffset + symbol->height + symbol->border_width) * scaler, symbol->border_width * scaler, image_width, image_height); if(symbol->rows > 1) { /* row binding */ for(r = 1; r < symbol->rows; r++) { - draw_bar(pixelbuf, (xoffset + 11), (symbol->width - 24), ((r * row_height) + textoffset + yoffset - 1), 2, image_width, image_height); + draw_bar(pixelbuf, (xoffset + 11) * scaler, (symbol->width - 24) * scaler, ((r * row_height) + textoffset + yoffset - 1) * scaler, 2 * scaler, image_width, image_height); } } } @@ -782,8 +784,8 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle) if (symbol->output_options == BARCODE_BOX) { /* side bars */ - draw_bar(pixelbuf, 0, symbol->border_width, textoffset, symbol->height + (2 * symbol->border_width), image_width, image_height); - draw_bar(pixelbuf, (symbol->width + xoffset + xoffset - symbol->border_width), symbol->border_width, textoffset, symbol->height + (2 * symbol->border_width), image_width, image_height); + draw_bar(pixelbuf, 0, symbol->border_width * scaler, textoffset * scaler, (symbol->height + (2 * symbol->border_width)) * scaler, image_width, image_height); + draw_bar(pixelbuf, (symbol->width + xoffset + xoffset - symbol->border_width) * scaler, symbol->border_width * scaler, textoffset * scaler, (symbol->height + (2 * symbol->border_width)) * scaler, image_width, image_height); } /* Put the human readable text at the bottom */ diff --git a/backend/ps.c b/backend/ps.c index 124f5066..45b59999 100644 --- a/backend/ps.c +++ b/backend/ps.c @@ -42,6 +42,7 @@ int ps_plot(struct zint_symbol *symbol) char textpart[10], addon[6]; int large_bar_count, comp_offset; float addon_text_posn; + float scaler = symbol->scale; row_height=0; textdone = 0; @@ -176,9 +177,9 @@ int ps_plot(struct zint_symbol *symbol) } fprintf(feps, "%%%%Pages: 0\n"); if(symbol->symbology != BARCODE_MAXICODE) { - fprintf(feps, "%%%%BoundingBox: 0 0 %d %d\n", (symbol->width + xoffset + xoffset), (symbol->height + textoffset + yoffset + yoffset)); + fprintf(feps, "%%%%BoundingBox: 0 0 %d %d\n", (int)((symbol->width + xoffset + xoffset) * scaler), (int)((symbol->height + textoffset + yoffset + yoffset) * scaler)); } else { - fprintf(feps, "%%%%BoundingBox: 0 0 74 72\n"); + fprintf(feps, "%%%%BoundingBox: 0 0 %d %d\n", (int)(74.0 * scaler), (int)(72.0 * scaler)); } fprintf(feps, "%%%%EndComments\n"); @@ -195,7 +196,7 @@ int ps_plot(struct zint_symbol *symbol) /* Now the actual representation */ fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_paper, green_paper, blue_paper); - fprintf(feps, "%d.00 0.00 TB 0.00 %d.00 TR\n", (symbol->height + textoffset + yoffset + yoffset), symbol->width + xoffset + xoffset); + fprintf(feps, "%.2f 0.00 TB 0.00 %.2f TR\n", (symbol->height + textoffset + yoffset + yoffset) * scaler, (symbol->width + xoffset + xoffset) * scaler); if(symbol->symbology == BARCODE_MAXICODE) { @@ -205,9 +206,9 @@ int ps_plot(struct zint_symbol *symbol) fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); - fprintf(feps, "35.76 35.60 10.85 35.76 35.60 8.97 44.73 35.60 TC\n"); - fprintf(feps, "35.76 35.60 7.10 35.76 35.60 5.22 40.98 35.60 TC\n"); - fprintf(feps, "35.76 35.60 3.31 35.76 35.60 1.43 37.19 35.60 TC\n"); + fprintf(feps, "%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f TC\n", 35.76 * scaler, 35.60 * scaler, 10.85 * scaler, 35.76 * scaler, 35.60 * scaler, 8.97 * scaler, 44.73 * scaler, 35.60 * scaler); + fprintf(feps, "%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f TC\n", 35.76 * scaler, 35.60 * scaler, 7.10 * scaler, 35.76 * scaler, 35.60 * scaler, 5.22 * scaler, 40.98 * scaler, 35.60 * scaler); + fprintf(feps, "%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f TC\n", 35.76 * scaler, 35.60 * scaler, 3.31 * scaler, 35.76 * scaler, 35.60 * scaler, 1.43 * scaler, 37.19 * scaler, 35.60 * scaler); for(r = 0; r < symbol->rows; r++) { for(i = 0; i < symbol->width; i++) { if(symbol->encoded_data[r][i] == '1') { @@ -230,7 +231,7 @@ int ps_plot(struct zint_symbol *symbol) dx = mx; ex = mx - 0.86; fx = mx - 0.86; - fprintf(feps, "%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f TH\n", ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy); + fprintf(feps, "%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f TH\n", ax * scaler, ay * scaler, bx * scaler, by * scaler, cx * scaler, cy * scaler, dx * scaler, dy * scaler, ex * scaler, ey * scaler, fx * scaler, fy * scaler); } } } @@ -260,7 +261,7 @@ int ps_plot(struct zint_symbol *symbol) fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); - fprintf(feps, "%.2f %.2f ", row_height, row_posn); + fprintf(feps, "%.2f %.2f ", row_height * scaler, row_posn * scaler); i = 0; if(symbol->encoded_data[this_row][0] == '1') { latch = 1; @@ -276,13 +277,13 @@ int ps_plot(struct zint_symbol *symbol) if((addon_latch == 0) && (r == 0) && (i > main_width)) { fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); - fprintf(feps, "%.2f %.2f ", (row_height - 5.0), (row_posn - 5.0)); + fprintf(feps, "%.2f %.2f ", (row_height - 5.0) * scaler, (row_posn - 5.0) * scaler); addon_text_posn = row_posn + row_height - 8.0; addon_latch = 1; } if(latch == 1) { /* a bar */ - fprintf(feps, "TB %d.00 %d.00 TR\n", i + xoffset, block_width); + fprintf(feps, "TB %.2f %.2f TR\n", (i + xoffset) * scaler, block_width * scaler); latch = 0; } else { /* a space */ @@ -305,13 +306,13 @@ int ps_plot(struct zint_symbol *symbol) case 14: fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); - fprintf(feps, "%.2f %.2f ", 5.0, 4.0 + yoffset); - fprintf(feps, "TB %d.00 %d.00 TR\n", 0 + xoffset, 1); - fprintf(feps, "TB %d.00 %d.00 TR\n", 2 + xoffset, 1); - fprintf(feps, "TB %d.00 %d.00 TR\n", 32 + xoffset, 1); - fprintf(feps, "TB %d.00 %d.00 TR\n", 34 + xoffset, 1); - fprintf(feps, "TB %d.00 %d.00 TR\n", 64 + xoffset, 1); - fprintf(feps, "TB %d.00 %d.00 TR\n", 66 + xoffset, 1); + fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (32 + xoffset) * scaler, 1 * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (34 + xoffset) * scaler, 1 * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (64 + xoffset) * scaler, 1 * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (66 + xoffset) * scaler, 1 * scaler); for(i = 0; i < 4; i++) { textpart[i] = symbol->text[i]; } @@ -320,9 +321,9 @@ int ps_plot(struct zint_symbol *symbol) fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = 17; - fprintf(feps, " 0 0 moveto %.2f 0.50 translate 0.00 rotate 0 0 moveto\n", textpos + xoffset); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.50 * scaler); fprintf(feps, " (%s) stringwidth\n", textpart); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -334,9 +335,9 @@ int ps_plot(struct zint_symbol *symbol) textpart[4] = '\0'; fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = 50; - fprintf(feps, " 0 0 moveto %.2f 0.50 translate 0.00 rotate 0 0 moveto\n", textpos + xoffset); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(feps, " (%s) stringwidth\n", textpart); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -347,9 +348,9 @@ int ps_plot(struct zint_symbol *symbol) case 2: fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = symbol->width + xoffset - 10; - fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos, addon_text_posn); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(feps, " (%s) stringwidth\n", addon); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -359,9 +360,9 @@ int ps_plot(struct zint_symbol *symbol) case 5: fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = symbol->width + xoffset - 23; - fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos, addon_text_posn); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(feps, " (%s) stringwidth\n", addon); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -376,22 +377,22 @@ int ps_plot(struct zint_symbol *symbol) case 19: fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); - fprintf(feps, "%.2f %.2f ", 5.0, 4.0 + yoffset); - fprintf(feps, "TB %d.00 %d.00 TR\n", 0 + xoffset, 1); - fprintf(feps, "TB %d.00 %d.00 TR\n", 2 + xoffset, 1); - fprintf(feps, "TB %d.00 %d.00 TR\n", 46 + xoffset, 1); - fprintf(feps, "TB %d.00 %d.00 TR\n", 48 + xoffset, 1); - fprintf(feps, "TB %d.00 %d.00 TR\n", 92 + xoffset, 1); - fprintf(feps, "TB %d.00 %d.00 TR\n", 94 + xoffset, 1); + fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (92 + xoffset) * scaler, 1 * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (94 + xoffset) * scaler, 1 * scaler); textpart[0] = symbol->text[0]; textpart[1] = '\0'; fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = -7; - fprintf(feps, " 0 0 moveto %.2f 0.50 translate 0.00 rotate 0 0 moveto\n", textpos + xoffset); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.50 * scaler); fprintf(feps, " (%s) stringwidth\n", textpart); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -403,9 +404,9 @@ int ps_plot(struct zint_symbol *symbol) textpart[6] = '\0'; fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = 24; - fprintf(feps, " 0 0 moveto %.2f 0.50 translate 0.00 rotate 0 0 moveto\n", textpos + xoffset); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.50 * scaler); fprintf(feps, " (%s) stringwidth\n", textpart); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -417,9 +418,9 @@ int ps_plot(struct zint_symbol *symbol) textpart[6] = '\0'; fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = 71; - fprintf(feps, " 0 0 moveto %.2f 0.50 translate 0.00 rotate 0 0 moveto\n", textpos + xoffset); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(feps, " (%s) stringwidth\n", textpart); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -430,9 +431,9 @@ int ps_plot(struct zint_symbol *symbol) case 2: fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = symbol->width + xoffset - 10; - fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos, addon_text_posn); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(feps, " (%s) stringwidth\n", addon); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -442,9 +443,9 @@ int ps_plot(struct zint_symbol *symbol) case 5: fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = symbol->width + xoffset - 23; - fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos, addon_text_posn); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(feps, " (%s) stringwidth\n", addon); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -461,7 +462,7 @@ int ps_plot(struct zint_symbol *symbol) /* guard bar extensions and text formatting for UPCA */ fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); - fprintf(feps, "%.2f %.2f ", 5.0, 4.0 + yoffset); + fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler); latch = 1; i = 0 + comp_offset; @@ -472,7 +473,7 @@ int ps_plot(struct zint_symbol *symbol) } while (symbol->encoded_data[symbol->rows - 1][i + block_width] == symbol->encoded_data[symbol->rows - 1][i]); if(latch == 1) { /* a bar */ - fprintf(feps, "TB %d.00 %d.00 TR\n", i + xoffset - comp_offset, block_width); + fprintf(feps, "TB %.2f %.2f TR\n", (i + xoffset - comp_offset) * scaler, block_width * scaler); latch = 0; } else { /* a space */ @@ -480,8 +481,8 @@ int ps_plot(struct zint_symbol *symbol) } i += block_width; } while (i < 11 + comp_offset); - fprintf(feps, "TB %d.00 %d.00 TR\n", 46 + xoffset, 1); - fprintf(feps, "TB %d.00 %d.00 TR\n", 48 + xoffset, 1); + fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler); latch = 1; i = 85 + comp_offset; do { @@ -491,7 +492,7 @@ int ps_plot(struct zint_symbol *symbol) } while (symbol->encoded_data[symbol->rows - 1][i + block_width] == symbol->encoded_data[symbol->rows - 1][i]); if(latch == 1) { /* a bar */ - fprintf(feps, "TB %d.00 %d.00 TR\n", i + xoffset - comp_offset, block_width); + fprintf(feps, "TB %.2f %.2f TR\n", (i + xoffset - comp_offset) * scaler, block_width * scaler); latch = 0; } else { /* a space */ @@ -505,9 +506,9 @@ int ps_plot(struct zint_symbol *symbol) fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "8.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler); textpos = -5; - fprintf(feps, " 0 0 moveto %.2f 0.50 translate 0.00 rotate 0 0 moveto\n", textpos + xoffset); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(feps, " (%s) stringwidth\n", textpart); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -519,9 +520,9 @@ int ps_plot(struct zint_symbol *symbol) textpart[5] = '\0'; fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = 27; - fprintf(feps, " 0 0 moveto %.2f 0.50 translate 0.00 rotate 0 0 moveto\n", textpos + xoffset); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(feps, " (%s) stringwidth\n", textpart); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -533,9 +534,9 @@ int ps_plot(struct zint_symbol *symbol) textpart[6] = '\0'; fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = 68; - fprintf(feps, " 0 0 moveto %.2f 0.50 translate 0.00 rotate 0 0 moveto\n", textpos + xoffset); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(feps, " (%s) stringwidth\n", textpart); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -545,9 +546,9 @@ int ps_plot(struct zint_symbol *symbol) textpart[1] = '\0'; fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "8.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler); textpos = 100; - fprintf(feps, " 0 0 moveto %.2f 0.50 translate 0.00 rotate 0 0 moveto\n", textpos + xoffset); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(feps, " (%s) stringwidth\n", textpart); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -558,9 +559,9 @@ int ps_plot(struct zint_symbol *symbol) case 2: fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = symbol->width + xoffset - 10; - fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos, addon_text_posn); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(feps, " (%s) stringwidth\n", addon); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -570,9 +571,9 @@ int ps_plot(struct zint_symbol *symbol) case 5: fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = symbol->width + xoffset - 23; - fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos, addon_text_posn); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(feps, " (%s) stringwidth\n", addon); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -587,21 +588,21 @@ int ps_plot(struct zint_symbol *symbol) /* guard bar extensions and text formatting for UPCE */ fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); - fprintf(feps, "%.2f %.2f ", 5.0, 4.0 + yoffset); - fprintf(feps, "TB %d.00 %d.00 TR\n", 0 + xoffset, 1); - fprintf(feps, "TB %d.00 %d.00 TR\n", 2 + xoffset, 1); - fprintf(feps, "TB %d.00 %d.00 TR\n", 46 + xoffset, 1); - fprintf(feps, "TB %d.00 %d.00 TR\n", 48 + xoffset, 1); - fprintf(feps, "TB %d.00 %d.00 TR\n", 50 + xoffset, 1); + fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler); + fprintf(feps, "TB %.2f %.2f TR\n", (50 + xoffset) * scaler, 1 * scaler); textpart[0] = symbol->text[0]; textpart[1] = '\0'; fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "8.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler); textpos = -5; - fprintf(feps, " 0 0 moveto %.2f 0.50 translate 0.00 rotate 0 0 moveto\n", textpos + xoffset); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(feps, " (%s) stringwidth\n", textpart); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -613,9 +614,9 @@ int ps_plot(struct zint_symbol *symbol) textpart[6] = '\0'; fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = 24; - fprintf(feps, " 0 0 moveto %.2f 0.50 translate 0.00 rotate 0 0 moveto\n", textpos + xoffset); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(feps, " (%s) stringwidth\n", textpart); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -625,9 +626,9 @@ int ps_plot(struct zint_symbol *symbol) textpart[1] = '\0'; fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "8.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler); textpos = 55; - fprintf(feps, " 0 0 moveto %.2f 0.50 translate 0.00 rotate 0 0 moveto\n", textpos + xoffset); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(feps, " (%s) stringwidth\n", textpart); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -638,9 +639,9 @@ int ps_plot(struct zint_symbol *symbol) case 2: fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = symbol->width + xoffset - 10; - fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos, addon_text_posn); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(feps, " (%s) stringwidth\n", addon); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -650,9 +651,9 @@ int ps_plot(struct zint_symbol *symbol) case 5: fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "11.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = symbol->width + xoffset - 23; - fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos, addon_text_posn); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(feps, " (%s) stringwidth\n", addon); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); @@ -672,32 +673,32 @@ int ps_plot(struct zint_symbol *symbol) /* boundary bars */ fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); - fprintf(feps, "%d.00 %d.00 TB %d.00 %d.00 TR\n", symbol->border_width, textoffset, 0, (symbol->width + xoffset + xoffset)); + fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", symbol->border_width * scaler, textoffset * scaler, 0.0, (symbol->width + xoffset + xoffset) * scaler); fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); - fprintf(feps, "%d.00 %d.00 TB %d.00 %d.00 TR\n", symbol->border_width, textoffset + symbol->height + symbol->border_width, 0, (symbol->width + xoffset + xoffset)); + fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", symbol->border_width * scaler, (textoffset + symbol->height + symbol->border_width) * scaler, 0.0, (symbol->width + xoffset + xoffset) * scaler); if(symbol->rows > 1) { /* row binding */ for(r = 1; r < symbol->rows; r++) { fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); - fprintf(feps, "%d.00 %.2f TB %d.00 %d.00 TR\n", 2, ((r * row_height) + textoffset + yoffset - 1), xoffset, symbol->width); + fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", 2.0, ((r * row_height) + textoffset + yoffset - 1) * scaler, xoffset * scaler, symbol->width * scaler); } } } else { /* boundary bars */ fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); - fprintf(feps, "%d.00 %d.00 TB %d.00 %d.00 TR\n", symbol->border_width, textoffset, xoffset, symbol->width); + fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", symbol->border_width * scaler, textoffset * scaler, xoffset * scaler, symbol->width * scaler); fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); - fprintf(feps, "%d.00 %d.00 TB %d.00 %d.00 TR\n", symbol->border_width, textoffset + symbol->height + symbol->border_width, xoffset, symbol->width); + fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", symbol->border_width * scaler, (textoffset + symbol->height + symbol->border_width) * scaler, xoffset * scaler, symbol->width * scaler); if(symbol->rows > 1) { /* row binding */ for(r = 1; r < symbol->rows; r++) { fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); - fprintf(feps, "%d.00 %.2f TB %d.00 %d.00 TR\n", 2, ((r * row_height) + textoffset + yoffset - 1), (xoffset + 11), (symbol->width - 24)); + fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", 2.0, ((r * row_height) + textoffset + yoffset - 1) * scaler, (xoffset + 11) * scaler, (symbol->width - 24) * scaler); } } } @@ -707,10 +708,10 @@ int ps_plot(struct zint_symbol *symbol) /* side bars */ fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); - fprintf(feps, "%d.00 %d.00 TB %d.00 %d.00 TR\n", symbol->height + (2 * symbol->border_width), textoffset, 0, symbol->border_width); + fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", (symbol->height + (2 * symbol->border_width)) * scaler, textoffset * scaler, 0.0, symbol->border_width * scaler); fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); - fprintf(feps, "%d.00 %d.00 TB %d.00 %d.00 TR\n", symbol->height + (2 * symbol->border_width), textoffset, (symbol->width + xoffset + xoffset - symbol->border_width), symbol->border_width); + fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", (symbol->height + (2 * symbol->border_width)) * scaler, textoffset * scaler, (symbol->width + xoffset + xoffset - symbol->border_width) * scaler, symbol->border_width * scaler); } /* Put the human readable text at the bottom */ @@ -719,9 +720,9 @@ int ps_plot(struct zint_symbol *symbol) fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n"); - fprintf(feps, "8.00 scalefont setfont\n"); + fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler); textpos = symbol->width / 2.0; - fprintf(feps, " 0 0 moveto %.2f 1.67 translate 0.00 rotate 0 0 moveto\n", textpos + xoffset); + fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 1.67 * scaler); fprintf(feps, " (%s) stringwidth\n", symbol->text); fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n"); diff --git a/backend/zint.h b/backend/zint.h index 892b2a03..bd332bb3 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -35,6 +35,7 @@ struct zint_symbol { char fgcolour[10]; char bgcolour[10]; char outfile[256]; + float scale; int option_1; int option_2; int option_3;