1
0
mirror of https://github.com/woo-j/zint.git synced 2024-12-27 11:21:30 +03:00

Allow resizing of DM89 symbols

This commit is contained in:
hooper114 2009-01-05 21:22:12 +00:00
parent 8bb378ed25
commit 7763292cf7

View File

@ -1072,6 +1072,9 @@ int matrix89(struct zint_symbol *symbol, unsigned char source[])
char randomized_stream[2210];
char header[20];
int symbol_size, hex_segment, width;
int error_number;
error_number = 0;
symbol_size = 0;
for(i = 0; i < input_length; i++) {
@ -1180,12 +1183,27 @@ int matrix89(struct zint_symbol *symbol, unsigned char source[])
strcpy(unrandomized_stream, header);
concat(unrandomized_stream, protected_stream);
/* Determine Symbol Size */
for(i = 20; i >= 0; i--) {
if(MatrixMaxCapacities[i] > strlen(unrandomized_stream)) {
symbol_size = i;
}
}
if((symbol->option_2 < 0) || (symbol->option_2 > 21)) {
strcpy(symbol->errtxt, "Invalid symbol size");
error_number = WARN_INVALID_OPTION;
symbol->option_2 = 0;
}
if(symbol->option_2 > symbol_size) {
symbol_size = symbol->option_2;
}
if((symbol->option_2 < symbol_size) && (symbol->option_2 != 0)) {
strcpy(symbol->errtxt, "Unable to fit data in specified symbol size");
error_number = WARN_INVALID_OPTION;
}
/* Add trailer (pad bits) */
input_length = strlen(unrandomized_stream);
for(i = input_length; i < MatrixMaxCapacities[symbol_size]; i++) {
@ -1266,7 +1284,7 @@ int matrix89(struct zint_symbol *symbol, unsigned char source[])
symbol->rows = width + 2;
symbol->width = width + 2;
return 0;
return error_number;
}
int dmatrix(struct zint_symbol *symbol, unsigned char source[])
@ -1290,7 +1308,7 @@ int dmatrix(struct zint_symbol *symbol, unsigned char source[])
error_number = iec16022ecc200(source, barcodelen, symbol);
if(error_number == 0) {
/* It worked! */
strcpy(symbol->errtxt, "Cannot make barcode fit");
strcpy(symbol->errtxt, "Unable to fit data in specified symbol size");
error_number = WARN_INVALID_OPTION;
}
}