mirror of
https://git.code.sf.net/p/zint/code
synced 2025-12-21 20:07:06 +00:00
- AZTEC/CHANNEL/CODABLOCKF/CODE16K/CODE49/CODEONE/DATAMATRIX/
DOTCODE/GRIDMATRIX/HANXIN/MICROPDF417/MICROQR/PDF417/QRCODE/
RMQR/ULTRA: set `option_1/2/3` to values used in encodation
("Feedback options"), and add new access methods
`encodedOption1()` etc. to Qt Backend, and use in GUI to provide
better feedback on "Automatic" selections
- AZTEC: give more precise warnings in low ECC situations, and
indicate via `option_1` by setting to -1 (min 3 words), 0
(<5% + 3 words) (`ecc_ratio`)
- set_height: fix non-compliance false positives by using epsilon
in checks (prompted by CODABLOCKF non-compliant warning for
zint-generated compliant height - floating point `rows` mult !=
`zero_count` div; one test regression for CODE93);
better warning messages on non-compliant heights (min/max)
- manual/man page: fix DATAMATRIX Sizes tables "28 12x26" ->
"27 12x26"
- GUI: AZTEC/CODEONE: add Zint versions to comboboxes
- DOTCODE: improve error messages re size too small/large
- ULTRA: better ZINT_TEST codeword dump (ZINT_DEBUG_TEST)
- general: various tabs -> spaces; prettify main .rc files;
trailing spaces; small amount of code fiddling (CODE16K)
This commit is contained in:
@@ -878,6 +878,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
|
||||
rs_uint_t rs_uint;
|
||||
unsigned int *data_part;
|
||||
unsigned int *ecc_part;
|
||||
float ecc_ratio;
|
||||
|
||||
if (gs1 && reader_init) {
|
||||
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 501, "Cannot use Reader Initialisation in GS1 mode");
|
||||
@@ -941,7 +942,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
|
||||
return ZINT_ERROR_INVALID_OPTION;
|
||||
}
|
||||
error_number = errtxt_adj(ZINT_WARN_INVALID_OPTION, symbol, "%1$s%2$s", ", ignoring");
|
||||
symbol->option_1 = -1;
|
||||
symbol->option_1 = -1; /* Feedback options */
|
||||
}
|
||||
|
||||
data_maxsize = 0; /* Keep compiler happy! */
|
||||
@@ -1019,6 +1020,8 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
|
||||
means that the binary string has had to be lengthened beyond the maximum number of bits that can
|
||||
be encoded in a symbol of the selected size */
|
||||
|
||||
symbol->option_2 = compact ? layers : layers + 4; /* Feedback options */
|
||||
|
||||
} else { /* The size of the symbol has been specified by the user */
|
||||
if ((symbol->option_2 < 0) || (symbol->option_2 > 36)) {
|
||||
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 510, "Version '%d' out of range (1 to 36)",
|
||||
@@ -1103,16 +1106,28 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
|
||||
} else {
|
||||
ecc_blocks = AztecSizes[layers - 1] - data_blocks;
|
||||
}
|
||||
if (ecc_blocks < data_blocks / 20) {
|
||||
error_number = ZEXT errtxtf(ZINT_WARN_NONCOMPLIANT, symbol, 708,
|
||||
"Number of ECC codewords %1$d less than %2$d (5%% of data codewords %3$d)",
|
||||
ecc_blocks, data_blocks / 20, data_blocks);
|
||||
if (ecc_blocks == 3) {
|
||||
ecc_ratio = 0.0f;
|
||||
error_number = ZEXT errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 706, "Number of ECC codewords 3 at minimum");
|
||||
symbol->option_1 = -1; /* Feedback options: indicate minimum 3 with -1 */
|
||||
} else {
|
||||
ecc_ratio = (float) (ecc_blocks - 3) / (data_blocks + ecc_blocks);
|
||||
if (ecc_ratio < 0.05f) {
|
||||
error_number = ZEXT errtxtf(ZINT_WARN_NONCOMPLIANT, symbol, 708,
|
||||
"Number of ECC codewords %1$d less than 5%% + 3 of data codewords %2$d",
|
||||
ecc_blocks, data_blocks);
|
||||
symbol->option_1 = 0; /* Feedback options: indicate < 5% + 3 with 0 */
|
||||
} else {
|
||||
/* Feedback options: 0.165 = (.1 + .23) / 2 etc */
|
||||
symbol->option_1 = ecc_ratio < 0.165f ? 1 : ecc_ratio < 0.295f ? 2 : ecc_ratio < 0.43f ? 3 : 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (debug_print) {
|
||||
printf("Generating a %s symbol with %d layers\n", compact ? "compact" : "full-size", layers);
|
||||
printf("Requires %d codewords of %d-bits\n", data_blocks + ecc_blocks, codeword_size);
|
||||
printf(" (%d data words, %d ecc words)\n", data_blocks, ecc_blocks);
|
||||
printf(" (%d data words, %d ecc words, %.1f%%, output option_1 %d, option_2 %d)\n",
|
||||
data_blocks, ecc_blocks, ecc_ratio * 100, symbol->option_1, symbol->option_2);
|
||||
}
|
||||
|
||||
data_part = (unsigned int *) z_alloca(sizeof(unsigned int) * data_blocks);
|
||||
|
||||
Reference in New Issue
Block a user