diff --git a/backend/DEVELOPER b/backend/DEVELOPER index f47fd466..68ca0483 100644 --- a/backend/DEVELOPER +++ b/backend/DEVELOPER @@ -24,6 +24,7 @@ auspost.c: aztec.c: Aztec Code Compact Aztec Code + Aztec Runes blockf.c: Codablock-F @@ -51,8 +52,15 @@ composite.c: CC-B Composite Symbology CC-C Composite Symbology +dm200.c: + Data Matrix ECC 200 + dmatrix.c: - Data Matrix (Semacode) + Data Matrix ECC 000 + Data Matrix ECC 050 + Data Matrix ECC 080 + Data Matrix ECC 100 + Data Matrix ECC 140 imail.c: USPS OneCode (Intelligent Mail) @@ -66,6 +74,9 @@ medical.c: Codabar Code 32 +micqr.c: + Micro QR Code + pdf417.c: PDF417 Truncated PDF417 diff --git a/backend/aztec.c b/backend/aztec.c index d8c82ff0..5ca7441b 100644 --- a/backend/aztec.c +++ b/backend/aztec.c @@ -1039,3 +1039,96 @@ int aztec(struct zint_symbol *symbol, unsigned char source[]) return err_code; } + +int aztec_runes(struct zint_symbol *symbol, unsigned char source[]) +{ + int input_length, error_number, i, y, x; + int input_value; + char binary_string[28]; + unsigned char data_codewords[3], ecc_codewords[6]; + + error_number = 0; + input_value = 0; + input_length = ustrlen(source); + if(input_length > 3) { + strcpy(symbol->errtxt, "Input too large"); + return ERROR_INVALID_DATA; + } + error_number = is_sane(NESET, source); + if(error_number != 0) { + strcpy(symbol->errtxt, "Invalid characters in input"); + return ERROR_INVALID_DATA; + } + switch(input_length) { + case 3: input_value = 100 * ctoi(source[0]); + input_value += 10 * ctoi(source[1]); + input_value += ctoi(source[2]); + break; + case 2: input_value = 10 * ctoi(source[0]); + input_value += ctoi(source[1]); + break; + case 1: input_value = ctoi(source[0]); + break; + } + + if(input_value > 255) { + strcpy(symbol->errtxt, "Input too large"); + return ERROR_INVALID_DATA; + } + + strcpy(binary_string, ""); + if(input_value & 0x80) { concat(binary_string, "1"); } else { concat(binary_string, "0"); } + if(input_value & 0x40) { concat(binary_string, "1"); } else { concat(binary_string, "0"); } + if(input_value & 0x20) { concat(binary_string, "1"); } else { concat(binary_string, "0"); } + if(input_value & 0x10) { concat(binary_string, "1"); } else { concat(binary_string, "0"); } + if(input_value & 0x08) { concat(binary_string, "1"); } else { concat(binary_string, "0"); } + if(input_value & 0x04) { concat(binary_string, "1"); } else { concat(binary_string, "0"); } + if(input_value & 0x02) { concat(binary_string, "1"); } else { concat(binary_string, "0"); } + if(input_value & 0x01) { concat(binary_string, "1"); } else { concat(binary_string, "0"); } + + data_codewords[0] = 0; + data_codewords[1] = 0; + + for(i = 0; i < 2; i++) { + if(binary_string[i * 4] == '1') { data_codewords[i] += 8; } + if(binary_string[(i * 4) + 1] == '1') { data_codewords[i] += 4; } + if(binary_string[(i * 4) + 2] == '1') { data_codewords[i] += 2; } + if(binary_string[(i * 4) + 3] == '1') { data_codewords[i] += 1; } + } + + rs_init_gf(0x13); + rs_init_code(5, 1); + rs_encode(2, data_codewords, ecc_codewords); + rs_free(); + + strcpy(binary_string, ""); + + for(i = 0; i < 5; i++) { + if(ecc_codewords[4 - i] & 0x08) { binary_string[(i * 4) + 8] = '1'; } else { binary_string[(i * 4) + 8] = '0'; } + if(ecc_codewords[4 - i] & 0x04) { binary_string[(i * 4) + 9] = '1'; } else { binary_string[(i * 4) + 9] = '0'; } + if(ecc_codewords[4 - i] & 0x02) { binary_string[(i * 4) + 10] = '1'; } else { binary_string[(i * 4) + 10] = '0'; } + if(ecc_codewords[4 - i] & 0x01) { binary_string[(i * 4) + 11] = '1'; } else { binary_string[(i * 4) + 11] = '0'; } + } + + for(i = 0; i < 28; i += 2) { + if(binary_string[i] == '1') { binary_string[i] = '0'; } else { binary_string[i] = '1'; } + } + + for(y = 8; y < 19; y++) { + for(x = 8; x < 19; x++) { + if(CompactAztecMap[(y * 27) + x] == 1) { + symbol->encoded_data[y - 8][x - 8] = '1'; + } + if(CompactAztecMap[(y * 27) + x] >= 2) { + if(binary_string[CompactAztecMap[(y * 27) + x] - 2000] == '1') { + symbol->encoded_data[y - 8][x - 8] = '1'; + } + } + } + symbol->row_height[y - 8] = 1; + } + symbol->rows = 11; + symbol->width = 11; + + return 0; +} \ No newline at end of file diff --git a/backend/library.c b/backend/library.c index f52753e7..48ef1d3a 100644 --- a/backend/library.c +++ b/backend/library.c @@ -110,6 +110,7 @@ extern int daft_code(struct zint_symbol *symbol, unsigned char source[]); /* DAF extern int ean_14(struct zint_symbol *symbol, unsigned char source[]); /* EAN-14 */ extern int nve_18(struct zint_symbol *symbol, unsigned char source[]); /* NVE-18 */ extern int microqr(struct zint_symbol *symbol, unsigned char source[]); /* Micro QR Code */ +extern int aztec_runes(struct zint_symbol *symbol, unsigned char source[]); /* Aztec Runes */ #ifndef NO_PNG int png_handle(struct zint_symbol *symbol, int rotate_angle); @@ -175,7 +176,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *input) if(symbol->symbology == 88) { symbol->symbology = BARCODE_EAN128; } if(symbol->symbology == 91) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128 [Z09]"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; } if((symbol->symbology >= 94) && (symbol->symbology <= 96)) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128 [Z10]"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; } - if((symbol->symbology >= 98) && (symbol->symbology <= 128)) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128 [Z10]"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; } + if((symbol->symbology >= 98) && (symbol->symbology <= 127)) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128 [Z10]"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; } /* Everything from 128 up is Zint-specific */ if(symbol->symbology >= 140) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128 [Z11]"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; } @@ -268,6 +269,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *input) case BARCODE_DAFT: error_number = daft_code(symbol, input); break; case BARCODE_EAN14: error_number = ean_14(symbol, input); break; case BARCODE_MICROQR: error_number = microqr(symbol, input); break; + case BARCODE_AZRUNE: error_number = aztec_runes(symbol, input); break; } if(error_number == 0) { error_number = error_buffer; diff --git a/backend/zint.h b/backend/zint.h index 993c06d9..e4bc09cb 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -112,6 +112,7 @@ struct zint_symbol { #define BARCODE_MICROQR 97 /* Zint specific */ +#define BARCODE_AZRUNE 128 #define BARCODE_CODE32 129 #define BARCODE_EANX_CC 130 #define BARCODE_EAN128_CC 131 diff --git a/docs/azrune.png b/docs/azrune.png new file mode 100644 index 00000000..0e6c8a27 Binary files /dev/null and b/docs/azrune.png differ diff --git a/docs/aztec.png b/docs/aztec.png index cd0b5822..e99dc3c9 100644 Binary files a/docs/aztec.png and b/docs/aztec.png differ diff --git a/docs/backend.html b/docs/backend.html index 9e4abbdb..0a6c0eb6 100644 --- a/docs/backend.html +++ b/docs/backend.html @@ -5,7 +5,7 @@ Using the API - +