diff --git a/backend/raster.c b/backend/raster.c index bbe22320..08ca5704 100644 --- a/backend/raster.c +++ b/backend/raster.c @@ -562,7 +562,7 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, in char *scaled_hexagon; int hexagon_size; - if (scaler <= 0.0f) { + if (scaler < 0.5f) { scaler = 0.5f; } @@ -748,10 +748,24 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int int latch; int block_width; float scaler = symbol->scale; + int si; + int half_int_scaling; int scale_width, scale_height; char *scaled_pixelbuf; int horiz, vert; + /* Ignore scaling < 0.5 for raster as would drop modules */ + if (scaler < 0.5f) { + scaler = 0.5f; + } + /* If half-integer scaling, then set integer scaler `si` to avoid scaling at end */ + half_int_scaling = scaler * 2.0f == (int) (scaler * 2.0f); + if (half_int_scaling) { + si = (int) (scaler * 2.0f); + } else { + si = 2; + } + large_bar_height = output_large_bar_height(symbol); textdone = 0; @@ -779,8 +793,8 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int textoffset = 0; } - image_width = 2 * (symbol->width + xoffset + roffset); - image_height = 2 * (symbol->height + textoffset + yoffset + boffset); + image_width = (symbol->width + xoffset + roffset) * si; + image_height = (symbol->height + textoffset + yoffset + boffset) * si; if (!(pixelbuf = (char *) malloc(image_width * image_height))) { strcpy(symbol->errtxt, "658: Insufficient memory for pixel buffer"); @@ -832,9 +846,9 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int if (module_fill) { /* a bar */ if (symbol->symbology == BARCODE_ULTRA) { - draw_bar(pixelbuf, (i + xoffset) * 2, block_width * 2, plot_yposn * 2, plot_height * 2, image_width, image_height, ultra_colour[module_fill]); + draw_bar(pixelbuf, (i + xoffset) * si, block_width * si, plot_yposn * si, plot_height * si, image_width, image_height, ultra_colour[module_fill]); } else { - draw_bar(pixelbuf, (i + xoffset) * 2, block_width * 2, plot_yposn * 2, plot_height * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (i + xoffset) * si, block_width * si, plot_yposn * si, plot_height * si, image_width, image_height, DEFAULT_INK); } } i += block_width; @@ -848,19 +862,19 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int /* Guard bar extension */ if (upceanflag == 6) { /* UPC-E */ - draw_bar(pixelbuf, (0 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (2 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (46 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (50 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (0 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (2 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (46 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (48 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (50 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); } else if (upceanflag == 8) { /* EAN-8 */ - draw_bar(pixelbuf, (0 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (2 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (32 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (34 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (64 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (66 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (0 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (2 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (32 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (34 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (64 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (66 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); } else if (upceanflag == 12) { /* UPC-A */ latch = 1; @@ -873,7 +887,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int } while ((i + block_width < symbol->width) && module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i)); if (latch == 1) { /* a bar */ - draw_bar(pixelbuf, (i + xoffset - comp_offset) * 2, block_width * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (i + xoffset - comp_offset) * si, block_width * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); latch = 0; } else { /* a space */ @@ -881,8 +895,8 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int } i += block_width; } while (i < 11 + comp_offset); - draw_bar(pixelbuf, (46 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (46 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (48 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); latch = 1; i = 85 + comp_offset; do { @@ -892,7 +906,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int } while ((i + block_width < symbol->width) && module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i)); if (latch == 1) { /* a bar */ - draw_bar(pixelbuf, (i + xoffset - comp_offset) * 2, block_width * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (i + xoffset - comp_offset) * si, block_width * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); latch = 0; } else { /* a space */ @@ -902,12 +916,12 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int } while (i < 96 + comp_offset); } else if (upceanflag == 13) { /* EAN-13 */ - draw_bar(pixelbuf, (0 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (2 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (46 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (92 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (94 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (0 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (2 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (46 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (48 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (92 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (94 + xoffset) * si, 1 * si, (4 + yoffset) * si, 5 * si, image_width, image_height, DEFAULT_INK); } } @@ -917,77 +931,77 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int output_upcean_split_text(upceanflag, symbol->text, textpart1, textpart2, textpart3, textpart4); if (upceanflag == 6) { /* UPC-E */ - textpos = 2 * (-5 + xoffset); + textpos = (-5 + xoffset) * si; draw_string(pixelbuf, textpart1, textpos, default_text_posn, textflags, image_width, image_height); - textpos = 2 * (24 + xoffset); + textpos = (24 + xoffset) * si; draw_string(pixelbuf, textpart2, textpos, default_text_posn, textflags, image_width, image_height); - textpos = 2 * (55 + xoffset); + textpos = (55 + xoffset) * si; draw_string(pixelbuf, textpart3, textpos, default_text_posn, textflags, image_width, image_height); textdone = 1; switch (ustrlen(addon)) { case 2: - textpos = 2 * (61 + xoffset + addon_gap); + textpos = (61 + xoffset + addon_gap) * si; draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); break; case 5: - textpos = 2 * (75 + xoffset + addon_gap); + textpos = (75 + xoffset + addon_gap) * si; draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); break; } } else if (upceanflag == 8) { /* EAN-8 */ - textpos = 2 * (17 + xoffset); + textpos = (17 + xoffset) * si; draw_string(pixelbuf, textpart1, textpos, default_text_posn, textflags, image_width, image_height); - textpos = 2 * (50 + xoffset); + textpos = (50 + xoffset) * si; draw_string(pixelbuf, textpart2, textpos, default_text_posn, textflags, image_width, image_height); textdone = 1; switch (ustrlen(addon)) { case 2: - textpos = 2 * (77 + xoffset + addon_gap); + textpos = (77 + xoffset + addon_gap) * si; draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); break; case 5: - textpos = 2 * (91 + xoffset + addon_gap); + textpos = (91 + xoffset + addon_gap) * si; draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); break; } } else if (upceanflag == 12) { /* UPC-A */ - textpos = 2 * (-5 + xoffset); + textpos = (-5 + xoffset) * si; draw_string(pixelbuf, textpart1, textpos, default_text_posn, textflags, image_width, image_height); - textpos = 2 * (27 + xoffset); + textpos = (27 + xoffset) * si; draw_string(pixelbuf, textpart2, textpos, default_text_posn, textflags, image_width, image_height); - textpos = 2 * (68 + xoffset); + textpos = (68 + xoffset) * si; draw_string(pixelbuf, textpart3, textpos, default_text_posn, textflags, image_width, image_height); - textpos = 2 * (100 + xoffset); + textpos = (100 + xoffset) * si; draw_string(pixelbuf, textpart4, textpos, default_text_posn, textflags, image_width, image_height); textdone = 1; switch (ustrlen(addon)) { case 2: - textpos = 2 * (107 + xoffset + addon_gap); + textpos = (107 + xoffset + addon_gap) * si; draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); break; case 5: - textpos = 2 * (121 + xoffset + addon_gap); + textpos = (121 + xoffset + addon_gap) * si; draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); break; } } else if (upceanflag == 13) { /* EAN-13 */ - textpos = 2 * (-7 + xoffset); + textpos = (-7 + xoffset) * si; draw_string(pixelbuf, textpart1, textpos, default_text_posn, textflags, image_width, image_height); - textpos = 2 * (24 + xoffset); + textpos = (24 + xoffset) * si; draw_string(pixelbuf, textpart2, textpos, default_text_posn, textflags, image_width, image_height); - textpos = 2 * (71 + xoffset); + textpos = (71 + xoffset) * si; draw_string(pixelbuf, textpart3, textpos, default_text_posn, textflags, image_width, image_height); textdone = 1; switch (ustrlen(addon)) { case 2: - textpos = 2 * (105 + xoffset + addon_gap); + textpos = (105 + xoffset + addon_gap) * si; draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); break; case 5: - textpos = 2 * (119 + xoffset + addon_gap); + textpos = (119 + xoffset + addon_gap) * si; draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); break; } @@ -998,7 +1012,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int unsigned char local_text[sizeof(symbol->text)]; to_iso8859_1(symbol->text, local_text); /* Put the human readable text at the bottom */ - textpos = 2 * (main_width / 2 + xoffset); + textpos = (main_width / 2 + xoffset) * si; draw_string(pixelbuf, local_text, textpos, default_text_posn, textflags, image_width, image_height); } } @@ -1015,12 +1029,14 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int /* row binding */ if (symbol->symbology != BARCODE_CODABLOCKF && symbol->symbology != BARCODE_HIBC_BLOCKF) { for (r = 1; r < symbol->rows; r++) { - draw_bar(pixelbuf, xoffset * 2, symbol->width * 2, ((r * row_height) + textoffset + yoffset - sep_height / 2) * 2, sep_height * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, xoffset * si, symbol->width * si, + ((r * row_height) + textoffset + yoffset - sep_height / 2) * si, sep_height * si, image_width, image_height, DEFAULT_INK); } } else { for (r = 1; r < symbol->rows; r++) { /* Avoid 11-module start and 13-module stop chars */ - draw_bar(pixelbuf, (xoffset + 11) * 2, (symbol->width - 24) * 2, ((r * row_height) + textoffset + yoffset - sep_height / 2) * 2, sep_height * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (xoffset + 11) * si, (symbol->width - 24) * si, + ((r * row_height) + textoffset + yoffset - sep_height / 2) * si, sep_height * si, image_width, image_height, DEFAULT_INK); } } } @@ -1029,25 +1045,27 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { /* boundary bars */ if ((symbol->output_options & BARCODE_BOX) || (symbol->symbology != BARCODE_CODABLOCKF && symbol->symbology != BARCODE_HIBC_BLOCKF)) { - draw_bar(pixelbuf, 0, (symbol->width + xoffset + roffset) * 2, textoffset * 2, symbol->border_width * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, 0, (symbol->width + xoffset + roffset) * 2, (textoffset + symbol->height + symbol->border_width) * 2, symbol->border_width * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, 0, (symbol->width + xoffset + roffset) * si, + textoffset * si, symbol->border_width * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, 0, (symbol->width + xoffset + roffset) * si, + (textoffset + symbol->height + symbol->border_width) * si, symbol->border_width * si, image_width, image_height, DEFAULT_INK); } else { - draw_bar(pixelbuf, xoffset * 2, symbol->width * 2, textoffset * 2, symbol->border_width * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, xoffset * 2, symbol->width * 2, (textoffset + symbol->height + symbol->border_width) * 2, symbol->border_width * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, xoffset * si, symbol->width * si, + textoffset * si, symbol->border_width * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, xoffset * si, symbol->width * si, + (textoffset + symbol->height + symbol->border_width) * si, symbol->border_width * si, image_width, image_height, DEFAULT_INK); } } if ((symbol->output_options & BARCODE_BOX)) { /* side bars */ - draw_bar(pixelbuf, 0, symbol->border_width * 2, textoffset * 2, (symbol->height + (2 * symbol->border_width)) * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (symbol->width + xoffset + roffset - symbol->border_width) * 2, symbol->border_width * 2, textoffset * 2, (symbol->height + (2 * symbol->border_width)) * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, 0, symbol->border_width * si, + textoffset * si, (symbol->height + (2 * symbol->border_width)) * si, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (symbol->width + xoffset + roffset - symbol->border_width) * si, symbol->border_width * si, + textoffset * si, (symbol->height + (2 * symbol->border_width)) * si, image_width, image_height, DEFAULT_INK); } } - if (scaler <= 0.0f) { - scaler = 0.5f; - } - - if (scaler != 1.0f) { + if (!half_int_scaling) { scale_width = image_width * scaler; scale_height = image_height * scaler; diff --git a/backend/tests/test_raster.c b/backend/tests/test_raster.c index 6f7ba1af..579cb238 100644 --- a/backend/tests/test_raster.c +++ b/backend/tests/test_raster.c @@ -204,42 +204,43 @@ static void test_buffer(int index, int generate, int debug) { /* 85*/ { BARCODE_KIX, "123456ABCDE", "", 8, 3, 87, 174, 16 }, /* 86*/ { BARCODE_AZTEC, "1234567890AB", "", 15, 15, 15, 30, 30 }, /* 87*/ { BARCODE_DAFT, "DAFTDAFTDAFTDAFT", "", 8, 3, 31, 62, 16 }, - /* 88*/ { BARCODE_MICROQR, "12345", "", 11, 11, 11, 22, 22 }, - /* 89*/ { BARCODE_HIBC_128, "0000000000", "", 50, 1, 134, 268, 118 }, - /* 90*/ { BARCODE_HIBC_39, "0000000000", "", 50, 1, 223, 446, 118 }, - /* 91*/ { BARCODE_HIBC_DM, "ABC", "", 12, 12, 12, 24, 24 }, - /* 92*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42, 42 }, - /* 93*/ { BARCODE_HIBC_PDF, "0000000000", "", 27, 9, 103, 206, 54 }, - /* 94*/ { BARCODE_HIBC_MICPDF, "0000000000", "", 34, 17, 38, 76, 68 }, - /* 95*/ { BARCODE_HIBC_BLOCKF, "0000000000", "", 30, 3, 101, 242, 64 }, - /* 96*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38, 38 }, - /* 97*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 33, 23 }, // Differs from vector - /* 98*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46, 46 }, - /* 99*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310, 20 }, - /*100*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22, 22 }, - /*101*/ { BARCODE_CODE32, "12345678", "", 50, 1, 103, 206, 118 }, - /*102*/ { BARCODE_EANX_CC, "123456789012", "[20]01", 50, 7, 99, 234, 118 }, - /*103*/ { BARCODE_EANX_CC, "123456789012+12", "[20]01", 50, 7, 126, 284, 118 }, - /*104*/ { BARCODE_EANX_CC, "123456789012+12345", "[20]01", 50, 7, 153, 338, 118 }, - /*105*/ { BARCODE_GS1_128_CC, "[01]12345678901234", "[20]01", 50, 5, 145, 290, 118 }, - /*106*/ { BARCODE_DBAR_OMN_CC, "1234567890123", "[20]01", 21, 5, 100, 200, 60 }, - /*107*/ { BARCODE_DBAR_LTD_CC, "1234567890123", "[20]01", 19, 6, 74, 148, 56 }, - /*108*/ { BARCODE_DBAR_EXP_CC, "[01]12345678901234", "[20]01", 41, 5, 134, 268, 100 }, - /*109*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 234, 118 }, - /*110*/ { BARCODE_UPCA_CC, "12345678901+12", "[20]01", 50, 7, 128, 284, 118 }, - /*111*/ { BARCODE_UPCA_CC, "12345678901+12345", "[20]01", 50, 7, 155, 338, 118 }, - /*112*/ { BARCODE_UPCE_CC, "1234567", "[20]01", 50, 9, 55, 142, 118 }, - /*113*/ { BARCODE_UPCE_CC, "1234567+12", "[20]01", 50, 9, 82, 192, 118 }, - /*114*/ { BARCODE_UPCE_CC, "1234567+12345", "[20]01", 50, 9, 109, 246, 118 }, - /*115*/ { BARCODE_DBAR_STK_CC, "0000000000000", "[20]01", 24, 9, 56, 112, 48 }, - /*116*/ { BARCODE_DBAR_OMNSTK_CC, "0000000000000", "[20]01", 80, 11, 56, 112, 160 }, - /*117*/ { BARCODE_DBAR_EXPSTK_CC, "[01]12345678901234", "[20]01", 78, 9, 102, 204, 156 }, - /*118*/ { BARCODE_CHANNEL, "00", "", 50, 1, 19, 38, 118 }, - /*119*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44, 44 }, - /*120*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36, 36 }, - /*121*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154, 154 }, - /*122*/ { BARCODE_ULTRA, "0000000000", "", 13, 13, 18, 36, 26 }, - /*123*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54, 22 }, + /* 88*/ { BARCODE_DPD, "0123456789012345678901234567", "", 50, 1, 189, 378, 118 }, + /* 89*/ { BARCODE_MICROQR, "12345", "", 11, 11, 11, 22, 22 }, + /* 90*/ { BARCODE_HIBC_128, "0000000000", "", 50, 1, 134, 268, 118 }, + /* 91*/ { BARCODE_HIBC_39, "0000000000", "", 50, 1, 223, 446, 118 }, + /* 92*/ { BARCODE_HIBC_DM, "ABC", "", 12, 12, 12, 24, 24 }, + /* 93*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42, 42 }, + /* 94*/ { BARCODE_HIBC_PDF, "0000000000", "", 27, 9, 103, 206, 54 }, + /* 95*/ { BARCODE_HIBC_MICPDF, "0000000000", "", 34, 17, 38, 76, 68 }, + /* 96*/ { BARCODE_HIBC_BLOCKF, "0000000000", "", 30, 3, 101, 242, 64 }, + /* 97*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38, 38 }, + /* 98*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 33, 23 }, // Differs from vector + /* 99*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46, 46 }, + /*100*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310, 20 }, + /*101*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22, 22 }, + /*102*/ { BARCODE_CODE32, "12345678", "", 50, 1, 103, 206, 118 }, + /*103*/ { BARCODE_EANX_CC, "123456789012", "[20]01", 50, 7, 99, 234, 118 }, + /*104*/ { BARCODE_EANX_CC, "123456789012+12", "[20]01", 50, 7, 126, 284, 118 }, + /*105*/ { BARCODE_EANX_CC, "123456789012+12345", "[20]01", 50, 7, 153, 338, 118 }, + /*106*/ { BARCODE_GS1_128_CC, "[01]12345678901234", "[20]01", 50, 5, 145, 290, 118 }, + /*107*/ { BARCODE_DBAR_OMN_CC, "1234567890123", "[20]01", 21, 5, 100, 200, 60 }, + /*108*/ { BARCODE_DBAR_LTD_CC, "1234567890123", "[20]01", 19, 6, 74, 148, 56 }, + /*109*/ { BARCODE_DBAR_EXP_CC, "[01]12345678901234", "[20]01", 41, 5, 134, 268, 100 }, + /*110*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 234, 118 }, + /*111*/ { BARCODE_UPCA_CC, "12345678901+12", "[20]01", 50, 7, 128, 284, 118 }, + /*112*/ { BARCODE_UPCA_CC, "12345678901+12345", "[20]01", 50, 7, 155, 338, 118 }, + /*113*/ { BARCODE_UPCE_CC, "1234567", "[20]01", 50, 9, 55, 142, 118 }, + /*114*/ { BARCODE_UPCE_CC, "1234567+12", "[20]01", 50, 9, 82, 192, 118 }, + /*115*/ { BARCODE_UPCE_CC, "1234567+12345", "[20]01", 50, 9, 109, 246, 118 }, + /*116*/ { BARCODE_DBAR_STK_CC, "0000000000000", "[20]01", 24, 9, 56, 112, 48 }, + /*117*/ { BARCODE_DBAR_OMNSTK_CC, "0000000000000", "[20]01", 80, 11, 56, 112, 160 }, + /*118*/ { BARCODE_DBAR_EXPSTK_CC, "[01]12345678901234", "[20]01", 78, 9, 102, 204, 156 }, + /*119*/ { BARCODE_CHANNEL, "00", "", 50, 1, 19, 38, 118 }, + /*120*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44, 44 }, + /*121*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36, 36 }, + /*122*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154, 154 }, + /*123*/ { BARCODE_ULTRA, "0000000000", "", 13, 13, 18, 36, 26 }, + /*124*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54, 22 }, }; int data_size = ARRAY_SIZE(data); @@ -849,6 +850,8 @@ static void test_scale(int index, int debug) { struct item { int symbology; int option_2; + int border_width; + int output_options; float scale; unsigned char *data; @@ -864,9 +867,19 @@ static void test_scale(int index, int debug) { }; // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { BARCODE_PDF417, -1, 0, "1", 18, 6, 103, 206, 36, 0, 36, 170, 14 }, // With no scaling - /* 1*/ { BARCODE_PDF417, -1, 0.6, "1", 18, 6, 103, 206 * 0.6, 36 * 0.6, 0, 36 * 0.6, 170 * 0.6 + 1, 14 * 0.6 }, // +1 set_col due to some scaling inversion difference - /* 2*/ { BARCODE_PDF417, -1, 1.2, "1", 18, 6, 103, 206 * 1.2, 36 * 1.2, 0, 36 * 1.2, 170 * 1.2 + 1, 14 * 1.2 }, // +1 set_col due to some scaling inversion difference + /* 0*/ { BARCODE_PDF417, -1, -1, -1, 0, "1", 18, 6, 103, 206, 36, 0, 36, 170, 14 }, // With no scaling + /* 1*/ { BARCODE_PDF417, -1, -1, -1, 0.6, "1", 18, 6, 103, 206 * 0.6, 36 * 0.6, 0, 36 * 0.6, 170 * 0.6 + 1, 14 * 0.6 }, // +1 set_col due to some scaling inversion difference + /* 2*/ { BARCODE_PDF417, -1, -1, -1, 1.2, "1", 18, 6, 103, 206 * 1.2, 36 * 1.2, 0, 36 * 1.2, 170 * 1.2 + 1, 14 * 1.2 }, // +1 set_col due to some scaling inversion difference + /* 3*/ { BARCODE_PDF417, -1, -1, -1, 0.5, "1", 18, 6, 103, 206 * 0.5, 36 * 0.5, 0, 36 * 0.5, 170 * 0.5, 14 * 0.5 }, + /* 4*/ { BARCODE_PDF417, -1, -1, -1, 1.0, "1", 18, 6, 103, 206 * 1.0, 36 * 1.0, 0, 36 * 1.0, 170 * 1.0, 14 * 1.0 }, + /* 5*/ { BARCODE_PDF417, -1, -1, -1, 1.5, "1", 18, 6, 103, 206 * 1.5, 36 * 1.5, 0, 36 * 1.5, 170 * 1.5, 14 * 1.5 }, + /* 6*/ { BARCODE_PDF417, -1, -1, -1, 2.5, "1", 18, 6, 103, 206 * 2.5, 36 * 2.5, 0, 36 * 2.5, 170 * 2.5, 14 * 2.5 }, + /* 7*/ { BARCODE_PDF417, -1, -1, -1, 3.0, "1", 18, 6, 103, 206 * 3.0, 36 * 3.0, 0, 36 * 3.0, 170 * 3.0, 14 * 3.0 }, + /* 8*/ { BARCODE_PDF417, -1, 3, BARCODE_BOX, 0, "1", 18, 6, 103, 218, 48, 0, 48, 176, 14 }, // With no scaling + /* 9*/ { BARCODE_PDF417, -1, 3, BARCODE_BOX, 0.6, "1", 18, 6, 103, 218 * 0.6, 48 * 0.6, 0, 48 * 0.6, 176 * 0.6 + 1, 14 * 0.6 }, // +1 set_col due to some scaling inversion difference + /* 10*/ { BARCODE_PDF417, -1, 3, BARCODE_BOX, 1.6, "1", 18, 6, 103, 218 * 1.6, 48 * 1.6, 0, 48 * 1.6, 176 * 1.6 + 1, 14 * 1.6 }, // +1 set_col due to some scaling inversion difference + /* 11*/ { BARCODE_PDF417, -1, 3, BARCODE_BOX, 1.5, "1", 18, 6, 103, 218 * 1.5, 48 * 1.5, 0, 48 * 1.5, 176 * 1.5, 14 * 1.5 }, + /* 12*/ { BARCODE_PDF417, -1, 3, BARCODE_BOX, 2.5, "1", 18, 6, 103, 218 * 2.5, 48 * 2.5, 0, 48 * 2.5, 176 * 2.5, 14 * 2.5 }, }; int data_size = ARRAY_SIZE(data); @@ -877,7 +890,10 @@ static void test_scale(int index, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - int length = testUtilSetSymbol(symbol, data[i].symbology, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); + int length = testUtilSetSymbol(symbol, data[i].symbology, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, data[i].output_options, data[i].data, -1, debug); + if (data[i].border_width != -1) { + symbol->border_width = data[i].border_width; + } if (data[i].scale) { symbol->scale = data[i].scale; } diff --git a/backend/tests/test_vector.c b/backend/tests/test_vector.c index 34b42803..0b128c11 100644 --- a/backend/tests/test_vector.c +++ b/backend/tests/test_vector.c @@ -226,42 +226,43 @@ static void test_buffer_vector(int index, int generate, int debug) { /* 85*/ { BARCODE_KIX, "123456ABCDE", "", 8, 3, 87, 174, 16 }, /* 86*/ { BARCODE_AZTEC, "1234567890AB", "", 15, 15, 15, 30, 30 }, /* 87*/ { BARCODE_DAFT, "DAFTDAFTDAFTDAFT", "", 8, 3, 31, 62, 16 }, - /* 88*/ { BARCODE_MICROQR, "12345", "", 11, 11, 11, 22, 22 }, - /* 89*/ { BARCODE_HIBC_128, "0000000000", "", 50, 1, 134, 268, 118 }, - /* 90*/ { BARCODE_HIBC_39, "0000000000", "", 50, 1, 223, 446, 118 }, - /* 91*/ { BARCODE_HIBC_DM, "ABC", "", 12, 12, 12, 24, 24 }, - /* 92*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42, 42 }, - /* 93*/ { BARCODE_HIBC_PDF, "0000000000", "", 27, 9, 103, 206, 54 }, - /* 94*/ { BARCODE_HIBC_MICPDF, "0000000000", "", 34, 17, 38, 76, 68 }, - /* 95*/ { BARCODE_HIBC_BLOCKF, "0000000000", "", 30, 3, 101, 242, 64 }, - /* 96*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38, 38 }, - /* 97*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 32, 22 }, // Differs from raster - /* 98*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46, 46 }, - /* 99*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310, 20 }, - /*100*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22, 22 }, - /*101*/ { BARCODE_CODE32, "12345678", "", 50, 1, 103, 206, 118 }, - /*102*/ { BARCODE_EANX_CC, "123456789012", "[20]01", 50, 7, 99, 234, 118 }, - /*103*/ { BARCODE_EANX_CC, "123456789012+12", "[20]01", 50, 7, 126, 284, 118 }, - /*104*/ { BARCODE_EANX_CC, "123456789012+12345", "[20]01", 50, 7, 153, 338, 118 }, - /*105*/ { BARCODE_GS1_128_CC, "[01]12345678901234", "[20]01", 50, 5, 145, 290, 118 }, - /*106*/ { BARCODE_DBAR_OMN_CC, "1234567890123", "[20]01", 21, 5, 100, 200, 60 }, - /*107*/ { BARCODE_DBAR_LTD_CC, "1234567890123", "[20]01", 19, 6, 74, 148, 56 }, - /*108*/ { BARCODE_DBAR_EXP_CC, "[01]12345678901234", "[20]01", 41, 5, 134, 268, 100 }, - /*109*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 234, 118 }, - /*110*/ { BARCODE_UPCA_CC, "12345678901+12", "[20]01", 50, 7, 128, 284, 118 }, - /*111*/ { BARCODE_UPCA_CC, "12345678901+12345", "[20]01", 50, 7, 155, 338, 118 }, - /*112*/ { BARCODE_UPCE_CC, "1234567", "[20]01", 50, 9, 55, 142, 118 }, - /*113*/ { BARCODE_UPCE_CC, "1234567+12", "[20]01", 50, 9, 82, 192, 118 }, - /*114*/ { BARCODE_UPCE_CC, "1234567+12345", "[20]01", 50, 9, 109, 246, 118 }, - /*115*/ { BARCODE_DBAR_STK_CC, "0000000000000", "[20]01", 24, 9, 56, 112, 48 }, - /*116*/ { BARCODE_DBAR_OMNSTK_CC, "0000000000000", "[20]01", 80, 11, 56, 112, 160 }, - /*117*/ { BARCODE_DBAR_EXPSTK_CC, "[01]12345678901234", "[20]01", 78, 9, 102, 204, 156 }, - /*118*/ { BARCODE_CHANNEL, "00", "", 50, 1, 19, 38, 118 }, - /*119*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44, 44 }, - /*120*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36, 36 }, - /*121*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154, 154 }, - /*122*/ { BARCODE_ULTRA, "0000000000", "", 13, 13, 18, 36, 26 }, - /*123*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54, 22 }, + /* 88*/ { BARCODE_DPD, "0123456789012345678901234567", "", 50, 1, 189, 378, 118 }, + /* 89*/ { BARCODE_MICROQR, "12345", "", 11, 11, 11, 22, 22 }, + /* 90*/ { BARCODE_HIBC_128, "0000000000", "", 50, 1, 134, 268, 118 }, + /* 91*/ { BARCODE_HIBC_39, "0000000000", "", 50, 1, 223, 446, 118 }, + /* 92*/ { BARCODE_HIBC_DM, "ABC", "", 12, 12, 12, 24, 24 }, + /* 93*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42, 42 }, + /* 94*/ { BARCODE_HIBC_PDF, "0000000000", "", 27, 9, 103, 206, 54 }, + /* 95*/ { BARCODE_HIBC_MICPDF, "0000000000", "", 34, 17, 38, 76, 68 }, + /* 96*/ { BARCODE_HIBC_BLOCKF, "0000000000", "", 30, 3, 101, 242, 64 }, + /* 97*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38, 38 }, + /* 98*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 32, 22 }, // Differs from raster + /* 99*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46, 46 }, + /*100*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310, 20 }, + /*101*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22, 22 }, + /*102*/ { BARCODE_CODE32, "12345678", "", 50, 1, 103, 206, 118 }, + /*103*/ { BARCODE_EANX_CC, "123456789012", "[20]01", 50, 7, 99, 234, 118 }, + /*104*/ { BARCODE_EANX_CC, "123456789012+12", "[20]01", 50, 7, 126, 284, 118 }, + /*105*/ { BARCODE_EANX_CC, "123456789012+12345", "[20]01", 50, 7, 153, 338, 118 }, + /*106*/ { BARCODE_GS1_128_CC, "[01]12345678901234", "[20]01", 50, 5, 145, 290, 118 }, + /*107*/ { BARCODE_DBAR_OMN_CC, "1234567890123", "[20]01", 21, 5, 100, 200, 60 }, + /*108*/ { BARCODE_DBAR_LTD_CC, "1234567890123", "[20]01", 19, 6, 74, 148, 56 }, + /*109*/ { BARCODE_DBAR_EXP_CC, "[01]12345678901234", "[20]01", 41, 5, 134, 268, 100 }, + /*110*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 234, 118 }, + /*111*/ { BARCODE_UPCA_CC, "12345678901+12", "[20]01", 50, 7, 128, 284, 118 }, + /*112*/ { BARCODE_UPCA_CC, "12345678901+12345", "[20]01", 50, 7, 155, 338, 118 }, + /*113*/ { BARCODE_UPCE_CC, "1234567", "[20]01", 50, 9, 55, 142, 118 }, + /*114*/ { BARCODE_UPCE_CC, "1234567+12", "[20]01", 50, 9, 82, 192, 118 }, + /*115*/ { BARCODE_UPCE_CC, "1234567+12345", "[20]01", 50, 9, 109, 246, 118 }, + /*116*/ { BARCODE_DBAR_STK_CC, "0000000000000", "[20]01", 24, 9, 56, 112, 48 }, + /*117*/ { BARCODE_DBAR_OMNSTK_CC, "0000000000000", "[20]01", 80, 11, 56, 112, 160 }, + /*118*/ { BARCODE_DBAR_EXPSTK_CC, "[01]12345678901234", "[20]01", 78, 9, 102, 204, 156 }, + /*119*/ { BARCODE_CHANNEL, "00", "", 50, 1, 19, 38, 118 }, + /*120*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44, 44 }, + /*121*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36, 36 }, + /*122*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154, 154 }, + /*123*/ { BARCODE_ULTRA, "0000000000", "", 13, 13, 18, 36, 26 }, + /*124*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54, 22 }, }; int data_size = sizeof(data) / sizeof(struct item); diff --git a/frontend/main.c b/frontend/main.c index dcd64a65..1e29f0f0 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -115,7 +115,7 @@ static void usage(void) { " -o, --output=FILE Send output to FILE. Default is out.png\n" " --primary=STRING Set structured primary message (Maxicode/Composite)\n" " -r, --reverse Reverse colours (white on black)\n" - " --rotate=NUMBER Rotate symbol by NUMBER degrees (BMP/GIF/PCX/PNG/TIF)\n" + " --rotate=NUMBER Rotate symbol by NUMBER degrees\n" " --rows=NUMBER Set number of rows (Codablock-F)\n" " --scale=NUMBER Adjust size of X-dimension\n" " --secure=NUMBER Set error correction level (ECC)\n" @@ -256,6 +256,25 @@ static void set_extension(char *file, char *filetype) { strcat(file, filetype); } +static char *raster_filetypes[] = { + "bmp", "gif", "pcx", "png", "tif", // TODO: Determine if PNG available +}; + +static int is_raster(char *filetype) { + int i; + char lc_filetype[4] = {0}; + + strcpy(lc_filetype, filetype); + to_lower(lc_filetype); + + for (i = 0; i < (int) ARRAY_SIZE(raster_filetypes); i++) { + if (strcmp(lc_filetype, raster_filetypes[i]) == 0) { + return 1; + } + } + return 0; +} + static int batch_process(struct zint_symbol *symbol, char *filename, int mirror_mode, char *filetype, int rotate_angle) { FILE *file; unsigned char buffer[7828] = {0}; // 7828 maximum HanXin input @@ -978,6 +997,10 @@ int main(int argc, char **argv) { // TODO: Determine if PNG available strcpy(filetype, outfile_extension && supported_filetype(outfile_extension) ? outfile_extension : "png"); } + if (my_symbol->scale < 0.5f && is_raster(filetype)) { + fprintf(stderr, "Warning 145: Scaling less than 0.5 will be set to 0.5 for '%s' output\n", filetype); + fflush(stderr); + } error_number = batch_process(my_symbol, arg_opts[0].arg, mirror_mode, filetype, rotate_angle); if (error_number != 0) { fprintf(stderr, "%s\n", my_symbol->errtxt); @@ -987,6 +1010,10 @@ int main(int argc, char **argv) { if (*filetype != '\0') { set_extension(my_symbol->outfile, filetype); } + if (my_symbol->scale < 0.5f && is_raster(get_extension(my_symbol->outfile))) { + fprintf(stderr, "Warning 146: Scaling less than 0.5 will be set to 0.5 for '%s' output\n", get_extension(my_symbol->outfile)); + fflush(stderr); + } for (i = 0; i < data_arg_num; i++) { if (arg_opts[i].opt == 'd') { ret = ZBarcode_Encode(my_symbol, (unsigned char *) arg_opts[i].arg, strlen(arg_opts[i].arg)); diff --git a/frontend/tests/test_args.c b/frontend/tests/test_args.c index 8e65dad3..a025a618 100644 --- a/frontend/tests/test_args.c +++ b/frontend/tests/test_args.c @@ -491,44 +491,46 @@ static void test_checks(int index, int debug) { }; // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { -2, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 139: Invalid add-on gap value" }, - /* 1*/ { 6, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 140: Invalid add-on gap value\nD2 13 9B 39 63 AC" }, - /* 2*/ { -1, -2, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 107: Invalid border width value" }, - /* 3*/ { -1, 1001, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 108: Border width out of range\nD2 13 9B 39 63 AC" }, - /* 4*/ { -1, -1, -1, 0.009, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 106: Invalid dot radius value\nD2 13 9B 39 63 AC" }, - /* 5*/ { -1, -1, -2, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 131: Invalid columns value" }, - /* 6*/ { -1, -1, 68, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 111: Number of columns out of range\nD2 13 9B 39 63 AC" }, - /* 7*/ { -1, -1, -1, -1, -2, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 138: Invalid ECI value" }, - /* 8*/ { -1, -1, -1, -1, 1000000, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 118: Invalid ECI code\nD2 13 9B 39 63 AC" }, - /* 9*/ { -1, -1, -1, -1, -1, "jpg", -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 142: File type 'jpg' not supported, ignoring\nD2 13 9B 39 63 AC" }, - /* 10*/ { -1, -1, -1, -1, -1, NULL, -2, -1, -1, -1, -1, -1, -1, -1, -1, "Error 109: Invalid symbol height value" }, - /* 11*/ { -1, -1, -1, -1, -1, NULL, 0, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 110: Symbol height out of range\nD2 13 9B 39 63 AC" }, - /* 12*/ { -1, -1, -1, -1, -1, NULL, -1, -2, -1, -1, -1, -1, -1, -1, -1, "Error 136: Invalid mode value" }, - /* 13*/ { -1, -1, -1, -1, -1, NULL, -1, 7, -1, -1, -1, -1, -1, -1, -1, "Warning 116: Invalid mode\nD2 13 9B 39 63 AC" }, - /* 14*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -2, -1, -1, -1, -1, -1, -1, "Error 117: Invalid rotation value" }, - /* 15*/ { -1, -1, -1, -1, -1, NULL, -1, -1, 45, -1, -1, -1, -1, -1, -1, "Warning 137: Invalid rotation parameter\nD2 13 9B 39 63 AC" }, - /* 16*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -2, -1, -1, -1, -1, -1, "Error 132: Invalid rows value" }, - /* 17*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, 45, -1, -1, -1, -1, -1, "Warning 112: Number of rows out of range\nD2 13 9B 39 63 AC" }, - /* 18*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -2, -1, -1, -1, -1, "Warning 105: Invalid scale value\nD2 13 9B 39 63 AC" }, - /* 19*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -2, -1, -1, -1, "Error 134: Invalid ECC value" }, - /* 20*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, 9, -1, -1, -1, "Warning 114: ECC level out of range\nD2 13 9B 39 63 AC" }, - /* 21*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -2, -1, -1, "Error 128: Invalid separator value" }, - /* 22*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, 5, -1, -1, "Warning 127: Invalid separator value\nD2 13 9B 39 63 AC" }, - /* 23*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -2, -1, "Error 133: Invalid version value" }, - /* 24*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, 85, -1, "Warning 113: Invalid version\nD2 13 9B 39 63 AC" }, - /* 25*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -2, "Error 120: Invalid whitespace value '-2'" }, - /* 26*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, 1001, "Warning 121: Whitespace value out of range\nD2 13 9B 39 63 AC" }, + /* 0*/ { -2, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 139: Invalid add-on gap value" }, + /* 1*/ { 6, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 140: Invalid add-on gap value" }, + /* 2*/ { -1, -2, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 107: Invalid border width value" }, + /* 3*/ { -1, 1001, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 108: Border width out of range" }, + /* 4*/ { -1, -1, -1, 0.009, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 106: Invalid dot radius value" }, + /* 5*/ { -1, -1, -2, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 131: Invalid columns value" }, + /* 6*/ { -1, -1, 68, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 111: Number of columns out of range" }, + /* 7*/ { -1, -1, -1, -1, -2, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 138: Invalid ECI value" }, + /* 8*/ { -1, -1, -1, -1, 1000000, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 118: Invalid ECI code" }, + /* 9*/ { -1, -1, -1, -1, -1, "jpg", -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 142: File type 'jpg' not supported, ignoring" }, + /* 10*/ { -1, -1, -1, -1, -1, NULL, -2, -1, -1, -1, -1, -1, -1, -1, -1, "Error 109: Invalid symbol height value" }, + /* 11*/ { -1, -1, -1, -1, -1, NULL, 0, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 110: Symbol height out of range" }, + /* 12*/ { -1, -1, -1, -1, -1, NULL, -1, -2, -1, -1, -1, -1, -1, -1, -1, "Error 136: Invalid mode value" }, + /* 13*/ { -1, -1, -1, -1, -1, NULL, -1, 7, -1, -1, -1, -1, -1, -1, -1, "Warning 116: Invalid mode" }, + /* 14*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -2, -1, -1, -1, -1, -1, -1, "Error 117: Invalid rotation value" }, + /* 15*/ { -1, -1, -1, -1, -1, NULL, -1, -1, 45, -1, -1, -1, -1, -1, -1, "Warning 137: Invalid rotation parameter" }, + /* 16*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -2, -1, -1, -1, -1, -1, "Error 132: Invalid rows value" }, + /* 17*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, 45, -1, -1, -1, -1, -1, "Warning 112: Number of rows out of range" }, + /* 18*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -2, -1, -1, -1, -1, "Warning 105: Invalid scale value" }, + /* 19*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, 0.49, -1, -1, -1, -1, "Warning 146: Scaling less than 0.5 will be set to 0.5 for 'png' output" }, + /* 20*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -2, -1, -1, -1, "Error 134: Invalid ECC value" }, + /* 21*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, 9, -1, -1, -1, "Warning 114: ECC level out of range" }, + /* 22*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -2, -1, -1, "Error 128: Invalid separator value" }, + /* 23*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, 5, -1, -1, "Warning 127: Invalid separator value" }, + /* 24*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -2, -1, "Error 133: Invalid version value" }, + /* 25*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, 85, -1, "Warning 113: Invalid version" }, + /* 26*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -2, "Error 120: Invalid whitespace value '-2'" }, + /* 27*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, 1001, "Warning 121: Whitespace value out of range" }, }; int data_size = ARRAY_SIZE(data); char cmd[4096]; char buf[4096]; + char *outfilename = "out.png"; for (int i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; - strcpy(cmd, "zint --dump -d '1'"); + strcpy(cmd, "zint -d '1'"); if (debug & ZINT_DEBUG_PRINT) { strcat(cmd, " --verbose"); } @@ -553,6 +555,10 @@ static void test_checks(int index, int debug) { assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i), "i:%d exec(%s) NULL\n", i, cmd); assert_zero(strcmp(buf, data[i].expected), "i:%d buf (%s) != expected (%s)\n", i, buf, data[i].expected); + + if (strncmp(data[i].expected, "Warning", 7) == 0) { + assert_zero(remove(outfilename), "i:%d remove(%s) != 0 (%d)\n", i, outfilename, errno); + } } testFinish();