raster: #197 optimize scaling for half-int vals, scale >= 0.5 only

This commit is contained in:
gitlost 2020-08-10 19:40:10 +01:00
parent 6f00c92beb
commit 6579efd271
5 changed files with 233 additions and 165 deletions

View file

@ -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;

View file

@ -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;
}

View file

@ -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);