Added scale value to change size of output image

This commit is contained in:
hooper114 2008-12-20 15:21:04 +00:00
parent 909394478f
commit 960d46981a
4 changed files with 153 additions and 148 deletions

View File

@ -42,6 +42,7 @@ struct zint_symbol *ZBarcode_Create()
strcpy(symbol->fgcolour, "000000"); strcpy(symbol->fgcolour, "000000");
strcpy(symbol->bgcolour, "ffffff"); strcpy(symbol->bgcolour, "ffffff");
strcpy(symbol->outfile, "out.png"); strcpy(symbol->outfile, "out.png");
symbol->scale = 1.0;
symbol->option_1 = -1; symbol->option_1 = -1;
symbol->option_2 = 0; symbol->option_2 = 0;
symbol->option_3 = 928; // PDF_MAX symbol->option_3 = 928; // PDF_MAX

View File

@ -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]"); strcpy(symbol->errtxt, "Can't open output file [B5]");
return ERROR_FILE_ACCESS; return ERROR_FILE_ACCESS;
} }
/* graphic->outfile = stdout; */
/* Set up error handling routine as proc() above */ /* Set up error handling routine as proc() above */
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, graphic, 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 */ /* Draw a rectangle */
int i, j, png_ypos; 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 /* This fudge is needed because EPS measures height from the bottom up but
PNG measures y position from the top down */ PNG measures y position from the top down */
for(i = (xpos * 2); i < (2 * (xpos + xlen)); i++) { for(i = (xpos); i < (xpos + xlen); i++) {
for( j = (png_ypos * 2); j < (2 * (png_ypos + ylen)); j++) { for( j = (png_ypos); j < (png_ypos + ylen); j++) {
*(pixelbuf + (image_width * j) + i) = '1'; *(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; int this_row, block_width, plot_height, plot_yposn, textpos;
float row_height, row_posn; float row_height, row_posn;
int error_number; int error_number;
int scaler = (int)(2 * symbol->scale);
textdone = 0; textdone = 0;
main_width = symbol->width; 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; xoffset = symbol->border_width + symbol->whitespace_width;
yoffset = symbol->border_width; yoffset = symbol->border_width;
image_width = 2 * (symbol->width + xoffset + xoffset); image_width = scaler * (symbol->width + xoffset + xoffset);
image_height = 2 * (symbol->height + textoffset + yoffset + yoffset); image_height = scaler * (symbol->height + textoffset + yoffset + yoffset);
if (!(pixelbuf = (char *) malloc(image_width * image_height))) { if (!(pixelbuf = (char *) malloc(image_width * image_height))) {
printf("Insifficient memory for pixel buffer [BA]"); printf("Insifficient memory for pixel buffer [BA]");
@ -552,7 +554,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
} }
if(latch == 1) { if(latch == 1) {
/* a bar */ /* 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; latch = 0;
} else { } else {
/* a space */ /* a space */
@ -571,33 +573,33 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
case 8: /* EAN-8 */ case 8: /* EAN-8 */
case 11: case 11:
case 14: case 14:
draw_bar(pixelbuf, (0 + 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), 1, (4 + (int)yoffset), 5, 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), 1, (4 + (int)yoffset), 5, 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), 1, (4 + (int)yoffset), 5, 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), 1, (4 + (int)yoffset), 5, 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), 1, (4 + (int)yoffset), 5, 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++) { for(i = 0; i < 4; i++) {
textpart[i] = symbol->text[i]; textpart[i] = symbol->text[i];
} }
textpart[4] = '\0'; textpart[4] = '\0';
textpos = 2 * (17 + xoffset); textpos = scaler * (17 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height);
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {
textpart[i] = symbol->text[i + 4]; textpart[i] = symbol->text[i + 4];
} }
textpart[4] = '\0'; textpart[4] = '\0';
textpos = 2 * (50 + xoffset); textpos = scaler * (50 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height);
textdone = 1; textdone = 1;
switch(strlen(addon)) { switch(strlen(addon)) {
case 2: case 2:
textpos = 2 * (symbol->width + xoffset - 10); textpos = scaler * (symbol->width + xoffset - 10);
draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height);
break; break;
case 5: case 5:
textpos = 2 * (symbol->width + xoffset - 23); textpos = scaler * (symbol->width + xoffset - 23);
draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height);
break; break;
} }
@ -605,38 +607,38 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
case 13: /* EAN 13 */ case 13: /* EAN 13 */
case 16: case 16:
case 19: case 19:
draw_bar(pixelbuf, (0 + 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), 1, (4 + (int)yoffset), 5, 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), 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), 1, (4 + (int)yoffset), 5, 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), 1, (4 + (int)yoffset), 5, 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), 1, (4 + (int)yoffset), 5, 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[0] = symbol->text[0];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = 2 * (-7 + xoffset); textpos = scaler * (-7 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height);
for(i = 0; i < 6; i++) { for(i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1]; textpart[i] = symbol->text[i + 1];
} }
textpart[6] = '\0'; textpart[6] = '\0';
textpos = 2 * (24 + xoffset); textpos = scaler * (24 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height);
for(i = 0; i < 6; i++) { for(i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 7]; textpart[i] = symbol->text[i + 7];
} }
textpart[6] = '\0'; textpart[6] = '\0';
textpos = 2 * (71 + xoffset); textpos = scaler * (71 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height);
textdone = 1; textdone = 1;
switch(strlen(addon)) { switch(strlen(addon)) {
case 2: case 2:
textpos = 2 * (symbol->width + xoffset - 10); textpos = scaler * (symbol->width + xoffset - 10);
draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height);
break; break;
case 5: case 5:
textpos = 2 * (symbol->width + xoffset - 23); textpos = scaler * (symbol->width + xoffset - 23);
draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height);
break; break;
} }
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]); } while (symbol->encoded_data[symbol->rows - 1][i + block_width] == symbol->encoded_data[symbol->rows - 1][i]);
if(latch == 1) { if(latch == 1) {
/* a bar */ /* 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; latch = 0;
} else { } else {
/* a space */ /* a space */
@ -664,8 +666,8 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
} }
i += block_width; i += block_width;
} while (i < 11 + comp_offset); } while (i < 11 + comp_offset);
draw_bar(pixelbuf, (46 + 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), 1, (4 + (int)yoffset), 5, image_width, image_height); draw_bar(pixelbuf, (48 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height);
latch = 1; latch = 1;
i = 85 + comp_offset; i = 85 + comp_offset;
do { 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]); } while (symbol->encoded_data[symbol->rows - 1][i + block_width] == symbol->encoded_data[symbol->rows - 1][i]);
if(latch == 1) { if(latch == 1) {
/* a bar */ /* 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; latch = 0;
} else { } else {
/* a space */ /* a space */
@ -685,33 +687,33 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
} while (i < 96 + comp_offset); } while (i < 96 + comp_offset);
textpart[0] = symbol->text[0]; textpart[0] = symbol->text[0];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = 2 * (-5 + xoffset); textpos = scaler * (-5 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height);
for(i = 0; i < 5; i++) { for(i = 0; i < 5; i++) {
textpart[i] = symbol->text[i + 1]; textpart[i] = symbol->text[i + 1];
} }
textpart[5] = '\0'; textpart[5] = '\0';
textpos = 2 * (27 + xoffset); textpos = scaler * (27 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height);
for(i = 0; i < 5; i++) { for(i = 0; i < 5; i++) {
textpart[i] = symbol->text[i + 6]; textpart[i] = symbol->text[i + 6];
} }
textpart[6] = '\0'; textpart[6] = '\0';
textpos = 2 * (68 + xoffset); textpos = scaler * (68 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height);
textpart[0] = symbol->text[11]; textpart[0] = symbol->text[11];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = 2 * (100 + xoffset); textpos = scaler * (100 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height);
textdone = 1; textdone = 1;
switch(strlen(addon)) { switch(strlen(addon)) {
case 2: case 2:
textpos = 2 * (symbol->width + xoffset - 10); textpos = scaler * (symbol->width + xoffset - 10);
draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height);
break; break;
case 5: case 5:
textpos = 2 * (symbol->width + xoffset - 23); textpos = scaler * (symbol->width + xoffset - 23);
draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height);
break; 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)) { if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
/* guard bar extensions and text formatting for UPCE */ /* 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, (0 + xoffset) * scaler, 1 * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height);
draw_bar(pixelbuf, (2 + xoffset), 1, (4 + (int)yoffset), 5, 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), 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), 1, (4 + (int)yoffset), 5, 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), 1, (4 + (int)yoffset), 5, 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[0] = symbol->text[0];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = 2 * (-5 + xoffset); textpos = scaler * (-5 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height);
for(i = 0; i < 6; i++) { for(i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1]; textpart[i] = symbol->text[i + 1];
} }
textpart[6] = '\0'; textpart[6] = '\0';
textpos = 2 * (24 + xoffset); textpos = scaler * (24 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height);
textpart[0] = symbol->text[7]; textpart[0] = symbol->text[7];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = 2 * (55 + xoffset); textpos = scaler * (55 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height);
textdone = 1; textdone = 1;
switch(strlen(addon)) { switch(strlen(addon)) {
case 2: case 2:
textpos = 2 * (symbol->width + xoffset - 10); textpos = scaler * (symbol->width + xoffset - 10);
draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height);
break; break;
case 5: case 5:
textpos = 2 * (symbol->width + xoffset - 23); textpos = scaler * (symbol->width + xoffset - 23);
draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, image_width, image_height); draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * scaler) - 13, image_width, image_height);
break; 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->output_options == BARCODE_BOX) || (symbol->output_options == BARCODE_BIND)) {
if(symbol->symbology != BARCODE_CODABLOCKF) { if(symbol->symbology != BARCODE_CODABLOCKF) {
/* boundary bars */ /* 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) * scaler, textoffset * scaler, symbol->border_width * scaler, 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 + symbol->height + symbol->border_width) * scaler, symbol->border_width * scaler, image_width, image_height);
if(symbol->rows > 1) { if(symbol->rows > 1) {
/* row binding */ /* row binding */
for(r = 1; r < symbol->rows; r++) { 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 { } else {
/* boundary bars */ /* boundary bars */
draw_bar(pixelbuf, xoffset, symbol->width, textoffset, 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, symbol->width, (textoffset + symbol->height + symbol->border_width), symbol->border_width, 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) { if(symbol->rows > 1) {
/* row binding */ /* row binding */
for(r = 1; r < symbol->rows; r++) { 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) { if (symbol->output_options == BARCODE_BOX) {
/* side bars */ /* side bars */
draw_bar(pixelbuf, 0, 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), symbol->border_width, textoffset, symbol->height + (2 * symbol->border_width), 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 */ /* Put the human readable text at the bottom */

View File

@ -42,6 +42,7 @@ int ps_plot(struct zint_symbol *symbol)
char textpart[10], addon[6]; char textpart[10], addon[6];
int large_bar_count, comp_offset; int large_bar_count, comp_offset;
float addon_text_posn; float addon_text_posn;
float scaler = symbol->scale;
row_height=0; row_height=0;
textdone = 0; textdone = 0;
@ -176,9 +177,9 @@ int ps_plot(struct zint_symbol *symbol)
} }
fprintf(feps, "%%%%Pages: 0\n"); fprintf(feps, "%%%%Pages: 0\n");
if(symbol->symbology != BARCODE_MAXICODE) { 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 { } 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"); fprintf(feps, "%%%%EndComments\n");
@ -195,7 +196,7 @@ int ps_plot(struct zint_symbol *symbol)
/* Now the actual representation */ /* 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_ink, green_ink, blue_ink);
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_paper, green_paper, blue_paper); 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) { if(symbol->symbology == BARCODE_MAXICODE) {
@ -205,9 +206,9 @@ int ps_plot(struct zint_symbol *symbol)
fprintf(feps, "TE\n"); 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, "%.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, "%.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, "35.76 35.60 7.10 35.76 35.60 5.22 40.98 35.60 TC\n"); 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, "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, 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(r = 0; r < symbol->rows; r++) {
for(i = 0; i < symbol->width; i++) { for(i = 0; i < symbol->width; i++) {
if(symbol->encoded_data[r][i] == '1') { if(symbol->encoded_data[r][i] == '1') {
@ -230,7 +231,7 @@ int ps_plot(struct zint_symbol *symbol)
dx = mx; dx = mx;
ex = mx - 0.86; ex = mx - 0.86;
fx = 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, "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, "%.2f %.2f ", row_height, row_posn); fprintf(feps, "%.2f %.2f ", row_height * scaler, row_posn * scaler);
i = 0; i = 0;
if(symbol->encoded_data[this_row][0] == '1') { if(symbol->encoded_data[this_row][0] == '1') {
latch = 1; latch = 1;
@ -276,13 +277,13 @@ int ps_plot(struct zint_symbol *symbol)
if((addon_latch == 0) && (r == 0) && (i > main_width)) { if((addon_latch == 0) && (r == 0) && (i > main_width)) {
fprintf(feps, "TE\n"); 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, "%.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_text_posn = row_posn + row_height - 8.0;
addon_latch = 1; addon_latch = 1;
} }
if(latch == 1) { if(latch == 1) {
/* a bar */ /* 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; latch = 0;
} else { } else {
/* a space */ /* a space */
@ -305,13 +306,13 @@ int ps_plot(struct zint_symbol *symbol)
case 14: case 14:
fprintf(feps, "TE\n"); 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, "%.2f %.2f ", 5.0, 4.0 + yoffset); fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 0 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 2 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 32 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (32 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 34 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (34 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 64 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (64 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 66 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (66 + xoffset) * scaler, 1 * scaler);
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {
textpart[i] = symbol->text[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, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "11.00 scalefont setfont\n"); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 17; 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, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -334,9 +335,9 @@ int ps_plot(struct zint_symbol *symbol)
textpart[4] = '\0'; textpart[4] = '\0';
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "11.00 scalefont setfont\n"); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 50; 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, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -347,9 +348,9 @@ int ps_plot(struct zint_symbol *symbol)
case 2: case 2:
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\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; 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, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -359,9 +360,9 @@ int ps_plot(struct zint_symbol *symbol)
case 5: case 5:
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\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; 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, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -376,22 +377,22 @@ int ps_plot(struct zint_symbol *symbol)
case 19: case 19:
fprintf(feps, "TE\n"); 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, "%.2f %.2f ", 5.0, 4.0 + yoffset); fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 0 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 2 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 46 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 48 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 92 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (92 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 94 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (94 + xoffset) * scaler, 1 * scaler);
textpart[0] = symbol->text[0]; textpart[0] = symbol->text[0];
textpart[1] = '\0'; textpart[1] = '\0';
fprintf(feps, "TE\n"); 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, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "11.00 scalefont setfont\n"); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = -7; 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, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -403,9 +404,9 @@ int ps_plot(struct zint_symbol *symbol)
textpart[6] = '\0'; textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "11.00 scalefont setfont\n"); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 24; 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, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -417,9 +418,9 @@ int ps_plot(struct zint_symbol *symbol)
textpart[6] = '\0'; textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "11.00 scalefont setfont\n"); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 71; 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, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -430,9 +431,9 @@ int ps_plot(struct zint_symbol *symbol)
case 2: case 2:
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\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; 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, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -442,9 +443,9 @@ int ps_plot(struct zint_symbol *symbol)
case 5: case 5:
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\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; 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, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\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 */ /* guard bar extensions and text formatting for UPCA */
fprintf(feps, "TE\n"); 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, "%.2f %.2f ", 5.0, 4.0 + yoffset); fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
latch = 1; latch = 1;
i = 0 + comp_offset; 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]); } while (symbol->encoded_data[symbol->rows - 1][i + block_width] == symbol->encoded_data[symbol->rows - 1][i]);
if(latch == 1) { if(latch == 1) {
/* a bar */ /* 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; latch = 0;
} else { } else {
/* a space */ /* a space */
@ -480,8 +481,8 @@ int ps_plot(struct zint_symbol *symbol)
} }
i += block_width; i += block_width;
} while (i < 11 + comp_offset); } while (i < 11 + comp_offset);
fprintf(feps, "TB %d.00 %d.00 TR\n", 46 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 48 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler);
latch = 1; latch = 1;
i = 85 + comp_offset; i = 85 + comp_offset;
do { 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]); } while (symbol->encoded_data[symbol->rows - 1][i + block_width] == symbol->encoded_data[symbol->rows - 1][i]);
if(latch == 1) { if(latch == 1) {
/* a bar */ /* 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; latch = 0;
} else { } else {
/* a space */ /* 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, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "8.00 scalefont setfont\n"); fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = -5; 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, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -519,9 +520,9 @@ int ps_plot(struct zint_symbol *symbol)
textpart[5] = '\0'; textpart[5] = '\0';
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "11.00 scalefont setfont\n"); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 27; 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, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -533,9 +534,9 @@ int ps_plot(struct zint_symbol *symbol)
textpart[6] = '\0'; textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "11.00 scalefont setfont\n"); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 68; 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, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -545,9 +546,9 @@ int ps_plot(struct zint_symbol *symbol)
textpart[1] = '\0'; textpart[1] = '\0';
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "8.00 scalefont setfont\n"); fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = 100; 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, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -558,9 +559,9 @@ int ps_plot(struct zint_symbol *symbol)
case 2: case 2:
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\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; 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, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -570,9 +571,9 @@ int ps_plot(struct zint_symbol *symbol)
case 5: case 5:
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\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; 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, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\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 */ /* guard bar extensions and text formatting for UPCE */
fprintf(feps, "TE\n"); 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, "%.2f %.2f ", 5.0, 4.0 + yoffset); fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 0 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 2 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 46 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 48 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %d.00 %d.00 TR\n", 50 + xoffset, 1); fprintf(feps, "TB %.2f %.2f TR\n", (50 + xoffset) * scaler, 1 * scaler);
textpart[0] = symbol->text[0]; textpart[0] = symbol->text[0];
textpart[1] = '\0'; textpart[1] = '\0';
fprintf(feps, "TE\n"); 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, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "8.00 scalefont setfont\n"); fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = -5; 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, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -613,9 +614,9 @@ int ps_plot(struct zint_symbol *symbol)
textpart[6] = '\0'; textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "11.00 scalefont setfont\n"); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 24; 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, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -625,9 +626,9 @@ int ps_plot(struct zint_symbol *symbol)
textpart[1] = '\0'; textpart[1] = '\0';
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "8.00 scalefont setfont\n"); fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = 55; 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, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -638,9 +639,9 @@ int ps_plot(struct zint_symbol *symbol)
case 2: case 2:
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\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; 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, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -650,9 +651,9 @@ int ps_plot(struct zint_symbol *symbol)
case 5: case 5:
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\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; 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, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
@ -672,32 +673,32 @@ int ps_plot(struct zint_symbol *symbol)
/* boundary bars */ /* boundary bars */
fprintf(feps, "TE\n"); 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, "%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, "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, "%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) { if(symbol->rows > 1) {
/* row binding */ /* row binding */
for(r = 1; r < symbol->rows; r++) { for(r = 1; r < symbol->rows; r++) {
fprintf(feps, "TE\n"); 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, "%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 { } else {
/* boundary bars */ /* boundary bars */
fprintf(feps, "TE\n"); 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, "%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, "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, "%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) { if(symbol->rows > 1) {
/* row binding */ /* row binding */
for(r = 1; r < symbol->rows; r++) { for(r = 1; r < symbol->rows; r++) {
fprintf(feps, "TE\n"); 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, "%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 */ /* side bars */
fprintf(feps, "TE\n"); 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, "%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, "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, "%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 */ /* 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, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\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; 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, " (%s) stringwidth\n", symbol->text);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");

View File

@ -35,6 +35,7 @@ struct zint_symbol {
char fgcolour[10]; char fgcolour[10];
char bgcolour[10]; char bgcolour[10];
char outfile[256]; char outfile[256];
float scale;
int option_1; int option_1;
int option_2; int option_2;
int option_3; int option_3;