diff options
Diffstat (limited to 'backend/png.c')
-rw-r--r-- | backend/png.c | 237 |
1 files changed, 123 insertions, 114 deletions
diff --git a/backend/png.c b/backend/png.c index e3522fe..085bbec 100644 --- a/backend/png.c +++ b/backend/png.c @@ -737,7 +737,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) local_text[0] = '\0'; } - textdone = 0; + textdone = (symbol->show_hrt != 0) ? 0 : 1; main_width = symbol->width; strcpy(addon, ""); comp_offset = 0; @@ -817,8 +817,8 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) } } addon[r] = '\0'; - - if(tlen) { + + if((symbol->show_hrt != 0) && tlen) { textoffset = 9; } else { textoffset = 0; @@ -827,7 +827,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) yoffset = symbol->border_width; image_width = 2 * (symbol->width + xoffset + xoffset); image_height = 2 * (symbol->height + textoffset + yoffset + yoffset); - + if (!(pixelbuf = (char *) malloc(image_width * image_height))) { printf("Insufficient memory for pixel buffer"); return ERROR_ENCODING_PROBLEM; @@ -836,7 +836,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) *(pixelbuf + i) = '0'; } } - + if(((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) { default_text_posn = image_height - 17; } else { @@ -905,29 +905,32 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) draw_bar(pixelbuf, (34 + xoffset) * 2, 1 * 2, (4 + (int)yoffset) * 2, 5 * 2, image_width, image_height); draw_bar(pixelbuf, (64 + xoffset) * 2, 1 * 2, (4 + (int)yoffset) * 2, 5 * 2, image_width, image_height); draw_bar(pixelbuf, (66 + xoffset) * 2, 1 * 2, (4 + (int)yoffset) * 2, 5 * 2, image_width, image_height); - for(i = 0; i < 4; i++) { - textpart[i] = symbol->text[i]; - } - textpart[4] = '\0'; - textpos = 2 * (17 + xoffset); - - draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); - for(i = 0; i < 4; i++) { - textpart[i] = symbol->text[i + 4]; - } - textpart[4] = '\0'; - textpos = 2 * (50 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); - textdone = 1; - switch(strlen(addon)) { - case 2: - textpos = 2 * (xoffset + 86); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); - break; - case 5: - textpos = 2 * (xoffset + 100); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); - break; + + if(symbol->show_hrt != 0) { + for(i = 0; i < 4; i++) { + textpart[i] = symbol->text[i]; + } + textpart[4] = '\0'; + textpos = 2 * (17 + xoffset); + + draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); + for(i = 0; i < 4; i++) { + textpart[i] = symbol->text[i + 4]; + } + textpart[4] = '\0'; + textpos = 2 * (50 + xoffset); + draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); + textdone = 1; + switch(strlen(addon)) { + case 2: + textpos = 2 * (xoffset + 86); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); + break; + case 5: + textpos = 2 * (xoffset + 100); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); + break; + } } break; @@ -941,42 +944,44 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) draw_bar(pixelbuf, (92 + xoffset) * 2, 1 * 2, (4 + (int)yoffset) * 2, 5 * 2, image_width, image_height); draw_bar(pixelbuf, (94 + xoffset) * 2, 1 * 2, (4 + (int)yoffset) * 2, 5 * 2, image_width, image_height); - textpart[0] = symbol->text[0]; - textpart[1] = '\0'; - textpos = 2 * (-7 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); - for(i = 0; i < 6; i++) { - textpart[i] = symbol->text[i + 1]; - } - textpart[6] = '\0'; - textpos = 2 * (24 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); - for(i = 0; i < 6; i++) { - textpart[i] = symbol->text[i + 7]; - } - textpart[6] = '\0'; - textpos = 2 * (71 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); - textdone = 1; - switch(strlen(addon)) { - case 2: - textpos = 2 * (xoffset + 114); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); - break; - case 5: - textpos = 2 * (xoffset + 128); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); - break; + if (symbol->show_hrt != 0) { + textpart[0] = symbol->text[0]; + textpart[1] = '\0'; + textpos = 2 * (-7 + xoffset); + draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); + for(i = 0; i < 6; i++) { + textpart[i] = symbol->text[i + 1]; + } + textpart[6] = '\0'; + textpos = 2 * (24 + xoffset); + draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); + for(i = 0; i < 6; i++) { + textpart[i] = symbol->text[i + 7]; + } + textpart[6] = '\0'; + textpos = 2 * (71 + xoffset); + draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); + textdone = 1; + switch(strlen(addon)) { + case 2: + textpos = 2 * (xoffset + 114); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); + break; + case 5: + textpos = 2 * (xoffset + 128); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); + break; + } + break; } - break; } - } + } if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) { /* guard bar extensions and text formatting for UPCA */ latch = 1; - + i = 0 + comp_offset; do { block_width = 0; @@ -1012,39 +1017,41 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) } i += block_width; } while (i < 96 + comp_offset); - textpart[0] = symbol->text[0]; - textpart[1] = '\0'; - textpos = 2 * (-5 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); - for(i = 0; i < 5; i++) { - textpart[i] = symbol->text[i + 1]; - } - textpart[5] = '\0'; - textpos = 2 * (27 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); - for(i = 0; i < 5; i++) { - textpart[i] = symbol->text[i + 6]; - } - textpart[6] = '\0'; - textpos = 2 * (68 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); - textpart[0] = symbol->text[11]; - textpart[1] = '\0'; - textpos = 2 * (100 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); - textdone = 1; - switch(strlen(addon)) { - case 2: - textpos = 2 * (xoffset + 116); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); - break; - case 5: - textpos = 2 * (xoffset + 130); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); - break; - } - } + if(symbol->show_hrt != 0) { + textpart[0] = symbol->text[0]; + textpart[1] = '\0'; + textpos = 2 * (-5 + xoffset); + draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); + for(i = 0; i < 5; i++) { + textpart[i] = symbol->text[i + 1]; + } + textpart[5] = '\0'; + textpos = 2 * (27 + xoffset); + draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); + for(i = 0; i < 5; i++) { + textpart[i] = symbol->text[i + 6]; + } + textpart[6] = '\0'; + textpos = 2 * (68 + xoffset); + draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); + textpart[0] = symbol->text[11]; + textpart[1] = '\0'; + textpos = 2 * (100 + xoffset); + draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); + textdone = 1; + switch(strlen(addon)) { + case 2: + textpos = 2 * (xoffset + 116); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); + break; + case 5: + textpos = 2 * (xoffset + 130); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); + break; + } + } + } if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) { /* guard bar extensions and text formatting for UPCE */ @@ -1054,36 +1061,38 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + (int)yoffset) * 2, 5 * 2, image_width, image_height); draw_bar(pixelbuf, (50 + xoffset) * 2, 1 * 2, (4 + (int)yoffset) * 2, 5 * 2, image_width, image_height); - textpart[0] = symbol->text[0]; - textpart[1] = '\0'; - textpos = 2 * (-5 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); - for(i = 0; i < 6; i++) { - textpart[i] = symbol->text[i + 1]; - } - textpart[6] = '\0'; - textpos = 2 * (24 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); - textpart[0] = symbol->text[7]; - textpart[1] = '\0'; - textpos = 2 * (55 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); - textdone = 1; - switch(strlen(addon)) { - case 2: - textpos = 2 * (xoffset + 70); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); - break; - case 5: - textpos = 2 * (xoffset + 84); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); - break; + if (symbol->show_hrt != 0) { + textpart[0] = symbol->text[0]; + textpart[1] = '\0'; + textpos = 2 * (-5 + xoffset); + draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); + for(i = 0; i < 6; i++) { + textpart[i] = symbol->text[i + 1]; + } + textpart[6] = '\0'; + textpos = 2 * (24 + xoffset); + draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); + textpart[0] = symbol->text[7]; + textpart[1] = '\0'; + textpos = 2 * (55 + xoffset); + draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); + textdone = 1; + switch(strlen(addon)) { + case 2: + textpos = 2 * (xoffset + 70); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); + break; + case 5: + textpos = 2 * (xoffset + 84); + draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, smalltext, image_width, image_height); + break; + } } } xoffset -= comp_offset; - + /* Put boundary bars or box around symbol */ if(((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) { /* boundary bars */ |