mirror of
https://git.code.sf.net/p/zint/code
synced 2025-06-01 07:38:26 -04:00
Added Aztec Runes
This commit is contained in:
parent
50f3861d0d
commit
49a14d9d73
11 changed files with 150 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue