Converted zint_symbol structure usage to a more compressed format

This commit is contained in:
hooper114 2009-05-31 20:33:54 +00:00
parent 90d301a6dc
commit cb0e4e27e8
29 changed files with 447 additions and 341 deletions

View File

@ -45,12 +45,12 @@ int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[])
strcpy(dest, "");
if(ustrlen(source) > 80) {
strcpy(symbol->errtxt, "Input too long [021]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [022]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -79,12 +79,12 @@ int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[])
strcpy(dest, "");
if(ustrlen(source) > 45) {
strcpy(symbol->errtxt, "Input too long [071]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid character in data [072]");
strcpy(symbol->errtxt, "Invalid character in data");
return error_number;
}
@ -112,12 +112,12 @@ int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[])
strcpy(dest, "");
if(ustrlen(source) > 45) {
strcpy(symbol->errtxt, "Input too long [041]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [042]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -146,12 +146,12 @@ int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[])
strcpy(dest, "");
if(ustrlen(source) > 80) {
strcpy(symbol->errtxt, "Input too long [061]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [062]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -180,12 +180,12 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[])
strcpy(dest, "");
if(ustrlen(source) > 90) {
strcpy(symbol->errtxt, "Input too long [031]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if (error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [032]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -252,13 +252,13 @@ int itf14(struct zint_symbol *symbol, unsigned char source[])
h = ustrlen(source);
if(h > 13) {
strcpy(symbol->errtxt, "Input too long [891]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid character in data [892]");
strcpy(symbol->errtxt, "Invalid character in data");
return error_number;
}
@ -302,12 +302,12 @@ int dpleit(struct zint_symbol *symbol, unsigned char source[])
count = 0;
h = ustrlen(source);
if(h > 13) {
strcpy(symbol->errtxt, "Input wrong length [211]");
strcpy(symbol->errtxt, "Input wrong length");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [212]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -345,12 +345,12 @@ int dpident(struct zint_symbol *symbol, unsigned char source[])
count = 0;
h = ustrlen(source);
if(h > 11) {
strcpy(symbol->errtxt, "Input wrong length [221]");
strcpy(symbol->errtxt, "Input wrong length");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [222]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}

View File

@ -128,17 +128,17 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[])
case 16: strcpy(fcc, "59"); error_number = is_sane(NESET, source); break;
case 18: strcpy(fcc, "62"); break;
case 23: strcpy(fcc, "62"); error_number = is_sane(NESET, source); break;
default: strcpy(symbol->errtxt, "Auspost input is wrong length [631]");
default: strcpy(symbol->errtxt, "Auspost input is wrong length");
return ERROR_TOO_LONG;
break;
}
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [632]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
} else {
if(ustrlen(source) > 8) {
strcpy(symbol->errtxt, "Auspost input is too long [633]");
strcpy(symbol->errtxt, "Auspost input is too long");
return ERROR_TOO_LONG;
}
switch(symbol->symbology) {
@ -157,7 +157,7 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[])
concat(localstr, (char*)source);
error_number = is_sane(GDSET, (unsigned char *)localstr);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [634]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -168,7 +168,7 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[])
dpid[8] = '\0';
error_number = is_sane(NESET, (unsigned char *)dpid);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in DPID [635]");
strcpy(symbol->errtxt, "Invalid characters in DPID");
return error_number;
}
@ -227,12 +227,12 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[])
{
if((data_pattern[loopey] == '1') || (data_pattern[loopey] == '0'))
{
symbol->encoded_data[0][writer] = '1';
set_module(symbol, 0, writer);
}
symbol->encoded_data[1][writer] = '1';
set_module(symbol, 1, writer);
if((data_pattern[loopey] == '2') || (data_pattern[loopey] == '0'))
{
symbol->encoded_data[2][writer] = '1';
set_module(symbol, 2, writer);
}
writer += 2;
}

View File

@ -1107,11 +1107,11 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
for(y = AztecCompactOffset[layers - 1]; y < (27 - AztecCompactOffset[layers - 1]); y++) {
for(x = AztecCompactOffset[layers - 1]; x < (27 - AztecCompactOffset[layers - 1]); x++) {
if(CompactAztecMap[(y * 27) + x] == 1) {
symbol->encoded_data[y - AztecCompactOffset[layers - 1]][x - AztecCompactOffset[layers - 1]] = '1';
set_module(symbol, y - AztecCompactOffset[layers - 1], x - AztecCompactOffset[layers - 1]);
}
if(CompactAztecMap[(y * 27) + x] >= 2) {
if(bit_pattern[CompactAztecMap[(y * 27) + x] - 2] == '1') {
symbol->encoded_data[y - AztecCompactOffset[layers - 1]][x - AztecCompactOffset[layers - 1]] = '1';
set_module(symbol, y - AztecCompactOffset[layers - 1], x - AztecCompactOffset[layers - 1]);
}
}
}
@ -1124,11 +1124,11 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
for(y = AztecOffset[layers - 1]; y < (151 - AztecOffset[layers - 1]); y++) {
for(x = AztecOffset[layers - 1]; x < (151 - AztecOffset[layers - 1]); x++) {
if(AztecMap[(y * 151) + x] == 1) {
symbol->encoded_data[y - AztecOffset[layers - 1]][x - AztecOffset[layers - 1]] = '1';
set_module(symbol, y - AztecOffset[layers - 1], x - AztecOffset[layers - 1]);
}
if(AztecMap[(y * 151) + x] >= 2) {
if(bit_pattern[AztecMap[(y * 151) + x] - 2] == '1') {
symbol->encoded_data[y - AztecOffset[layers - 1]][x - AztecOffset[layers - 1]] = '1';
set_module(symbol, y - AztecOffset[layers - 1], x - AztecOffset[layers - 1]);
}
}
}
@ -1218,11 +1218,11 @@ int aztec_runes(struct zint_symbol *symbol, unsigned char source[])
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';
set_module(symbol, y - 8, x - 8);
}
if(CompactAztecMap[(y * 27) + x] >= 2) {
if(binary_string[CompactAztecMap[(y * 27) + x] - 2000] == '1') {
symbol->encoded_data[y - 8][x - 8] = '1';
set_module(symbol, y - 8, x - 8);
}
}
}

View File

@ -592,7 +592,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[])
final_mode = MODEA;
if(input_length > 5450) {
strcpy(symbol->errtxt, "Input data too long [741]");
strcpy(symbol->errtxt, "Input data too long");
return ERROR_TOO_LONG;
}
@ -624,7 +624,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[])
columns_needed = (estimate_codelength + 2) / rows_needed;
if(columns_needed < 4) { columns_needed = 4; }
if(columns_needed > 62) {
strcpy(symbol->errtxt, "Input data too long [742]");
strcpy(symbol->errtxt, "Input data too long");
return ERROR_TOO_LONG;
}
@ -632,7 +632,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[])
error_number = data_encode_blockf(source, subset_selector, blockmatrix, &columns_needed, &rows_needed, &final_mode, symbol->nullchar, gs1);
if(error_number > 0) {
if(error_number == ERROR_TOO_LONG) {
strcpy(symbol->errtxt, "Input data too long [743]");
strcpy(symbol->errtxt, "Input data too long");
}
return error_number;
}
@ -736,10 +736,9 @@ int codablock(struct zint_symbol *symbol, unsigned char source[])
for (j = 0; j < strlen(row_pattern); j++) {
for(k = 0; k < ctoi(row_pattern[j]); k++) {
if(flip_flop == 1) {
symbol->encoded_data[i][writer] = '1';
set_module(symbol, i, writer);
writer++;
} else {
symbol->encoded_data[i][writer] = '0';
writer++;
}
}

View File

@ -864,8 +864,8 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
/* Add the separator pattern for composite symbols */
if(symbol->symbology == BARCODE_EAN128_CC) {
for(i = 0; i < symbol->width; i++) {
if(symbol->encoded_data[separator_row + 1][i] != '1') {
symbol->encoded_data[separator_row][i] = '1';
if(module_is_set(symbol, separator_row + 1, i)) {
set_module(symbol, separator_row, i);
}
}
}

View File

@ -537,10 +537,9 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
for (mx_reader = 0; mx_reader < strlen(width_pattern); mx_reader++) {
for(looper = 0; looper < ctoi(width_pattern[mx_reader]); looper++) {
if(flip_flop == 1) {
symbol->encoded_data[current_row][writer] = '1';
set_module(symbol, current_row, writer);
writer++; }
else {
symbol->encoded_data[current_row][writer] = '0';
writer++; }
}
if(flip_flop == 0) { flip_flop = 1; } else { flip_flop = 0; }

View File

@ -120,6 +120,67 @@ void lookup(char set_string[], char *table[], char data, char dest[])
if (data == set_string[i]) { concat(dest, table[i]); } }
}
int module_is_set(struct zint_symbol *symbol, int y_coord, int x_coord)
{
int x_char, x_sub, result;
x_char = x_coord / 7;
x_sub = x_coord % 7;
result = 0;
switch(x_sub) {
case 0: if((symbol->encoded_data[y_coord][x_char] & 0x01) != 0) { result = 1; } break;
case 1: if((symbol->encoded_data[y_coord][x_char] & 0x02) != 0) { result = 1; } break;
case 2: if((symbol->encoded_data[y_coord][x_char] & 0x04) != 0) { result = 1; } break;
case 3: if((symbol->encoded_data[y_coord][x_char] & 0x08) != 0) { result = 1; } break;
case 4: if((symbol->encoded_data[y_coord][x_char] & 0x10) != 0) { result = 1; } break;
case 5: if((symbol->encoded_data[y_coord][x_char] & 0x20) != 0) { result = 1; } break;
case 6: if((symbol->encoded_data[y_coord][x_char] & 0x40) != 0) { result = 1; } break;
}
return result;
}
void set_module(struct zint_symbol *symbol, int y_coord, int x_coord)
{
if(module_is_set(symbol, y_coord, x_coord)) { return; }
int x_char, x_sub;
x_char = x_coord / 7;
x_sub = x_coord % 7;
switch(x_sub) {
case 0: symbol->encoded_data[y_coord][x_char] += 0x01; break;
case 1: symbol->encoded_data[y_coord][x_char] += 0x02; break;
case 2: symbol->encoded_data[y_coord][x_char] += 0x04; break;
case 3: symbol->encoded_data[y_coord][x_char] += 0x08; break;
case 4: symbol->encoded_data[y_coord][x_char] += 0x10; break;
case 5: symbol->encoded_data[y_coord][x_char] += 0x20; break;
case 6: symbol->encoded_data[y_coord][x_char] += 0x40; break;
} /* The last binary digit is reserved for colour barcodes */
}
void unset_module(struct zint_symbol *symbol, int y_coord, int x_coord)
{
if(!(module_is_set(symbol, y_coord, x_coord))) { return; }
int x_char, x_sub;
x_char = x_coord / 7;
x_sub = x_coord % 7;
switch(x_sub) {
case 0: symbol->encoded_data[y_coord][x_char] -= 0x01; break;
case 1: symbol->encoded_data[y_coord][x_char] -= 0x02; break;
case 2: symbol->encoded_data[y_coord][x_char] -= 0x04; break;
case 3: symbol->encoded_data[y_coord][x_char] -= 0x08; break;
case 4: symbol->encoded_data[y_coord][x_char] -= 0x10; break;
case 5: symbol->encoded_data[y_coord][x_char] -= 0x20; break;
case 6: symbol->encoded_data[y_coord][x_char] -= 0x40; break;
} /* The last binary digit is reserved for colour barcodes */
}
void expand(struct zint_symbol *symbol, char data[])
{ /* Expands from a width pattern to a bit pattern */
@ -131,7 +192,7 @@ void expand(struct zint_symbol *symbol, char data[])
for(reader = 0; reader < strlen(data); reader++) {
for(i = 0; i < ctoi(data[reader]); i++) {
symbol->encoded_data[symbol->rows][writer] = latch;
if(latch == '1') { set_module(symbol, symbol->rows, writer); }
writer++;
}
if(latch == '1') {

View File

@ -41,4 +41,7 @@ int posn(char set_string[], char data);
void expand(struct zint_symbol *symbol, char data[]);
int is_stackable(int symbology);
int roundup(float input);
int module_is_set(struct zint_symbol *symbol, int y_coord, int x_coord);
void set_module(struct zint_symbol *symbol, int y_coord, int x_coord);
void unset_module(struct zint_symbol *symbol, int y_coord, int x_coord);

View File

@ -299,7 +299,7 @@ int cc_a(struct zint_symbol *symbol, unsigned char source[], int cc_width)
/* so now pattern[] holds the string of '1's and '0's. - copy this to the symbol */
for(loop = 0; loop < strlen(pattern); loop++) {
symbol->encoded_data[i][loop] = pattern[loop];
if(pattern[loop] == '1') { set_module(symbol, i, loop); }
}
symbol->row_height[i] = 2;
symbol->rows++;
@ -527,7 +527,7 @@ int cc_b(struct zint_symbol *symbol, unsigned char source[], int cc_width)
/* so now pattern[] holds the string of '1's and '0's. - copy this to the symbol */
for(loop = 0; loop < strlen(pattern); loop++) {
symbol->encoded_data[i][loop] = pattern[loop];
if(pattern[loop] == '1') { set_module(symbol, i, loop); }
}
symbol->row_height[i] = 2;
@ -683,7 +683,7 @@ int cc_c(struct zint_symbol *symbol, unsigned char source[], int cc_width, int e
lookup(BRSET, PDFttf, codebarre[loop], pattern);
}
for(loop = 0; loop < strlen(pattern); loop++) {
symbol->encoded_data[i][loop] = pattern[loop];
if(pattern[loop] == '1') { set_module(symbol, i, loop); }
}
symbol->row_height[i] = 3;
}
@ -1851,10 +1851,10 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
/* Move the 2d component of the symbol horizontally */
for(i = 0; i <= symbol->rows; i++) {
for(j = (symbol->width + top_shift); j >= top_shift; j--) {
symbol->encoded_data[i][j] = symbol->encoded_data[i][j - top_shift];
if(module_is_set(symbol, i, j - top_shift)) { set_module(symbol, i, j); } else { unset_module(symbol, i, j); }
}
for(j = 0; j < top_shift; j++) {
symbol->encoded_data[i][j] = '0';
unset_module(symbol, i, j);
}
}
}
@ -1863,7 +1863,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
for(i = 0; i <= linear->rows; i++) {
symbol->row_height[symbol->rows + i] = linear->row_height[i];
for(j = 0; j <= linear->width; j++) {
symbol->encoded_data[i + symbol->rows][j + bottom_shift] = linear->encoded_data[i][j];
if(module_is_set(linear, i, j)) { set_module(symbol, i + symbol->rows, j + bottom_shift); } else { unset_module(symbol, i + symbol->rows, j + bottom_shift); }
}
}
if((linear->width + bottom_shift) > symbol->width) {

View File

@ -842,9 +842,8 @@ int data_matrix_200(struct zint_symbol *symbol, unsigned char source[])
int x;
for(x = 0; x < W; x++) {
if(grid[W * y + x]) {
symbol->encoded_data[(H - y) - 1][x] = '1'; }
else {
symbol->encoded_data[(H - y) - 1][x] = '0'; }
set_module(symbol, (H - y) - 1, x);
}
}
symbol->row_height[(H - y) - 1] = 1;
}

View File

@ -1241,41 +1241,41 @@ int matrix89(struct zint_symbol *symbol, unsigned char source[])
symbol->row_height[0] = 1;
/* Fill corners */
symbol->encoded_data[0][0] = '1';
symbol->encoded_data[0][width + 1] = '1';
symbol->encoded_data[width + 1][0] = '1';
symbol->encoded_data[width + 1][width + 1] = '1';
set_module(symbol, 0, 0);
set_module(symbol, 0, width + 1);
set_module(symbol, width + 1, 0);
set_module(symbol, width + 1, width + 1);
for(i = 0; i < width; i++) {
/* Fill sides */
symbol->encoded_data[i + 1][0] = '1';
symbol->encoded_data[width + 1][i + 1] = '1';
set_module(symbol, i + 1, 0);
set_module(symbol, width + 1, i + 1);
if((i % 2) == 0) {
symbol->encoded_data[i][width + 1] = '1';
symbol->encoded_data[0][i] = '1';
set_module(symbol, i, width + 1);
set_module(symbol, 0, i);
}
for(j = 0; j < width; j++) {
switch(symbol_size) {
case 0: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh1[(i * width) + j]]; break;
case 1: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh2[(i * width) + j]]; break;
case 2: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh3[(i * width) + j]]; break;
case 3: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh4[(i * width) + j]]; break;
case 4: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh5[(i * width) + j]]; break;
case 5: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh6[(i * width) + j]]; break;
case 6: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh7[(i * width) + j]]; break;
case 7: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh8[(i * width) + j]]; break;
case 8: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh9[(i * width) + j]]; break;
case 9: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh10[(i * width) + j]]; break;
case 10: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh11[(i * width) + j]]; break;
case 11: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh12[(i * width) + j]]; break;
case 12: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh13[(i * width) + j]]; break;
case 13: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh14[(i * width) + j]]; break;
case 14: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh15[(i * width) + j]]; break;
case 15: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh16[(i * width) + j]]; break;
case 16: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh17[(i * width) + j]]; break;
case 17: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh18[(i * width) + j]]; break;
case 18: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh19[(i * width) + j]]; break;
case 19: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh20[(i * width) + j]]; break;
case 20: symbol->encoded_data[i + 1][j + 1] = randomized_stream[tableh21[(i * width) + j]]; break;
case 0: if(randomized_stream[tableh1[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 1: if(randomized_stream[tableh2[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 2: if(randomized_stream[tableh3[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 3: if(randomized_stream[tableh4[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 4: if(randomized_stream[tableh5[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 5: if(randomized_stream[tableh6[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 6: if(randomized_stream[tableh7[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 7: if(randomized_stream[tableh8[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 8: if(randomized_stream[tableh9[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 9: if(randomized_stream[tableh10[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 10: if(randomized_stream[tableh11[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 11: if(randomized_stream[tableh12[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 12: if(randomized_stream[tableh13[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 13: if(randomized_stream[tableh14[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 14: if(randomized_stream[tableh15[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 15: if(randomized_stream[tableh16[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 16: if(randomized_stream[tableh17[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 17: if(randomized_stream[tableh18[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 18: if(randomized_stream[tableh19[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 19: if(randomized_stream[tableh20[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
case 20: if(randomized_stream[tableh21[(i * width) + j]] == '1') { set_module(symbol, i + 1, j + 1); } break;
}
}
symbol->row_height[i + 1] = 1;

View File

@ -313,12 +313,12 @@ int imail(struct zint_symbol *symbol, unsigned char source[])
errno = 0;
if(ustrlen(source) > 32) {
strcpy(symbol->errtxt, "Input too long [851]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
errno = is_sane(NASET, source);
if(errno == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [852]");
strcpy(symbol->errtxt, "Invalid characters in data");
return errno;
}
@ -361,11 +361,11 @@ int imail(struct zint_symbol *symbol, unsigned char source[])
}
if(strlen(tracker) != 20) {
strcpy(symbol->errtxt, "Invalid length tracking code [853]");
strcpy(symbol->errtxt, "Invalid length tracking code");
return ERROR_INVALID_DATA;
}
if(strlen(zip) > 11) {
strcpy(symbol->errtxt, "Invalid ZIP code [854]");
strcpy(symbol->errtxt, "Invalid ZIP code");
return ERROR_INVALID_DATA;
}
@ -672,12 +672,12 @@ int imail(struct zint_symbol *symbol, unsigned char source[])
{
if((data_pattern[i] == '1') || (data_pattern[i] == '0'))
{
symbol->encoded_data[0][read] = '1';
set_module(symbol, 0, read);
}
symbol->encoded_data[1][read] = '1';
set_module(symbol, 1, read);
if((data_pattern[i] == '2') || (data_pattern[i] == '0'))
{
symbol->encoded_data[2][read] = '1';
set_module(symbol, 2, read);
}
read += 2;
}

View File

@ -54,7 +54,7 @@ struct zint_symbol *ZBarcode_Create()
strcpy(symbol->primary, "");
for(i = 0; i < 178; i++) {
for(j = 0; j < 1000; j++) {
symbol->encoded_data[i][j] = '0';
unset_module(symbol, i, j);
}
symbol->row_height[i] = 0;
}
@ -585,6 +585,15 @@ int ZBarcode_Print(struct zint_symbol *symbol)
int error_number;
char output[4];
int i, j;
for(i = 0; i < symbol->rows; i++) {
for(j = 0; j < symbol->width / 7; j++) {
printf("%2.2X ", symbol->encoded_data[i][j]);
}
printf("\n");
}
if(strlen(symbol->outfile) > 3) {
output[0] = symbol->outfile[strlen(symbol->outfile) - 3];
output[1] = symbol->outfile[strlen(symbol->outfile) - 2];

View File

@ -579,19 +579,19 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[])
}
if((mode < 2) || (mode > 6)) { /* Only codes 2 to 6 supported */
strcpy(symbol->errtxt, "Invalid Maxicode Mode [571]");
strcpy(symbol->errtxt, "Invalid Maxicode Mode");
return ERROR_INVALID_OPTION;
}
if((mode == 2) || (mode == 3)) { /* Modes 2 and 3 need data in symbol->primary */
if(strlen(symbol->primary) != 15) {
strcpy(symbol->errtxt, "Invalid Primary String [572]");
strcpy(symbol->errtxt, "Invalid Primary String");
return ERROR_INVALID_DATA;
}
for(i = 9; i < 15; i++) { /* check that country code and service are numeric */
if((symbol->primary[i] < 48) || (symbol->primary[i] > 57)) {
strcpy(symbol->errtxt, "Invalid Primary String [573]");
strcpy(symbol->errtxt, "Invalid Primary String");
return ERROR_INVALID_DATA;
}
}
@ -630,7 +630,7 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[])
i = maxi_text_process(mode, source, symbol->nullchar);
if(i == ERROR_TOO_LONG ) {
strcpy(symbol->errtxt, "Input data too long [574]");
strcpy(symbol->errtxt, "Input data too long");
return i;
}
@ -648,7 +648,6 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[])
/* Copy data into symbol grid */
for(i = 0; i < 33; i++) {
for(j = 0; j < 30; j++) {
symbol->encoded_data[i][j] = '0';
block = (MaxiGrid[(i * 30) + j] + 5) / 6;
bit = (MaxiGrid[(i * 30) + j] + 5) % 6;
@ -662,26 +661,26 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[])
bit_pattern[5] = (maxi_codeword[block - 1] & 0x1);
if(bit_pattern[bit] != 0) {
symbol->encoded_data[i][j] = '1';
set_module(symbol, i, j);
}
}
}
}
/* Add orientation markings */
symbol->encoded_data[0][28] = '1'; // Top right filler
symbol->encoded_data[0][29] = '1';
symbol->encoded_data[9][10] = '1'; // Top left marker
symbol->encoded_data[9][11] = '1';
symbol->encoded_data[10][11] = '1';
symbol->encoded_data[15][7] = '1'; // Left hand marker
symbol->encoded_data[16][8] = '1';
symbol->encoded_data[16][20] = '1'; // Right hand marker
symbol->encoded_data[17][20] = '1';
symbol->encoded_data[22][10] = '1'; // Bottom left marker
symbol->encoded_data[23][10] = '1';
symbol->encoded_data[22][17] = '1'; // Bottom right marker
symbol->encoded_data[23][17] = '1';
set_module(symbol, 0, 28); // Top right filler
set_module(symbol, 0, 29);
set_module(symbol, 9, 10); // Top left marker
set_module(symbol, 0, 11);
set_module(symbol, 10, 11);
set_module(symbol, 15, 7); // Left hand marker
set_module(symbol, 16, 8);
set_module(symbol, 16, 20); // Right hand marker
set_module(symbol, 17, 20);
set_module(symbol, 22, 10); // Bottom left marker
set_module(symbol, 23, 10);
set_module(symbol, 22, 17); // Bottom right marker
set_module(symbol, 23, 17);
symbol->width = 30;
symbol->rows = 33;

View File

@ -58,12 +58,12 @@ int pharma_one(struct zint_symbol *symbol, unsigned char source[])
strcpy(dest, "");
if(ustrlen(source) > 6) {
strcpy(symbol->errtxt, "Input too long [511]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [512]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -71,7 +71,7 @@ int pharma_one(struct zint_symbol *symbol, unsigned char source[])
tester = atoi((char*)source);
if((tester < 3) || (tester > 131070)) {
strcpy(symbol->errtxt, "Data out of range [513]");
strcpy(symbol->errtxt, "Data out of range");
return ERROR_INVALID_DATA;
}
@ -120,7 +120,7 @@ int pharma_two_calc(struct zint_symbol *symbol, unsigned char source[], char des
if((tester < 4) || (tester > 64570080))
{
strcpy(symbol->errtxt, "Data out of range [533]");
strcpy(symbol->errtxt, "Data out of range");
return ERROR_INVALID_DATA;
}
do
@ -161,12 +161,12 @@ int pharma_two(struct zint_symbol *symbol, unsigned char source[])
strcpy(height_pattern, "");
if(ustrlen(source) > 8) {
strcpy(symbol->errtxt, "Input too long [531]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [532]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
error_number = pharma_two_calc(symbol, source, height_pattern);
@ -179,11 +179,11 @@ int pharma_two(struct zint_symbol *symbol, unsigned char source[])
{
if((height_pattern[loopey] == '2') || (height_pattern[loopey] == '3'))
{
symbol->encoded_data[0][writer] = '1';
set_module(symbol, 0, writer);
}
if((height_pattern[loopey] == '1') || (height_pattern[loopey] == '3'))
{
symbol->encoded_data[1][writer] = '1';
set_module(symbol, 1, writer);
}
writer += 2;
}
@ -204,13 +204,13 @@ int codabar(struct zint_symbol *symbol, unsigned char source[])
strcpy(dest, "");
if(ustrlen(source) > 60) { /* No stack smashing please */
strcpy(symbol->errtxt, "Input too long [181]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(CASET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [182]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -218,14 +218,14 @@ int codabar(struct zint_symbol *symbol, unsigned char source[])
if(((source[0] != 'A') && (source[0] != 'B')) &&
((source[0] != 'C') && (source[0] != 'D')))
{
strcpy(symbol->errtxt, "Invalid characters in data [183]");
strcpy(symbol->errtxt, "Invalid characters in data");
return 6;
}
if(((source[ustrlen(source) - 1] != 'A') && (source[ustrlen(source) - 1] != 'B')) &&
((source[ustrlen(source) - 1] != 'C') && (source[ustrlen(source) - 1] != 'D')))
{
strcpy(symbol->errtxt, "Invalid characters in data [184]");
strcpy(symbol->errtxt, "Invalid characters in data");
return 6;
}
@ -249,12 +249,12 @@ int code32(struct zint_symbol *symbol, unsigned char source[])
/* Validate the input */
if(ustrlen(source) > 8) {
strcpy(symbol->errtxt, "Input too long [C91]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [C92]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}

View File

@ -940,7 +940,7 @@ int microqr(struct zint_symbol *symbol, unsigned char source[])
/* Copy data into symbol */
for(i = 0; i < width; i++) {
for(j = 0; j < width; j++) {
symbol->encoded_data[i][j] = candidate[i][j];
if(candidate[i][j] == '1') { set_module(symbol, i, j); }
}
symbol->row_height[i] = 1;
}

View File

@ -701,7 +701,7 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[])
lookup(BRSET, PDFttf, codebarre[loop], pattern);
}
for(loop = 0; loop < strlen(pattern); loop++) {
symbol->encoded_data[i][loop] = pattern[loop];
if(pattern[loop] == '1') { set_module(symbol, i, loop); }
}
symbol->row_height[i] = 3;
}
@ -720,12 +720,12 @@ int pdf417enc(struct zint_symbol *symbol, unsigned char source[])
errno = 0;
if((symbol->option_1 < -1) || (symbol->option_1 > 8)) {
strcpy(symbol->errtxt, "Security value out of range [551]");
strcpy(symbol->errtxt, "Security value out of range");
symbol->option_1 = -1;
errno = WARN_INVALID_OPTION;
}
if((symbol->option_2 < 0) || (symbol->option_2 > 30)) {
strcpy(symbol->errtxt, "Number of columns out of range [552]");
strcpy(symbol->errtxt, "Number of columns out of range");
symbol->option_2 = 0;
errno = WARN_INVALID_OPTION;
}
@ -737,23 +737,23 @@ int pdf417enc(struct zint_symbol *symbol, unsigned char source[])
if(codeerr != 0) {
switch(codeerr) {
case 1:
strcpy(symbol->errtxt, "No such file or file unreadable [553]");
strcpy(symbol->errtxt, "No such file or file unreadable");
errno = ERROR_INVALID_OPTION;
break;
case 2:
strcpy(symbol->errtxt, "Input string too long [554]");
strcpy(symbol->errtxt, "Input string too long");
errno = ERROR_TOO_LONG;
break;
case 3:
strcpy(symbol->errtxt, "Number of codewords per row too small [555]");
strcpy(symbol->errtxt, "Number of codewords per row too small");
errno = WARN_INVALID_OPTION;
break;
case 4:
strcpy(symbol->errtxt, "Data too long for specified number of columns [556]");
strcpy(symbol->errtxt, "Data too long for specified number of columns");
errno = ERROR_TOO_LONG;
break;
default:
strcpy(symbol->errtxt, "Something strange happened [557]");
strcpy(symbol->errtxt, "Something strange happened");
errno = ERROR_ENCODING_PROBLEM;
break;
}
@ -821,11 +821,11 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[])
/* This is where it all changes! */
if(mclength > 126) {
strcpy(symbol->errtxt, "Input data too long [841]");
strcpy(symbol->errtxt, "Input data too long");
return ERROR_TOO_LONG;
}
if(symbol->option_2 > 4) {
strcpy(symbol->errtxt, "Specified width out of range [842]");
strcpy(symbol->errtxt, "Specified width out of range");
symbol->option_2 = 0;
codeerr = WARN_INVALID_OPTION;
}
@ -837,21 +837,21 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[])
if((symbol->option_2 == 1) && (mclength > 20)) {
/* the user specified 1 column but the data doesn't fit - go to automatic */
symbol->option_2 = 0;
strcpy(symbol->errtxt, "Specified symbol size too small for data [843]");
strcpy(symbol->errtxt, "Specified symbol size too small for data");
codeerr = WARN_INVALID_OPTION;
}
if((symbol->option_2 == 2) && (mclength > 37)) {
/* the user specified 2 columns but the data doesn't fit - go to automatic */
symbol->option_2 = 0;
strcpy(symbol->errtxt, "Specified symbol size too small for data [844]");
strcpy(symbol->errtxt, "Specified symbol size too small for data");
codeerr = WARN_INVALID_OPTION;
}
if((symbol->option_2 == 3) && (mclength > 82)) {
/* the user specified 3 columns but the data doesn't fit - go to automatic */
symbol->option_2 = 0;
strcpy(symbol->errtxt, "Specified symbol size too small for data [845]");
strcpy(symbol->errtxt, "Specified symbol size too small for data");
codeerr = WARN_INVALID_OPTION;
}
@ -1038,7 +1038,7 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[])
/* so now pattern[] holds the string of '1's and '0's. - copy this to the symbol */
for(loop = 0; loop < strlen(pattern); loop++) {
symbol->encoded_data[i][loop] = pattern[loop];
if(pattern[loop] == '1') { set_module(symbol, i, loop); }
}
symbol->row_height[i] = 2;

View File

@ -47,12 +47,12 @@ int plessey(struct zint_symbol *symbol, unsigned char source[])
strcpy(dest, "");
if(ustrlen(source) > 65) {
strcpy(symbol->errtxt, "Input too long [861]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(SSET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [862]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
checkptr = calloc (1, ustrlen(source) * 4 + 8);
@ -109,12 +109,12 @@ int msi_plessey(struct zint_symbol *symbol, unsigned char source[])
strcpy(dest, "");
if(ustrlen(source) > 55) {
strcpy(symbol->errtxt, "Input too long [471]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [472]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -147,12 +147,12 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[])
strcpy(dest, "");
if(ustrlen(source) > 55) {
strcpy(symbol->errtxt, "Input too long [473]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [474]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -245,12 +245,12 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[])
strcpy(dest, "");
if(ustrlen(source) > 55) { /* No Entry Stack Smashers! */
strcpy(symbol->errtxt, "Input too long [475]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if (error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [476]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -402,12 +402,12 @@ int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[])
strcpy(dest, "");
if(ustrlen(source) > 55) {
strcpy(symbol->errtxt, "Input too long [477]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [478]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -472,12 +472,12 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[])
strcpy(dest, "");
if(ustrlen(source) > 55) {
strcpy(symbol->errtxt, "Input too long [479]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if (error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [47A]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}

View File

@ -396,7 +396,7 @@ int maxi_png_plot(struct zint_symbol *symbol, int rotate_angle)
yposn = row * 9;
for(column = 0; column < symbol->width; column++) {
xposn = column * 10;
if(symbol->encoded_data[row][column] == '1') {
if(module_is_set(symbol, row, column)) {
if((row % 2) == 0) {
/* Even (full) row */
draw_hexagon(pixelbuf, image_width, xposn + (scaler * xoffset), yposn + (scaler * yoffset));
@ -501,7 +501,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
symbol->height = preset_height;
}
while(symbol->encoded_data[symbol->rows - 1][comp_offset] != '1') {
while(!(module_is_set(symbol, symbol->rows - 1, comp_offset))) {
comp_offset++;
}
@ -597,7 +597,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
plot_yposn = (int)row_posn;
i = 0;
if(symbol->encoded_data[this_row][0] == '1') {
if(module_is_set(symbol, this_row, 0)) {
latch = 1;
} else {
latch = 0;
@ -607,7 +607,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
block_width = 0;
do {
block_width++;
} while (symbol->encoded_data[this_row][i + block_width] == symbol->encoded_data[this_row][i]);
} while (module_is_set(symbol, this_row, i + block_width) == module_is_set(symbol, this_row, i));
if((addon_latch == 0) && (r == 0) && (i > main_width)) {
plot_height = (int)(row_height - 5.0);
plot_yposn = (int)(row_posn - 5.0);
@ -718,7 +718,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
block_width = 0;
do {
block_width++;
} while (symbol->encoded_data[symbol->rows - 1][i + block_width] == symbol->encoded_data[symbol->rows - 1][i]);
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if(latch == 1) {
/* a bar */
draw_bar(pixelbuf, (i + xoffset - comp_offset) * scaler, block_width * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height);
@ -737,7 +737,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
block_width = 0;
do {
block_width++;
} while (symbol->encoded_data[symbol->rows - 1][i + block_width] == symbol->encoded_data[symbol->rows - 1][i]);
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if(latch == 1) {
/* a bar */
draw_bar(pixelbuf, (i + xoffset - comp_offset) * scaler, block_width * scaler, (4 + (int)yoffset) * scaler, 5 * scaler, image_width, image_height);

View File

@ -67,12 +67,12 @@ int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[])
error_number = 0;
if(ustrlen(source) > 38) {
strcpy(symbol->errtxt, "Input too long [401]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [402]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
sum = 0;
@ -116,9 +116,9 @@ int post_plot(struct zint_symbol *symbol, unsigned char source[])
{
if(height_pattern[loopey] == 'L')
{
symbol->encoded_data[0][writer] = '1';
set_module(symbol, 0, writer);
}
symbol->encoded_data[1][writer] = '1';
set_module(symbol, 1, writer);
writer += 3;
}
symbol->row_height[0] = 6;
@ -138,12 +138,12 @@ int planet(struct zint_symbol *symbol, unsigned char source[], char dest[])
error_number = 0;
if(ustrlen(source) > 38) {
strcpy(symbol->errtxt, "Input too long [821]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [822]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
sum = 0;
@ -187,9 +187,9 @@ int planet_plot(struct zint_symbol *symbol, unsigned char source[])
{
if(height_pattern[loopey] == 'L')
{
symbol->encoded_data[0][writer] = '1';
set_module(symbol, 0, writer);
}
symbol->encoded_data[1][writer] = '1';
set_module(symbol, 1, writer);
writer += 3;
}
symbol->row_height[0] = 6;
@ -208,12 +208,12 @@ int korea_post(struct zint_symbol *symbol, unsigned char source[])
error_number = 0;
h = ustrlen(source);
if(h > 6) {
strcpy(symbol->errtxt, "Input too long [771]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [772]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
strcpy(localstr, "");
@ -255,12 +255,12 @@ int fim(struct zint_symbol *symbol, unsigned char source[])
to_upper(source);
if(ustrlen(source) > 1) {
strcpy(symbol->errtxt, "Input too long [491]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(BESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [492]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
lookup(BESET, FIMTable, source[0], dest);
@ -317,12 +317,12 @@ int royal_plot(struct zint_symbol *symbol, unsigned char source[])
to_upper(source);
if(ustrlen(source) > 120) {
strcpy(symbol->errtxt, "Input too long [701]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(KRSET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [702]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
check = rm4scc((char*)source, (unsigned char*)height_pattern);
@ -332,12 +332,12 @@ int royal_plot(struct zint_symbol *symbol, unsigned char source[])
{
if((height_pattern[loopey] == '1') || (height_pattern[loopey] == '0'))
{
symbol->encoded_data[0][writer] = '1';
set_module(symbol, 0, writer);
}
symbol->encoded_data[1][writer] = '1';
set_module(symbol, 1, writer);
if((height_pattern[loopey] == '2') || (height_pattern[loopey] == '0'))
{
symbol->encoded_data[2][writer] = '1';
set_module(symbol, 2, writer);
}
writer += 2;
}
@ -366,12 +366,12 @@ int kix_code(struct zint_symbol *symbol, unsigned char source[])
to_upper(source);
if(ustrlen(source) > 11) {
strcpy(symbol->errtxt, "Input too long [901]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(KRSET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [902]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -392,12 +392,12 @@ int kix_code(struct zint_symbol *symbol, unsigned char source[])
{
if((height_pattern[loopey] == '1') || (height_pattern[loopey] == '0'))
{
symbol->encoded_data[0][writer] = '1';
set_module(symbol, 0, writer);
}
symbol->encoded_data[1][writer] = '1';
set_module(symbol, 1, writer);
if((height_pattern[loopey] == '2') || (height_pattern[loopey] == '0'))
{
symbol->encoded_data[2][writer] = '1';
set_module(symbol, 2, writer);
}
writer += 2;
}
@ -447,12 +447,12 @@ int daft_code(struct zint_symbol *symbol, unsigned char source[])
{
if((height_pattern[loopey] == '1') || (height_pattern[loopey] == '0'))
{
symbol->encoded_data[0][writer] = '1';
set_module(symbol, 0, writer);
}
symbol->encoded_data[1][writer] = '1';
set_module(symbol, 1, writer);
if((height_pattern[loopey] == '2') || (height_pattern[loopey] == '0'))
{
symbol->encoded_data[2][writer] = '1';
set_module(symbol, 2, writer);
}
writer += 2;
}
@ -476,12 +476,12 @@ int flattermarken(struct zint_symbol *symbol, unsigned char source[])
strcpy(dest, "");
if(ustrlen(source) > 90) {
strcpy(symbol->errtxt, "Input too long [281]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [282]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -570,12 +570,12 @@ int japan_post(struct zint_symbol *symbol, unsigned char source[])
{
if((pattern[loopey] == '2') || (pattern[loopey] == '1'))
{
symbol->encoded_data[0][writer] = '1';
set_module(symbol, 0, writer);
}
symbol->encoded_data[1][writer] = '1';
set_module(symbol, 1, writer);
if((pattern[loopey] == '3') || (pattern[loopey] == '1'))
{
symbol->encoded_data[2][writer] = '1';
set_module(symbol, 2, writer);
}
writer += 2;
}

View File

@ -116,7 +116,7 @@ int ps_plot(struct zint_symbol *symbol)
symbol->height = preset_height;
}
while(symbol->encoded_data[symbol->rows - 1][comp_offset] != '1') {
while(!(module_is_set(symbol, symbol->rows - 1, comp_offset))) {
comp_offset++;
}
@ -238,7 +238,7 @@ int ps_plot(struct zint_symbol *symbol)
fprintf(feps, "%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f TC\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 3.31 * scaler, (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 1.43 * scaler, (37.19 + xoffset) * scaler, (35.60 + yoffset) * scaler);
for(r = 0; r < symbol->rows; r++) {
for(i = 0; i < symbol->width; i++) {
if(symbol->encoded_data[r][i] == '1') {
if(module_is_set(symbol, r, i)) {
/* Dump a hexagon */
my = ((symbol->rows - r - 1)) * 2.135 + 1.43;
ay = my + 1.0 + yoffset;
@ -290,7 +290,7 @@ int ps_plot(struct zint_symbol *symbol)
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "%.2f %.2f ", row_height * scaler, row_posn * scaler);
i = 0;
if(symbol->encoded_data[this_row][0] == '1') {
if(module_is_set(symbol, this_row, 0)) {
latch = 1;
} else {
latch = 0;
@ -300,7 +300,7 @@ int ps_plot(struct zint_symbol *symbol)
block_width = 0;
do {
block_width++;
} while (symbol->encoded_data[this_row][i + block_width] == symbol->encoded_data[this_row][i]);
} while (module_is_set(symbol, this_row, i + block_width) == module_is_set(symbol, this_row, i));
if((addon_latch == 0) && (r == 0) && (i > main_width)) {
fprintf(feps, "TE\n");
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
@ -498,7 +498,7 @@ int ps_plot(struct zint_symbol *symbol)
block_width = 0;
do {
block_width++;
} while (symbol->encoded_data[symbol->rows - 1][i + block_width] == symbol->encoded_data[symbol->rows - 1][i]);
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if(latch == 1) {
/* a bar */
fprintf(feps, "TB %.2f %.2f TR\n", (i + xoffset - comp_offset) * scaler, block_width * scaler);
@ -517,7 +517,7 @@ int ps_plot(struct zint_symbol *symbol)
block_width = 0;
do {
block_width++;
} while (symbol->encoded_data[symbol->rows - 1][i + block_width] == symbol->encoded_data[symbol->rows - 1][i]);
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if(latch == 1) {
/* a bar */
fprintf(feps, "TB %.2f %.2f TR\n", (i + xoffset - comp_offset) * scaler, block_width * scaler);

View File

@ -71,7 +71,7 @@ int qr_code(struct zint_symbol *symbol, unsigned char source[])
code = encode(symbol->option_1, symbol->option_2, source, kanji);
if(code == NULL) {
strcpy(symbol->errtxt, "libqrencode failed to encode the input data [581]");
strcpy(symbol->errtxt, "libqrencode failed to encode the input data");
return ERROR_ENCODING_PROBLEM;
}
@ -80,10 +80,8 @@ int qr_code(struct zint_symbol *symbol, unsigned char source[])
for(i = 0; i < code->width; i++) {
for(j = 0; j < code->width; j++) {
if((*(code->data + (i * code->width) + j) & 0x01) == 0) {
symbol->encoded_data[i][j] = '0';
} else {
symbol->encoded_data[i][j] = '1';
if((*(code->data + (i * code->width) + j) & 0x01) != 0) {
set_module(symbol, i, j);
}
}
symbol->row_height[i] = 1;
@ -98,7 +96,7 @@ int qr_code(struct zint_symbol *symbol, unsigned char source[])
/* Handler if no QR Encode library is available */
int qr_code(struct zint_symbol *symbol, unsigned char source[])
{
strcpy(symbol->errtxt, "QR Code library <qrencode> not available [580]");
strcpy(symbol->errtxt, "QR Code library <qrencode> not available");
return ERROR_INVALID_OPTION;
}
#endif

View File

@ -151,12 +151,12 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
separator_row = 0;
if(ustrlen(source) > 13) {
strcpy(symbol->errtxt, "Input too long [291]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [292]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -371,7 +371,7 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
latch = '0';
for(i = 0; i < 46; i++) {
for(j = 0; j < total_widths[i]; j++) {
symbol->encoded_data[symbol->rows][writer] = latch;
if(latch == '1') { set_module(symbol, symbol->rows, writer); }
writer++;
}
if(latch == '1') {
@ -384,35 +384,36 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
if(symbol->symbology == BARCODE_RSS14_CC) {
/* separator pattern for composite symbol */
for(i = 4; i < 92; i++) {
if(symbol->encoded_data[separator_row + 1][i] != '1') {
symbol->encoded_data[separator_row][i] = '1';
}
if(!(module_is_set(symbol, separator_row + 1, i))) {
set_module(symbol, separator_row, i); }
}
latch = '1';
for(i = 16; i < 32; i++) {
if(symbol->encoded_data[separator_row + 1][i] != '1') {
symbol->encoded_data[separator_row][i] = latch;
if(!(module_is_set(symbol, separator_row + 1, i))) {
if(latch == '1') {
set_module(symbol, separator_row, i);
latch = '0';
} else {
unset_module(symbol, separator_row, i);
latch = '1';
}
} else {
symbol->encoded_data[separator_row][i] = '0';
unset_module(symbol, separator_row, i);
latch = '1';
}
}
latch = '1';
for(i = 63; i < 78; i++) {
if(symbol->encoded_data[separator_row + 1][i] != '1') {
symbol->encoded_data[separator_row][i] = latch;
if(!(module_is_set(symbol, separator_row + 1, i))) {
if(latch == '1') {
set_module(symbol, separator_row, i);
latch = '0';
} else {
unset_module(symbol, separator_row, i);
latch = '1';
}
} else {
symbol->encoded_data[separator_row][i] = '0';
unset_module(symbol, separator_row, i);
latch = '1';
}
}
@ -455,7 +456,11 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
latch = '0';
for(i = 0; i < 23; i++) {
for(j = 0; j < total_widths[i]; j++) {
symbol->encoded_data[symbol->rows][writer] = latch;
if(latch == '1') {
set_module(symbol, symbol->rows, writer);
} else {
unset_module(symbol, symbol->rows, writer);
}
writer++;
}
if(latch == '1') {
@ -464,18 +469,22 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
latch = '1';
}
}
symbol->encoded_data[symbol->rows][writer] = '1';
symbol->encoded_data[symbol->rows][writer + 1] = '0';
set_module(symbol, symbol->rows, writer);
unset_module(symbol, symbol->rows, writer + 1);
symbol->row_height[symbol->rows] = 5;
/* bottom row */
symbol->rows = symbol->rows + 2;
symbol->encoded_data[symbol->rows][0] = '1';
symbol->encoded_data[symbol->rows][1] = '0';
set_module(symbol, symbol->rows, 0);
unset_module(symbol, symbol->rows, 1);
writer = 0;
latch = '1';
for(i = 23; i < 46; i++) {
for(j = 0; j < total_widths[i]; j++) {
symbol->encoded_data[symbol->rows][writer + 2] = latch;
if(latch == '1') {
set_module(symbol, symbol->rows, writer + 2);
} else {
unset_module(symbol, symbol->rows, writer + 2);
}
writer++;
}
if(latch == '1') {
@ -487,13 +496,13 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
symbol->row_height[symbol->rows] = 7;
/* separator pattern */
for(i = 4; i < 46; i++) {
if(symbol->encoded_data[symbol->rows - 2][i] == symbol->encoded_data[symbol->rows][i]) {
if(symbol->encoded_data[symbol->rows - 2][i] == '0') {
symbol->encoded_data[symbol->rows - 1][i] = '1';
if(module_is_set(symbol, symbol->rows - 2, i) == module_is_set(symbol, symbol->rows, i)) {
if(!(module_is_set(symbol, symbol->rows - 2, i))) {
set_module(symbol, symbol->rows - 1, i);
}
} else {
if(symbol->encoded_data[symbol->rows - 1][i - 1] != '1') {
symbol->encoded_data[symbol->rows - 1][i] = '1';
if(!(module_is_set(symbol, symbol->rows - 1, i - 1))) {
set_module(symbol, symbol->rows - 1, i);
}
}
}
@ -501,21 +510,22 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
if(symbol->symbology == BARCODE_RSS14STACK_CC) {
/* separator pattern for composite symbol */
for(i = 4; i < 46; i++) {
if(symbol->encoded_data[separator_row + 1][i] != '1') {
symbol->encoded_data[separator_row][i] = '1';
if(!(module_is_set(symbol, separator_row + 1, i))) {
set_module(symbol, separator_row, i);
}
}
latch = '1';
for(i = 16; i < 32; i++) {
if(symbol->encoded_data[separator_row + 1][i] != '1') {
symbol->encoded_data[separator_row][i] = latch;
if(!(module_is_set(symbol, separator_row + 1, i))) {
if(latch == '1') {
set_module(symbol, separator_row, i);
latch = '0';
} else {
unset_module(symbol, separator_row, i);
latch = '1';
}
} else {
symbol->encoded_data[separator_row][i] = '0';
unset_module(symbol, separator_row, i);
latch = '1';
}
}
@ -530,7 +540,7 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
latch = '0';
for(i = 0; i < 23; i++) {
for(j = 0; j < total_widths[i]; j++) {
symbol->encoded_data[symbol->rows][writer] = latch;
if(latch == '1') { set_module(symbol, symbol->rows, writer); } else { unset_module(symbol, symbol->rows, writer); }
writer++;
}
if(latch == '1') {
@ -539,17 +549,17 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
latch = '1';
}
}
symbol->encoded_data[symbol->rows][writer] = '1';
symbol->encoded_data[symbol->rows][writer + 1] = '0';
set_module(symbol, symbol->rows, writer);
unset_module(symbol, symbol->rows, writer + 1);
/* bottom row */
symbol->rows = symbol->rows + 4;
symbol->encoded_data[symbol->rows][0] = '1';
symbol->encoded_data[symbol->rows][1] = '0';
set_module(symbol, symbol->rows, 0);
unset_module(symbol, symbol->rows, 1);
writer = 0;
latch = '1';
for(i = 23; i < 46; i++) {
for(j = 0; j < total_widths[i]; j++) {
symbol->encoded_data[symbol->rows][writer + 2] = latch;
if(latch == '1') { set_module(symbol, symbol->rows, writer + 2); } else { unset_module(symbol, symbol->rows, writer + 2); }
writer++;
}
if(latch == '1') {
@ -560,47 +570,49 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
}
/* middle separator */
for(i = 5; i < 46; i += 2) {
symbol->encoded_data[symbol->rows - 2][i] = '1';
set_module(symbol, symbol->rows - 2, i);
}
symbol->row_height[symbol->rows - 2] = 1;
/* top separator */
for(i = 4; i < 46; i++) {
if(symbol->encoded_data[symbol->rows - 4][i] != '1') {
symbol->encoded_data[symbol->rows - 3][i] = '1';
if(!(module_is_set(symbol, symbol->rows - 4, i))) {
set_module(symbol, symbol->rows - 3, i);
}
}
latch = '1';
for(i = 17; i < 33; i++) {
if(symbol->encoded_data[symbol->rows - 4][i] != '1') {
symbol->encoded_data[symbol->rows - 3][i] = latch;
if(!(module_is_set(symbol, symbol->rows - 4, i))) {
if(latch == '1') {
set_module(symbol, symbol->rows - 3, i);
latch = '0';
} else {
unset_module(symbol, symbol->rows - 3, i);
latch = '1';
}
} else {
symbol->encoded_data[symbol->rows - 3][i] = '0';
unset_module(symbol, symbol->rows - 3, i);
latch = '1';
}
}
symbol->row_height[symbol->rows - 3] = 1;
/* bottom separator */
for(i = 4; i < 46; i++) {
if(symbol->encoded_data[symbol->rows][i] != '1') {
symbol->encoded_data[symbol->rows - 1][i] = '1';
if(!(module_is_set(symbol, symbol->rows, i))) {
set_module(symbol, symbol->rows - 1, i);
}
}
latch = '1';
for(i = 16; i < 32; i++) {
if(symbol->encoded_data[symbol->rows][i] != '1') {
symbol->encoded_data[symbol->rows - 1][i] = latch;
if(!(module_is_set(symbol, symbol->rows, i))) {
if(latch == '1') {
set_module(symbol, symbol->rows - 1, i);
latch = '0';
} else {
unset_module(symbol, symbol->rows - 1, i);
latch = '1';
}
} else {
symbol->encoded_data[symbol->rows - 1][i] = '0';
unset_module(symbol, symbol->rows - 1, i);
latch = '1';
}
}
@ -609,21 +621,22 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
if(symbol->symbology == BARCODE_RSS14_OMNI_CC) {
/* separator pattern for composite symbol */
for(i = 4; i < 46; i++) {
if(symbol->encoded_data[separator_row + 1][i] != '1') {
symbol->encoded_data[separator_row][i] = '1';
if(!(module_is_set(symbol, separator_row + 1, i))) {
set_module(symbol, separator_row, i);
}
}
latch = '1';
for(i = 16; i < 32; i++) {
if(symbol->encoded_data[separator_row + 1][i] != '1') {
symbol->encoded_data[separator_row][i] = latch;
if(!(module_is_set(symbol, separator_row + 1, i))) {
if(latch == '1') {
set_module(symbol, separator_row, i);
latch = '0';
} else {
unset_module(symbol, separator_row, i);
latch = '1';
}
} else {
symbol->encoded_data[separator_row][i] = '0';
unset_module(symbol, separator_row, i);
latch = '1';
}
}
@ -648,12 +661,12 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[])
separator_row = 0;
if(ustrlen(source) > 13) {
strcpy(symbol->errtxt, "Input too long [301]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
error_number = is_sane(NESET, source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [302]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -846,7 +859,7 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[])
latch = '0';
for(i = 0; i < 46; i++) {
for(j = 0; j < total_widths[i]; j++) {
symbol->encoded_data[symbol->rows][writer] = latch;
if(latch == '1') { set_module(symbol, symbol->rows, writer); } else { unset_module(symbol, symbol->rows, writer); }
writer++;
}
if(latch == '1') {
@ -861,8 +874,8 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[])
/* add separator pattern if composite symbol */
if(symbol->symbology == BARCODE_RSS_LTD_CC) {
for(i = 4; i < 70; i++) {
if(symbol->encoded_data[separator_row + 1][i] != '1') {
symbol->encoded_data[separator_row][i] = '1';
if(!(module_is_set(symbol, separator_row + 1, i))) {
set_module(symbol, separator_row, i);
}
}
}
@ -1190,7 +1203,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
if((source[i] < '0') || (source[i] > '9')) {
if((source[i] != '[') && (source[i] != ']')) {
/* Something is wrong */
strcpy(symbol->errtxt, "Invalid characters in input data [314]");
strcpy(symbol->errtxt, "Invalid characters in input data");
return ERROR_INVALID_DATA;
}
}
@ -1561,7 +1574,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
if(latch == 1) {
/* Invalid characters in input data */
strcpy(symbol->errtxt, "Invalid characters in input data [315]");
strcpy(symbol->errtxt, "Invalid characters in input data");
return ERROR_INVALID_DATA;
}
@ -1794,7 +1807,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
}
if(strlen(binary_string) > 252) {
strcpy(symbol->errtxt, "Input too long [316]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
@ -1995,7 +2008,7 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
latch = '0';
for(i = 0; i < pattern_width; i++) {
for(j = 0; j < elements[i]; j++) {
symbol->encoded_data[symbol->rows][writer] = latch;
if(latch == '1') { set_module(symbol, symbol->rows, writer); } else { unset_module(symbol, symbol->rows, writer); }
writer++;
}
if(latch == '1') {
@ -2008,20 +2021,20 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
symbol->rows = symbol->rows + 1;
if(symbol->symbology == BARCODE_RSS_EXP_CC) {
for(j = 4; j < (symbol->width - 4); j++) {
if(symbol->encoded_data[separator_row + 1][j] == '1') {
symbol->encoded_data[separator_row][j] = '0';
if(module_is_set(symbol, separator_row + 1, j)) {
unset_module(symbol, separator_row, j);
} else {
symbol->encoded_data[separator_row][j] = '1';
set_module(symbol, separator_row, j);
}
}
/* finder bar adjustment */
for(j = 0; j < (writer / 49); j++) {
k = (49 * j) + 18;
for(i = 0; i < 15; i++) {
if((symbol->encoded_data[separator_row + 1][i + k - 1] == '0') &&
(symbol->encoded_data[separator_row + 1][i + k] == '0') &&
(symbol->encoded_data[separator_row][i + k - 1] == '1')) {
symbol->encoded_data[separator_row][i + k] = '0';
if((!(module_is_set(symbol, separator_row + 1, i + k - 1))) &&
(!(module_is_set(symbol, separator_row + 1, i + k))) &&
module_is_set(symbol, separator_row, i + k - 1)) {
unset_module(symbol, separator_row, i + k);
}
}
}
@ -2133,7 +2146,7 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
writer = 0;
for(i = 0; i < elements_in_sub; i++) {
for(j = 0; j < sub_elements[i]; j++) {
symbol->encoded_data[symbol->rows][writer] = latch;
if(latch == '1') { set_module(symbol, symbol->rows, writer); } else { unset_module(symbol, symbol->rows, writer); }
writer++;
}
if(latch == '1') {
@ -2147,15 +2160,15 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
if(current_row != 1) {
/* middle separator pattern (above current row) */
for(j = 5; j < (49 * symbol->option_2); j += 2) {
symbol->encoded_data[symbol->rows - 2][j] = '1';
set_module(symbol, symbol->rows - 2, j);
}
symbol->row_height[symbol->rows - 2] = 1;
/* bottom separator pattern (above current row) */
for(j = 4; j < (writer - 4); j++) {
if(symbol->encoded_data[symbol->rows][j] == '1') {
symbol->encoded_data[symbol->rows - 1][j] = '0';
if(module_is_set(symbol, symbol->rows, j)) {
unset_module(symbol, symbol->rows - 1, j);
} else {
symbol->encoded_data[symbol->rows - 1][j] = '1';
set_module(symbol, symbol->rows - 1, j);
}
}
symbol->row_height[symbol->rows - 1] = 1;
@ -2168,18 +2181,18 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
}
if(left_to_right) {
for(i = 0; i < 15; i++) {
if((symbol->encoded_data[symbol->rows][i + k - 1] == '0') &&
(symbol->encoded_data[symbol->rows][i + k] == '0') &&
(symbol->encoded_data[symbol->rows - 1][i + k - 1] == '1')) {
symbol->encoded_data[symbol->rows - 1][i + k] = '0';
if((!(module_is_set(symbol, symbol->rows, i + k - 1))) &&
(!(module_is_set(symbol, symbol->rows, i + k))) &&
module_is_set(symbol, symbol->rows - 1, i + k - 1)) {
unset_module(symbol, symbol->rows - 1, i + k);
}
}
} else {
for(i = 14; i >= 0; i--) {
if((symbol->encoded_data[symbol->rows][i + k + 1] == '0') &&
(symbol->encoded_data[symbol->rows][i + k] == '0') &&
(symbol->encoded_data[symbol->rows - 1][i + k + 1] == '1')) {
symbol->encoded_data[symbol->rows - 1][i + k] = '0';
if((!(module_is_set(symbol, symbol->rows, i + k + 1))) &&
(!(module_is_set(symbol, symbol->rows, i + k))) &&
module_is_set(symbol, symbol->rows - 1, i + k + 1)) {
unset_module(symbol, symbol->rows - 1, i + k);
}
}
}
@ -2189,10 +2202,10 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
if(current_row != stack_rows) {
/* top separator pattern (below current row) */
for(j = 4; j < (writer - 4); j++) {
if(symbol->encoded_data[symbol->rows][j] == '1') {
symbol->encoded_data[symbol->rows + 1][j] = '0';
if(module_is_set(symbol, symbol->rows, j)) {
unset_module(symbol, symbol->rows + 1, j);
} else {
symbol->encoded_data[symbol->rows + 1][j] = '1';
set_module(symbol, symbol->rows + 1, j);
}
}
symbol->row_height[symbol->rows + 1] = 1;
@ -2201,18 +2214,18 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
k = (49 * j) + 18;
if(left_to_right) {
for(i = 0; i < 15; i++) {
if((symbol->encoded_data[symbol->rows][i + k - 1] == '0') &&
(symbol->encoded_data[symbol->rows][i + k] == '0') &&
(symbol->encoded_data[symbol->rows + 1][i + k - 1] == '1')) {
symbol->encoded_data[symbol->rows + 1][i + k] = '0';
if((!(module_is_set(symbol, symbol->rows, i + k - 1))) &&
(!(module_is_set(symbol, symbol->rows, i + k))) &&
module_is_set(symbol, symbol->rows + 1, i + k - 1)) {
unset_module(symbol, symbol->rows + 1, i + k);
}
}
} else{
for(i = 14; i >= 0; i--) {
if((symbol->encoded_data[symbol->rows][i + k + 1] == '0') &&
(symbol->encoded_data[symbol->rows][i + k] == '0') &&
(symbol->encoded_data[symbol->rows + 1][i + k + 1] == '1')) {
symbol->encoded_data[symbol->rows + 1][i + k] = '0';
if((!(module_is_set(symbol, symbol->rows, i + k + 1))) &&
(!(module_is_set(symbol, symbol->rows, i + k))) &&
module_is_set(symbol, symbol->rows + 1, i + k + 1)) {
unset_module(symbol, symbol->rows + 1, i + k);
}
}
}
@ -2224,20 +2237,20 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
symbol->rows = symbol->rows - 3;
if(symbol->symbology == BARCODE_RSS_EXPSTACK_CC) {
for(j = 4; j < (symbol->width - 4); j++) {
if(symbol->encoded_data[separator_row + 1][j] == '1') {
symbol->encoded_data[separator_row][j] = '0';
if(module_is_set(symbol, separator_row + 1, j)) {
unset_module(symbol, separator_row, j);
} else {
symbol->encoded_data[separator_row][j] = '1';
set_module(symbol, separator_row, j);
}
}
/* finder bar adjustment */
for(j = 0; j < reader; j++) {
k = (49 * j) + 18;
for(i = 0; i < 15; i++) {
if((symbol->encoded_data[separator_row + 1][i + k - 1] == '0') &&
(symbol->encoded_data[separator_row + 1][i + k] == '0') &&
(symbol->encoded_data[separator_row][i + k - 1] == '1')) {
symbol->encoded_data[separator_row][i + k] = '0';
if((!(module_is_set(symbol, separator_row + 1, i + k - 1))) &&
(!(module_is_set(symbol, separator_row + 1, i + k))) &&
module_is_set(symbol, separator_row, i + k - 1)) {
unset_module(symbol, separator_row, i + k);
}
}
}

View File

@ -112,7 +112,7 @@ int svg_plot(struct zint_symbol *symbol)
symbol->height = preset_height;
}
while(symbol->encoded_data[symbol->rows - 1][comp_offset] != '1') {
while(!(module_is_set(symbol, symbol->rows - 1, comp_offset))) {
comp_offset++;
}
@ -222,7 +222,7 @@ int svg_plot(struct zint_symbol *symbol)
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 1.43 * scaler, symbol->bgcolour);
for(r = 0; r < symbol->rows; r++) {
for(i = 0; i < symbol->width; i++) {
if(symbol->encoded_data[r][i] == '1') {
if(module_is_set(symbol, r, i)) {
/* Dump a hexagon */
my = r * 2.135 + 1.43;
ay = my + 1.0 + yoffset;
@ -271,7 +271,7 @@ int svg_plot(struct zint_symbol *symbol)
row_posn += yoffset;
i = 0;
if(symbol->encoded_data[this_row][0] == '1') {
if(module_is_set(symbol, this_row, 0)) {
latch = 1;
} else {
latch = 0;
@ -281,7 +281,7 @@ int svg_plot(struct zint_symbol *symbol)
block_width = 0;
do {
block_width++;
} while (symbol->encoded_data[this_row][i + block_width] == symbol->encoded_data[this_row][i]);
} while (module_is_set(symbol, this_row, i + block_width) == module_is_set(symbol, this_row, i));
if((addon_latch == 0) && (r == 0) && (i > main_width)) {
addon_text_posn = 9.0 + symbol->border_width;
addon_latch = 1;
@ -423,7 +423,7 @@ int svg_plot(struct zint_symbol *symbol)
block_width = 0;
do {
block_width++;
} while (symbol->encoded_data[symbol->rows - 1][i + block_width] == symbol->encoded_data[symbol->rows - 1][i]);
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if(latch == 1) {
/* a bar */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (i + xoffset - comp_offset) * scaler, row_posn, block_width * scaler, 5.0 * scaler);
@ -442,7 +442,7 @@ int svg_plot(struct zint_symbol *symbol)
block_width = 0;
do {
block_width++;
} while (symbol->encoded_data[symbol->rows - 1][i + block_width] == symbol->encoded_data[symbol->rows - 1][i]);
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if(latch == 1) {
/* a bar */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (i + xoffset - comp_offset) * scaler, row_posn, block_width * scaler, 5.0 * scaler);

View File

@ -62,14 +62,14 @@ int telepen(struct zint_symbol *symbol, unsigned char source[])
count = 0;
if(ustrlen(source) > 30) {
strcpy(symbol->errtxt, "Input too long [321]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
for(i = 0; i < ustrlen(source); i++) {
if(source[i] > 127) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "Invalid characters in input data [322]");
strcpy(symbol->errtxt, "Invalid characters in input data");
return ERROR_INVALID_DATA;
}
}
@ -115,13 +115,13 @@ int telepen_num(struct zint_symbol *symbol, unsigned char source[])
count = 0;
if(input_length > 60) {
strcpy(symbol->errtxt, "Input too long [871]");
strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG;
}
to_upper(local_source);
error_number = is_sane(NASET, local_source);
if(error_number == ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Invalid characters in data [872]");
strcpy(symbol->errtxt, "Invalid characters in data");
return error_number;
}
@ -146,7 +146,7 @@ int telepen_num(struct zint_symbol *symbol, unsigned char source[])
for (i=0; i < input_length; i+=2)
{
if(local_source[i] == 'X') {
strcpy(symbol->errtxt, "Invalid position of X in Telepen data [873]");
strcpy(symbol->errtxt, "Invalid position of X in Telepen data");
return ERROR_INVALID_DATA;
}

View File

@ -650,23 +650,23 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
case BARCODE_EANX_CC:
switch(ustrlen(first_part))
{ /* Adds vertical separator bars according to ISO/IEC 24723 section 11.4 */
case 7: symbol->encoded_data[symbol->rows][1] = '1';
symbol->encoded_data[symbol->rows][67] = '1';
symbol->encoded_data[symbol->rows + 1][0] = '1';
symbol->encoded_data[symbol->rows + 1][68] = '1';
symbol->encoded_data[symbol->rows + 2][1] = '1';
symbol->encoded_data[symbol->rows + 2][67] = '1';
case 7: set_module(symbol, symbol->rows, 1);
set_module(symbol, symbol->rows, 67);
set_module(symbol, symbol->rows + 1, 0);
set_module(symbol, symbol->rows + 1, 68);
set_module(symbol, symbol->rows + 2, 1);
set_module(symbol, symbol->rows + 1, 67);
symbol->row_height[symbol->rows] = 2;
symbol->row_height[symbol->rows + 1] = 2;
symbol->row_height[symbol->rows + 2] = 2;
symbol->rows += 3;
ean8(symbol, first_part, (char*)dest); break;
case 12:symbol->encoded_data[symbol->rows][1] = '1';
symbol->encoded_data[symbol->rows][95] = '1';
symbol->encoded_data[symbol->rows + 1][0] = '1';
symbol->encoded_data[symbol->rows + 1][96] = '1';
symbol->encoded_data[symbol->rows + 2][1] = '1';
symbol->encoded_data[symbol->rows + 2][95] = '1';
case 12:set_module(symbol, symbol->rows, 1);
set_module(symbol, symbol->rows, 95);
set_module(symbol, symbol->rows + 1, 0);
set_module(symbol, symbol->rows + 1, 96);
set_module(symbol, symbol->rows + 2, 1);
set_module(symbol, symbol->rows + 2, 95);
symbol->row_height[symbol->rows] = 2;
symbol->row_height[symbol->rows + 1] = 2;
symbol->row_height[symbol->rows + 2] = 2;
@ -685,12 +685,12 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
break;
case BARCODE_UPCA_CC:
if(ustrlen(first_part) == 11) {
symbol->encoded_data[symbol->rows][1] = '1';
symbol->encoded_data[symbol->rows][95] = '1';
symbol->encoded_data[symbol->rows + 1][0] = '1';
symbol->encoded_data[symbol->rows + 1][96] = '1';
symbol->encoded_data[symbol->rows + 2][1] = '1';
symbol->encoded_data[symbol->rows + 2][95] = '1';
set_module(symbol, symbol->rows, 1);
set_module(symbol, symbol->rows, 95);
set_module(symbol, symbol->rows + 1, 0);
set_module(symbol, symbol->rows + 1, 96);
set_module(symbol, symbol->rows + 2, 1);
set_module(symbol, symbol->rows + 2, 95);
symbol->row_height[symbol->rows] = 2;
symbol->row_height[symbol->rows + 1] = 2;
symbol->row_height[symbol->rows + 2] = 2;
@ -711,12 +711,12 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
break;
case BARCODE_UPCE_CC:
if((ustrlen(first_part) >= 6) && (ustrlen(first_part) <= 7)) {
symbol->encoded_data[symbol->rows][1] = '1';
symbol->encoded_data[symbol->rows][51] = '1';
symbol->encoded_data[symbol->rows + 1][0] = '1';
symbol->encoded_data[symbol->rows + 1][52] = '1';
symbol->encoded_data[symbol->rows + 2][1] = '1';
symbol->encoded_data[symbol->rows + 2][51] = '1';
set_module(symbol, symbol->rows, 1);
set_module(symbol, symbol->rows, 51);
set_module(symbol, symbol->rows + 1, 0);
set_module(symbol, symbol->rows + 1, 52);
set_module(symbol, symbol->rows + 2, 1);
set_module(symbol, symbol->rows + 2, 51);
symbol->row_height[symbol->rows] = 2;
symbol->row_height[symbol->rows + 1] = 2;
symbol->row_height[symbol->rows + 2] = 2;
@ -761,9 +761,13 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
case BARCODE_UPCE_CC:
/* shift the symbol to the right one space to allow for separator bars */
for(i = (symbol->width + 1); i >= 1; i--) {
symbol->encoded_data[symbol->rows - 1][i] = symbol->encoded_data[symbol->rows - 1][i - 1];
if(module_is_set(symbol, symbol->rows - 1, i - 1)) {
set_module(symbol, symbol->rows - 1, i);
} else {
unset_module(symbol, symbol->rows - 1, i);
}
symbol->encoded_data[symbol->rows - 1][0] = '0';
}
unset_module(symbol, symbol->rows - 1, 0);
symbol->width += 2;
break;
}

View File

@ -44,8 +44,8 @@ struct zint_symbol {
int rows;
int width;
char primary[100];
char encoded_data[178][1000];
int row_height[155];
unsigned char encoded_data[178][143];
int row_height[178]; /* Largest symbol is 177x177 QR Code */
char errtxt[100];
char nullchar;
};

View File

@ -254,6 +254,27 @@ bool QZint::save_to_file(QString filename)
if(error == 0) { return true; } else { return false; }
}
int QZint::module_set(int y_coord, int x_coord)
{
int x_char, x_sub, result;
x_char = x_coord / 7;
x_sub = x_coord % 7;
result = 0;
switch(x_sub) {
case 0: if((m_zintSymbol->encoded_data[y_coord][x_char] & 0x01) != 0) { result = 1; } break;
case 1: if((m_zintSymbol->encoded_data[y_coord][x_char] & 0x02) != 0) { result = 1; } break;
case 2: if((m_zintSymbol->encoded_data[y_coord][x_char] & 0x04) != 0) { result = 1; } break;
case 3: if((m_zintSymbol->encoded_data[y_coord][x_char] & 0x08) != 0) { result = 1; } break;
case 4: if((m_zintSymbol->encoded_data[y_coord][x_char] & 0x10) != 0) { result = 1; } break;
case 5: if((m_zintSymbol->encoded_data[y_coord][x_char] & 0x20) != 0) { result = 1; } break;
case 6: if((m_zintSymbol->encoded_data[y_coord][x_char] & 0x40) != 0) { result = 1; } break;
}
return result;
}
void QZint::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode mode)
{
encode();
@ -375,7 +396,7 @@ void QZint::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode
}
}
while(m_zintSymbol->encoded_data[m_zintSymbol->rows - 1][comp_offset] != '1') {
while(!(module_set(m_zintSymbol->rows - 1, comp_offset))) {
comp_offset++;
}
xoffset = comp_offset;
@ -425,7 +446,7 @@ void QZint::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode
{
for (int c=0;c<m_zintSymbol->width;c++)
{
if (m_zintSymbol->encoded_data[r][c]=='1')
if (module_set(r, c))
{
qreal col=(qreal)c*(maxi_width+1)+(r%2)*((maxi_width+1)/2);
qreal row=(qreal)r*(maxi_width+1)*0.868;
@ -456,15 +477,15 @@ void QZint::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode
for (int row=0;row<m_zintSymbol->rows;row++)
{
for (int i=0;i<m_zintSymbol->width;i++) {
if (m_zintSymbol->encoded_data[row][i]!='0')
if (module_set(row, i))
{
int ed=m_zintSymbol->encoded_data[row][i];
int ed = module_set(row, i);
int linewidth=0;
for (int j=i;j<m_zintSymbol->width;j++,linewidth++)
if (ed!=m_zintSymbol->encoded_data[row][j])
if (ed != module_set(row, j))
break;
QColor color;
switch(ed)
/* switch(ed)
{
case 'R':
color=qRgb(0xff,0x00,0x00);
@ -490,10 +511,10 @@ void QZint::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode
color=qRgb(0xff,0xff,0x00);
break;
default:
default: */
color=m_fgColor;
break;
}
/* break;
} */
if(!((i > main_width) && (row == m_zintSymbol->rows - 1))) {
painter.fillRect(i,y,linewidth,m_zintSymbol->row_height[row],QBrush(color));
} else {
@ -574,7 +595,7 @@ void QZint::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode
block_width = 0;
do {
block_width++;
} while (m_zintSymbol->encoded_data[m_zintSymbol->rows - 1][j + block_width] == m_zintSymbol->encoded_data[m_zintSymbol->rows - 1][j]);
} while (module_set(m_zintSymbol->rows - 1, j + block_width) == module_set(m_zintSymbol->rows - 1, j));
if(latch == true) {
/* a bar */
painter.fillRect(j + xoffset - comp_offset,m_zintSymbol->height,block_width,5,QBrush(m_fgColor));
@ -593,7 +614,7 @@ void QZint::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode
block_width = 0;
do {
block_width++;
} while (m_zintSymbol->encoded_data[m_zintSymbol->rows - 1][j + block_width] == m_zintSymbol->encoded_data[m_zintSymbol->rows - 1][j]);
} while (module_set(m_zintSymbol->rows - 1, j + block_width) == module_set(m_zintSymbol->rows - 1, j));
if(latch == true) {
/* a bar */
painter.fillRect(j + xoffset - comp_offset,m_zintSymbol->height,block_width,5,QBrush(m_fgColor));

View File

@ -89,6 +89,7 @@ public:
bool save_to_file(QString filename);
private:
void encode();
int module_set(int y_coords, int x_coords);
private:
int m_symbol;