From 49a14d9d73d87468d858d6c195509659ae54de72 Mon Sep 17 00:00:00 2001 From: hooper114 Date: Sun, 9 Nov 2008 10:06:05 +0000 Subject: [PATCH] Added Aztec Runes --- backend/DEVELOPER | 13 ++++++- backend/aztec.c | 93 +++++++++++++++++++++++++++++++++++++++++++++ backend/library.c | 4 +- backend/zint.h | 1 + docs/azrune.png | Bin 0 -> 163 bytes docs/aztec.png | Bin 1316 -> 336 bytes docs/backend.html | 13 ++++++- docs/frontend.html | 10 ++++- docs/index.html | 2 + docs/twodims.html | 11 +++++- frontend/test.sh | 9 +++++ 11 files changed, 150 insertions(+), 6 deletions(-) create mode 100644 docs/azrune.png 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 0000000000000000000000000000000000000000..0e6c8a27f8bfd2068898822fbfe7bda300bdf2c6 GIT binary patch literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubWS)MMAAr`0ahHT_zP~dQW{9ph2 zK}V%UD$`umoR3Tk5-9|#t==|MYradQRnN4kkscQo%@y1>Im(Df>~Uy!&c!{}EMi|* z{fV5lrSr&KBaXC9JG>5Dd6em%vG2wokCg1zS(iliXuh!Zx_O0f>S{}&sc+A^18rsS MboFyt=akR{0NCq2mH+?% literal 0 HcmV?d00001 diff --git a/docs/aztec.png b/docs/aztec.png index cd0b58228bf0d1192389d3d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