Ensure maxium error correction capacity in QR Code

Fixes #107 reported by Daniel Gredler
This commit is contained in:
Robin Stuart 2018-06-21 00:03:55 +01:00
parent 628078021b
commit 2642a418b9

View File

@ -1569,15 +1569,15 @@ int qr_code(struct zint_symbol *symbol, const unsigned char source[], size_t len
return ZINT_ERROR_TOO_LONG;
}
}
/* Ensure maxium error correction capacity */
if (est_binlen <= qr_data_codewords_M[version - 1]) {
if (est_binlen <= qr_data_codewords_M[version - 1] * 8) {
ecc_level = LEVEL_M;
}
if (est_binlen <= qr_data_codewords_Q[version - 1]) {
if (est_binlen <= qr_data_codewords_Q[version - 1] * 8) {
ecc_level = LEVEL_Q;
}
if (est_binlen <= qr_data_codewords_H[version - 1]) {
if (est_binlen <= qr_data_codewords_H[version - 1] * 8) {
ecc_level = LEVEL_H;
}