mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Change height and row_height array to floats; DAFT tracker ratio
This commit is contained in:
@ -305,7 +305,8 @@ static int in_numeric(const unsigned int gbdata[], const int length, const int i
|
||||
return 0;
|
||||
}
|
||||
*p_end = i;
|
||||
*p_cost = digit_cnt == 1 ? 60 /* 10 * HX_MULT */ : digit_cnt == 2 ? 30 /* (10 / 2) * HX_MULT */ : 20 /* (10 / 3) * HX_MULT */;
|
||||
*p_cost = digit_cnt == 1
|
||||
? 60 /* 10 * HX_MULT */ : digit_cnt == 2 ? 30 /* (10 / 2) * HX_MULT */ : 20 /* (10 / 3) * HX_MULT */;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -693,10 +694,12 @@ static void calculate_binary(char binary[], const char mode[], unsigned int sour
|
||||
}
|
||||
|
||||
/* Terminator */
|
||||
bp = bin_append_posn(position + block_length == length || mode[position + block_length] != '2' ? 4095 : 4094, 12, binary, bp);
|
||||
bp = bin_append_posn(position + block_length == length || mode[position + block_length] != '2'
|
||||
? 4095 : 4094, 12, binary, bp);
|
||||
|
||||
if (debug & ZINT_DEBUG_PRINT) {
|
||||
printf("(TERM %x)\n", position + block_length == length || mode[position + block_length] != '2' ? 4095 : 4094);
|
||||
printf("(TERM %x)\n", position + block_length == length || mode[position + block_length] != '2'
|
||||
? 4095 : 4094);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -728,10 +731,12 @@ static void calculate_binary(char binary[], const char mode[], unsigned int sour
|
||||
}
|
||||
|
||||
/* Terminator */
|
||||
bp = bin_append_posn(position + block_length == length || mode[position + block_length] != '1' ? 4095 : 4094, 12, binary, bp);
|
||||
bp = bin_append_posn(position + block_length == length || mode[position + block_length] != '1'
|
||||
? 4095 : 4094, 12, binary, bp);
|
||||
|
||||
if (debug & ZINT_DEBUG_PRINT) {
|
||||
printf("(TERM %x)\n", position + block_length == length || mode[position + block_length] != '1' ? 4095 : 4094);
|
||||
printf("(TERM %x)\n", position + block_length == length || mode[position + block_length] != '1'
|
||||
? 4095 : 4094);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -883,7 +888,8 @@ static void hx_safe_plot(unsigned char *grid, const int size, const int x, const
|
||||
}
|
||||
|
||||
/* Plot an alignment pattern around top and right of a module */
|
||||
static void hx_plot_alignment(unsigned char *grid, const int size, const int x, const int y, const int w, const int h) {
|
||||
static void hx_plot_alignment(unsigned char *grid, const int size, const int x, const int y, const int w,
|
||||
const int h) {
|
||||
int i;
|
||||
hx_safe_plot(grid, size, x, y, 0x11);
|
||||
hx_safe_plot(grid, size, x - 1, y + 1, 0x10);
|
||||
@ -1148,7 +1154,8 @@ static void hx_set_function_info(unsigned char *grid, const int size, const int
|
||||
}
|
||||
|
||||
if (debug & ZINT_DEBUG_PRINT) {
|
||||
printf("Version: %d, ECC: %d, Mask: %d, Structural Info: %.34s\n", version, ecc_level, bitmask, function_information);
|
||||
printf("Version: %d, ECC: %d, Mask: %d, Structural Info: %.34s\n", version, ecc_level, bitmask,
|
||||
function_information);
|
||||
}
|
||||
|
||||
/* Add function information to symbol */
|
||||
@ -1289,7 +1296,8 @@ static int hx_evaluate(const unsigned char *local, const int size) {
|
||||
* position of the module.” - however i being the length of the run of the
|
||||
* same colour (i.e. "block" below) in the same fashion as ISO/IEC 18004
|
||||
* makes more sense. -- Confirmed by Wang Yi */
|
||||
/* Fixed in ISO/IEC 20830 (draft 2019-10-10) section 5.8.3.2 "In Table 12 below, i refers to the modules with same color." */
|
||||
/* Fixed in ISO/IEC 20830 (draft 2019-10-10) section 5.8.3.2 "In Table 12 below, i refers to the modules with
|
||||
same color." */
|
||||
|
||||
/* Vertical */
|
||||
for (x = 0; x < size; x++) {
|
||||
@ -1351,8 +1359,8 @@ static void hx_apply_bitmask(unsigned char *grid, const int size, const int vers
|
||||
unsigned char mask[size_squared];
|
||||
unsigned char local[size_squared];
|
||||
#else
|
||||
unsigned char *mask = (unsigned char *) _alloca(size_squared * sizeof(unsigned char));
|
||||
unsigned char *local = (unsigned char *) _alloca(size_squared * sizeof(unsigned char));
|
||||
unsigned char *mask = (unsigned char *) _alloca(size_squared);
|
||||
unsigned char *local = (unsigned char *) _alloca(size_squared);
|
||||
#endif
|
||||
|
||||
/* Perform data masking */
|
||||
@ -1569,7 +1577,8 @@ INTERNAL int han_xin(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
|
||||
/* If there is spare capacity, increase the level of ECC */
|
||||
|
||||
if (symbol->option_1 == -1 || symbol->option_1 != ecc_level) { /* Unless explicitly specified (within min/max bounds) by user */
|
||||
/* Unless explicitly specified (within min/max bounds) by user */
|
||||
if (symbol->option_1 == -1 || symbol->option_1 != ecc_level) {
|
||||
if ((ecc_level == 1) && (codewords < hx_data_codewords_L2[version - 1])) {
|
||||
ecc_level = 2;
|
||||
data_codewords = hx_data_codewords_L2[version - 1];
|
||||
@ -1595,10 +1604,10 @@ INTERNAL int han_xin(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
unsigned char picket_fence[hx_total_codewords[version - 1]];
|
||||
unsigned char grid[size_squared];
|
||||
#else
|
||||
datastream = (unsigned char *) _alloca((data_codewords) * sizeof (unsigned char));
|
||||
fullstream = (unsigned char *) _alloca((hx_total_codewords[version - 1]) * sizeof (unsigned char));
|
||||
picket_fence = (unsigned char *) _alloca((hx_total_codewords[version - 1]) * sizeof (unsigned char));
|
||||
grid = (unsigned char *) _alloca(size_squared * sizeof(unsigned char));
|
||||
datastream = (unsigned char *) _alloca(data_codewords);
|
||||
fullstream = (unsigned char *) _alloca(hx_total_codewords[version - 1]);
|
||||
picket_fence = (unsigned char *) _alloca(hx_total_codewords[version - 1]);
|
||||
grid = (unsigned char *) _alloca(size_squared);
|
||||
#endif
|
||||
|
||||
memset(datastream, 0, data_codewords);
|
||||
@ -1657,6 +1666,7 @@ INTERNAL int han_xin(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
}
|
||||
symbol->row_height[i] = 1;
|
||||
}
|
||||
symbol->height = size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user