From 30272dd955f109c2fce3423fa8e29dcafb1edf0a Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Mon, 5 Jun 2017 19:17:22 +0100 Subject: [PATCH] Use more accurate guess of bit length when calculating smallest available version Fixes #66, Bug report by jthie --- backend/qr.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/backend/qr.c b/backend/qr.c index 8057b558..68af861b 100644 --- a/backend/qr.c +++ b/backend/qr.c @@ -1589,10 +1589,7 @@ int qr_code(struct zint_symbol *symbol, const unsigned char source[], size_t len if (autosize == 1) { canShrink = 0; } else { - if (tribus(autosize - 1, 1, 2, 3) != tribus(autosize, 1, 2, 3)) { - // Length of binary needed to encode the data in the smaller symbol is different, recalculate - est_binlen = getBinaryLength(autosize - 1, mode, jisdata, length, gs1, symbol->eci); - } + est_binlen = getBinaryLength(autosize - 1, mode, jisdata, length, gs1, symbol->eci); switch (ecc_level) { case LEVEL_L: @@ -1622,9 +1619,7 @@ int qr_code(struct zint_symbol *symbol, const unsigned char source[], size_t len autosize--; } else { // Data did not fit in the smaller symbol, revert to original size - if (tribus(autosize - 1, 1, 2, 3) != tribus(autosize, 1, 2, 3)) { - est_binlen = getBinaryLength(autosize, mode, jisdata, length, gs1, symbol->eci); - } + est_binlen = getBinaryLength(autosize, mode, jisdata, length, gs1, symbol->eci); } } } while (canShrink == 1);