AZTEC: fix bit-stuffing; AZTECRUNE: fix >= 128; DATAMATRIX: eod shift -> 0 pad; Qt6

This commit is contained in:
gitlost 2020-10-26 12:21:43 +00:00
parent 90012ab23f
commit 943ba79866
53 changed files with 2324 additions and 913 deletions

View File

@ -100,13 +100,38 @@ ENDIF(APPLE)
add_subdirectory(backend)
add_subdirectory(frontend)
if($ENV{CMAKE_PREFIX_PATH} MATCHES "6[.][0-9][.][0-9]")
set(USE_QT6 TRUE)
message(STATUS "Using Qt6")
cmake_policy(SET CMP0012 NEW) # Recognize constants in if()
cmake_policy(SET CMP0072 NEW) # Choose OpenGL over legacy GL
find_package(Qt6Widgets)
find_package(Qt6Gui)
find_package(Qt6UiTools)
if(Qt6Widgets_FOUND AND Qt6Gui_FOUND AND Qt6UiTools_FOUND)
set(QT_USE_QTGUI TRUE)
set(QT_USE_QTUITOOLS TRUE)
set(QT_USE_QTXML TRUE)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${Qt6Widgets_INCLUDES}
${Qt6Gui_INCLUDES}
${Qt6UiTools_INCLUDES}
${CMAKE_CURRENT_BINARY_DIR}
)
add_subdirectory(backend_qt)
add_subdirectory(frontend_qt)
else()
message(STATUS "Could NOT find Qt6")
endif()
else()
message(STATUS "Using Qt5")
find_package(Qt5Widgets)
find_package(Qt5Gui)
find_package(Qt5UiTools)
if (Qt5Widgets_FOUND)
if (Qt5Gui_FOUND)
if (Qt5UiTools_FOUND)
if(Qt5Widgets_FOUND AND Qt5Gui_FOUND AND Qt5UiTools_FOUND)
set(QT_USE_QTGUI TRUE)
set(QT_USE_QTUITOOLS TRUE)
set(QT_USE_QTXML TRUE)
@ -119,16 +144,17 @@ if (Qt5Widgets_FOUND)
)
add_subdirectory(backend_qt)
add_subdirectory(frontend_qt)
endif(Qt5UiTools_FOUND)
endif(Qt5Gui_FOUND)
endif(Qt5Widgets_FOUND)
else()
message(STATUS "Could NOT find Qt5")
endif()
endif()
CONFIGURE_FILE(
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
# staniek: don't install

View File

@ -49,14 +49,14 @@ static int count_doubles(const unsigned char source[], const int posn, const siz
int i = posn;
int cond = 1;
do {
while ((i + 1 < (int) src_len) && cond) {
if (((source[i] == '.') || (source[i] == ',')) && (source[i + 1] == ' ')) {
c++;
} else {
cond = 0;
}
i += 2;
} while ((i < (int) src_len) && cond);
}
return c;
}
@ -66,14 +66,14 @@ static int count_cr(unsigned char source[], int posn, int length) {
int i = posn;
int cond = 1;
do {
while ((i < length) && cond) {
if (source[i] == 13) {
c++;
} else {
cond = 0;
}
i++;
} while ((i < length) && cond);
}
return c;
}
@ -83,14 +83,14 @@ static int count_dotcomma(unsigned char source[], int posn, int length) {
int i = posn;
int cond = 1;
do {
while ((i < length) && cond) {
if ((source[i] == '.') || (source[i] == ',')) {
c++;
} else {
cond = 0;
}
i++;
} while ((i < length) && cond);
}
return c;
}
@ -100,14 +100,14 @@ static int count_spaces(unsigned char source[], int posn, int length) {
int i = posn;
int cond = 1;
do {
while ((i < length) && cond) {
if (source[i] == ' ') {
c++;
} else {
cond = 0;
}
i++;
} while ((i < length) && cond);
}
return c;
}
@ -168,7 +168,7 @@ static int aztec_text_process(const unsigned char source[], const size_t src_len
// Deal first with letter combinations which can be combined to one codeword
// Combinations are (CR LF) (. SP) (, SP) (: SP) in Punct mode
current_mode = 'U';
for (i = 0; i < (int) src_len - 1; i++) {
for (i = 0; i + 1 < (int) src_len; i++) {
// Combination (CR LF) should always be in Punct mode
if ((source[i] == 13) && (source[i + 1] == 10)) {
encode_mode[i] = 'P';
@ -249,19 +249,19 @@ static int aztec_text_process(const unsigned char source[], const size_t src_len
i = 0;
j = 0;
while (i < (int) src_len) {
if ((source[i] == 13) && (source[i + 1] == 10)) { // CR LF
if ((source[i] == 13) && (i + 1 < (int) src_len) && (source[i + 1] == 10)) { // CR LF
reduced_source[j] = 'a';
reduced_encode_mode[j] = encode_mode[i];
i += 2;
} else if (((source[i] == '.') && (source[i + 1] == ' ')) && (encode_mode[i] == 'P')) {
} else if ((source[i] == '.') && (i + 1 < (int) src_len) && (source[i + 1] == ' ') && (encode_mode[i] == 'P')) {
reduced_source[j] = 'b';
reduced_encode_mode[j] = encode_mode[i];
i += 2;
} else if (((source[i] == ',') && (source[i + 1] == ' ')) && (encode_mode[i] == 'P')) {
} else if ((source[i] == ',') && (i + 1 < (int) src_len) && (source[i + 1] == ' ') && (encode_mode[i] == 'P')) {
reduced_source[j] = 'c';
reduced_encode_mode[j] = encode_mode[i];
i += 2;
} else if ((source[i] == ':') && (source[i + 1] == ' ')) {
} else if ((source[i] == ':') && (i + 1 < (int) src_len) && (source[i + 1] == ' ')) {
reduced_source[j] = 'd';
reduced_encode_mode[j] = encode_mode[i];
i += 2;
@ -530,7 +530,7 @@ static int aztec_text_process(const unsigned char source[], const size_t src_len
printf("\n");
}
strcpy(binary_string, "");
*binary_string = '\0';
if (gs1) {
bin_append(0, 5, binary_string); // P/S
@ -1128,25 +1128,20 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], const siz
j = 0;
count = 0;
for (i = 0; i < data_length; i++) {
if ((j + 1) % codeword_size == 0) {
// Last bit of codeword
/* 7.3.1.2 "whenever the first B-1 bits ... are all “0”s, then a dummy “1” is inserted..."
* "Similarly a message codeword that starts with B-1 “1”s has a dummy “0” inserted..." */
if (count == (codeword_size - 1)) {
// Codeword of B-1 '1's
adjusted_string[j] = '0';
if (count == 0 || count == (codeword_size - 1)) {
// Codeword of B-1 '0's or B-1 '1's
adjusted_string[j] = count == 0 ? '1' : '0';
j++;
}
if (count == 0) {
// Codeword of B-1 '0's
adjusted_string[j] = '1';
j++;
}
count = binary_string[i] == '1' ? 1 : 0;
} else {
count = 0;
}
} else if (binary_string[i] == '1') { /* Skip B so only counting B-1 */
count++;
}
@ -1235,19 +1230,15 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], const siz
if ((j + 1) % codeword_size == 0) {
// Last bit of codeword
if (count == (codeword_size - 1)) {
// Codeword of B-1 '1's
adjusted_string[j] = '0';
if (count == 0 || count == (codeword_size - 1)) {
// Codeword of B-1 '0's or B-1 '1's
adjusted_string[j] = count == 0 ? '1' : '0';
j++;
}
if (count == 0) {
// Codeword of B-1 '0's
adjusted_string[j] = '1';
j++;
}
count = binary_string[i] == '1' ? 1 : 0;
} else {
count = 0;
}
} else if (binary_string[i] == '1') { /* Skip B so only counting B-1 */
count++;
}
@ -1581,6 +1572,7 @@ INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int
int input_value, error_number, i, y, x;
char binary_string[28];
unsigned char data_codewords[3], ecc_codewords[6];
int debug = symbol->debug & ZINT_DEBUG_PRINT;
input_value = 0;
if (length > 3) {
@ -1609,7 +1601,7 @@ INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int
return ZINT_ERROR_INVALID_DATA;
}
strcpy(binary_string, "");
*binary_string = '\0';
bin_append(input_value, 8, binary_string);
data_codewords[0] = 0;
@ -1635,8 +1627,6 @@ INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int
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';
@ -1668,6 +1658,10 @@ INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int
}
}
if (debug) {
printf("Binary String: %.28s\n", binary_string);
}
for (y = 8; y < 19; y++) {
for (x = 8; x < 19; x++) {
if (CompactAztecMap[(y * 27) + x] == 1) {

View File

@ -64,9 +64,10 @@ INTERNAL void bin_append_posn(const int arg, const int length, char *binary, siz
start = 0x01 << (length - 1);
for (i = 0; i < length; i++) {
binary[posn + i] = '0';
if (arg & (start >> i)) {
binary[posn + i] = '1';
} else {
binary[posn + i] = '0';
}
}
}
@ -114,11 +115,12 @@ INTERNAL int is_sane(const char test_string[], const unsigned char source[], con
/* Replaces huge switch statements for looking up in tables */
INTERNAL void lookup(const char set_string[], const char *table[], const char data, char dest[]) {
size_t i, n = strlen(set_string);
int i, n = (int) strlen(set_string);
for (i = 0; i < n; i++) {
if (data == set_string[i]) {
strcat(dest, table[i]);
break;
}
}
}
@ -162,22 +164,23 @@ INTERNAL void unset_module(struct zint_symbol *symbol, const int y_coord, const
/* Expands from a width pattern to a bit pattern */
INTERNAL void expand(struct zint_symbol *symbol, const char data[]) {
size_t reader, n = strlen(data);
int reader, n = (int) strlen(data);
int writer, i;
char latch;
int latch, num;
writer = 0;
latch = '1';
latch = 1;
for (reader = 0; reader < n; reader++) {
for (i = 0; i < ctoi(data[reader]); i++) {
if (latch == '1') {
num = ctoi(data[reader]);
for (i = 0; i < num; i++) {
if (latch) {
set_module(symbol, symbol->rows, writer);
}
writer++;
}
latch = (latch == '1' ? '0' : '1');
latch = !latch;
}
if (symbol->symbology != BARCODE_PHARMA) {

View File

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2009 - 2020 Robin Stuart <rstuart114@gmail.com>
developed from and including some functions from:
IEC16022 bar code generation
@ -40,8 +40,6 @@
/* vim: set ts=4 sw=4 et : */
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#ifdef _MSC_VER
@ -528,7 +526,8 @@ static int look_ahead_test(const unsigned char inputData[], const size_t sourcel
/* Encodes data using ASCII, C40, Text, X12, EDIFACT or Base 256 modes as appropriate
Supports encoding FNC1 in supporting systems */
static int dm200encode(struct zint_symbol *symbol, const unsigned char source[], unsigned char target[], int *last_mode, size_t *length_p, int process_buffer[], int *process_p, int *binlen_p) {
static int dm200encode(struct zint_symbol *symbol, const unsigned char source[], unsigned char target[],
int *last_mode, int *last_shift, size_t *length_p, int process_buffer[], int *process_p, int *binlen_p) {
size_t sp;
int tp, i, gs1;
@ -543,7 +542,7 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
sp = 0;
tp = 0;
memset(process_buffer, 0, 8);
memset(process_buffer, 0, 8 * sizeof(int));
*process_p = 0;
strcpy(binary, "");
@ -645,7 +644,7 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
if (istwodigits(source, inputlen, sp)) {
target[tp] = (unsigned char) ((10 * ctoi(source[sp])) + ctoi(source[sp + 1]) + 130);
if (debug) printf("N%d ", target[tp] - 130);
if (debug) printf("N%02d ", target[tp] - 130);
tp++;
strcat(binary, " ");
sp += 2;
@ -735,10 +734,6 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
shift_set = c40_shift[source[sp] - 128];
value = c40_value[source[sp] - 128];
} else {
shift_set = c40_shift[source[sp]];
value = c40_value[source[sp]];
}
if (gs1 && (source[sp] == '[')) {
if (gs1 == 2) {
shift_set = c40_shift[29];
@ -747,6 +742,13 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
shift_set = 2;
value = 27; /* FNC1 */
}
} else {
shift_set = c40_shift[source[sp]];
value = c40_value[source[sp]];
}
if (*process_p % 3 == 2) {
*last_shift = shift_set;
}
}
if (shift_set != 0) {
@ -803,10 +805,6 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
shift_set = text_shift[source[sp] - 128];
value = text_value[source[sp] - 128];
} else {
shift_set = text_shift[source[sp]];
value = text_value[source[sp]];
}
if (gs1 && (source[sp] == '[')) {
if (gs1 == 2) {
shift_set = text_shift[29];
@ -815,6 +813,13 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
shift_set = 2;
value = 27; /* FNC1 */
}
} else {
shift_set = text_shift[source[sp]];
value = text_value[source[sp]];
}
if (*process_p % 3 == 2) {
*last_shift = shift_set;
}
}
if (shift_set != 0) {
@ -865,20 +870,15 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
int value = 0;
if (source[sp] == 13) {
value = 0;
}
if (source[sp] == '*') {
} else if (source[sp] == '*') {
value = 1;
}
if (source[sp] == '>') {
} else if (source[sp] == '>') {
value = 2;
}
if (source[sp] == ' ') {
} else if (source[sp] == ' ') {
value = 3;
}
if ((source[sp] >= '0') && (source[sp] <= '9')) {
} else if ((source[sp] >= '0') && (source[sp] <= '9')) {
value = (source[sp] - '0') + 4;
}
if ((source[sp] >= 'A') && (source[sp] <= 'Z')) {
} else if ((source[sp] >= 'A') && (source[sp] <= 'Z')) {
value = (source[sp] - 'A') + 14;
}
@ -977,6 +977,8 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
} /* while */
if (debug) printf("\n");
/* Add length and randomising algorithm to b256 */
i = 0;
while (i < tp) {
@ -1024,19 +1026,28 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
}
static int dm200encode_remainder(unsigned char target[], int target_length, const unsigned char source[], const size_t inputlen,
const int last_mode, const int process_buffer[], const int process_p, const int symbols_left, int debug) {
const int last_mode, const int last_shift, const int process_buffer[], const int process_p, const int symbols_left, int debug) {
switch (last_mode) {
case DM_C40:
case DM_TEXT:
if (debug) printf(" %s symbols_left %d, process_p %d\n", last_mode == DM_C40 ? "C40" : "TEXT", symbols_left, process_p);
/* NOTE: the use of a 0-padded doublet is only mentioned in ISO/IEC 16022:2006 for case 5.2.5.2 (b) when 2 symbols and
* 2 C40/Text characters are left, but using it here also for other cases. This matches the behaviour of tec-it (but
* not BWIPP) and is used for figures 4.15-1-1 and 4.15-1-1 in GS1 General Specifications. */
if (debug) printf("%s last_shift %d, symbols_left %d, process_p %d ", last_mode == DM_C40 ? "C40" : "TEX", last_shift, symbols_left, process_p);
if (process_p == 1) // 1 data character left to encode.
{
if (last_shift) {
target[target_length - 1] -= last_shift - 1; // Remove shift from second half of previous doublet leaving pad value (0)
}
if (symbols_left > 1) {
target[target_length] = 254;
target_length++; // Unlatch and encode remaining data in ascii.
if (debug) printf("ASC ");
}
target[target_length] = source[inputlen - 1] + 1;
if (debug) printf("A%02X ", target[target_length] - 1);
target_length++;
} else if (process_p == 2) // 2 data characters left to encode.
{
@ -1046,55 +1057,62 @@ static int dm200encode_remainder(unsigned char target[], int target_length, cons
target_length++;
target[target_length] = (unsigned char) (intValue % 256);
target_length++;
if (debug) printf("[%d %d %d] ", process_buffer[0], process_buffer[1], 0);
if (symbols_left > 2) {
target[target_length] = 254; // Unlatch
target_length++;
if (debug) printf("ASC ");
}
} else {
if (symbols_left > 0) {
target[target_length] = 254; // Unlatch
target_length++;
if (debug) printf("ASC ");
}
}
break;
case DM_X12:
if (debug) printf(" X12 symbols_left %d, process_p %d\n", symbols_left, process_p);
if (debug) printf("X12 symbols_left %d, process_p %d ", symbols_left, process_p);
if ((symbols_left == process_p) && (process_p == 1)) {
// Unlatch not required!
target[target_length] = source[inputlen - 1] + 1;
if (debug) printf("A%02X ", target[target_length] - 1);
target_length++;
} else if (symbols_left) {
target[target_length] = (254);
target_length++; // Unlatch.
if (debug) printf("ASC ");
if (process_p == 1) {
target[target_length] = source[inputlen - 1] + 1;
if (debug) printf("A%02X ", target[target_length] - 1);
target_length++;
}
if (process_p == 2) {
} else if (process_p == 2) {
target[target_length] = source[inputlen - 2] + 1;
if (debug) printf("A%02X ", target[target_length] - 1);
target_length++;
target[target_length] = source[inputlen - 1] + 1;
if (debug) printf("A%02X ", target[target_length] - 1);
target_length++;
}
}
break;
case DM_EDIFACT:
if (debug) printf(" EDIFACT symbols_left %d, process_p %d\n", symbols_left, process_p);
if (debug) printf("EDI symbols_left %d, process_p %d ", symbols_left, process_p);
if (symbols_left <= 2) // Unlatch not required!
{
if (process_p == 1) {
target[target_length] = source[inputlen - 1] + 1;
if (debug) printf("A%02X ", target[target_length] - 1);
target_length++;
}
if (process_p == 2) {
} else if (process_p == 2) {
target[target_length] = source[inputlen - 2] + 1;
if (debug) printf("A%02X ", target[target_length] - 1);
target_length++;
target[target_length] = source[inputlen - 1] + 1;
if (debug) printf("A%02X ", target[target_length] - 1);
target_length++;
}
} else {
@ -1102,31 +1120,29 @@ static int dm200encode_remainder(unsigned char target[], int target_length, cons
if (process_p == 0) {
target[target_length] = (unsigned char) (31 << 2);
target_length++;
}
if (process_p == 1) {
if (debug) printf("[31 0 0 0] ");
} else if (process_p == 1) {
target[target_length] = (unsigned char) ((process_buffer[0] << 2) + ((31 & 0x30) >> 4));
target_length++;
target[target_length] = (unsigned char) ((31 & 0x0f) << 4);
target_length++;
}
if (process_p == 2) {
if (debug) printf("[%d 31 0 0] ", process_buffer[0]);
} else if (process_p == 2) {
target[target_length] = (unsigned char) ((process_buffer[0] << 2) + ((process_buffer[1] & 0x30) >> 4));
target_length++;
target[target_length] = (unsigned char) (((process_buffer[1] & 0x0f) << 4) + ((31 & 0x3c) >> 2));
target_length++;
target[target_length] = (unsigned char) (((31 & 0x03) << 6));
target_length++;
}
if (process_p == 3) {
if (debug) printf("[%d %d 31 0] ", process_buffer[0], process_buffer[1]);
} else if (process_p == 3) {
target[target_length] = (unsigned char) ((process_buffer[0] << 2) + ((process_buffer[1] & 0x30) >> 4));
target_length++;
target[target_length] = (unsigned char) (((process_buffer[1] & 0x0f) << 4) + ((process_buffer[2] & 0x3c) >> 2));
target_length++;
target[target_length] = (unsigned char) (((process_buffer[2] & 0x03) << 6) + 31);
target_length++;
if (debug) printf("[%d %d %d 31] ", process_buffer[0], process_buffer[1], process_buffer[2]);
}
}
break;
@ -1134,9 +1150,9 @@ static int dm200encode_remainder(unsigned char target[], int target_length, cons
if (debug) {
int i;
printf("\n\n");
printf("\nData (%d): ", target_length);
for (i = 0; i < target_length; i++)
printf("%03d ", target[i]);
printf("%d ", target[i]);
printf("\n");
}
@ -1177,10 +1193,12 @@ static int data_matrix_200(struct zint_symbol *symbol,const unsigned char source
int taillength, error_number = 0;
int H, W, FH, FW, datablock, bytes, rsblock;
int last_mode = DM_ASCII;
int last_shift = 0;
int symbols_left;
int debug = symbol->debug & ZINT_DEBUG_PRINT;
/* inputlen may be decremented by 2 if macro character is used */
error_number = dm200encode(symbol, source, binary, &last_mode, &inputlen, process_buffer, &process_p, &binlen);
error_number = dm200encode(symbol, source, binary, &last_mode, &last_shift, &inputlen, process_buffer, &process_p, &binlen);
if (error_number != 0) {
return error_number;
}
@ -1226,7 +1244,7 @@ static int data_matrix_200(struct zint_symbol *symbol,const unsigned char source
// Now we know the symbol size we can handle the remaining data in the process buffer.
symbols_left = matrixbytes[symbolsize] - binlen;
binlen = dm200encode_remainder(binary, binlen, source, inputlen, last_mode, process_buffer, process_p, symbols_left, symbol->debug & ZINT_DEBUG_PRINT);
binlen = dm200encode_remainder(binary, binlen, source, inputlen, last_mode, last_shift, process_buffer, process_p, symbols_left, debug);
if (binlen > matrixbytes[symbolsize]) {
strcpy(symbol->errtxt, "523: Data too long to fit in symbol");
@ -1246,27 +1264,23 @@ static int data_matrix_200(struct zint_symbol *symbol,const unsigned char source
if (taillength != 0) {
add_tail(binary, binlen, taillength);
}
if (debug) {
printf("Pads (%d): ", taillength);
for (i = binlen; i < binlen + taillength; i++) printf("%d ", binary[i]);
printf("\n");
}
// ecc code
if (symbolsize == INTSYMBOL144) {
skew = 1;
}
ecc200(binary, bytes, datablock, rsblock, skew);
// Print Codewords
#ifdef DEBUG
{
int CWCount;
int posCur;
if (skew)
CWCount = 1558 + 620;
else
CWCount = bytes + rsblock * (bytes / datablock);
printf("Codewords (%i):", CWCount);
for (posCur = 0; posCur < CWCount; posCur++)
printf(" %3i", binary[posCur]);
puts("\n");
if (debug) {
printf("ECC (%d): ", rsblock * (bytes / datablock));
for (i = bytes; i < bytes + rsblock * (bytes / datablock); i++) printf("%d ", binary[i]);
printf("\n");
}
#endif
#ifdef ZINT_TEST
if (symbol->debug & ZINT_DEBUG_TEST) debug_test_codeword_dump(symbol, binary, skew ? 1558 + 620 : bytes + rsblock * (bytes / datablock));
#endif

View File

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2009 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -40,8 +40,6 @@
#ifndef __DMATRIX_H
#define __DMATRIX_H
#define MAXBARCODE 3116
#define DM_NULL 0
#define DM_ASCII 1
#define DM_C40 2
@ -99,7 +97,6 @@ static const unsigned short int intsymbol[] = {
24, /* 39: 16x64 , 62*/ 19, /* 40: 20x36 , 44*/ 22, /* 41: 20x44 , 56*/ 30, /* 42: 20x64 , 84*/
28, /* 43: 22x48 , 72*/ 29, /* 44: 24x48 , 80*/ 33, /* 45: 24x64 ,108*/ 27, /* 46: 26x40 , 70*/
32, /* 47: 26x48 , 90*/ 35, /* 48: 26x64 ,118*/
0
};
// Number of DM Sizes

View File

@ -166,7 +166,8 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
int hexagon_count, this_hexagon;
int string_count, this_text;
int bytecount, recordcount;
float radius;
float previous_diameter;
float radius, half_radius, half_sqrt3_radius;
int colours_used = 0;
int rectangle_count_bycolour[9];
unsigned char *this_string[6];
@ -443,10 +444,14 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
}
//Circles
previous_diameter = radius = 0.0f;
circ = symbol->vector->circles;
this_circle = 0;
while (circ) {
radius = circ->diameter / 2.0;
if (previous_diameter != circ->diameter) {
previous_diameter = circ->diameter;
radius = (float) (0.5 * previous_diameter);
}
circle[this_circle].type = 0x0000002a; // EMR_ELLIPSE
circle[this_circle].size = 24;
circle[this_circle].box.top = circ->y - radius;
@ -460,6 +465,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
}
//Hexagons
previous_diameter = radius = half_radius = half_sqrt3_radius = 0.0f;
hex = symbol->vector->hexagons;
this_hexagon = 0;
while (hex) {
@ -467,33 +473,38 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
hexagon[this_hexagon].size = 76;
hexagon[this_hexagon].count = 6;
radius = hex->diameter / 2.0;
if (previous_diameter != hex->diameter) {
previous_diameter = hex->diameter;
radius = (float) (0.5 * previous_diameter);
half_radius = (float) (0.25 * previous_diameter);
half_sqrt3_radius = (float) (0.43301270189221932338 * previous_diameter);
}
if ((hex->rotation == 0) || (hex->rotation == 180)) {
ay = hex->y + (1.0 * radius);
by = hex->y + (0.5 * radius);
cy = hex->y - (0.5 * radius);
dy = hex->y - (1.0 * radius);
ey = hex->y - (0.5 * radius);
fy = hex->y + (0.5 * radius);
ay = hex->y + radius;
by = hex->y + half_radius;
cy = hex->y - half_radius;
dy = hex->y - radius;
ey = hex->y - half_radius;
fy = hex->y + half_radius;
ax = hex->x;
bx = hex->x + (0.86 * radius);
cx = hex->x + (0.86 * radius);
bx = hex->x + half_sqrt3_radius;
cx = hex->x + half_sqrt3_radius;
dx = hex->x;
ex = hex->x - (0.86 * radius);
fx = hex->x - (0.86 * radius);
ex = hex->x - half_sqrt3_radius;
fx = hex->x - half_sqrt3_radius;
} else {
ay = hex->y;
by = hex->y + (0.86 * radius);
cy = hex->y + (0.86 * radius);
by = hex->y + half_sqrt3_radius;
cy = hex->y + half_sqrt3_radius;
dy = hex->y;
ey = hex->y - (0.86 * radius);
fy = hex->y - (0.86 * radius);
ax = hex->x - (1.0 * radius);
bx = hex->x - (0.5 * radius);
cx = hex->x + (0.5 * radius);
dx = hex->x + (1.0 * radius);
ex = hex->x + (0.5 * radius);
fx = hex->x - (0.5 * radius);
ey = hex->y - half_sqrt3_radius;
fy = hex->y - half_sqrt3_radius;
ax = hex->x - radius;
bx = hex->x - half_radius;
cx = hex->x + half_radius;
dx = hex->x + radius;
ex = hex->x + half_radius;
fx = hex->x - half_radius;
}
hexagon[this_hexagon].a_points_a.x = ax;

View File

@ -48,12 +48,6 @@ struct zint_symbol *ZBarcode_Create() {
memset(symbol, 0, sizeof (*symbol));
symbol->symbology = BARCODE_CODE128;
symbol->height = 0;
symbol->whitespace_width = 0;
symbol->border_width = 0;
symbol->output_options = 0;
symbol->rows = 0;
symbol->width = 0;
strcpy(symbol->fgcolour, "000000");
symbol->fgcolor = &symbol->fgcolour[0];
strcpy(symbol->bgcolour, "ffffff");
@ -61,19 +55,14 @@ struct zint_symbol *ZBarcode_Create() {
strcpy(symbol->outfile, "out.png");
symbol->scale = 1.0f;
symbol->option_1 = -1;
symbol->option_2 = 0;
symbol->option_3 = 0;
symbol->show_hrt = 1; // Show human readable text
symbol->fontsize = 8;
symbol->input_mode = DATA_MODE;
symbol->bitmap = NULL;
symbol->bitmap_width = 0;
symbol->bitmap_height = 0;
symbol->alphamap = NULL;
symbol->eci = 0; // Default 0 uses ECI 3
symbol->dot_size = 4.0f / 5.0f;
symbol->vector = NULL;
symbol->debug = 0;
symbol->warn_level = WARN_DEFAULT;
return symbol;
}
@ -786,9 +775,9 @@ int ZBarcode_ValidID(int symbol_id) {
return result;
}
static int reduced_charset(struct zint_symbol *symbol, const unsigned char *source, size_t in_length);
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, size_t in_length);
static int extended_or_reduced_charset(struct zint_symbol *symbol, const unsigned char *source, const int length) {
static int extended_or_reduced_charset(struct zint_symbol *symbol, unsigned char *source, const int length) {
int error_number = 0;
switch (symbol->symbology) {
@ -812,30 +801,25 @@ static int extended_or_reduced_charset(struct zint_symbol *symbol, const unsigne
return error_number;
}
static int reduced_charset(struct zint_symbol *symbol, const unsigned char *source, size_t in_length) {
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, size_t in_length) {
/* These are the "norm" standards which only support Latin-1 at most, though a few support ECI */
int error_number = 0;
unsigned char *preprocessed = source;
#ifndef _MSC_VER
unsigned char preprocessed[in_length + 1];
unsigned char preprocessed_buf[in_length + 1];
#else
unsigned char* preprocessed = (unsigned char*) _alloca(in_length + 1);
unsigned char *preprocessed_buf = (unsigned char *) _alloca(in_length + 1);
#endif
switch (symbol->input_mode & 0x07) {
case DATA_MODE:
case GS1_MODE:
memcpy(preprocessed, source, in_length);
preprocessed[in_length] = '\0';
break;
case UNICODE_MODE:
if ((symbol->input_mode & 0x07) == UNICODE_MODE) {
/* Prior check ensures ECI only set for those that support it */
preprocessed = preprocessed_buf;
error_number = utf_to_eci(symbol->eci && symbol->eci <= 899 ? symbol->eci : 3, source, preprocessed, &in_length);
if (error_number != 0) {
strcpy(symbol->errtxt, "204: Invalid characters in input data");
return error_number;
}
break;
}
if ((symbol->height == 0) && is_linear(symbol->symbology)) {
@ -1197,22 +1181,16 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
symbol->symbology = BARCODE_CODE128;
error_number = ZINT_WARN_INVALID_OPTION;
}
}
/* symbol->symbologys 1 to 86 are defined by tbarcode */
if (symbol->symbology == 5) {
} else if (symbol->symbology == 5) {
symbol->symbology = BARCODE_C25STANDARD;
}
if ((symbol->symbology >= 10) && (symbol->symbology <= 12)) {
} else if ((symbol->symbology >= 10) && (symbol->symbology <= 12)) {
symbol->symbology = BARCODE_EANX;
}
if (symbol->symbology == 15) {
} else if (symbol->symbology == 15) {
symbol->symbology = BARCODE_EANX;
}
if (symbol->symbology == 17) {
} else if (symbol->symbology == 17) {
symbol->symbology = BARCODE_UPCA;
}
if (symbol->symbology == 19) {
} else if (symbol->symbology == 19) {
strcpy(symbol->errtxt, "207: Codabar 18 not supported");
if (symbol->warn_level == WARN_FAIL_ALL) {
return WARN_FAIL_ALL;
@ -1220,30 +1198,22 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
symbol->symbology = BARCODE_CODABAR;
error_number = ZINT_WARN_INVALID_OPTION;
}
}
if (symbol->symbology == 26) {
} else if (symbol->symbology == 26) {
symbol->symbology = BARCODE_UPCA;
}
if (symbol->symbology == 27) {
} else if (symbol->symbology == 27) {
strcpy(symbol->errtxt, "208: UPCD1 not supported");
error_number = ZINT_ERROR_INVALID_OPTION;
}
if (symbol->symbology == 33) {
} else if (symbol->symbology == 33) {
symbol->symbology = BARCODE_GS1_128;
}
if (symbol->symbology == 36) {
} else if (symbol->symbology == 36) {
symbol->symbology = BARCODE_UPCA;
}
if ((symbol->symbology >= 41) && (symbol->symbology <= 45)) {
} else if ((symbol->symbology >= 41) && (symbol->symbology <= 45)) {
symbol->symbology = BARCODE_POSTNET;
}
if (symbol->symbology == 46) {
} else if (symbol->symbology == 46) {
symbol->symbology = BARCODE_PLESSEY;
}
if (symbol->symbology == 48) {
} else if (symbol->symbology == 48) {
symbol->symbology = BARCODE_NVE18;
}
if (symbol->symbology == 54) {
} else if (symbol->symbology == 54) {
strcpy(symbol->errtxt, "210: General Parcel Code not supported");
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
@ -1251,26 +1221,19 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
symbol->symbology = BARCODE_CODE128;
error_number = ZINT_WARN_INVALID_OPTION;
}
}
if ((symbol->symbology == 59) || (symbol->symbology == 61)) {
} else if ((symbol->symbology == 59) || (symbol->symbology == 61)) {
symbol->symbology = BARCODE_CODE128;
}
if (symbol->symbology == 62) {
} else if (symbol->symbology == 62) {
symbol->symbology = BARCODE_CODE93;
}
if ((symbol->symbology == 64) || (symbol->symbology == 65)) {
} else if ((symbol->symbology == 64) || (symbol->symbology == 65)) {
symbol->symbology = BARCODE_AUSPOST;
}
if (symbol->symbology == 78) {
} else if (symbol->symbology == 78) {
symbol->symbology = BARCODE_DBAR_OMN;
}
if (symbol->symbology == 83) {
} else if (symbol->symbology == 83) {
symbol->symbology = BARCODE_PLANET;
}
if (symbol->symbology == 88) {
} else if (symbol->symbology == 88) {
symbol->symbology = BARCODE_GS1_128;
}
if (symbol->symbology == 91) {
} else if (symbol->symbology == 91) {
strcpy(symbol->errtxt, "212: Symbology out of range");
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
@ -1278,8 +1241,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
symbol->symbology = BARCODE_CODE128;
error_number = ZINT_WARN_INVALID_OPTION;
}
}
if ((symbol->symbology >= 94) && (symbol->symbology <= 95)) {
} else if ((symbol->symbology >= 94) && (symbol->symbology <= 95)) {
strcpy(symbol->errtxt, "213: Symbology out of range");
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
@ -1287,29 +1249,21 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
symbol->symbology = BARCODE_CODE128;
error_number = ZINT_WARN_INVALID_OPTION;
}
}
if (symbol->symbology == 100) {
} else if (symbol->symbology == 100) {
symbol->symbology = BARCODE_HIBC_128;
}
if (symbol->symbology == 101) {
} else if (symbol->symbology == 101) {
symbol->symbology = BARCODE_HIBC_39;
}
if (symbol->symbology == 103) {
} else if (symbol->symbology == 103) {
symbol->symbology = BARCODE_HIBC_DM;
}
if (symbol->symbology == 105) {
} else if (symbol->symbology == 105) {
symbol->symbology = BARCODE_HIBC_QR;
}
if (symbol->symbology == 107) {
} else if (symbol->symbology == 107) {
symbol->symbology = BARCODE_HIBC_PDF;
}
if (symbol->symbology == 109) {
} else if (symbol->symbology == 109) {
symbol->symbology = BARCODE_HIBC_MICPDF;
}
if (symbol->symbology == 111) {
} else if (symbol->symbology == 111) {
symbol->symbology = BARCODE_HIBC_BLOCKF;
}
if ((symbol->symbology == 113) || (symbol->symbology == 114)) {
} else if ((symbol->symbology == 113) || (symbol->symbology == 114)) {
strcpy(symbol->errtxt, "214: Symbology out of range");
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
@ -1317,11 +1271,9 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
symbol->symbology = BARCODE_CODE128;
error_number = ZINT_WARN_INVALID_OPTION;
}
}
if (symbol->symbology == 115) {
} else if (symbol->symbology == 115) {
symbol->symbology = BARCODE_DOTCODE;
}
if ((symbol->symbology >= 117) && (symbol->symbology <= 127)) {
} else if ((symbol->symbology >= 117) && (symbol->symbology <= 127)) {
if (symbol->symbology != 121) {
strcpy(symbol->errtxt, "215: Symbology out of range");
if (symbol->warn_level == WARN_FAIL_ALL) {
@ -1331,9 +1283,8 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
error_number = ZINT_WARN_INVALID_OPTION;
}
}
}
/* Everything from 128 up is Zint-specific */
if (symbol->symbology > 145) {
} else if (symbol->symbology > 145) {
strcpy(symbol->errtxt, "216: Symbology out of range");
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;

View File

@ -139,7 +139,8 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
float cyan_paper, magenta_paper, yellow_paper, black_paper;
int error_number = 0;
float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy;
float radius;
float previous_diameter;
float radius, half_radius, half_sqrt3_radius;
int colour_index, colour_rect_counter;
char ps_color[30];
int draw_background = 1;
@ -180,58 +181,58 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
bgred = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]);
bggrn = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]);
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
red_ink = fgred / 256.0;
green_ink = fggrn / 256.0;
blue_ink = fgblu / 256.0;
red_paper = bgred / 256.0;
green_paper = bggrn / 256.0;
blue_paper = bgblu / 256.0;
red_ink = (float) (fgred / 256.0);
green_ink = (float) (fggrn / 256.0);
blue_ink = (float) (fgblu / 256.0);
red_paper = (float) (bgred / 256.0);
green_paper = (float) (bggrn / 256.0);
blue_paper = (float) (bgblu / 256.0);
/* Convert RGB to CMYK */
if (red_ink > green_ink) {
if (blue_ink > red_ink) {
black_ink = 1 - blue_ink;
black_ink = 1.0f - blue_ink;
} else {
black_ink = 1 - red_ink;
black_ink = 1.0f - red_ink;
}
} else {
if (blue_ink > red_ink) {
black_ink = 1 - blue_ink;
black_ink = 1.0f - blue_ink;
} else {
black_ink = 1 - green_ink;
black_ink = 1.0f - green_ink;
}
}
if (black_ink < 1.0) {
cyan_ink = (1 - red_ink - black_ink) / (1 - black_ink);
magenta_ink = (1 - green_ink - black_ink) / (1 - black_ink);
yellow_ink = (1 - blue_ink - black_ink) / (1 - black_ink);
if (black_ink < 1.0f) {
cyan_ink = (1.0f - red_ink - black_ink) / (1.0f - black_ink);
magenta_ink = (1.0f - green_ink - black_ink) / (1.0f - black_ink);
yellow_ink = (1.0f - blue_ink - black_ink) / (1.0f - black_ink);
} else {
cyan_ink = 0.0;
magenta_ink = 0.0;
yellow_ink = 0.0;
cyan_ink = 0.0f;
magenta_ink = 0.0f;
yellow_ink = 0.0f;
}
if (red_paper > green_paper) {
if (blue_paper > red_paper) {
black_paper = 1 - blue_paper;
black_paper = 1.0f - blue_paper;
} else {
black_paper = 1 - red_paper;
black_paper = 1.0f - red_paper;
}
} else {
if (blue_paper > red_paper) {
black_paper = 1 - blue_paper;
black_paper = 1.0f - blue_paper;
} else {
black_paper = 1 - green_paper;
black_paper = 1.0f - green_paper;
}
}
if (black_paper < 1.0) {
cyan_paper = (1 - red_paper - black_paper) / (1 - black_paper);
magenta_paper = (1 - green_paper - black_paper) / (1 - black_paper);
yellow_paper = (1 - blue_paper - black_paper) / (1 - black_paper);
if (black_paper < 1.0f) {
cyan_paper = (1.0f - red_paper - black_paper) / (1.0f - black_paper);
magenta_paper = (1.0f - green_paper - black_paper) / (1.0f - black_paper);
yellow_paper = (1.0f - blue_paper - black_paper) / (1.0f - black_paper);
} else {
cyan_paper = 0.0;
magenta_paper = 0.0;
yellow_paper = 0.0;
cyan_paper = 0.0f;
magenta_paper = 0.0f;
yellow_paper = 0.0f;
}
for (i = 0, len = (int) ustrlen(symbol->text); i < len; i++) {
@ -329,43 +330,54 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
}
// Hexagons
previous_diameter = radius = half_radius = half_sqrt3_radius = 0.0f;
hex = symbol->vector->hexagons;
while (hex) {
radius = hex->diameter / 2.0;
if (previous_diameter != hex->diameter) {
previous_diameter = hex->diameter;
radius = (float) (0.5 * previous_diameter);
half_radius = (float) (0.25 * previous_diameter);
half_sqrt3_radius = (float) (0.43301270189221932338 * previous_diameter);
}
if ((hex->rotation == 0) || (hex->rotation == 180)) {
ay = (symbol->vector->height - hex->y) + (1.0 * radius);
by = (symbol->vector->height - hex->y) + (0.5 * radius);
cy = (symbol->vector->height - hex->y) - (0.5 * radius);
dy = (symbol->vector->height - hex->y) - (1.0 * radius);
ey = (symbol->vector->height - hex->y) - (0.5 * radius);
fy = (symbol->vector->height - hex->y) + (0.5 * radius);
ay = (symbol->vector->height - hex->y) + radius;
by = (symbol->vector->height - hex->y) + half_radius;
cy = (symbol->vector->height - hex->y) - half_radius;
dy = (symbol->vector->height - hex->y) - radius;
ey = (symbol->vector->height - hex->y) - half_radius;
fy = (symbol->vector->height - hex->y) + half_radius;
ax = hex->x;
bx = hex->x + (0.86 * radius);
cx = hex->x + (0.86 * radius);
bx = hex->x + half_sqrt3_radius;
cx = hex->x + half_sqrt3_radius;
dx = hex->x;
ex = hex->x - (0.86 * radius);
fx = hex->x - (0.86 * radius);
ex = hex->x - half_sqrt3_radius;
fx = hex->x - half_sqrt3_radius;
} else {
ay = (symbol->vector->height - hex->y);
by = (symbol->vector->height - hex->y) + (0.86 * radius);
cy = (symbol->vector->height - hex->y) + (0.86 * radius);
by = (symbol->vector->height - hex->y) + half_sqrt3_radius;
cy = (symbol->vector->height - hex->y) + half_sqrt3_radius;
dy = (symbol->vector->height - hex->y);
ey = (symbol->vector->height - hex->y) - (0.86 * radius);
fy = (symbol->vector->height - hex->y) - (0.86 * radius);
ax = hex->x - (1.0 * radius);
bx = hex->x - (0.5 * radius);
cx = hex->x + (0.5 * radius);
dx = hex->x + (1.0 * radius);
ex = hex->x + (0.5 * radius);
fx = hex->x - (0.5 * radius);
ey = (symbol->vector->height - hex->y) - half_sqrt3_radius;
fy = (symbol->vector->height - hex->y) - half_sqrt3_radius;
ax = hex->x - radius;
bx = hex->x - half_radius;
cx = hex->x + half_radius;
dx = hex->x + radius;
ex = hex->x + half_radius;
fx = hex->x - half_radius;
}
fprintf(feps, "%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f TH\n", ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy);
hex = hex->next;
}
// Circles
previous_diameter = radius = 0.0f;
circle = symbol->vector->circles;
while (circle) {
if (previous_diameter != circle->diameter) {
previous_diameter = circle->diameter;
radius = (float) (0.5 * previous_diameter);
}
if (circle->colour) {
// A 'white' circle
if ((symbol->output_options & CMYK_COLOUR) == 0) {
@ -373,7 +385,7 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_paper, magenta_paper, yellow_paper, black_paper);
}
fprintf(feps, "%.2f %.2f %.2f TD\n", circle->x, (symbol->vector->height - circle->y), circle->diameter / 2.0);
fprintf(feps, "%.2f %.2f %.2f TD\n", circle->x, (symbol->vector->height - circle->y), radius);
if (circle->next) {
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
@ -383,7 +395,7 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
}
} else {
// A 'black' circle
fprintf(feps, "%.2f %.2f %.2f TD\n", circle->x, (symbol->vector->height - circle->y), circle->diameter / 2.0);
fprintf(feps, "%.2f %.2f %.2f TD\n", circle->x, (symbol->vector->height - circle->y), radius);
}
circle = circle->next;
}

View File

@ -667,28 +667,34 @@ static int plot_raster_dotty(struct zint_symbol *symbol, int rotate_angle, int f
int r, i;
int scale_width, scale_height;
int error_number = 0;
int image_width, image_height;
int xoffset, yoffset, roffset, boffset;
int dot_overspill = 0;
float dot_overspill;
float dotoffset;
float dotradius_scaled;
int dot_overspill_scaled;
if (scaler < 2.0f) {
scaler = 2.0f;
}
symbol->height = symbol->rows; // This is true because only 2d matrix symbols are processed here
output_set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset);
dot_overspill = (int) ceil(symbol->dot_size - 1); /* Allow for exceeding 1X */
if (dot_overspill < 0) {
dot_overspill = 0;
dot_overspill = symbol->dot_size - 1.0f; /* Allow for exceeding 1X */
if (dot_overspill < 0.0f) {
dotoffset = -dot_overspill / 2.0f;
dot_overspill_scaled = 0;
} else {
dotoffset = 0.0f;
dot_overspill_scaled = dot_overspill * scaler;
}
if (dot_overspill_scaled == 0) {
dot_overspill_scaled = 1;
}
image_width = symbol->width + dot_overspill + xoffset + roffset;
image_height = symbol->height + dot_overspill + yoffset + boffset;
if (scaler < 2.0f) {
scaler = 2.0f;
}
scale_width = image_width * scaler;
scale_height = image_height * scaler;
scale_width = (symbol->width + xoffset + roffset) * scaler + dot_overspill_scaled;
scale_height = (symbol->height + yoffset + boffset) * scaler + dot_overspill_scaled;
/* Apply scale options by creating another pixel buffer */
if (!(scaled_pixelbuf = (char *) malloc(scale_width * scale_height))) {
@ -700,11 +706,11 @@ static int plot_raster_dotty(struct zint_symbol *symbol, int rotate_angle, int f
/* Plot the body of the symbol to the pixel buffer */
dotradius_scaled = (symbol->dot_size * scaler) / 2.0f;
for (r = 0; r < symbol->rows; r++) {
float row_scaled = (r + yoffset) * scaler + dotradius_scaled;
float row_scaled = (r + dotoffset + yoffset) * scaler + dotradius_scaled;
for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, r, i)) {
draw_circle(scaled_pixelbuf, scale_width, scale_height,
(i + xoffset) * scaler + dotradius_scaled,
(i + dotoffset + xoffset) * scaler + dotradius_scaled,
row_scaled,
dotradius_scaled,
DEFAULT_INK);
@ -1178,15 +1184,13 @@ INTERNAL int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_
return error;
}
if (symbol->output_options & BARCODE_DOTTY_MODE) {
error = plot_raster_dotty(symbol, rotate_angle, file_type);
} else {
if (symbol->symbology == BARCODE_MAXICODE) {
error = plot_raster_maxicode(symbol, rotate_angle, file_type);
} else if (symbol->output_options & BARCODE_DOTTY_MODE) {
error = plot_raster_dotty(symbol, rotate_angle, file_type);
} else {
error = plot_raster_default(symbol, rotate_angle, file_type);
}
}
return error;
}

View File

@ -41,7 +41,7 @@
#include "common.h"
void pick_colour(int colour, char colour_code[]) {
static void pick_colour(int colour, char colour_code[]) {
switch(colour) {
case 1: // Cyan
strcpy(colour_code, "00ffff");
@ -119,12 +119,14 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
int error_number = 0;
const char *locale = NULL;
float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy;
float radius;
float previous_diameter;
float radius, half_radius, half_sqrt3_radius;
int i;
char fgcolour_string[7];
char bgcolour_string[7];
int bg_alpha = 0xff;
int fg_alpha = 0xff;
float fg_alpha_opacity = 0.0f, bg_alpha_opacity = 0.0f;
const char *font_family = "Helvetica, sans-serif";
int bold;
@ -149,9 +151,15 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
if (strlen(symbol->fgcolour) > 6) {
fg_alpha = (16 * ctoi(symbol->fgcolour[6])) + ctoi(symbol->fgcolour[7]);
if (fg_alpha != 0xff) {
fg_alpha_opacity = (float) (fg_alpha / 255.0);
}
}
if (strlen(symbol->bgcolour) > 6) {
bg_alpha = (16 * ctoi(symbol->bgcolour[6])) + ctoi(symbol->bgcolour[7]);
if (bg_alpha != 0xff) {
bg_alpha_opacity = (float) (bg_alpha / 255.0);
}
}
html_len = strlen((char *)symbol->text) + 1;
@ -204,7 +212,7 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
if (bg_alpha != 0) {
fprintf(fsvg, " <rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\"", (int) ceil(symbol->vector->width), (int) ceil(symbol->vector->height), bgcolour_string);
if (bg_alpha != 0xff) {
fprintf(fsvg, " opacity=\"%.3f\"", (float) bg_alpha / 255.0);
fprintf(fsvg, " opacity=\"%.3f\"", bg_alpha_opacity);
}
fprintf(fsvg, " />\n");
}
@ -217,63 +225,74 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
fprintf(fsvg, " fill=\"#%s\"", colour_code);
}
if (fg_alpha != 0xff) {
fprintf(fsvg, " opacity=\"%.3f\"", (float) fg_alpha / 255.0);
fprintf(fsvg, " opacity=\"%.3f\"", fg_alpha_opacity);
}
fprintf(fsvg, " />\n");
rect = rect->next;
}
previous_diameter = radius = half_radius = half_sqrt3_radius = 0.0f;
hex = symbol->vector->hexagons;
while (hex) {
radius = hex->diameter / 2.0;
if (previous_diameter != hex->diameter) {
previous_diameter = hex->diameter;
radius = (float) (0.5 * previous_diameter);
half_radius = (float) (0.25 * previous_diameter);
half_sqrt3_radius = (float) (0.43301270189221932338 * previous_diameter);
}
if ((hex->rotation == 0) || (hex->rotation == 180)) {
ay = hex->y + (1.0 * radius);
by = hex->y + (0.5 * radius);
cy = hex->y - (0.5 * radius);
dy = hex->y - (1.0 * radius);
ey = hex->y - (0.5 * radius);
fy = hex->y + (0.5 * radius);
ay = hex->y + radius;
by = hex->y + half_radius;
cy = hex->y - half_radius;
dy = hex->y - radius;
ey = hex->y - half_radius;
fy = hex->y + half_radius;
ax = hex->x;
bx = hex->x + (0.86 * radius);
cx = hex->x + (0.86 * radius);
bx = hex->x + half_sqrt3_radius;
cx = hex->x + half_sqrt3_radius;
dx = hex->x;
ex = hex->x - (0.86 * radius);
fx = hex->x - (0.86 * radius);
ex = hex->x - half_sqrt3_radius;
fx = hex->x - half_sqrt3_radius;
} else {
ay = hex->y;
by = hex->y + (0.86 * radius);
cy = hex->y + (0.86 * radius);
by = hex->y + half_sqrt3_radius;
cy = hex->y + half_sqrt3_radius;
dy = hex->y;
ey = hex->y - (0.86 * radius);
fy = hex->y - (0.86 * radius);
ax = hex->x - (1.0 * radius);
bx = hex->x - (0.5 * radius);
cx = hex->x + (0.5 * radius);
dx = hex->x + (1.0 * radius);
ex = hex->x + (0.5 * radius);
fx = hex->x - (0.5 * radius);
ey = hex->y - half_sqrt3_radius;
fy = hex->y - half_sqrt3_radius;
ax = hex->x - radius;
bx = hex->x - half_radius;
cx = hex->x + half_radius;
dx = hex->x + radius;
ex = hex->x + half_radius;
fx = hex->x - half_radius;
}
fprintf(fsvg, " <path d=\"M %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f Z\"", ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy);
if (fg_alpha != 0xff) {
fprintf(fsvg, " opacity=\"%.3f\"", (float) fg_alpha / 255.0);
fprintf(fsvg, " opacity=\"%.3f\"", fg_alpha_opacity);
}
fprintf(fsvg, " />\n");
hex = hex->next;
}
previous_diameter = radius = 0.0f;
circle = symbol->vector->circles;
while (circle) {
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\"", circle->x, circle->y, circle->diameter / 2.0);
if (previous_diameter != circle->diameter) {
previous_diameter = circle->diameter;
radius = (float) (0.5 * previous_diameter);
}
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\"", circle->x, circle->y, radius);
if (circle->colour) {
fprintf(fsvg, " fill=\"#%s\"", bgcolour_string);
if (bg_alpha != 0xff) {
// This doesn't work how the user is likely to expect - more work needed!
fprintf(fsvg, " opacity=\"%.3f\"", (float) bg_alpha / 255.0);
fprintf(fsvg, " opacity=\"%.3f\"", bg_alpha_opacity);
}
} else {
if (fg_alpha != 0xff) {
fprintf(fsvg, " opacity=\"%.3f\"", (float) fg_alpha / 255.0);
fprintf(fsvg, " opacity=\"%.3f\"", fg_alpha_opacity);
}
}
fprintf(fsvg, " />\n");
@ -290,7 +309,7 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
fprintf(fsvg, " font-weight=\"bold\"");
}
if (fg_alpha != 0xff) {
fprintf(fsvg, " opacity=\"%.3f\"", (float) fg_alpha / 255.0);
fprintf(fsvg, " opacity=\"%.3f\"", fg_alpha_opacity);
}
if (string->rotation != 0) {
fprintf(fsvg, " transform=\"rotate(%d,%.2f,%.2f)\"", string->rotation, string->x, string->y);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -15,42 +15,42 @@ newpath
100.00 0.00 TB 0.00 130.00 TR
TE
0.00 0.00 0.00 setrgbcolor
4.00 96.00 4.00 TD
24.00 96.00 4.00 TD
64.00 96.00 4.00 TD
84.00 96.00 4.00 TD
104.00 96.00 4.00 TD
124.00 96.00 4.00 TD
34.00 86.00 4.00 TD
4.00 76.00 4.00 TD
44.00 76.00 4.00 TD
84.00 76.00 4.00 TD
104.00 76.00 4.00 TD
124.00 76.00 4.00 TD
14.00 66.00 4.00 TD
74.00 66.00 4.00 TD
94.00 66.00 4.00 TD
44.00 56.00 4.00 TD
64.00 56.00 4.00 TD
104.00 56.00 4.00 TD
14.00 46.00 4.00 TD
54.00 46.00 4.00 TD
114.00 46.00 4.00 TD
4.00 36.00 4.00 TD
44.00 36.00 4.00 TD
64.00 36.00 4.00 TD
84.00 36.00 4.00 TD
124.00 36.00 4.00 TD
14.00 26.00 4.00 TD
34.00 26.00 4.00 TD
54.00 26.00 4.00 TD
94.00 26.00 4.00 TD
4.00 16.00 4.00 TD
44.00 16.00 4.00 TD
84.00 16.00 4.00 TD
104.00 16.00 4.00 TD
124.00 16.00 4.00 TD
14.00 6.00 4.00 TD
34.00 6.00 4.00 TD
74.00 6.00 4.00 TD
114.00 6.00 4.00 TD
5.00 95.00 4.00 TD
25.00 95.00 4.00 TD
65.00 95.00 4.00 TD
85.00 95.00 4.00 TD
105.00 95.00 4.00 TD
125.00 95.00 4.00 TD
35.00 85.00 4.00 TD
5.00 75.00 4.00 TD
45.00 75.00 4.00 TD
85.00 75.00 4.00 TD
105.00 75.00 4.00 TD
125.00 75.00 4.00 TD
15.00 65.00 4.00 TD
75.00 65.00 4.00 TD
95.00 65.00 4.00 TD
45.00 55.00 4.00 TD
65.00 55.00 4.00 TD
105.00 55.00 4.00 TD
15.00 45.00 4.00 TD
55.00 45.00 4.00 TD
115.00 45.00 4.00 TD
5.00 35.00 4.00 TD
45.00 35.00 4.00 TD
65.00 35.00 4.00 TD
85.00 35.00 4.00 TD
125.00 35.00 4.00 TD
15.00 25.00 4.00 TD
35.00 25.00 4.00 TD
55.00 25.00 4.00 TD
95.00 25.00 4.00 TD
5.00 15.00 4.00 TD
45.00 15.00 4.00 TD
85.00 15.00 4.00 TD
105.00 15.00 4.00 TD
125.00 15.00 4.00 TD
15.00 5.00 4.00 TD
35.00 5.00 4.00 TD
75.00 5.00 4.00 TD
115.00 5.00 4.00 TD

Binary file not shown.

Before

Width:  |  Height:  |  Size: 688 B

After

Width:  |  Height:  |  Size: 694 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 B

After

Width:  |  Height:  |  Size: 682 B

View File

@ -8,44 +8,44 @@
<g id="barcode" fill="#000000">
<rect x="0" y="0" width="130" height="100" fill="#FFFFFF" />
<circle cx="4.00" cy="4.00" r="4.00" />
<circle cx="24.00" cy="4.00" r="4.00" />
<circle cx="64.00" cy="4.00" r="4.00" />
<circle cx="84.00" cy="4.00" r="4.00" />
<circle cx="104.00" cy="4.00" r="4.00" />
<circle cx="124.00" cy="4.00" r="4.00" />
<circle cx="34.00" cy="14.00" r="4.00" />
<circle cx="4.00" cy="24.00" r="4.00" />
<circle cx="44.00" cy="24.00" r="4.00" />
<circle cx="84.00" cy="24.00" r="4.00" />
<circle cx="104.00" cy="24.00" r="4.00" />
<circle cx="124.00" cy="24.00" r="4.00" />
<circle cx="14.00" cy="34.00" r="4.00" />
<circle cx="74.00" cy="34.00" r="4.00" />
<circle cx="94.00" cy="34.00" r="4.00" />
<circle cx="44.00" cy="44.00" r="4.00" />
<circle cx="64.00" cy="44.00" r="4.00" />
<circle cx="104.00" cy="44.00" r="4.00" />
<circle cx="14.00" cy="54.00" r="4.00" />
<circle cx="54.00" cy="54.00" r="4.00" />
<circle cx="114.00" cy="54.00" r="4.00" />
<circle cx="4.00" cy="64.00" r="4.00" />
<circle cx="44.00" cy="64.00" r="4.00" />
<circle cx="64.00" cy="64.00" r="4.00" />
<circle cx="84.00" cy="64.00" r="4.00" />
<circle cx="124.00" cy="64.00" r="4.00" />
<circle cx="14.00" cy="74.00" r="4.00" />
<circle cx="34.00" cy="74.00" r="4.00" />
<circle cx="54.00" cy="74.00" r="4.00" />
<circle cx="94.00" cy="74.00" r="4.00" />
<circle cx="4.00" cy="84.00" r="4.00" />
<circle cx="44.00" cy="84.00" r="4.00" />
<circle cx="84.00" cy="84.00" r="4.00" />
<circle cx="104.00" cy="84.00" r="4.00" />
<circle cx="124.00" cy="84.00" r="4.00" />
<circle cx="14.00" cy="94.00" r="4.00" />
<circle cx="34.00" cy="94.00" r="4.00" />
<circle cx="74.00" cy="94.00" r="4.00" />
<circle cx="114.00" cy="94.00" r="4.00" />
<circle cx="5.00" cy="5.00" r="4.00" />
<circle cx="25.00" cy="5.00" r="4.00" />
<circle cx="65.00" cy="5.00" r="4.00" />
<circle cx="85.00" cy="5.00" r="4.00" />
<circle cx="105.00" cy="5.00" r="4.00" />
<circle cx="125.00" cy="5.00" r="4.00" />
<circle cx="35.00" cy="15.00" r="4.00" />
<circle cx="5.00" cy="25.00" r="4.00" />
<circle cx="45.00" cy="25.00" r="4.00" />
<circle cx="85.00" cy="25.00" r="4.00" />
<circle cx="105.00" cy="25.00" r="4.00" />
<circle cx="125.00" cy="25.00" r="4.00" />
<circle cx="15.00" cy="35.00" r="4.00" />
<circle cx="75.00" cy="35.00" r="4.00" />
<circle cx="95.00" cy="35.00" r="4.00" />
<circle cx="45.00" cy="45.00" r="4.00" />
<circle cx="65.00" cy="45.00" r="4.00" />
<circle cx="105.00" cy="45.00" r="4.00" />
<circle cx="15.00" cy="55.00" r="4.00" />
<circle cx="55.00" cy="55.00" r="4.00" />
<circle cx="115.00" cy="55.00" r="4.00" />
<circle cx="5.00" cy="65.00" r="4.00" />
<circle cx="45.00" cy="65.00" r="4.00" />
<circle cx="65.00" cy="65.00" r="4.00" />
<circle cx="85.00" cy="65.00" r="4.00" />
<circle cx="125.00" cy="65.00" r="4.00" />
<circle cx="15.00" cy="75.00" r="4.00" />
<circle cx="35.00" cy="75.00" r="4.00" />
<circle cx="55.00" cy="75.00" r="4.00" />
<circle cx="95.00" cy="75.00" r="4.00" />
<circle cx="5.00" cy="85.00" r="4.00" />
<circle cx="45.00" cy="85.00" r="4.00" />
<circle cx="85.00" cy="85.00" r="4.00" />
<circle cx="105.00" cy="85.00" r="4.00" />
<circle cx="125.00" cy="85.00" r="4.00" />
<circle cx="15.00" cy="95.00" r="4.00" />
<circle cx="35.00" cy="95.00" r="4.00" />
<circle cx="75.00" cy="95.00" r="4.00" />
<circle cx="115.00" cy="95.00" r="4.00" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -282,7 +282,7 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);

View File

@ -282,7 +282,7 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);

File diff suppressed because it is too large Load Diff

View File

@ -380,7 +380,7 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, data[i].option_2, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);

View File

@ -444,7 +444,7 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, data[i].option_1, data[i].option_2, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, debug)) {
if (!data[i].bwipp_cmp) {
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
} else {

View File

@ -368,7 +368,7 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, data[i].option_2, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);

View File

@ -234,7 +234,7 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, data[i].option_2, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);

View File

@ -665,7 +665,7 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
if (!data[i].bwipp_cmp) {
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
} else {

View File

@ -278,7 +278,7 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);

View File

@ -212,7 +212,7 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);

View File

@ -1265,7 +1265,7 @@ static void test_examples(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, data[i].option_1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, data[i].option_1, -1, -1, data[i].composite, composite_length, symbol->primary, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
@ -1431,7 +1431,7 @@ static void test_odd_numbered_numeric(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, data[i].option_1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, data[i].option_1, -1, -1, data[i].composite, composite_length, symbol->primary, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
@ -1561,7 +1561,7 @@ static void test_ean128_cc_shift(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, data[i].option_1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, -1, -1, debug)) {
if (!data[i].bwipp_cmp) {
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
} else {
@ -2112,7 +2112,7 @@ static void test_encodation_0(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, data[i].option_1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, data[i].option_1, -1, -1, data[i].composite, composite_length, symbol->primary, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
@ -2251,7 +2251,7 @@ static void test_encodation_10(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, data[i].option_1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, data[i].option_1, -1, -1, data[i].composite, composite_length, symbol->primary, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
@ -2633,7 +2633,7 @@ static void test_encodation_11(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, data[i].option_1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, data[i].option_1, -1, -1, data[i].composite, composite_length, symbol->primary, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
@ -2786,7 +2786,7 @@ static void test_addongap(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, data[i].option_1, data[i].option_2, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, debug)) {
ret = testUtilBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, composite, composite_length, symbol->primary, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);

View File

@ -92,19 +92,19 @@ static void test_buffer(int index, int debug) {
int ret;
struct item {
char *data;
int eci;
int input_mode;
int output_options;
char *data;
int ret;
char *comment;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { "1", 16383, UNICODE_MODE, READER_INIT, 0, "" },
/* 1*/ { "000106j 05 Galeria A Nação0000000000", 3, UNICODE_MODE, 0, 0, "From Okapi, consecutive use of upper shift; ticket #176" },
/* 0*/ { 16383, UNICODE_MODE, READER_INIT, "1", 0, "" },
/* 1*/ { 3, UNICODE_MODE, 0, "000106j 05 Galeria A Nação0000000000", 0, "From Okapi, consecutive use of upper shift; #176" },
};
int data_size = sizeof(data) / sizeof(struct item);
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
@ -113,13 +113,7 @@ static void test_buffer(int index, int debug) {
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->symbology = BARCODE_DATAMATRIX;
symbol->input_mode = data[i].input_mode;
symbol->eci = data[i].eci;
symbol->output_options = data[i].output_options;
symbol->debug |= debug;
int length = strlen(data[i].data);
int length = testUtilSetSymbol(symbol, BARCODE_DATAMATRIX, data[i].input_mode, data[i].eci, -1 /*option_1*/, -1, -1, data[i].output_options, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
@ -130,6 +124,118 @@ static void test_buffer(int index, int debug) {
testFinish();
}
static void test_options(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int option_1;
int option_2;
int option_3;
char *data;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, -1, -1, -1, "1", 0, 10, 10 },
/* 1*/ { BARCODE_DATAMATRIX, 2, -1, -1, "1", ZINT_ERROR_INVALID_OPTION, -1, -1 },
/* 2*/ { BARCODE_DATAMATRIX, -1, 1, -1, "1", 0, 10, 10 },
/* 3*/ { BARCODE_DATAMATRIX, -1, 2, -1, "1", 0, 12, 12 },
/* 4*/ { BARCODE_DATAMATRIX, -1, 48, -1, "1", 0, 26, 64 },
/* 5*/ { BARCODE_DATAMATRIX, -1, 49, -1, "1", 0, 10, 10 }, // Ignored
/* 6*/ { BARCODE_DATAMATRIX, -1, -1, -1, "ABCDEFGHIJK", 0, 8, 32 },
/* 7*/ { BARCODE_DATAMATRIX, -1, -1, DM_SQUARE, "ABCDEFGHIJK", 0, 16, 16 },
/* 8*/ { BARCODE_DATAMATRIX, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 32, 32 },
/* 9*/ { BARCODE_DATAMATRIX, -1, -1, DM_DMRE, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 20, 44 },
/* 10*/ { BARCODE_DATAMATRIX, -1, -1, 9999, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 32, 32 }, // Ignored
};
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, symbol->errtxt);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, symbol->errtxt);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_reader_init(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int input_mode;
int output_options;
char *data;
int ret;
int expected_rows;
int expected_width;
char *expected;
char *comment;
};
struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, UNICODE_MODE, READER_INIT, "A", 0, 10, 10, "EA 42 81 19 A4 53 21 DF", "TODO: Check this" },
/* 1*/ { BARCODE_DATAMATRIX, GS1_MODE, READER_INIT, "[91]A", ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 521: Cannot encode in GS1 mode and Reader Initialisation at the same time", "" },
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, data[i].output_options, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (generate) {
printf(" /*%3d*/ { %s, %s, %s, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n",
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), testUtilOutputOptionsName(data[i].output_options),
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_input(int index, int generate, int debug) {
testStart("");
@ -138,7 +244,6 @@ static void test_input(int index, int generate, int debug) {
struct item {
int input_mode;
int eci;
int option_1;
int option_2;
int option_3;
char *data;
@ -151,16 +256,78 @@ static void test_input(int index, int generate, int debug) {
char *comment;
};
struct item data[] = {
/* 0*/ { UNICODE_MODE, 0, -1, -1, -1, "0466010592130100000k*AGUATY80", 0, 0, 18, 18, "(32) 86 C4 83 87 DE 8F 83 82 82 31 6C EE 08 85 D6 D2 EF 65 93 B0 1C 3C 76 FB D4 AB 16 11", "" },
/* 1*/ { UNICODE_MODE, 0, -1, 5, -1, "0466010592130100000k*AGUATY80", 0, 0, 18, 18, "(32) 86 C4 83 87 DE 8F 83 82 82 31 6C EE 08 85 D6 D2 EF 65 93 B0 1C 3C 76 FB D4 AB 16 11", "" },
/* 2*/ { UNICODE_MODE, 0, -1, -1, -1, "0466010592130100000k*AGUATY8", 0, 0, 18, 18, "(32) 86 C4 83 87 DE 8F 83 82 82 E6 19 5C 07 B7 82 5F D4 3D 65 B5 97 30 00 FC 2C 4C 30 52", "" },
/* 3*/ { UNICODE_MODE, 0, -1, -1, -1, "0466010592130100000k*AGUATY80U", 0, 0, 20, 20, "(40) 86 C4 83 87 DE 8F 83 82 82 31 6C EE 08 85 D6 D2 EF 65 FE 56 81 76 4F AB 22 B8 6F 0A", "" },
/* 4*/ { UNICODE_MODE, 0, -1, 5, -1, "0466010592130100000k*AGUATY80U", ZINT_ERROR_TOO_LONG, -1, 0, 0, "Error 522: Input too long for selected symbol size", "" },
/* 5*/ { UNICODE_MODE, 0, -1, 6, -1, "0466010592130100000k*AGUATY80U", 0, 0, 20, 20, "(40) 86 C4 83 87 DE 8F 83 82 82 31 6C EE 08 85 D6 D2 EF 65 FE 56 81 76 4F AB 22 B8 6F 0A", "" },
/* 6*/ { UNICODE_MODE, 0, -1, -1, -1, "0466010592130100000k*AGUATY80UA", 0, 0, 20, 20, "(40) 86 C4 83 87 DE 8F 83 82 82 31 6C E6 07 B7 82 5F D4 3D 1E 5F FE 81 1E 1B B0 FE E7 54", "" },
/* 7*/ { UNICODE_MODE, 0, -1, -1, -1, "A*0>B1*", 0, 0, 14, 14, "EE 57 AD 0E DE FE 2B 81 F8 05 75 94 1E 5F 24 0C A0 D3", "X12 symbols_left 3, process_p 1" },
/* 8*/ { UNICODE_MODE, 0, -1, -1, -1, "A*0>B1*2", 0, 0, 14, 14, "EE 57 AD 0E DE FE 2B 33 E7 BB FB 78 F9 F5 4B 11 BB 5A", "X12 symbols_left 3, process_p 2" },
/* 9*/ { UNICODE_MODE, 0, -1, -1, -1, "A*0>B1*2>", 0, 0, 14, 14, "EE 57 AD 0E DE 07 33 FE 75 99 1B 4D 76 0E 9E 49 E0 37", "X12 symbols_left 1, process_p 0" },
/* 0*/ { UNICODE_MODE, 0, -1, -1, "0466010592130100000k*AGUATY80", 0, 0, 18, 18, "(32) 86 C4 83 87 DE 8F 83 82 82 31 6C EE 08 85 D6 D2 EF 65 93 B0 1C 3C 76 FB D4 AB 16 11", "#208" },
/* 1*/ { UNICODE_MODE, 0, 5, -1, "0466010592130100000k*AGUATY80", 0, 0, 18, 18, "(32) 86 C4 83 87 DE 8F 83 82 82 31 6C EE 08 85 D6 D2 EF 65 93 B0 1C 3C 76 FB D4 AB 16 11", "" },
/* 2*/ { UNICODE_MODE, 0, -1, -1, "0466010592130100000k*AGUATY8", 0, 0, 18, 18, "(32) 86 C4 83 87 DE 8F 83 82 82 E6 19 5C 07 B7 82 5F D4 3D 65 B5 97 30 00 FC 2C 4C 30 52", "" },
/* 3*/ { UNICODE_MODE, 0, -1, -1, "0466010592130100000k*AGUATY80U", 0, 0, 20, 20, "(40) 86 C4 83 87 DE 8F 83 82 82 31 6C EE 08 85 D6 D2 EF 65 FE 56 81 76 4F AB 22 B8 6F 0A", "" },
/* 4*/ { UNICODE_MODE, 0, 5, -1, "0466010592130100000k*AGUATY80U", ZINT_ERROR_TOO_LONG, -1, 0, 0, "Error 522: Input too long for selected symbol size", "" },
/* 5*/ { UNICODE_MODE, 0, 6, -1, "0466010592130100000k*AGUATY80U", 0, 0, 20, 20, "(40) 86 C4 83 87 DE 8F 83 82 82 31 6C EE 08 85 D6 D2 EF 65 FE 56 81 76 4F AB 22 B8 6F 0A", "" },
/* 6*/ { UNICODE_MODE, 0, -1, -1, "0466010592130100000k*AGUATY80UA", 0, 0, 20, 20, "(40) 86 C4 83 87 DE 8F 83 82 82 31 6C E6 07 B7 82 5F D4 3D 1E 5F FE 81 1E 1B B0 FE E7 54", "" },
/* 7*/ { UNICODE_MODE, 0, -1, -1, "A*0>B1*", 0, 0, 14, 14, "EE 57 AD 0E DE FE 2B 81 F8 05 75 94 1E 5F 24 0C A0 D3", "X12 symbols_left 3, process_p 1" },
/* 8*/ { UNICODE_MODE, 0, -1, -1, "A*0>B1*2", 0, 0, 14, 14, "EE 57 AD 0E DE FE 2B 33 E7 BB FB 78 F9 F5 4B 11 BB 5A", "X12 symbols_left 3, process_p 2" },
/* 9*/ { UNICODE_MODE, 0, -1, -1, "A*0>B1*2>", 0, 0, 14, 14, "EE 57 AD 0E DE 07 33 FE 75 99 1B 4D 76 0E 9E 49 E0 37", "X12 symbols_left 1, process_p 0" },
/* 10*/ { UNICODE_MODE, 0, -1, -1, "ABCDEF", 0, 0, 12, 12, "E6 59 E9 6D 24 3D 15 EF AA 21 F9 59", "C40 last_shift 0, symbols_left 0, process_p 0" },
/* 11*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFG", 0, 0, 14, 14, "E6 59 E9 6D 24 FE 48 81 8C 7E 09 5E 10 64 BC 5F 4C 91", "C40 last_shift 0, symbols_left 3, process_p 1" },
/* 12*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH", 0, 0, 14, 14, "E6 59 E9 6D 24 80 49 FE DD 85 9E 5B E9 8F 4D F3 02 9C", "C40 last_shift 0, symbols_left 3, process_p 2" },
/* 13*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHI", 0, 0, 14, 14, "E6 59 E9 6D 24 80 5F FE 01 DE 20 9F AA C2 FF 8F 08 97", "C40 last_shift 0, symbols_left 1, process_p 0" },
/* 14*/ { UNICODE_MODE, 0, -1, -1, "ABCDEF\001G", 0, 0, 14, 14, "E6 59 E9 6D 24 00 3D FE 5D 5A F5 0A 8A 4E 1D 63 07 B9", "C40 last_shift 0, symbols_left 1, process_p 0" },
/* 15*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFG\001", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 02 FE 14 A3 27 63 01 2F B1 94 FE FA", "C40 last_shift 0, symbols_left 1, process_p 0" },
/* 16*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFG\001H", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 02 49 C2 E6 DD 06 89 51 BA 8E 9D 1F", "C40 last_shift 0, symbols_left 1, process_p 1" },
/* 17*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH\001", 0, 0, 14, 14, "E6 59 E9 6D 24 80 49 02 4F 4D 86 23 5F 1B F9 8C 67 7E", "C40 last_shift 1, symbols_left 1, process_p 1" },
/* 18*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH\001I", 0, 0, 8, 32, "E6 59 E9 6D 24 80 49 09 B1 FE 27 19 F1 CA B7 85 D0 25 0D 5E 24", "C40 last_shift 1, symbols_left 3, process_p 2" },
/* 19*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHI\001", 0, 0, 8, 32, "E6 59 E9 6D 24 80 5F FE 02 81 47 6C 3E 49 D3 FA 46 47 53 6E E5", "Switches to ASC for last char" },
/* 20*/ { UNICODE_MODE, 0, -1, -1, "ABCDEF+G", 0, 0, 14, 14, "E6 59 E9 6D 24 07 E5 FE 6B 35 71 7F 3D 57 59 46 F7 B9", "C40 last_shift 0, symbols_left 1, process_p 0" },
/* 21*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFG+", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 33 FE 33 F5 97 60 73 48 13 2E E5 74", "C40 last_shift 0, symbols_left 1, process_p 0" },
/* 22*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFG+H", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 33 49 E5 B0 6D 05 FB 36 18 34 86 91", "C40 last_shift 0, symbols_left 1, process_p 1" },
/* 23*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH+", 0, 0, 14, 14, "E6 59 E9 6D 24 80 49 2C 67 1F 09 CA 1A CD 0D 55 80 21", "C40 last_shift 2, symbols_left 1, process_p 1" },
/* 24*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGH+I", 0, 0, 8, 32, "E6 59 E9 6D 24 80 4A 41 F1 FE 41 81 CF 13 E2 64 43 2F E1 D1 11", "C40 last_shift 2, symbols_left 3, process_p 2" },
/* 25*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHI+", 0, 0, 8, 32, "E6 59 E9 6D 24 80 5F FE 2C 81 F8 BC 8D 12 17 7E 22 27 DE 7F E2", "Switches to ASC for last char" },
/* 26*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFjG", 0, 0, 14, 14, "E6 59 E9 6D 24 0E 25 FE DA 14 D7 15 47 69 9D 4A 54 6D", "C40 last_shift 0, symbols_left 1, process_p 0" },
/* 27*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGj", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 5B FE B5 F3 24 0A 99 26 D6 CC A8 40", "C40 last_shift 0, symbols_left 1, process_p 0" },
/* 28*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGjH", 0, 0, 14, 14, "E6 59 E9 6D 24 7D 5B 49 63 B6 DE 6F 11 58 DD D6 CB A5", "C40 last_shift 0, symbols_left 1, process_p 1" },
/* 29*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHj", 0, 0, 14, 14, "E6 59 E9 6D 24 80 49 6B 12 00 5B FD B0 3A D9 DF 26 B6", "C40 last_shift 3, symbols_left 1, process_p 1" },
/* 30*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHjI", 0, 0, 8, 32, "E6 59 E9 6D 24 80 4B 41 F1 FE FB 10 AC 51 A1 56 8F 20 98 18 1B", "C40 last_shift 3, symbols_left 3, process_p 2" },
/* 31*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHIj", 0, 0, 8, 32, "E6 59 E9 6D 24 80 5F FE 6B 81 17 79 06 42 7E 96 B2 70 79 F8 3C", "Switches to ASC for last char" },
/* 32*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHIJÊ", 0, 0, 16, 16, "E6 59 E9 6D 24 80 5F FE 4B EB 4B 81 DD D9 F9 C9 C5 38 F3 4B DB 80 92 A7", "Switches to ASC for last 2 chars" },
/* 33*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHIJKÊ", 0, 0, 16, 16, "E6 59 E9 6D 24 80 5F 93 82 BF 19 FE E7 50 32 B4 0B CC 8C 07 D2 78 8D F5", "C40 last_shift 0, symbols_left 3, process_p 2" },
/* 34*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHIJKª", 0, 0, 16, 16, "E6 59 E9 6D 24 80 5F 93 82 BB B2 FE 11 5C 60 32 A6 DE FC 7B 30 F1 03 56", "C40 last_shift 0, symbols_left 1, process_p 0" },
/* 35*/ { UNICODE_MODE, 0, -1, -1, "ABCDEFGHIJKê", 0, 0, 16, 16, "E6 59 E9 6D 24 80 5F 93 82 BB DB FE 78 43 69 3C C2 FE F5 2E 1B 4F B6 04", "C40 last_shift 0, symbols_left 1, process_p 0" },
/* 36*/ { UNICODE_MODE, 0, -1, -1, "abcdef", 0, 0, 12, 12, "EF 59 E9 6D 24 E2 CC D9 B4 55 E2 6A", "TEX last_shift 0, symbols_left 0, process_p 0" },
/* 37*/ { UNICODE_MODE, 0, -1, -1, "abcdefg", 0, 0, 14, 14, "EF 59 E9 6D 24 FE 68 81 A9 65 CD 3A A2 E9 E0 B7 E1 E5", "TEX last_shift 0, symbols_left 3, process_p 1" },
/* 38*/ { UNICODE_MODE, 0, -1, -1, "abcdefgh", 0, 0, 14, 14, "EF 59 E9 6D 24 80 49 FE 06 E4 44 D2 32 58 90 31 E9 F8", "TEX last_shift 0, symbols_left 3, process_p 2" },
/* 39*/ { UNICODE_MODE, 0, -1, -1, "abcdefghi", 0, 0, 14, 14, "EF 59 E9 6D 24 80 5F FE DA BF FA 16 71 15 22 4D E3 F3", "TEX last_shift 0, symbols_left 1, process_p 0" },
/* 40*/ { UNICODE_MODE, 0, -1, -1, "abcdef\001g", 0, 0, 14, 14, "EF 59 E9 6D 24 00 3D FE 86 3B 2F 83 51 99 C0 A1 EC DD", "TEX last_shift 0, symbols_left 1, process_p 0" },
/* 41*/ { UNICODE_MODE, 0, -1, -1, "abcdefg\001", 0, 0, 14, 14, "EF 59 E9 6D 24 7D 02 FE CF C2 FD EA DA F8 6C 56 15 9E", "TEX last_shift 0, symbols_left 1, process_p 0" },
/* 42*/ { UNICODE_MODE, 0, -1, -1, "abcdefg\001h", 0, 0, 14, 14, "EF 59 E9 6D 24 7D 02 69 7A 9B EB A4 5E DE 99 25 01 8C", "TEX last_shift 0, symbols_left 1, process_p 1" },
/* 43*/ { UNICODE_MODE, 0, -1, -1, "abcdefgh\001", 0, 0, 14, 14, "EF 59 E9 6D 24 80 49 02 94 2C 5C AA 84 CC 24 4E 8C 1A", "TEX last_shift 1, symbols_left 1, process_p 1" },
/* 44*/ { UNICODE_MODE, 0, -1, -1, "abcdefgh\001i", 0, 0, 8, 32, "EF 59 E9 6D 24 80 49 09 B1 FE 2D DE FF 05 A9 AE 0B 91 4B C5 70", "TEX last_shift 1, symbols_left 3, process_p 2" },
/* 45*/ { UNICODE_MODE, 0, -1, -1, "abcdefghi\001", 0, 0, 8, 32, "EF 59 E9 6D 24 80 5F FE 02 81 4D AB 30 86 CD D1 9D F3 15 F5 B1", "Switches to ASC for last char" },
/* 46*/ { UNICODE_MODE, 0, -1, -1, "abcdefJg", 0, 0, 14, 14, "EF 59 E9 6D 24 0E 25 FE 01 75 0D 9C 9C BE 40 88 BF 09", "TEX last_shift 0, symbols_left 1, process_p 0" },
/* 47*/ { UNICODE_MODE, 0, -1, -1, "abcdefgJ", 0, 0, 14, 14, "EF 59 E9 6D 24 7D 5B FE 6E 92 FE 83 42 F1 0B 0E 43 24", "TEX last_shift 0, symbols_left 1, process_p 0" },
/* 48*/ { UNICODE_MODE, 0, -1, -1, "abcdefgJh", 0, 0, 14, 14, "EF 59 E9 6D 24 7D 5B 69 DB CB E8 CD C6 D7 FE 7D 57 36", "TEX last_shift 0, symbols_left 1, process_p 1" },
/* 49*/ { UNICODE_MODE, 0, -1, -1, "abcdefghJ", 0, 0, 14, 14, "EF 59 E9 6D 24 80 49 4B AA 7D 6D 5F 67 B5 FA 74 BA 25", "TEX last_shift 3, symbols_left 1, process_p 1" },
/* 50*/ { UNICODE_MODE, 0, -1, -1, "abcdefghJi", 0, 0, 8, 32, "EF 59 E9 6D 24 80 4B 41 F1 FE F1 D7 A2 9E BF 7D 54 94 DE 83 4F", "TEX last_shift 3, symbols_left 3, process_p 2" },
/* 51*/ { UNICODE_MODE, 0, -1, -1, "abcdefghiJ", 0, 0, 8, 32, "EF 59 E9 6D 24 80 5F FE 4B 81 B3 A5 20 E3 DC F9 74 40 09 30 46", "Switches to ASC for last char" },
/* 52*/ { UNICODE_MODE, 0, -1, -1, "abcdefghijkÊ", 0, 0, 16, 16, "EF 59 E9 6D 24 80 5F 93 82 BB DB FE 3E C8 EC 73 58 A7 42 46 10 49 25 99", "TEX last_shift 0, symbols_left 1, process_p 0" },
/* 53*/ { UNICODE_MODE, 0, -1, -1, "abcdefghijkª", 0, 0, 16, 16, "EF 59 E9 6D 24 80 5F 93 82 BB B2 FE 57 D7 E5 7D 3C 87 4B 13 3B F7 90 CB", "TEX last_shift 0, symbols_left 1, process_p 0" },
/* 54*/ { UNICODE_MODE, 0, -1, -1, "abcdefghijkê", 0, 0, 16, 16, "EF 59 E9 6D 24 80 5F 93 82 BF 19 FE A1 DB B7 FB 91 95 3B 6F D9 7E 1E 68", "TEX last_shift 2, symbols_left 3, process_p 2" },
/* 55*/ { UNICODE_MODE, 0, -1, -1, "@AB@CD@E", 0, 0, 14, 14, "F0 00 10 80 0C 40 05 81 45 D9 9B 1F BC 09 CD E4 7F F4", "EDIFACT symbols_left 1, process_p 0" },
/* 56*/ { UNICODE_MODE, 0, -1, -1, "@AB@CD@EF", 0, 0, 14, 14, "F0 00 10 80 0C 40 05 47 AC D8 F1 F0 DE 6C 30 5E 30 D4", "EDIFACT symbols_left 1, process_p 1" },
/* 57*/ { UNICODE_MODE, 0, -1, -1, "@AB@CD@EF@", 0, 0, 8, 32, "F0 00 10 80 0C 40 05 18 07 C0 6C 60 CA 7E 7B F3 38 A1 9D D0 CC", "EDIFACT symbols_left 3, process_p 2" },
/* 58*/ { UNICODE_MODE, 0, -1, -1, "@AB@CD@EF@G", 0, 0, 8, 32, "F0 00 10 80 0C 40 05 18 01 DF 71 FB 95 EA E6 4B 36 E0 23 9B 4C", "EDIFACT symbols_left 3, process_p 3" },
/* 59*/ { UNICODE_MODE, 0, -1, -1, "@AB@CD@EF@GH", 0, 0, 8, 32, "F0 00 10 80 0C 40 05 18 01 C8 77 0F 96 AD 39 FB F3 04 3B BF 99", "EDIFACT symbols_left 0, process_p 0" },
/* 60*/ { UNICODE_MODE, 0, -1, -1, "@AB@CD@EF@GH@", 0, 0, 16, 16, "F0 00 10 80 0C 40 05 18 01 C8 41 81 4A 43 1E F1 26 2E 4B EB B8 6A 2B 64", "EDIFACT symbols_left 2, process_p 1" },
/* 61*/ { UNICODE_MODE, 0, -1, -1, "@AB@CD@EF@GH@I", 0, 0, 16, 16, "F0 00 10 80 0C 40 05 18 01 C8 41 4A 49 B3 34 91 8C 2A C4 0E 16 2F 45 9B", "EDIFACT symbols_left 2, process_p 2" },
/* 62*/ { DATA_MODE, 0, -1, -1, "\377\376", 0, 0, 12, 12, "EB 80 EB 7F 81 6F A8 0F 21 6F 5F 88", "FN4 A7F FN4 A7E" },
/* 63*/ { DATA_MODE, 0, -1, -1, "\377\376\375", 0, 0, 12, 12, "E7 2F C0 55 E9 52 B7 8D 38 76 E8 6E", "BAS BFF BFE BFD" },
/* 64*/ { DATA_MODE, 3, -1, -1, "\101\102\103\104\300\105\310", 0, 3, 16, 16, "F1 04 E7 5E 2D C4 5B F1 03 1D 36 81 64 0E C0 77 9A 18 52 B2 F9 F0 04 39", "ECI 4 BAS B41 B42 B43 B44 BC0 B45 BC8" },
/* 65*/ { UNICODE_MODE, 26, -1, -1, "ABCDÀEÈ", 0, 26, 12, 26, "F1 1B E7 60 2D C4 5B F1 06 58 B3 C7 21 81 57 ED 3D C0 12 2E 6C 80 58 CC 2C 05 0D 31 FC 2D", "ECI 27 BAS B41 B42 B43 B44 BC3 B80 B45 BC3 B88" },
/* 66*/ { UNICODE_MODE, 0, -1, -1, "β", ZINT_WARN_USES_ECI, 9, 12, 12, "Warning F1 0A EB 63 81 41 56 DA C0 3D 2D CC", "ECI 10 FN4 A62" },
/* 67*/ { UNICODE_MODE, 127, -1, -1, "A", 0, 127, 12, 12, "F1 80 01 42 81 14 A2 86 07 F5 27 30", "ECI 128 A41" },
/* 68*/ { UNICODE_MODE, 16382, -1, -1, "A", 0, 16382, 12, 12, "F1 BF FE 42 81 29 57 AA A0 92 B2 45", "ECI 16383 A41" },
/* 69*/ { UNICODE_MODE, 810899, -1, -1, "A", 0, 810899, 12, 12, "F1 CC 51 05 42 BB A5 A7 8A C6 6E 0F", "ECI 810900 A41" },
/* 70*/ { UNICODE_MODE, 26, -1, -1, "abcdefghi1234FGHIJKLMNabc@@@@@@@@@é", 0, 26, 24, 24, "(60) F1 1B EF 59 E9 6D 24 80 5F FE 8E A4 E6 79 F6 8D 31 A0 6C FE 62 63 64 F0 00 00 00 00", "Mix of modes TEX ASC C40 ASC EDI BAS" },
/* 71*/ { UNICODE_MODE | ESCAPE_MODE, -1, -1, -1, "[)>\\R05\\GA\\R\\E", 0, 0, 10, 10, "EC 42 81 5D 17 49 F6 B6", "Macro05 A41" },
};
int data_size = ARRAY_SIZE(data);
@ -175,14 +342,14 @@ static void test_input(int index, int generate, int debug) {
symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
int length = testUtilSetSymbol(symbol, BARCODE_DATAMATRIX, data[i].input_mode, data[i].eci, data[i].option_1, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
int length = testUtilSetSymbol(symbol, BARCODE_DATAMATRIX, data[i].input_mode, data[i].eci, -1 /*option_1*/, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
if (generate) {
printf(" /*%3d*/ { %s, %d, %d, %d, %d, \"%s\", %s, %d, %d, %d, \"%s\", \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_1, data[i].option_2, data[i].option_3, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
printf(" /*%3d*/ { %s, %d, %d, %d, \"%s\", %s, %d, %d, %d, \"%s\", \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_2, data[i].option_3, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), ret < 5 ? symbol->eci : -1, symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
} else {
if (ret < 5) {
@ -203,20 +370,28 @@ static void test_encode(int index, int generate, int debug) {
testStart("");
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); // Only do BWIPP test if asked, too slow otherwise
int ret;
struct item {
int symbology;
int input_mode;
int eci;
int output_options;
int option_2;
int option_3;
char *data;
int ret;
int expected_rows;
int expected_width;
int bwipp_cmp;
char *comment;
char *expected;
};
// Verified manually against ISO/IEC 16022:2006, GS1 General Specifications 20.0 (GGS), ANSI/HIBC LIC 2.6-2016 (HIBC/LIC) and ANSI/HIBC PAS 1.3-2010 (HIBC/PAS), with noted exceptions
struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, -1, "1234abcd", 0, 14, 14, "",
/* 0*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, "1234abcd", 0, 14, 14, 1, "",
"10101010101010"
"11001010001111"
"11000101100100"
@ -232,7 +407,7 @@ static void test_encode(int index, int generate, int debug) {
"10011111000100"
"11111111111111"
},
/* 1*/ { BARCODE_DATAMATRIX, -1, "A1B2C3D4E5F6G7H8I9J0K1L2", 0, 18, 18, "ISO 16022:2006 Figure 1",
/* 1*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, "A1B2C3D4E5F6G7H8I9J0K1L2", 0, 18, 18, 1, "ISO 16022:2006 Figure 1",
"101010101010101010"
"101000101010001111"
"101100000111000010"
@ -252,7 +427,7 @@ static void test_encode(int index, int generate, int debug) {
"100011000000100100"
"111111111111111111"
},
/* 2*/ { BARCODE_DATAMATRIX, -1, "123456", 0, 10, 10, "ISO 16022:2006 Figure O.2",
/* 2*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, "123456", 0, 10, 10, 1, "ISO 16022:2006 Figure O.2",
"1010101010"
"1100101101"
"1100000100"
@ -264,7 +439,7 @@ static void test_encode(int index, int generate, int debug) {
"1001110100"
"1111111111"
},
/* 3*/ { BARCODE_DATAMATRIX, -1, "30Q324343430794<OQQ", 0, 16, 16, "ISO 16022:2006 Figure R.1",
/* 3*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, "30Q324343430794<OQQ", 0, 16, 16, 1, "ISO 16022:2006 Figure R.1",
"1010101010101010"
"1010101010000001"
"1010101011101100"
@ -282,7 +457,7 @@ static void test_encode(int index, int generate, int debug) {
"1110010010100010"
"1111111111111111"
},
/* 4*/ { BARCODE_DATAMATRIX, GS1_MODE, "[01]09501101530003[17]150119[10]AB-123", 0, 20, 20, "GS1 General Specfications 20.0 Figure 2.6.14-3",
/* 4*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, -1, -1, "[01]09501101530003[17]150119[10]AB-123", 0, 20, 20, 1, "GGS Figure 2.6.14-3",
"10101010101010101010"
"11001111010100000111"
"10001010001001010100"
@ -304,7 +479,7 @@ static void test_encode(int index, int generate, int debug) {
"10011011100101011010"
"11111111111111111111"
},
/* 5*/ { BARCODE_DATAMATRIX, GS1_MODE, "[01]04012345678901[21]ABCDEFG123456789", 0, 20, 20, "GS1 General Specfications 20.0 Figure 2.6.14-4",
/* 5*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, -1, -1, "[01]04012345678901[21]ABCDEFG123456789", 0, 20, 20, 1, "GGS Figure 2.6.14-4",
"10101010101010101010"
"11011000001101000111"
"10001001100001110100"
@ -326,7 +501,7 @@ static void test_encode(int index, int generate, int debug) {
"10001000100001111010"
"11111111111111111111"
},
/* 6*/ { BARCODE_DATAMATRIX, GS1_MODE, "[01]04012345678901[17]170101[10]ABC123", 0, 20, 20, "GS1 General Specfications 20.0 Figure 4.15-1",
/* 6*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, -1, -1, "[01]04012345678901[17]170101[10]ABC123", 0, 20, 20, 1, "GGS Figure 4.15-1 (and 5.1-6)",
"10101010101010101010"
"11011000010100000111"
"10001001100001010100"
@ -348,7 +523,41 @@ static void test_encode(int index, int generate, int debug) {
"10001000000101111010"
"11111111111111111111"
},
/* 7*/ { BARCODE_DATAMATRIX, GS1_MODE, "[01]09504000059101[21]12345678p901[10]1234567p[17]141120[8200]http://www.gs1.org/demo/", 0, 32, 32, "GS1 General Specfications 20.0 Figure 4.15.1-2 **NOT SMAE** TODO: investigate",
/* 7*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, GS1_GS_SEPARATOR, -1, -1, "[01]09504000059101[21]12345678p901[10]1234567p[17]141120[8200]http://www.gs1.org/demo/", 0, 32, 32, 1, "GGS Figure 4.15.1-1; BWIPP does not support GS1_GS_SEPARATOR",
"10101010101010101010101010101010"
"11001111010000111101100000101001"
"10001010011111001011011001000010"
"10111011001001111101111101000101"
"11100101000010001000011011011110"
"10000101001101111010111000100101"
"10010001000100101000000010011110"
"10010110011101011000101100101111"
"11101010110010001100011100110100"
"11011100110110111101010000001001"
"10001010000101001100001111001110"
"10110011010101111000011101111101"
"11101100100110101110111010101110"
"11100100000001111000001111101001"
"10100010111011101110111100110100"
"11111111111111111111111111111111"
"10101010101010101010101010101010"
"11100011100111111000011111010111"
"11001100001100001001110100001010"
"10111011010001111010100110101101"
"11101011010011001101110011011010"
"10010000011010011110111111111011"
"11000101110110101110001110011000"
"10000010111010011001011100011111"
"10110011101000001100011001110010"
"10111010000110011100110100001001"
"10010001100011101101100010101110"
"11101001011010111000000100111001"
"10000010111010001001110111010000"
"11001101000110011110000111010101"
"10111100011001001010011100011000"
"11111111111111111111111111111111"
},
/* 8*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, -1, -1, "[01]09504000059101[21]12345678p901[10]1234567p[17]141120[8200]http://www.gs1.org/demo/", 0, 32, 32, 0, "GGS Figure 4.15.1-2; BWIPP different encodation (does not use 0 padded Text)",
"10101010101010101010101010101010"
"11001111010000111101100000101001"
"10001010011111001011011001000010"
@ -358,31 +567,191 @@ static void test_encode(int index, int generate, int debug) {
"10010001110100101000000010011110"
"10010110101101011000101100101111"
"11101010000010001100011100110100"
"11011100110110111101010000001001"
"10001010000101001100000111011010"
"10110011010101111000011001111001"
"11101100100110101110010100010110"
"11100100000001111000101100010101"
"10100010111011101100011101011010"
"11011100110110111101010000000001"
"10001010000101001100000111001010"
"10110011010101111000011101001001"
"11101100100110101110111101100110"
"11100100000001111000010101110111"
"10100010111011101101011111011100"
"11111111111111111111111111111111"
"10101010101010101010101010101010"
"11111011100111111011101011111111"
"11010100001100001001011001001010"
"10100011010010011101010101001101"
"11101011010000101011001110001110"
"10010000011001111110010000110111"
"11000101110110101010001111101000"
"10000010110111111010001011110011"
"10110011100010101010001011101000"
"10111010000000111100111100110001"
"10010000110001101101001110110110"
"11101001001110011001101111101001"
"10000000111100001100000010010000"
"11001101001100011110110001010101"
"10110100011001101010010100011000"
"11111011100111111011010111011111"
"11010100001100101101010101100010"
"10100011010001111101001011000101"
"11101011010011101001011111100010"
"10010000011001011100110010100111"
"11000101110000001000000000001100"
"10000010110010111010010010011001"
"10110011010000001010100111110000"
"10111010001101111111010011010001"
"10010000001110101110101110001110"
"11101010000000111000010000000001"
"10000101011111101011001111101100"
"11000111011001111110111101000101"
"10111010011011101010011100011000"
"11111111111111111111111111111111"
},
/* 8*/ { BARCODE_HIBC_DM, -1, "A123BJC5D6E71", 0, 16, 16, "**NOT SAME** ANSI/HIBC 2.6 - 2016 Figure 3 TODO: investigate",
/* 9*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, -1, -1, "[01]09512345678901[15]170810[21]abcde", 0, 20, 20, 1, "GGS Figure 5.6.2-1",
"10101010101010101010"
"11001111010111100111"
"10001010100101010100"
"10110111010010011001"
"11100010010101101110"
"10101100101000111101"
"11111010011000000110"
"10010011100000101101"
"10101001101011000010"
"11000110000100011111"
"10001011010001100010"
"10110000101001000011"
"11110011011001011100"
"11011101001000101011"
"11111101001000110110"
"11011100110000101111"
"11000100001111110000"
"11011111110010101101"
"10011010101001110010"
"11111111111111111111"
},
/* 10*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, -1, -1, "[01]00012345678905[17]040115", 0, 12, 26, 1, "GGS Figure 5.6.2-1 (left)",
"10101010101010101010101010"
"11001000010011010100111111"
"10001001100010001111001010"
"10110111011000001001001111"
"11100010100100100010001100"
"10101100110101011101101001"
"11111000111110101001010010"
"10011111101010111001100001"
"10101110101000110000010010"
"11001101010110000111100111"
"10001001100010100010100000"
"11111111111111111111111111"
},
/* 11*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, -1, DM_SQUARE, "[01]00012345678905[17]040115", 0, 18, 18, 1, "GGS Figure 5.6.2-1 (right)",
"101010101010101010"
"110010000100010101"
"100010011010111110"
"101101110001101111"
"111000100010101100"
"101011001100010001"
"111110000010101010"
"100101100110101101"
"101010101001110110"
"110011110001110011"
"100000111010111100"
"111100000000010111"
"111011010101010010"
"111111111001001011"
"100011100101010000"
"111100011101000011"
"100000101110000100"
"111111111111111111"
},
/* 12*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, -1, -1, "[01]00012345678905[17]180401[21]ABCDEFGHIJKL12345678[91]ABCDEFGHI123456789[92]abcdefghi", 0, 32, 32, 0, "GGS Figure 5.6.3.2-3 (left) **NOT SAME** different encodation; BWIP different encodation, same no. of codewords",
"10101010101010101010101010101010"
"11001000010111111000100110101011"
"10001001100001101100110010100010"
"10110111001101111110011001000111"
"11100010001100101100101001011110"
"10101101101011111110000000100101"
"11111010010010101101000010011110"
"10010100101111011101101100101111"
"10101000101101101111111100110100"
"11001110011000111111110000001001"
"10001010001010101101001111001110"
"11110001000000111101011100101101"
"11010001111011001000011010000010"
"11011100101001111001000111111111"
"10111100101001101111011101000010"
"11111111111111111111111111111111"
"10101010101010101010101010101010"
"11010100111011111001101111100111"
"11100111010011001011100001001010"
"11111001010111011101111000110011"
"11110000000010101101001110000110"
"11101110000001111011101000010101"
"11110101001101101101110000001000"
"10101011000111111010111001100111"
"11000101010010001100000011101010"
"11111101110111011001111011001101"
"11010111011010001000011101001010"
"10100111111110111101010111100011"
"10111011111010001001001100101110"
"10010101001110111101000101111101"
"11110110001001001010110111010110"
"11111111111111111111111111111111"
},
/* 13*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, 30, -1, "[01]00012345678905[17]180401[21]ABCDEFGHIJKL12345678[91]abcdefghi", 0, 16, 48, 1, "GGS Figure 5.6.3.2-3 (right) **NOT SAME** different encodation",
"101010101010101010101010101010101010101010101010"
"110010000101111001000011101101100100111011001111"
"100010011000011101111100100100011000110010111100"
"101101110011011100100111100111101110111110100011"
"111000100011001100111010101000011110001110111110"
"101011011010110100101101100100010101101110101111"
"111110100100100101111000101001100001101001001010"
"100101001011111001111001110110100101101100010111"
"101010001011111100111100100010000000011110001100"
"110011100101101010111011110111110111100111011001"
"100010100011010010111100100100101000001000011110"
"111100010010101101110001100001000001010110001001"
"110100001000101000011100101010101100011001001010"
"110111001110010000011111101111000110100011011011"
"101110001010001011101010101101111111111000000100"
"111111111111111111111111111111111111111111111111"
},
/* 14*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, -1, DM_SQUARE, "[00]395011010013000129[403]123+1021JK+0320+12[421]5281500KM", 0, 24, 24, 1, "GGS Figure 6.6.5-6 **NOT SAME** figure has unnecessary FNC1 at end of data",
"101010101010101010101010"
"110001110100011010101101"
"100010100100101000011000"
"101000110001001011100001"
"111010110110100001100010"
"100001001001010100001111"
"100110110111100000000100"
"100101110011001001100001"
"110000010110101011100010"
"110011001100011101110101"
"100000100011111010000000"
"101010110110011011000001"
"111010001001101000110000"
"110001000100011110101101"
"101011011101110000101000"
"110111000100011101011111"
"110101001010111101000010"
"110000111110111111111001"
"100101110010001010110110"
"111011010010000000100111"
"100110111101001000000100"
"101111000010010011111101"
"111001011011101100011010"
"111111111111111111111111"
},
/* 15*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, -1, -1, "[00]093123450000000012[421]0362770[401]931234518430GR[403]MEL", 0, 24, 24, 1, "GGS Figure 6.6.5-7 **NOT SAME** different encodation",
"101010101010101010101010"
"110011100101100110110101"
"100010001001111010000100"
"101001110100001011100011"
"111000110111000001101010"
"101011010010100110000111"
"101110011000011000001100"
"100101101011010001101001"
"110000100101011011101110"
"110010010110101101110001"
"100010101101001011010000"
"101010001000100000011001"
"101000101010000010000100"
"100110101110101100010101"
"100010010000111001000000"
"101000001001111000011011"
"111110000111001110000010"
"110001110101001101101111"
"110111110101100111101110"
"110100010010101011110101"
"110011000001011110100010"
"100111010001010011000101"
"101110011001110010101010"
"111111111111111111111111"
},
/* 16*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, "A123BJC5D6E71", 0, 16, 16, 1, "HIBC/LIC Figure 3 **NOT SAME** different encodation, same no. of codewords",
"1010101010101010"
"1110000011011011"
"1100001110001000"
@ -400,7 +769,7 @@ static void test_encode(int index, int generate, int debug) {
"1100101101000010"
"1111111111111111"
},
/* 9*/ { BARCODE_HIBC_DM, -1, "A123BJC5D6E71/$$52001510X3", 0, 20, 20, "**NOT SAME** ANSI/HIBC 2.6 - 2016 Section 4.3.3 TODO: investigate",
/* 17*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, "A123BJC5D6E71/$$52001510X3", 0, 20, 20, 1, "HIBC/LIC Section 4.3.3 **NOT SAME** different encodation; also figure has weird CRLF after check digit",
"10101010101010101010"
"11100000100101100001"
"11000011111010101100"
@ -422,7 +791,7 @@ static void test_encode(int index, int generate, int debug) {
"10110110110000011010"
"11111111111111111111"
},
/* 10*/ { BARCODE_HIBC_DM, -1, "H123ABC01234567890", 0, 12, 26, "ANSI/HIBC 2.6 - 2016 Figure C2, same",
/* 18*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, "H123ABC01234567890", 0, 12, 26, 1, "HIBC/LIC Figure C2, same",
"10101010101010101010101010"
"10111011011011110101001101"
"10010110000001001100110100"
@ -436,9 +805,223 @@ static void test_encode(int index, int generate, int debug) {
"10010010001100110000011010"
"11111111111111111111111111"
},
/* 19*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, DM_SQUARE, "/ACMRN123456/V200912190833", 0, 20, 20, 1, "HIBC/PAS Section 2.2 Patient Id, same",
"10101010101010101010"
"10001000010011001001"
"11100110001010110100"
"10000010111001010101"
"11011100101010111100"
"10010001110010100001"
"11011110100100100110"
"10110000100000101111"
"11111100011100001000"
"11001011011010001101"
"11001010111110110000"
"11000001111100001111"
"11110010001100000100"
"10011011100010110011"
"11111100110000111110"
"11000110111111110001"
"11000001011001100110"
"10101010010101100101"
"10000100100110010010"
"11111111111111111111"
},
/* 20*/ { BARCODE_DATAMATRIX, DATA_MODE | ESCAPE_MODE, -1, -1, -1, -1, "[)>\\R06\\G+/ACMRN123456/V2009121908334\\R\\E", 0, 20, 20, 1, "HIBC/PAS Section 2.2 Patient Id Macro, same",
"10101010101010101010"
"10000000001110001111"
"11010101001010011100"
"11000000011100110101"
"11011001101011001100"
"11001100000100010001"
"11110111101011000100"
"11010010001101100001"
"11110010010110011110"
"11010010010000010011"
"10010001100010110000"
"11101100100001000111"
"11101010000011111100"
"11000010000101001011"
"11001110111110010010"
"11000010110100011101"
"11001011001001011100"
"10010110010000010101"
"11100110001010111010"
"11111111111111111111"
},
/* 21*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, "/EO523201", 0, 14, 14, 1, "HIBC/PAS Section 2.2 Purchase Order, same",
"10101010101010"
"10011001010101"
"11101000011010"
"10001100011101"
"11101100101100"
"10100001101111"
"10010001010110"
"10000001011001"
"11100000010100"
"11011010100101"
"10111110101110"
"11110000101101"
"10010010000100"
"11111111111111"
},
/* 22*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, DM_SQUARE, "/EU720060FF0/O523201", 0, 18, 18, 1, "HIBC/PAS Section 2.2 2nd Purchase Order, same",
"101010101010101010"
"100110010100100001"
"111011110110010110"
"100000101110011001"
"111001001010000100"
"100000000000011101"
"100101100000101110"
"111000000111111011"
"110110111000101010"
"101001000111000111"
"100011110101010110"
"111111001101010011"
"100000000001101000"
"110100100011011111"
"111000100110101110"
"111010100101000011"
"111000010011001010"
"111111111111111111"
},
/* 23*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, "/EU720060FF0/O523201/Z34H159/M9842431340", 0, 22, 22, 1, "HIBC/PAS Section 2.2 3rd Purchase Order (left), same",
"1010101010101010101010"
"1001100101001000000011"
"1110111101100001111010"
"1000001011101100111111"
"1110010010010000111100"
"1000000000011100000111"
"1001011010011000001110"
"1110000010001001101001"
"1101100110001010100100"
"1010010011011101000101"
"1000100011010000001110"
"1111010100101000010111"
"1000001001011011101110"
"1111110111111101100011"
"1001010110011010000000"
"1101010100110100010011"
"1001010011000110000000"
"1111001010100101110111"
"1100110010110011010000"
"1100001011100001000111"
"1010110000010001001000"
"1111111111111111111111"
},
/* 24*/ { BARCODE_DATAMATRIX, DATA_MODE | ESCAPE_MODE, -1, -1, -1, -1, "[)>\\R06\\G+/EU720060FF0/O523201/Z34H159/M9842431340V\\R\\E", 0, 22, 22, 1, "HIBC/PAS Section 2.2 3rd Purchase Order (right), same",
"1010101010101010101010"
"1000000000111010011101"
"1101011100101001011100"
"1100010000000001101001"
"1111110110000111100000"
"1100100000110011001101"
"1001011001000010000110"
"1000100101110111110111"
"1100001001110111111100"
"1011111001001010001101"
"1000011000010100101010"
"1111001101110100101101"
"1110001101101100001100"
"1001010101111010110011"
"1000110111011100101010"
"1111110011011111010101"
"1101000011100111101110"
"1011000010010100110111"
"1001110101111101000000"
"1110101001011011000111"
"1001110110011101101000"
"1111111111111111111111"
},
/* 25*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, "/E+/KN12345", 0, 16, 16, 1, "HIBC/PAS Section 2.2 Asset Tag **NOT SAME** check digit 'A' in figure is for '/KN12345', but actual data is as given here, when check digit is 'J'",
"1010101010101010"
"1001101010001111"
"1110001000101100"
"1000110100101101"
"1101000000110010"
"1000101001000001"
"1110000111001100"
"1010001101111101"
"1111101010101000"
"1101100101010001"
"1100001011010010"
"1100001111001001"
"1100010100000110"
"1010001101001101"
"1001000000000010"
"1111111111111111"
},
/* 26*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, "/LAH123/NC903", 0, 16, 16, 1, "HIBC/PAS Section 2.2 Surgical Instrument, same",
"1010101010101010"
"1001010001010001"
"1110010100000100"
"1000001100000011"
"1110001100101000"
"1000111111100001"
"1011001110000100"
"1100110000001101"
"1000001110010000"
"1011001110111111"
"1001011010011010"
"1111000110111011"
"1010010101000100"
"1011001110110101"
"1100000101010010"
"1111111111111111"
},
/* 27*/ { BARCODE_DATAMATRIX, DATA_MODE, 3, -1, -1, -1, "\101\300", 0, 12, 12, 1, "",
"101010101010"
"100010101111"
"100001011110"
"110000010001"
"101100110000"
"110010100111"
"101011011100"
"110100111101"
"101100110100"
"101011100101"
"100011011010"
"111111111111"
},
/* 28*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 26, -1, -1, -1, "", 0, 14, 14, 1, "",
"10101010101010"
"10001010100001"
"10110101100100"
"10110001000101"
"10111000100010"
"11101011110011"
"10011100001100"
"10001100101111"
"10110110111110"
"10000111010001"
"10000001111000"
"11110100110001"
"11000110001100"
"11111111111111"
},
/* 29*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, -1, -1, -1, "abcdefgh+", 0, 14, 14, 0, "TEX last_shift 2, symbols_left 1, process_p 1; BWIPP different encodation (does not use 0 padded Text)",
"10101010101010"
"10100110111011"
"10110010100010"
"10011000100101"
"11101000000000"
"11000110110111"
"11000010110100"
"10101011010111"
"10111110000100"
"11011001001111"
"11110111100000"
"11001011110101"
"10010111010100"
"11111111111111"
},
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
char bwipp_buf[8192];
char bwipp_msg[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
@ -446,15 +1029,16 @@ static void test_encode(int index, int generate, int debug) {
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, data[i].eci, -1 /*option_1*/, data[i].option_2, data[i].option_3, data[i].output_options, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
if (generate) {
printf(" /*%3d*/ { %s, %s, \"%s\", %s, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode),
data[i].data, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
printf(" /*%3d*/ { %s, %s, %d, %s, %d, %s, \"%s\", %s, %d, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].eci, testUtilOutputOptionsName(data[i].output_options),
data[i].option_2, testUtilOption3Name(data[i].option_3), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
} else {
@ -462,10 +1046,21 @@ static void test_encode(int index, int generate, int debug) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
if (ret == 0) {
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, debug)) {
if (!data[i].bwipp_cmp) {
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
} else {
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, data[i].option_3, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected);
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
i, testUtilBarcodeName(symbol->symbology), ret, bwipp_msg, bwipp_buf, data[i].expected);
}
}
}
}
@ -481,6 +1076,8 @@ int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_large", test_large, 1, 0, 1 },
{ "test_buffer", test_buffer, 1, 0, 1 },
{ "test_options", test_options, 1, 0, 1 },
{ "test_reader_init", test_reader_init, 1, 1, 1 },
{ "test_input", test_input, 1, 1, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
};

View File

@ -213,7 +213,7 @@ static void test_gs1_reduce(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, -1, -1, text, length, symbol->primary, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);

View File

@ -267,7 +267,7 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);

View File

@ -283,7 +283,7 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, data[i].option_2, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);

View File

@ -186,7 +186,7 @@ static void test_input(int index, int generate, int debug) {
char *comment;
};
// é U+00E9 (\351, 233), UTF-8 C3A9
// β U+03B2 in ISO 8859-7 Greek (but not other ISO 8859 or Win page), in Shift JIS 0x83C0, UTF-8 CEB2
// β U+03B2 in ISO 8859-7 Greek (but not other ISO 8859 or Win page) (\342, 226), UTF-8 CEB2
struct item data[] = {
/* 0*/ { BARCODE_PDF417, UNICODE_MODE, -1, "é", 0, 0, 6, 103, "(12) 4 913 233 900 398 878 279 350 217 295 231 77", "" },
/* 1*/ { BARCODE_PDF417, UNICODE_MODE, 3, "é", 0, 3, 7, 103, "(14) 6 927 3 913 233 900 162 81 551 529 607 384 164 108", "" },
@ -261,6 +261,7 @@ static void test_encode(int index, int generate, int debug) {
int ret;
struct item {
int symbology;
int eci;
int input_mode;
int option_1;
int option_2;
@ -274,7 +275,7 @@ static void test_encode(int index, int generate, int debug) {
char *expected;
};
struct item data[] = {
/* 0*/ { BARCODE_PDF417, UNICODE_MODE, 1, 2, "PDF417 Symbology Standard", 0, 10, 103, 0, "ISO 15438:2015 Figure 1, same, BWIPP uses different encodation, same codeword count",
/* 0*/ { BARCODE_PDF417, -1, UNICODE_MODE, 1, 2, "PDF417 Symbology Standard", 0, 10, 103, 0, "ISO 15438:2015 Figure 1, same, BWIPP uses different encodation, same codeword count",
"1111111101010100011101010011100000111010110011110001110111011001100011110101011110000111111101000101001"
"1111111101010100011111010100110000110100001110001001111010001010000011111010100110000111111101000101001"
"1111111101010100011101010111111000101100110111100001110111111000101011010100111110000111111101000101001"
@ -286,14 +287,14 @@ static void test_encode(int index, int generate, int debug) {
"1111111101010100011010011011111100110000101001111101101111100010001010100110011111000111111101000101001"
"1111111101010100010100011000001100100010111101111001100011100011001011010001100011100111111101000101001"
},
/* 1*/ { BARCODE_PDF417, UNICODE_MODE, 1, 2, "PDF417", 0, 5, 103, 1, "ISO 15438:2015 Annex Q example for generating ECC",
/* 1*/ { BARCODE_PDF417, -1, UNICODE_MODE, 1, 2, "PDF417", 0, 5, 103, 1, "ISO 15438:2015 Annex Q example for generating ECC",
"1111111101010100011110101011110000110101000110000001110111011001100011110101011110000111111101000101001"
"1111111101010100011111101010011100110100001110001001111010001010000011111101010111000111111101000101001"
"1111111101010100011101010111111000101100110011110001100011111001001011101010011111100111111101000101001"
"1111111101010100010101111001111000101011101110000001100001101000100010101111001111000111111101000101001"
"1111111101010100011101011100011000100001101011111101111110110001011011101011100110000111111101000101001"
},
/* 2*/ { BARCODE_PDF417, UNICODE_MODE, 0, 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ ", 0, 17, 86, 1, "Text Compaction Alpha",
/* 2*/ { BARCODE_PDF417, -1, UNICODE_MODE, 0, 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ ", 0, 17, 86, 1, "Text Compaction Alpha",
"11111111010101000111110101001111101101011001110000011101010111000000111111101000101001"
"11111111010101000111111010101110001111110101011100011110101000100000111111101000101001"
"11111111010101000110101011111000001010011001111100011101010111111000111111101000101001"
@ -312,7 +313,7 @@ static void test_encode(int index, int generate, int debug) {
"11111111010101000110010110111000001100011000100001011100101000111000111111101000101001"
"11111111010101000101000111100100001110000101100010010100011110000100111111101000101001"
},
/* 3*/ { BARCODE_PDF417, UNICODE_MODE, 1, 1, "abcdefghijklmnopqrstuvwxyz ", 0, 19, 86, 1, "Text Compaction Lower",
/* 3*/ { BARCODE_PDF417, -1, UNICODE_MODE, 1, 1, "abcdefghijklmnopqrstuvwxyz ", 0, 19, 86, 1, "Text Compaction Lower",
"11111111010101000110101000110000001101011001110000011101010111000000111111101000101001"
"11111111010101000111110101001100001100000101110010011111010100011000111111101000101001"
"11111111010101000110101011111000001111101011110110011010100111110000111111101000101001"
@ -333,14 +334,14 @@ static void test_encode(int index, int generate, int debug) {
"11111111010101000111111001011101101010000001001111010010111001111110111111101000101001"
"11111111010101000111011010000110001000100111001110011110110100111000111111101000101001"
},
/* 4*/ { BARCODE_PDF417, UNICODE_MODE, 1, 4, "0123456&\015\011,:#-.$/+%*=^ 789", 0, 5, 137, 1, "Text Compaction Mixed",
/* 4*/ { BARCODE_PDF417, -1, UNICODE_MODE, 1, 4, "0123456&\015\011,:#-.$/+%*=^ 789", 0, 5, 137, 1, "Text Compaction Mixed",
"11111111010101000111101010111100001110101100111100010000110111001100110101111001111101010001110111000011101010011100000111111101000101001"
"11111111010101000111111010100111001010001111000001011101101111001100110110011110010001110010000011010011111101010111000111111101000101001"
"11111111010101000110101001111100001100111010000111011011110010110000100000101011110001101111101010000011101010011111100111111101000101001"
"11111111010101000101011110011110001000010000100001010010011000011000110010000100110001000011000110010010101111101111100111111101000101001"
"11111111010101000111010111000110001001111001001111010000101111101100100011110010111101001111110110111011101011100110000111111101000101001"
},
/* 5*/ { BARCODE_PDF417, UNICODE_MODE, 3, 2, ";<>@[\\]_'~!\015\011,:\012-.$/\"|*()?{", 0, 16, 103, 1, "Text Compaction Punctuation",
/* 5*/ { BARCODE_PDF417, -1, UNICODE_MODE, 3, 2, ";<>@[\\]_'~!\015\011,:\012-.$/\"|*()?{", 0, 16, 103, 1, "Text Compaction Punctuation",
"1111111101010100011111010100111110111010110011110001000111011100100011110101011110000111111101000101001"
"1111111101010100011111010100001100111111010101110001101011111101111011110101000100000111111101000101001"
"1111111101010100011101010111111000101000001000111101011011001111000011010100001111100111111101000101001"
@ -358,26 +359,26 @@ static void test_encode(int index, int generate, int debug) {
"1111111101010100011101000011111010111111010001101001011000010011100010010101111000000111111101000101001"
"1111111101010100011001011011100000110011001100001101100100101100000011110010100011110111111101000101001"
},
/* 6*/ { BARCODE_PDF417, UNICODE_MODE, 2, 3, "12345678901234", 0, 5, 120, 1, "Numeric Compaction",
/* 6*/ { BARCODE_PDF417, -1, UNICODE_MODE, 2, 3, "12345678901234", 0, 5, 120, 1, "Numeric Compaction",
"111111110101010001111010101111000011101010001110000100111101111010001001011100001110011111010101111100111111101000101001"
"111111110101010001111110101000111011010000001110010111111011010011001111010100000010011111101010111000111111101000101001"
"111111110101010001010100111100000010111000110011100101110011000011101110001111110101011101010001111110111111101000101001"
"111111110101010001010111100111100010001100001100010100001100011101101110101100111100011010111100111110111111101000101001"
"111111110101010001110101110000110011000000101110010110001001110000101011001000111111011101011100110000111111101000101001"
},
/* 7*/ { BARCODE_PDF417, UNICODE_MODE, 1, 4, "\177\177\177\177\177\177\177\177\177\177\177", 0, 4, 137, 1, "Byte Compaction",
/* 7*/ { BARCODE_PDF417, -1, UNICODE_MODE, 1, 4, "\177\177\177\177\177\177\177\177\177\177\177", 0, 4, 137, 1, "Byte Compaction",
"11111111010101000111101010111100001101011011100000010000010000100010111001001100111101000010100001000011101010011100000111111101000101001"
"11111111010101000111110101001100001110010000111011010100111110000110111101001100001101111101000100011011111101010111000111111101000101001"
"11111111010101000110101001111100001010000001011110010100000010111100101000000101111001010000001011110011010100111110000111111101000101001"
"11111111010101000101011110011110001010001000001000011011000010100000111000110001001101100111000110010010101111101111100111111101000101001"
},
/* 8*/ { BARCODE_PDF417, UNICODE_MODE, 1, 4, "\177\177\177\177\177\177\177\177\177\177\177\177", 0, 4, 137, 1, "Byte Compaction, mod 6 == 0 (924 emitted)",
/* 8*/ { BARCODE_PDF417, -1, UNICODE_MODE, 1, 4, "\177\177\177\177\177\177\177\177\177\177\177\177", 0, 4, 137, 1, "Byte Compaction, mod 6 == 0 (924 emitted)",
"11111111010101000111101010111100001101011011100000011000111000110100111001001100111101000010100001000011101010011100000111111101000101001"
"11111111010101000111110101001100001110010000111011010100111110000110111101001100001101111001010010000011111101010111000111111101000101001"
"11111111010101000110101001111100001001110000100110010011000100001110101000011001111101101000101111100011010100111110000111111101000101001"
"11111111010101000101011110011110001101000100011000010011000111001100110001100001000101110100010111000010101111101111100111111101000101001"
},
/* 9*/ { BARCODE_PDF417, UNICODE_MODE, -1, 5, "ABCDEF1234567890123\177\177\177\177VWXYZ", 0, 6, 154, 1, "Text, Numeric, Byte, Text",
/* 9*/ { BARCODE_PDF417, -1, UNICODE_MODE, -1, 5, "ABCDEF1234567890123\177\177\177\177VWXYZ", 0, 6, 154, 1, "Text, Numeric, Byte, Text",
"1111111101010100011110101011110000110101110111100001111010101111000010100111001110000110100000101100001001111011110100011110101001111000111111101000101001"
"1111111101010100011110101000010000111101011001100001010011110000100011111100011101010110000010111000101111001011011000011111101010111000111111101000101001"
"1111111101010100011101010011111100110011111101100101010000001011110010100000010111100101000000101111001010000001011110010101000011110000111111101000101001"
@ -385,7 +386,7 @@ static void test_encode(int index, int generate, int debug) {
"1111111101010100011010111000001000101111110101100001011111101011000011001011111001110111100100100100001011111101011000011101011100110000111111101000101001"
"1111111101010100011111010111100110110111110110011001101001011111000010101110011111100100100001000111101011000000101110011110101111101100111111101000101001"
},
/* 10*/ { BARCODE_PDF417COMP, UNICODE_MODE, 1, 2, "PDF417 APK", 0, 6, 69, 0, "ISO 15438:2015 Figure G.1, same, BWIPP uses different encodation, same codeword count",
/* 10*/ { BARCODE_PDF417COMP, -1, UNICODE_MODE, 1, 2, "PDF417 APK", 0, 6, 69, 0, "ISO 15438:2015 Figure G.1, same, BWIPP uses different encodation, same codeword count",
"111111110101010001111010101111000011010100001100000111011101100110001"
"111111110101010001111010100010000011010000111000100111101000101000001"
"111111110101010001110101011111100010110011011110000100111110011000101"
@ -393,7 +394,7 @@ static void test_encode(int index, int generate, int debug) {
"111111110101010001111010111000111011011000001111010110010011101000001"
"111111110101010001111010111101000011110100111101000110010010011111001"
},
/* 11*/ { BARCODE_PDF417COMP, UNICODE_MODE, 4, 4, "ABCDEFG", 0, 10, 103, 1, "",
/* 11*/ { BARCODE_PDF417COMP, -1, UNICODE_MODE, 4, 4, "ABCDEFG", 0, 10, 103, 1, "",
"1111111101010100011101010011100000110101000011000001111010101111000010100111001110000110100000101100001"
"1111111101010100011110101000000100110100000011100101011111101011000010111111010110000101111110101100001"
"1111111101010100011010100111110000101111001100011001000001111010100010011111001100100111001011111001001"
@ -405,7 +406,7 @@ static void test_encode(int index, int generate, int debug) {
"1111111101010100010100110011111000100110000110111101100111000010111010010001011110000110011111010001001"
"1111111101010100010100011000001100110001101010000001100011000110011011001001101110000111110111110101001"
},
/* 12*/ { BARCODE_HIBC_PDF, UNICODE_MODE, -1, 3, "H123ABC01234567890D", 0, 8, 120, 0, "BWIPP uses different encodation, same codeword count but zint half-pad shorter",
/* 12*/ { BARCODE_HIBC_PDF, -1, UNICODE_MODE, -1, 3, "H123ABC01234567890D", 0, 8, 120, 0, "BWIPP uses different encodation, same codeword count but zint half-pad shorter",
"111111110101010001111101010111110011101011001111000100000100010010001110001110100010011111010101111100111111101000101001"
"111111110101010001111110101000111011110000010001010110101111110111101111100011101101011110101001000000111111101000101001"
"111111110101010001010100111100000011111010111101100100001111000101001100101000011111011101010001111110111111101000101001"
@ -415,7 +416,7 @@ static void test_encode(int index, int generate, int debug) {
"111111110101010001110100111011111010100110001100000110100011100111101111010010111100011101001110111110111111101000101001"
"111111110101010001111101001011000011100001001100100111010000011001001111011000110100010101111110111000111111101000101001"
},
/* 13*/ { BARCODE_HIBC_PDF, UNICODE_MODE, 1, 3, "A123BJC5D6E71", 0, 6, 120, 1, "BWIPP example",
/* 13*/ { BARCODE_HIBC_PDF, -1, UNICODE_MODE, 1, 3, "A123BJC5D6E71", 0, 6, 120, 1, "BWIPP example",
"111111110101010001111010101111000011110101101111100100000100010010001000011011100110011111010101111100111111101000101001"
"111111110101010001111010100010000011110000010001010110101111110111101111000001000101011111101010111000111111101000101001"
"111111110101010001010100111100000010110001100011110101111110111101101000111100011011010101000111100000111111101000101001"
@ -423,7 +424,7 @@ static void test_encode(int index, int generate, int debug) {
"111111110101010001111010111000111011010111110011100110100000011100101111110101000111011101011100110000111111101000101001"
"111111110101010001111101011110110010011100110011100100011110110011001011001011100000011110101111000100111111101000101001"
},
/* 14*/ { BARCODE_MICROPDF417, UNICODE_MODE, -1, 1, "ABCDEFGHIJKLMNOPQRSTUV", 0, 20, 38, 1, "ISO 24728:2006 Figure 1 1st 1x20, same",
/* 14*/ { BARCODE_MICROPDF417, -1, UNICODE_MODE, -1, 1, "ABCDEFGHIJKLMNOPQRSTUV", 0, 20, 38, 1, "ISO 24728:2006 Figure 1 1st 1x20, same",
"11110101001000011000110010011110101001"
"11100101001111110101011100011100101001"
"11101101001010011001111100011101101001"
@ -445,7 +446,7 @@ static void test_encode(int index, int generate, int debug) {
"11011101001111011111011010011011101001"
"11011001001100010001110100011011001001"
},
/* 15*/ { BARCODE_MICROPDF417, UNICODE_MODE, -1, 2, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD", 0, 20, 55, 1, "ISO 24728:2006 Figure 1 2nd 2x20, same",
/* 15*/ { BARCODE_MICROPDF417, -1, UNICODE_MODE, -1, 2, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD", 0, 20, 55, 1, "ISO 24728:2006 Figure 1 2nd 2x20, same",
"1111010100100001100011001001111010101111000011110101001"
"1110010100110101111110111101111101000100110011100101001"
"1110110100101101100111100001011001110011111011101101001"
@ -467,7 +468,7 @@ static void test_encode(int index, int generate, int debug) {
"1101110100111010110011110001000001001101100011011101001"
"1101100100111100110110100001001001111001000011011001001"
},
/* 16*/ { BARCODE_MICROPDF417, UNICODE_MODE, -1, 3, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMN", 0, 20, 82, 1, "ISO 24728:2006 Figure 1 3rd 3x20",
/* 16*/ { BARCODE_MICROPDF417, -1, UNICODE_MODE, -1, 3, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMN", 0, 20, 82, 1, "ISO 24728:2006 Figure 1 3rd 3x20",
"1100100010100001100011001001011110010111101010111100001010011100111000011100101101"
"1110100010111110100010011001011110110101000011111001101001011110010000011000101101"
"1110110010111100010111101001001110110110111011001111001001100001000111011000101001"
@ -489,7 +490,7 @@ static void test_encode(int index, int generate, int debug) {
"1111010100101111011110100001011001000111110011010111101011110111110110011010000101"
"1110010100110010001111011001011001100111000010111011001110001011100110011011000101"
},
/* 17*/ { BARCODE_MICROPDF417, UNICODE_MODE, -1, 4, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB", 0, 20, 99, 1, "ISO 24728:2006 Figure 1 4th 4x20, same",
/* 17*/ { BARCODE_MICROPDF417, -1, UNICODE_MODE, -1, 4, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB", 0, 20, 99, 1, "ISO 24728:2006 Figure 1 4th 4x20, same",
"110010001010000110001100100111101010111100001011110010101001110011100001101000001011000011100101101"
"111010001010100001111100110100101111001000001011110110111011011110011001101100111100100011000101101"
"111011001010011000010001110110011101000011101001110110110111100101100001000001010111100011000101001"
@ -511,7 +512,7 @@ static void test_encode(int index, int generate, int debug) {
"111101010011100011101010000110001011101111001011001000111110111101011001100101110111100011010000101"
"111001010010001000001111010111100010100001001011001100100111101101111101001110100111110011011000101"
},
/* 18*/ { BARCODE_MICROPDF417, UNICODE_MODE, -1, 1, "123456789012345", 0, 14, 38, 1, "Number Compaction",
/* 18*/ { BARCODE_MICROPDF417, -1, UNICODE_MODE, -1, 1, "123456789012345", 0, 14, 38, 1, "Number Compaction",
"11101110101011111101001100011101110101"
"11100110101110101011111100011100110101"
"11110110101000001011001100011110110101"
@ -527,7 +528,7 @@ static void test_encode(int index, int generate, int debug) {
"11100101001101011110000110011100101001"
"11101101001101000111111001011101101001"
},
/* 19*/ { BARCODE_MICROPDF417, UNICODE_MODE, -1, 2, "\177\177\177", 0, 8, 55, 1, "Byte Compaction",
/* 19*/ { BARCODE_MICROPDF417, -1, UNICODE_MODE, -1, 2, "\177\177\177", 0, 8, 55, 1, "Byte Compaction",
"1100100010100000100001000101010000010010000011001000101"
"1110100010111110100010001101111101000100011011101000101"
"1110110010110001111100100101100011111001001011101100101"
@ -537,7 +538,7 @@ static void test_encode(int index, int generate, int debug) {
"1100111010111001111001100101000001001101100011001110101"
"1110111010111000101111011101110001000011010011101110101"
},
/* 20*/ { BARCODE_MICROPDF417, UNICODE_MODE, -1, 2, "\177\177\177\177\177\177", 0, 8, 55, 1, "Byte Compaction, mod 6 == 0 (924 emitted)",
/* 20*/ { BARCODE_MICROPDF417, -1, UNICODE_MODE, -1, 2, "\177\177\177\177\177\177", 0, 8, 55, 1, "Byte Compaction, mod 6 == 0 (924 emitted)",
"1100100010110001110001101001110010011001111011001000101"
"1110100010100010001111010001110010000111011011101000101"
"1110110010101000011001111101101000101111100011101100101"
@ -547,7 +548,7 @@ static void test_encode(int index, int generate, int debug) {
"1100111010100100010000100001110111101100001011001110101"
"1110111010111110011010100001101100001111010011101110101"
},
/* 21*/ { BARCODE_MICROPDF417, UNICODE_MODE, -1, 3, "ABCDEFG\177\177\177", 0, 8, 82, 1, "Text & Byte Compaction",
/* 21*/ { BARCODE_MICROPDF417, -1, UNICODE_MODE, -1, 3, "ABCDEFG\177\177\177", 0, 8, 82, 1, "Text & Byte Compaction",
"1100111010100001100011001001000010110111101010111100001010011100111000011001110101"
"1110111010111110100010011001000010010110100000011100101101111110101110011101110101"
"1110011010101000000101111001000011010101000000101111001010000001011110011100110101"
@ -557,7 +558,7 @@ static void test_encode(int index, int generate, int debug) {
"1100001010111110111010111001001100010110011100011000101101100001100110011000010101"
"1100011010110100011100001001001110010110110000111101001100011011110010011000110101"
},
/* 22*/ { BARCODE_MICROPDF417, UNICODE_MODE, -1, 4, "\177\177\177abcdefgh1234567890123", 0, 8, 99, 1, "Byte & Text & Numeric Compaction",
/* 22*/ { BARCODE_MICROPDF417, -1, UNICODE_MODE, -1, 4, "\177\177\177abcdefgh1234567890123", 0, 8, 99, 1, "Byte & Text & Numeric Compaction",
"110011101010000010000100010101000001001000001000010110101000001001000001010000010010000011001110101"
"111011101010111111010110000110000010111001001000010010111101011100111001110100111001100011101110101"
"111001101011111001011110110101100110011110001000011010100001111000101001111110101100010011100110101"
@ -567,7 +568,7 @@ static void test_encode(int index, int generate, int debug) {
"110000101011000011010000100100000101101100001001100010101110111110111001111001110010110011000010101"
"110001101011101110111100010100100011110100001001110010100000101111000101111001010010000011000110101"
},
/* 23*/ { BARCODE_HIBC_MICPDF, UNICODE_MODE, -1, 4, "H123ABC01234567890D", 0, 8, 99, 0, "BWIPP uses different encodation, same codeword count but zint full-pad shorter",
/* 23*/ { BARCODE_HIBC_MICPDF, -1, UNICODE_MODE, -1, 4, "H123ABC01234567890D", 0, 8, 99, 0, "BWIPP uses different encodation, same codeword count but zint full-pad shorter",
"110011101010000110001100100100000100010010001000010110111000111010001001000001001100011011001110101"
"111011101011010111111011110111110001110110101000010010111101011100111001011111101001100011101110101"
"111001101011001010000111110100011110101000001000011010100111110001101001011011000111100011100110101"
@ -577,7 +578,7 @@ static void test_encode(int index, int generate, int debug) {
"110000101010110110001000000111000101100111101001100010110111101110000101100010101100000011000010101"
"110001101011110110000011010111100100001101101001110010101101011111100001111001000110011011000110101"
},
/* 24*/ { BARCODE_HIBC_MICPDF, UNICODE_MODE, -1, 1, "/EAH783", 0, 17, 38, 1, "HIBC Provider Applications Standard (PAS) example",
/* 24*/ { BARCODE_HIBC_MICPDF, -1, UNICODE_MODE, -1, 1, "/EAH783", 0, 17, 38, 1, "HIBC Provider Applications Standard (PAS) example",
"11001101001100011111001001011001101001"
"11011101001000001000100100011011101001"
"11011001001000100011110100011011001001"
@ -596,6 +597,31 @@ static void test_encode(int index, int generate, int debug) {
"11010000101101100100001111011010000101"
"11011000101110111000100010011011000101"
},
/* 25*/ { BARCODE_PDF417, 9, DATA_MODE, -1, -1, "\342", 0, 7, 103, 1, "β",
"1111111101010100011111010101111100110101000110000001100011100011001011110101011110000111111101000101001"
"1111111101010100011111010100011000111110101000011001011111100100011011110101001000000111111101000101001"
"1111111101010100011101010111111000110110010011110001100011111001001011010100011111000111111101000101001"
"1111111101010100011010111100111110100110011100110001010001100001100010101111001111000111111101000101001"
"1111111101010100011010111000010000110110001111000101111110010010111011110101110011100111111101000101001"
"1111111101010100011110101111010000100011110001000101000110010111000011110101111000010111111101000101001"
"1111111101010100011101001110111110101110001110001001010001101100000011010011101111000111111101000101001"
},
/* 26*/ { BARCODE_MICROPDF417, 9, DATA_MODE, -1, 1, "\342\343", 0, 14, 38, 1, "βγ",
"11101110101001111110010110011101110101"
"11100110101101010000111110011100110101"
"11110110101000001000010001011110110101"
"11110010101111001011001100011110010101"
"11100010101110110010011111011100010101"
"11000010101000011000110010011000010101"
"11000110101011111101011000011000110101"
"11000100101001111000101000011000100101"
"11100100101000100000101000011100100101"
"11110100101101110010111111011110100101"
"11110101101101100101111000011110101101"
"11110101001101011100111100011110101001"
"11100101001011100101111100011100101001"
"11101101001101001001111100011101101001"
},
};
int data_size = sizeof(data) / sizeof(struct item);
@ -610,24 +636,14 @@ static void test_encode(int index, int generate, int debug) {
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->symbology = data[i].symbology;
symbol->input_mode = data[i].input_mode;
if (data[i].option_1 != -1) {
symbol->option_1 = data[i].option_1;
}
if (data[i].option_2 != -1) {
symbol->option_2 = data[i].option_2;
}
symbol->debug |= debug;
int length = strlen(data[i].data);
int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, data[i].eci, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (generate) {
printf(" /*%3d*/ { %s, %s, %d, %d, \"%s\", %s, %d, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2,
printf(" /*%3d*/ { %s, %d, %s, %d, %d, \"%s\", %s, %d, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), data[i].eci, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2,
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret),
symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
@ -641,7 +657,7 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, data[i].option_1, data[i].option_2, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, debug)) {
if (!data[i].bwipp_cmp) {
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
} else {

View File

@ -406,7 +406,7 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);

View File

@ -219,7 +219,7 @@ static void test_buffer(int index, int generate, int debug) {
/* 95*/ { BARCODE_HIBC_MICPDF, "1234567890", "", 28, 14, 38, 76, 56 },
/* 96*/ { BARCODE_HIBC_BLOCKF, "1234567890", "", 30, 3, 101, 242, 64 },
/* 97*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38, 38 },
/* 98*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 32, 22 },
/* 98*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 33, 23 },
/* 99*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46, 46 },
/*100*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310, 20 },
/*101*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22, 22 },
@ -660,35 +660,41 @@ static void test_output_options(int index, int debug) {
/* 27*/ { BARCODE_QRCODE, 5, 6, BARCODE_BIND, 0, "A123", 0, 21, 21, 21, 62, 66, 1, 0, 0 },
/* 28*/ { BARCODE_QRCODE, 5, 6, BARCODE_BIND, 0, "A123", 0, 21, 21, 21, 62, 66, 0, 12, 0 },
/* 29*/ { BARCODE_QRCODE, 5, 6, BARCODE_BOX, 0, "A123", 0, 21, 21, 21, 86, 66, 1, 12, 0 },
/* 30*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 42, 42, 1, 0, 0 },
/* 31*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 42, 42, 0, 1, 1 },
/* 32*/ { BARCODE_QRCODE, -1, 4, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 42, 42, 1, 0, 0 },
/* 33*/ { BARCODE_QRCODE, -1, 4, BARCODE_BIND | BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 42, 58, -1, -1, -1 }, // TODO: fix (bind/box in dotty mode)
/* 34*/ { BARCODE_QRCODE, 1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 62, 58, -1, -1, -1 }, // TODO: fix (bind/box in dotty mode)
/* 35*/ { BARCODE_QRCODE, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 21, 21, 21, 42, 42, 0, 2, 2 },
/* 36*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 21, 21, 21, 42, 42, 1, 0, 0 },
/* 37*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 180, "A123", 0, 21, 21, 21, 42, 42, 0, 40, 1 },
/* 38*/ { BARCODE_MAXICODE, -1, -1, -1, 0, "A123", 0, 165, 33, 30, 300, 300, 0, 0, 0 },
/* 39*/ { BARCODE_MAXICODE, -1, -1, -1, 270, "A123", 0, 165, 33, 30, 300, 300, 0, 0, 0 },
/* 40*/ { BARCODE_MAXICODE, -1, 5, -1, 0, "A123", 0, 165, 33, 30, 300, 300, 0, 0, 0 },
/* 41*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 300, 320, 1, 0, 0 },
/* 42*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 300, 320, 0, 10, 0 },
/* 43*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BOX, 0, "A123", 0, 165, 33, 30, 320, 320, 1, 10, 0 },
/* 44*/ { BARCODE_MAXICODE, -1, -1, -1, 0, "A123", 0, 165, 33, 30, 300, 300, 1, 0, 14 },
/* 45*/ { BARCODE_MAXICODE, 6, -1, -1, 0, "A123", 0, 165, 33, 30, 324, 300, 0, 0, 14 },
/* 46*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 324, 320, 1, 10, 25 },
/* 47*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 324, 320, 0, 10, 9 },
/* 48*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BOX, 0, "A123", 0, 165, 33, 30, 344, 320, 1, 10, 9 },
/* 49*/ { BARCODE_MAXICODE, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 },
/* 50*/ { BARCODE_MAXICODE, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 165, 33, 30, 300, 300, 0, 0, 0 },
/* 51*/ { BARCODE_MAXICODE, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 165, 33, 30, 300, 300, 1, 0, 14 },
/* 52*/ { BARCODE_MAXICODE, -1, -1, OUT_BUFFER_INTERMEDIATE, 270, "A123", 0, 165, 33, 30, 300, 300, 0, 0, 0 },
/* 53*/ { BARCODE_ITF14, -1, -1, -1, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 },
/* 54*/ { BARCODE_ITF14, -1, -1, -1, 90, "123", 0, 50, 1, 135, 136, 330, 1, 0, 110 },
/* 55*/ { BARCODE_ITF14, -1, 0, -1, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 },
/* 56*/ { BARCODE_ITF14, -1, 0, BARCODE_BOX, 0, "123", 0, 50, 1, 135, 310, 116, 0, 100, 0 },
/* 57*/ { BARCODE_ITF14, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 },
/* 58*/ { BARCODE_ITF14, -1, -1, OUT_BUFFER_INTERMEDIATE, 90, "123", 0, 50, 1, 135, 136, 330, 1, 0, 110 },
/* 30*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 },
/* 31*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 2, 2 },
/* 32*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 41, 1 },
/* 33*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 40, 2 },
/* 34*/ { BARCODE_QRCODE, -1, 4, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 },
/* 35*/ { BARCODE_QRCODE, -1, 4, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 2, 2 },
/* 36*/ { BARCODE_QRCODE, -1, 4, BARCODE_BIND | BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 59, -1, -1, -1 }, // TODO: fix (bind/box in dotty mode)
/* 37*/ { BARCODE_QRCODE, 1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 63, 59, -1, -1, -1 }, // TODO: fix (bind/box in dotty mode)
/* 38*/ { BARCODE_QRCODE, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 21, 21, 21, 42, 42, 1, 1, 1 },
/* 39*/ { BARCODE_QRCODE, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 21, 21, 21, 42, 42, 0, 2, 2 },
/* 40*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 },
/* 41*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 2, 2 },
/* 42*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 180, "A123", 0, 21, 21, 21, 43, 43, 1, 41, 1 },
/* 43*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 180, "A123", 0, 21, 21, 21, 43, 43, 0, 40, 2 },
/* 44*/ { BARCODE_MAXICODE, -1, -1, -1, 0, "A123", 0, 165, 33, 30, 300, 300, 0, 0, 0 },
/* 45*/ { BARCODE_MAXICODE, -1, -1, -1, 270, "A123", 0, 165, 33, 30, 300, 300, 0, 0, 0 },
/* 46*/ { BARCODE_MAXICODE, -1, 5, -1, 0, "A123", 0, 165, 33, 30, 300, 300, 0, 0, 0 },
/* 47*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 300, 320, 1, 0, 0 },
/* 48*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 300, 320, 0, 10, 0 },
/* 49*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BOX, 0, "A123", 0, 165, 33, 30, 320, 320, 1, 10, 0 },
/* 50*/ { BARCODE_MAXICODE, -1, -1, -1, 0, "A123", 0, 165, 33, 30, 300, 300, 1, 0, 14 },
/* 51*/ { BARCODE_MAXICODE, 6, -1, -1, 0, "A123", 0, 165, 33, 30, 324, 300, 0, 0, 14 },
/* 52*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 324, 320, 1, 10, 25 },
/* 53*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 324, 320, 0, 10, 9 },
/* 54*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BOX, 0, "A123", 0, 165, 33, 30, 344, 320, 1, 10, 9 },
/* 55*/ { BARCODE_MAXICODE, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 },
/* 56*/ { BARCODE_MAXICODE, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 165, 33, 30, 300, 300, 0, 0, 0 },
/* 57*/ { BARCODE_MAXICODE, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 165, 33, 30, 300, 300, 1, 0, 14 },
/* 58*/ { BARCODE_MAXICODE, -1, -1, OUT_BUFFER_INTERMEDIATE, 270, "A123", 0, 165, 33, 30, 300, 300, 0, 0, 0 },
/* 59*/ { BARCODE_ITF14, -1, -1, -1, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 },
/* 60*/ { BARCODE_ITF14, -1, -1, -1, 90, "123", 0, 50, 1, 135, 136, 330, 1, 0, 110 },
/* 61*/ { BARCODE_ITF14, -1, 0, -1, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 },
/* 62*/ { BARCODE_ITF14, -1, 0, BARCODE_BOX, 0, "123", 0, 50, 1, 135, 310, 116, 0, 100, 0 },
/* 63*/ { BARCODE_ITF14, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 },
/* 64*/ { BARCODE_ITF14, -1, -1, OUT_BUFFER_INTERMEDIATE, 90, "123", 0, 50, 1, 135, 136, 330, 1, 0, 110 },
};
int data_size = ARRAY_SIZE(data);

View File

@ -164,7 +164,7 @@ static void test_binary_div_modulo_divisor(int index, int generate, int debug) {
ret = ZBarcode_Buffer_Vector(symbol, 0);
assert_zero(ret, "i:%d ZBarcode_Buffer_Vector ret %d != 0\n", i, ret);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, -1, -1, text, length, symbol->primary, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
@ -663,7 +663,7 @@ static void test_examples(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, data[i].option_2, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);

View File

@ -258,7 +258,7 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, -1, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);

View File

@ -696,7 +696,7 @@ static void test_encode(int index, int generate, int debug) {
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, data[i].option_2, -1, debug)) {
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf));
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);

View File

@ -1427,7 +1427,7 @@ int testUtilVerifyLibreOffice(char *filename, int debug) {
char cmd[512 + 128];
char svg[512];
char *slash, *dot;
char buf[32768];
char buf[16384];
char *b = buf, *be = buf + sizeof(buf) - 1;
FILE *fp;
int len;
@ -1536,7 +1536,7 @@ int testUtilVerifyVnu(char *filename, int debug) {
return system(buf);
}
static const char *testUtilBwippName(int symbology, int option_1, int option_2, int option_3, int *linear_row_height, int *gs1_cvt) {
static const char *testUtilBwippName(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3, int debug, int *linear_row_height, int *gs1_cvt) {
struct item {
const char *name;
int define;
@ -1619,7 +1619,7 @@ static const char *testUtilBwippName(int symbology, int option_1, int option_2,
{ "", BARCODE_AUSREDIRECT, 68, 0, 0, 0, 0, 0, },
{ "isbn", BARCODE_ISBNX, 69, 0, 1, 0, 0, 1 /*gs1_cvt*/, },
{ "royalmail", BARCODE_RM4SCC, 70, 0, 0, 0, 0, 0, },
{ "datamatrix", BARCODE_DATAMATRIX, 71, 0, 0, 0, 0, 0, },
{ "datamatrix", BARCODE_DATAMATRIX, 71, 0, 1, 1, 0, 0, },
{ "ean14", BARCODE_EAN14, 72, 0, 0, 0, 0, 1 /*gs1_cvt*/, },
{ "code39", BARCODE_VIN, 73, 0, 0, 0, 0, 0, },
{ "codablockf", BARCODE_CODABLOCKF, 74, 1, 1, 0, 10 /*linear_row_height*/, 0, },
@ -1640,7 +1640,7 @@ static const char *testUtilBwippName(int symbology, int option_1, int option_2,
{ "itf14", BARCODE_ITF14, 89, 0, 0, 0, 0, 0, },
{ "kix", BARCODE_KIX, 90, 0, 0, 0, 0, 0, },
{ "", -1, 91, 0, 0, 0, 0, 0, },
{ "azteccode", BARCODE_AZTEC, 92, 0, 0, 0, 0, 0, },
{ "azteccode", BARCODE_AZTEC, 92, 0, 1, 0, 0, 0, },
{ "daft", BARCODE_DAFT, 93, 0, 0, 0, 0, 0, },
{ "", -1, 94, 0, 0, 0, 0, 0, },
{ "", -1, 95, 0, 0, 0, 0, 0, },
@ -1650,7 +1650,7 @@ static const char *testUtilBwippName(int symbology, int option_1, int option_2,
{ "hibccode39", BARCODE_HIBC_39, 99, 0, 0, 0, 0, 0, },
{ "", -1, 100, 0, 0, 0, 0, 0, },
{ "", -1, 101, 0, 0, 0, 0, 0, },
{ "hibcdatamatrix", BARCODE_HIBC_DM, 102, 0, 0, 0, 0, 0, },
{ "hibcdatamatrix", BARCODE_HIBC_DM, 102, 0, 1, 1, 0, 0, },
{ "", -1, 103, 0, 0, 0, 0, 0, },
{ "hibcqrcode", BARCODE_HIBC_QR, 104, 0, 0, 0, 0, 0, },
{ "", -1, 105, 0, 0, 0, 0, 0, },
@ -1660,7 +1660,7 @@ static const char *testUtilBwippName(int symbology, int option_1, int option_2,
{ "", -1, 109, 0, 0, 0, 0, 0, },
{ "hibccodablockf", BARCODE_HIBC_BLOCKF, 110, 1, 1, 0, 10 /*linear_row_height*/, 0, },
{ "", -1, 111, 0, 0, 0, 0, 0, },
{ "hibcazteccode", BARCODE_HIBC_AZTEC, 112, 0, 0, 0, 0, 0, },
{ "hibcazteccode", BARCODE_HIBC_AZTEC, 112, 1, 0, 1, 0, 0, },
{ "", -1, 113, 0, 0, 0, 0, 0, },
{ "", -1, 114, 0, 0, 0, 0, 0, },
{ "dotcode", BARCODE_DOTCODE, 115, 0, 0, 0, 0, 0, },
@ -1697,27 +1697,43 @@ static const char *testUtilBwippName(int symbology, int option_1, int option_2,
};
static const int data_size = ARRAY_SIZE(data);
int symbology = symbol->symbology;
int gs1 = (symbol->input_mode & 0x07) == GS1_MODE;
if (symbology < 0 || symbology >= data_size) {
return NULL;
fprintf(stderr, "testUtilBwippName: unknown symbology (%d)\n", symbology);
abort();
}
if (data[symbology].val != symbology || (data[symbology].define != -1 && data[symbology].define != symbology)) { // Self-check
fprintf(stderr, "testUtilBwippName: data table out of sync (%d)\n", symbology);
abort();
}
if (data[symbology].name[0] == '\0') {
if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s no BWIPP mapping\n", index, testUtilBarcodeName(symbology));
}
return NULL;
}
if ((option_1 != -1 && !data[symbology].can_option_1) || (option_2 != -1 && !data[symbology].can_option_2)
|| (option_3 != -1 && !data[symbology].can_option_3)) {
if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not BWIPP compatible, options not supported, option_1 %d, option_2 %d, option_3 %d\n", index, testUtilBarcodeName(symbology), option_1, option_2, option_3);
}
return NULL;
}
if (symbology == BARCODE_CODE11) {
if (option_2 != 1 && option_2 != 2) { /* 2 check digits (Zint default) not supported */
if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not BWIPP compatible, 2 check digits not supported, option_1 %d, option_2 %d\n", index, testUtilBarcodeName(symbology), option_1, option_2);
}
return NULL;
}
} else if (symbology == BARCODE_CODABLOCKF || symbology == BARCODE_HIBC_BLOCKF) {
if (option_1 == 1) { /* Single row i.e. CODE128 not supported */
if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not BWIPP compatible, single row not supported, option_1 %d\n", index, testUtilBarcodeName(symbology), option_1);
}
return NULL;
}
}
@ -1728,19 +1744,31 @@ static const char *testUtilBwippName(int symbology, int option_1, int option_2,
if (gs1_cvt) {
*gs1_cvt = data[symbology].gs1_cvt;
}
if (gs1) {
if (symbology == BARCODE_DATAMATRIX) {
if (symbol->output_options & GS1_GS_SEPARATOR) { /* Not supported */
if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not BWIPP compatible, GS1_GS_SEPARATOR not supported\n", index, testUtilBarcodeName(symbology));
}
return NULL;
}
if (gs1_cvt) {
*gs1_cvt = 1;
}
return "gs1datamatrix";
} else if (symbology == BARCODE_AZTEC) {
if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not BWIPP compatible, GS1_MODE not supported\n", index, testUtilBarcodeName(symbology));
}
return NULL;
}
}
return data[symbology].name;
}
int testUtilCanBwipp(int symbology, int option_1, int option_2, int option_3, int debug) {
if (testUtilBwippName(symbology, option_1, option_2, option_3, NULL, NULL) != NULL) {
return 1;
}
if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("testUtilCanBwipp: not supported %s, option_1 %d, option_2 %d, option_3 %d\n", testUtilBarcodeName(symbology), option_1, option_2, option_3);
}
return 0;
int testUtilCanBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3, int debug) {
return testUtilBwippName(index, symbol, option_1, option_2, option_3, debug, NULL, NULL) != NULL;
}
static void testUtilBwippCvtGS1Data(char *bwipp_data, int upcean, int *addon_posn) {
@ -1763,21 +1791,59 @@ static void testUtilBwippCvtGS1Data(char *bwipp_data, int upcean, int *addon_pos
}
}
static char *testUtilBwippEscape(char *bwipp_data, int bwipp_data_size, const char *data, int length, int *parse) {
static char *testUtilBwippEscape(char *bwipp_data, int bwipp_data_size, const char *data, int length, int zint_escape_mode, int eci, int *parse, int *parsefnc) {
char *b = bwipp_data;
char *be = b + bwipp_data_size;
unsigned char *d = (unsigned char *) data;
unsigned char *de = (unsigned char *) data + length;
*parse = 0;
*parse = *parsefnc = 0;
if (eci) {
sprintf(bwipp_data, "^ECI%06d", eci);
*parsefnc = 1;
b = bwipp_data + 10;
}
while (b < be && d < de) {
/* Have to escape double quote otherwise Ghostscript gives "Unterminated quote in @-file" for some reason */
/* Escape single quote also to avoid having to do proper shell escaping TODO: proper shell escaping */
if (*d < 0x20 || *d >= 0x7F || *d == '^' || *d == '"' || *d == '\'') {
if (b + 4 >= be) {
fprintf(stderr, "testUtilBwippEscape: bwipp_data buffer full\n");
return NULL;
}
sprintf(b, "^%03u", *d++);
b += 4;
*parse = 1;
} else if (zint_escape_mode && *d == '\\' && d + 1 < de) {
int val;
switch (*++d) {
case '0': val = 0x00; /* Null */ break;
case 'E': val = 0x04; /* End of Transmission */ break;
case 'a': val = 0x07; /* Bell */ break;
case 'b': val = 0x08; /* Backspace */ break;
case 't': val = 0x09; /* Horizontal tab */ break;
case 'n': val = 0x0a; /* Line feed */ break;
case 'v': val = 0x0b; /* Vertical tab */ break;
case 'f': val = 0x0c; /* Form feed */ break;
case 'r': val = 0x0d; /* Carriage return */ break;
case 'e': val = 0x1b; /* Escape */ break;
case 'G': val = 0x1d; /* Group Separator */ break;
case 'R': val = 0x1e; /* Record Separator */ break;
//case 'x': val = 0; /* TODO: implement */ break;
case '\\': val = '\\'; break;
//case 'u': val = 0; /* TODO: implement */ break;
default: fprintf(stderr, "testUtilBwippEscape: unknown escape %c\n", *d); return NULL; break;
}
if (b + 4 >= be) {
fprintf(stderr, "testUtilBwippEscape: bwipp_data buffer full\n");
return NULL;
}
sprintf(b, "^%03d", val);
b += 4;
d++;
*parse = 1;
} else {
*b++ = *d++;
}
@ -1838,7 +1904,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
char *b = buffer;
char *be = buffer + buffer_size;
int r, h;
int parse;
int parse, parsefnc;
int upcean = is_extendable(symbology);
int upca = symbology == BARCODE_UPCA || symbology == BARCODE_UPCA_CHK || symbology == BARCODE_UPCA_CC;
@ -1846,7 +1912,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
bwipp_data[0] = bwipp_opts_buf[0] = '\0';
bwipp_barcode = testUtilBwippName(symbology, option_1, option_2, option_3, &linear_row_height, &gs1_cvt);
bwipp_barcode = testUtilBwippName(index, symbol, option_1, option_2, option_3, 0, &linear_row_height, &gs1_cvt);
if (!bwipp_barcode) {
fprintf(stderr, "i:%d testUtilBwipp: no mapping for %s, option_1 %d, option_2 %d, option_3 %d\n", index, testUtilBarcodeName(symbology), option_1, option_2, option_3);
return -1;
@ -1924,11 +1990,18 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
}
}
} else {
testUtilBwippEscape(bwipp_data, sizeof(bwipp_data), data, data_len, &parse);
int eci = symbol->eci >= 3 && ZBarcode_Cap(symbology, ZINT_CAP_ECI) ? symbol->eci : 0;
if (testUtilBwippEscape(bwipp_data, sizeof(bwipp_data), data, data_len, symbol->input_mode & ESCAPE_MODE, eci, &parse, &parsefnc) == NULL) {
return -1;
}
if (parse) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sparse", strlen(bwipp_opts_buf) ? " " : "");
bwipp_opts = bwipp_opts_buf;
}
if (parsefnc) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sparsefnc", strlen(bwipp_opts_buf) ? " " : "");
bwipp_opts = bwipp_opts_buf;
}
if (symbology == BARCODE_CODE93) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sincludecheck", strlen(bwipp_opts_buf) ? " " : "");
@ -2010,12 +2083,69 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
for (r = 0; r < symbol->rows; r++) bwipp_row_height[r] = 8; /* Change from 10 */
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%ssepheight=0", strlen(bwipp_opts_buf) ? " " : "");
bwipp_opts = bwipp_opts_buf;
} else if (symbology == BARCODE_AZTEC || symbology == BARCODE_HIBC_AZTEC) {
int compact = 0;
if (option_1 >= 1 && option_1 <= 4) {
int eclevel;
if (option_1 == 1) {
eclevel = 10;
} else if (option_1 == 2) {
eclevel = 23;
} else if (option_1 == 3) {
eclevel = 36;
} else {
eclevel = 50;
}
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%seclevel=%d", strlen(bwipp_opts_buf) ? " " : "", eclevel);
bwipp_opts = bwipp_opts_buf;
}
if (option_2 >= 1) {
int layers;
if (option_2 <= 4) {
compact = 1;
layers = option_2;
} else {
layers = option_2 - 4;
}
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%slayers=%d", strlen(bwipp_opts_buf) ? " " : "", layers);
bwipp_opts = bwipp_opts_buf;
}
if (symbol->output_options & READER_INIT) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sreaderinit", strlen(bwipp_opts_buf) ? " " : "");
bwipp_opts = bwipp_opts_buf;
}
if (symbology == BARCODE_HIBC_AZTEC) {
compact = 1;
}
if (compact) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sformat=compact", strlen(bwipp_opts_buf) ? " " : "");
bwipp_opts = bwipp_opts_buf;
}
}
}
if (symbology == BARCODE_DATAMATRIX || symbology == BARCODE_HIBC_DM) {
#include "../dmatrix.h"
(void)matrixrsblock; (void)matrixdatablock; (void)matrixbytes; (void)matrixFW; (void)matrixFH;
(void)isDMRE; (void)text_value; (void)text_shift; (void)c40_value; (void)c40_shift;
if (option_2 >= 1 && option_2 <= (int) sizeof(intsymbol)) {
int idx = intsymbol[option_2 - 1];
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%srows=%d columns=%d", strlen(bwipp_opts_buf) ? " " : "", matrixH[idx], matrixW[idx]);
bwipp_opts = bwipp_opts_buf;
}
if (option_3 != DM_SQUARE && symbol->width != symbol->height) {
sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sformat=rectangle", strlen(bwipp_opts_buf) ? " " : "");
bwipp_opts = bwipp_opts_buf;
}
if (option_3 != -1) {
bwipp_opts = bwipp_opts_buf;
}
}
}
if ((option_1 != -1 || option_2 != -1 || option_3 != -1) && !bwipp_opts) {
fprintf(stderr, "i:%d testUtilBwipp: no mapping option_1 %d, option_2 %d, option_3 %d for symbology %s\n", index, option_1, option_2, option_3, testUtilBarcodeName(symbology));
fprintf(stderr, "i:%d testUtilBwipp: no BWIPP options set option_1 %d, option_2 %d, option_3 %d for symbology %s\n", index, option_1, option_2, option_3, testUtilBarcodeName(symbology));
return -1;
}

View File

@ -112,7 +112,7 @@ int testUtilHaveGhostscript();
int testUtilVerifyGhostscript(char *filename, int debug);
int testUtilHaveVnu();
int testUtilVerifyVnu(char *filename, int debug);
int testUtilCanBwipp(int symbology, int option_1, int option_2, int option_3, int debug);
int testUtilCanBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3, int debug);
int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3, const char *data, int length, const char *primary, char *buffer, int buffer_size);
int testUtilBwippCmp(const struct zint_symbol *symbol, char *msg, const char *bwipp_buf, const char *expected);
int testUtilBwippCmpRow(const struct zint_symbol *symbol, int row, char *msg, const char *bwipp_buf, const char *expected);

View File

@ -1,5 +1,5 @@
--- ../../../../postscriptbarcode/build/monolithic/barcode.ps 2020-10-02 20:03:59.411955883 +0100
+++ ../tools/bwipp_dump.ps 2020-10-03 01:47:30.454223200 +0100
--- ../../../../postscriptbarcode/build/monolithic/barcode.ps 2020-10-26 01:13:25.080992540 +0000
+++ ../tools/bwipp_dump.ps 2020-10-26 11:19:21.268222231 +0000
@@ -29,6 +29,8 @@
% CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
% IN THE SOFTWARE.
@ -9,7 +9,7 @@
% --BEGIN TEMPLATE--
% --BEGIN RESOURCE preamble--
@@ -25404,34 +25406,80 @@
@@ -24466,34 +24468,80 @@
pop
} ifelse
@ -109,7 +109,7 @@
end
@@ -25490,7 +25538,7 @@
@@ -24552,7 +24600,7 @@
pop
} ifelse
@ -118,7 +118,7 @@
% Get the result of encoding with ean8 and gs1-cc
options (lintype) (ean8) put
@@ -25498,29 +25546,75 @@
@@ -24560,29 +24608,75 @@
options (dontdraw) true put
% Plot the linear part
@ -214,7 +214,7 @@
end
@@ -25579,34 +25673,80 @@
@@ -24641,34 +24735,80 @@
pop
} ifelse
@ -314,7 +314,7 @@
end
@@ -25680,34 +25820,80 @@
@@ -24742,34 +24882,80 @@
/opt options
>> def
@ -414,7 +414,7 @@
end
@@ -25766,7 +25952,7 @@
@@ -24828,7 +25014,7 @@
pop
} ifelse
@ -423,7 +423,7 @@
options (lintype) (databaromni) put
options (linkage) true put
@@ -25777,7 +25963,7 @@
@@ -24839,7 +25025,7 @@
linear options //databaromni exec
dup (sbs) get /linsbs exch def
dup (bhs) get 0 get 72 mul /linheight exch def
@ -432,7 +432,7 @@
% Plot the separator
/sepfinder {
@@ -25808,20 +25994,66 @@
@@ -24870,20 +25056,66 @@
sep 0 [0 0 0] putinterval
sep sep length 4 sub [0 0 0 0] putinterval
18 sepfinder 64 sepfinder
@ -511,7 +511,7 @@
end
@@ -25879,7 +26111,7 @@
@@ -24941,7 +25173,7 @@
pop
} ifelse
@ -520,7 +520,7 @@
options (lintype) (databarstacked) put
options (linkage) true put
@@ -25890,7 +26122,7 @@
@@ -24952,7 +25184,7 @@
linear options //databarstacked exec
dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def
dup (pixy) get /linheight exch def
@ -529,7 +529,7 @@
% Plot the separator
/sepfinder {
@@ -25918,20 +26150,52 @@
@@ -24980,20 +25212,52 @@
sep 0 [ 0 0 0 0 ] putinterval
sep sep length 4 sub [ 0 0 0 0 ] putinterval
18 sepfinder
@ -594,7 +594,7 @@
end
@@ -25989,7 +26253,7 @@
@@ -25051,7 +25315,7 @@
pop
} ifelse
@ -603,7 +603,7 @@
options (lintype) (databarstackedomni) put
options (linkage) true put
@@ -26000,7 +26264,7 @@
@@ -25062,7 +25326,7 @@
linear options //databarstackedomni exec
dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def
dup (pixy) get /linheight exch def
@ -612,7 +612,7 @@
% Plot the separator
/sepfinder {
@@ -26028,20 +26292,52 @@
@@ -25090,20 +25354,52 @@
sep 0 [ 0 0 0 0 ] putinterval
sep sep length 4 sub [ 0 0 0 0 ] putinterval
18 sepfinder
@ -677,7 +677,7 @@
end
@@ -26214,7 +26510,7 @@
@@ -25276,7 +25572,7 @@
pop
} ifelse
@ -686,7 +686,7 @@
options (lintype) (databarlimited) put
options (linkage) true put
@@ -26225,7 +26521,7 @@
@@ -25287,7 +25583,7 @@
linear options //databarlimited exec
dup (sbs) get /linsbs exch def
dup (bhs) get 0 get 72 mul /linheight exch def
@ -695,7 +695,7 @@
% Plot the separator
mark
@@ -26233,22 +26529,68 @@
@@ -25295,22 +25591,68 @@
counttomark 1 sub array astore /sep exch def pop pop
sep 0 [0 0 0] putinterval
sep sep length 9 sub [0 0 0 0 0 0 0 0 0] putinterval % 4 + 5 right guard spaces
@ -778,7 +778,7 @@
end
@@ -26307,7 +26649,7 @@
@@ -25369,7 +25711,7 @@
pop
} ifelse
@ -787,7 +787,7 @@
options (lintype) (databarexpanded) put
options (linkage) true put
@@ -26318,7 +26660,7 @@
@@ -25380,7 +25722,7 @@
linear options //databarexpanded exec
dup (sbs) get /linsbs exch def
dup (bhs) get 0 get 72 mul /linheight exch def
@ -796,7 +796,7 @@
% Plot the separator
/sepfinder {
@@ -26347,20 +26689,60 @@
@@ -25409,20 +25751,60 @@
18 98 bot length 13 sub {} for
69 98 bot length 13 sub {} for
] {sepfinder} forall
@ -869,7 +869,7 @@
end
@@ -26418,7 +26800,7 @@
@@ -25480,7 +25862,7 @@
pop
} ifelse
@ -878,7 +878,7 @@
options (lintype) (databarexpandedstacked) put
options (linkage) true put
@@ -26429,7 +26811,7 @@
@@ -25491,7 +25873,7 @@
linear options //databarexpandedstacked exec
dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def
dup (pixy) get /linheight exch def
@ -887,14 +887,7 @@
% Plot the separator
/sepfinder {
@@ -26449,27 +26831,55 @@
} for
} bind def
/sep [ bot {1 exch sub} forall ] def
- sep 0 [ 0 0 0 ] putinterval
+ sep 0 [ 0 0 0 0 ] putinterval
sep sep length 4 sub [ 0 0 0 0 ] putinterval
[ % Finder pattern module positions
@@ -25517,21 +25899,49 @@
19 98 bot length 13 sub {} for
70 98 bot length 13 sub {} for
] {sepfinder} forall
@ -957,7 +950,7 @@
end
@@ -26528,7 +26938,7 @@
@@ -25590,7 +26000,7 @@
pop
} ifelse
@ -966,7 +959,7 @@
options (inkspread) (0) put
options (dontdraw) true put
@@ -26555,35 +26965,87 @@
@@ -25617,35 +26027,87 @@
linear << options {} forall >> //gs1-128 exec
dup (sbs) get /linsbs exch def
dup (bhs) get 0 get 72 mul /linheight exch def
@ -1068,7 +1061,7 @@
end
@@ -27881,3 +28343,176 @@
@@ -26919,3 +27381,176 @@
% --END ENCODER hibcazteccode--
% --END TEMPLATE--

View File

@ -15,6 +15,7 @@ function run_bwipp_test() {
run_bwipp_test "test_2of5" "encode"
run_bwipp_test "test_auspost" "encode"
run_bwipp_test "test_aztec" "encode"
run_bwipp_test "test_channel" "encode"
run_bwipp_test "test_codablock" "encode"
run_bwipp_test "test_code" "encode"
@ -23,6 +24,7 @@ run_bwipp_test "test_code128" "encode"
run_bwipp_test "test_code16k" "encode"
run_bwipp_test "test_code49" "encode"
run_bwipp_test "test_composite"
run_bwipp_test "test_dmatrix" "encode"
run_bwipp_test "test_gs1" "gs1_reduce"
run_bwipp_test "test_imail" "encode"
run_bwipp_test "test_medical" "encode"

View File

@ -101,14 +101,14 @@ static char upc_check(char source[]) {
/* UPC A is usually used for 12 digit numbers, but this function takes a source of any length */
static void upca_draw(char source[], char dest[]) {
unsigned int i, half_way;
unsigned int i, half_way, length = strlen(source);
half_way = strlen(source) / 2;
half_way = length / 2;
/* start character */
strcat(dest, "111");
for (i = 0; i <= strlen(source); i++) {
for (i = 0; i < length; i++) {
if (i == half_way) {
/* middle character - separates manufacturer no. from product no. */
/* also inverts right hand characters */
@ -157,7 +157,7 @@ static int upca(struct zint_symbol *symbol, unsigned char source[], char dest[])
/* UPC E is a zero-compressed version of UPC A */
static int upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
unsigned int i, num_system;
unsigned int i, num_system, length;
char emode, equivalent[12], check_digit, parity[8], temp[9];
char hrt[9];
int error_number = 0;
@ -285,7 +285,8 @@ static int upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
/* start character */
strcat(dest, "111");
for (i = 0; i <= ustrlen(source); i++) {
length = ustrlen(source);
for (i = 0; i < length; i++) {
switch (parity[i]) {
case 'A': lookup(NEON, EANsetA, source[i], dest);
break;
@ -321,7 +322,7 @@ static int upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
/* EAN-2 and EAN-5 add-on codes */
static void add_on(unsigned char source[], char dest[], int addon_gap) {
char parity[6];
unsigned int i, code_type;
unsigned int i, code_type, length;
/* If an add-on then append with space */
if (addon_gap != 0) {
@ -363,7 +364,8 @@ static void add_on(unsigned char source[], char dest[], int addon_gap) {
strcpy(parity, EAN5Parity[parity_bit]);
}
for (i = 0; i < ustrlen(source); i++) {
length = ustrlen(source);
for (i = 0; i < length; i++) {
switch (parity[i]) {
case 'A': lookup(NEON, EANsetA, source[i], dest);
break;
@ -441,7 +443,7 @@ static int ean13(struct zint_symbol *symbol, unsigned char source[], char dest[]
/* start character */
strcat(dest, "111");
length = strlen(gtin);
for (i = 1; i <= length; i++) {
for (i = 1; i < length; i++) {
if (i == half_way) {
/* middle character - separates manufacturer no. from product no. */
/* also inverses right hand characters */

View File

@ -79,7 +79,7 @@ static struct zint_vector_hexagon *vector_plot_create_hexagon(float x, float y,
hexagon->next = NULL;
hexagon->x = x;
hexagon->y = y;
hexagon->diameter = (diameter * 5.0f) / 4.0f; // Ugly kludge for legacy support
hexagon->diameter = diameter;
hexagon->rotation = 0;
return hexagon;
@ -407,7 +407,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
float dot_overspill = 0.0f;
float dotoffset = 0.0f;
int rect_count, last_row_start;
int rect_count, last_row_start = 0;
int this_row;
struct zint_vector *vector;
@ -469,14 +469,16 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
if ((symbol->symbology != BARCODE_MAXICODE) && (symbol->output_options & BARCODE_DOTTY_MODE)) {
dot_overspill = symbol->dot_size - 1.0f; /* Allow for exceeding 1X */
if (dot_overspill < 0.0f) {
dotoffset = -dot_overspill / 2.0f;
dot_overspill = 0.0f;
} else {
dotoffset = 0.1f; /* Fudge for anti-aliasing */
dot_overspill += 0.1f; /* Fudge for anti-aliasing */
dotoffset = 0.05f;
}
}
vector->width = symbol->width + dotoffset * 2.0f + dot_overspill + (xoffset + roffset);
vector->height = symbol->height + textoffset + dotoffset * 2.0f + dot_overspill + (yoffset + boffset);
vector->width = symbol->width + dot_overspill + (xoffset + roffset);
vector->height = symbol->height + textoffset + dot_overspill + (yoffset + boffset);
if (symbol->border_width > 0 && ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND))) {
default_text_posn = symbol->height + text_height + text_gap + symbol->border_width + symbol->border_width;
@ -484,11 +486,52 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
default_text_posn = symbol->height + text_height + text_gap;
}
rect_count = 0;
last_row_start = 0;
// Plot Maxicode symbols
if (symbol->symbology == BARCODE_MAXICODE) {
struct zint_vector_circle *circle;
float hex_diameter = (float) (symbol->dot_size * 5.0 / 4.0); // Ugly kludge for legacy support
vector->width = 37.0f + (xoffset + roffset);
vector->height = 36.0f + (yoffset + boffset);
// Bullseye
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 10.85f, 0);
vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 8.97f, 1);
vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 7.10f, 0);
vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 5.22f, 1);
vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 3.31f, 0);
vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 1.43f, 1);
vector_plot_add_circle(symbol, circle, &last_circle);
/* Hexagons */
for (r = 0; r < symbol->rows; r++) {
for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, r, i)) {
//struct zint_vector_hexagon *hexagon = vector_plot_create_hexagon(((i * 0.88) + ((r & 1) ? 1.76 : 1.32)), ((r * 0.76) + 0.76), hex_diameter);
struct zint_vector_hexagon *hexagon = vector_plot_create_hexagon(((i * 1.23f) + 0.615f + ((r & 1) ? 0.615f : 0.0f)) + xoffset,
((r * 1.067f) + 0.715f) + yoffset, hex_diameter);
vector_plot_add_hexagon(symbol, hexagon, &last_hexagon);
}
}
}
// Dotty mode
} else if (symbol->output_options & BARCODE_DOTTY_MODE) {
float dotradius = symbol->dot_size / 2.0f;
for (r = 0; r < symbol->rows; r++) {
for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, r, i)) {
struct zint_vector_circle *circle = vector_plot_create_circle(i + dotradius + dotoffset + xoffset, r + dotradius + dotoffset + yoffset, symbol->dot_size, 0);
vector_plot_add_circle(symbol, circle, &last_circle);
}
}
}
// Plot rectangles - most symbols created here
if ((symbol->symbology != BARCODE_MAXICODE) && ((symbol->output_options & BARCODE_DOTTY_MODE) == 0)) {
} else {
rect_count = 0;
row_posn = yoffset;
for (r = 0; r < symbol->rows; r++) {
this_row = r;
@ -537,52 +580,6 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
}
}
// Plot Maxicode symbols
if (symbol->symbology == BARCODE_MAXICODE) {
struct zint_vector_circle *circle;
vector->width = 37.0f + (xoffset + roffset);
vector->height = 36.0f + (yoffset + boffset);
// Bullseye
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 10.85f, 0);
vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 8.97f, 1);
vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 7.10f, 0);
vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 5.22f, 1);
vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 3.31f, 0);
vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 1.43f, 1);
vector_plot_add_circle(symbol, circle, &last_circle);
/* Hexagons */
for (r = 0; r < symbol->rows; r++) {
for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, r, i)) {
//struct zint_vector_hexagon *hexagon = vector_plot_create_hexagon(((i * 0.88) + ((r & 1) ? 1.76 : 1.32)), ((r * 0.76) + 0.76), symbol->dot_size);
struct zint_vector_hexagon *hexagon = vector_plot_create_hexagon(((i * 1.23f) + 0.615f + ((r & 1) ? 0.615f : 0.0f)) + xoffset,
((r * 1.067f) + 0.715f) + yoffset, symbol->dot_size);
vector_plot_add_hexagon(symbol, hexagon, &last_hexagon);
}
}
}
}
// Dotty mode
if ((symbol->symbology != BARCODE_MAXICODE) && (symbol->output_options & BARCODE_DOTTY_MODE)) {
float dotradius = symbol->dot_size / 2.0f;
for (r = 0; r < symbol->rows; r++) {
for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, r, i)) {
struct zint_vector_circle *circle = vector_plot_create_circle(i + dotradius + dotoffset + xoffset, r + dotradius + dotoffset + yoffset, symbol->dot_size, 0);
vector_plot_add_circle(symbol, circle, &last_circle);
}
}
}
}
if (upceanflag) {
/* Guard bar extension */
if (upceanflag == 6) { /* UPC-E */

View File

@ -1,11 +1,17 @@
# (c) 2008 by BogDan Vatra < bogdan@licentia.eu >
# vim: set ts=4 sw=4 et :
project(QZint)
include_directories(BEFORE "${CMAKE_SOURCE_DIR}/backend" )
set(QZint_SRCS qzint.cpp)
QT5_WRAP_CPP(QZint_SRCS qzint.h)
if(USE_QT6)
qt6_wrap_cpp(QZint_SRCS qzint.h)
else()
qt5_wrap_cpp(QZint_SRCS qzint.h)
endif()
add_library(QZint SHARED ${QZint_SRCS})
@ -16,7 +22,11 @@ add_dependencies(QZint zint)
link_directories( "${CMAKE_BINARY_DIR}/backend" )
if(USE_QT6)
target_link_libraries(QZint zint Qt6::Widgets Qt6::Gui)
else()
target_link_libraries(QZint zint Qt5::Widgets Qt5::Gui)
endif()
install(TARGETS QZint ${INSTALL_TARGETS_DEFAULT_ARGS} )
install(FILES qzint.h DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)

View File

@ -411,7 +411,6 @@ namespace Zint {
struct zint_vector_hexagon *hex;
struct zint_vector_circle *circle;
struct zint_vector_string *string;
qreal radius;
(void)mode; /* Not currently used */
@ -454,9 +453,6 @@ namespace Zint {
xtr += (qreal) (paintRect.width() - gwidth * scale) / 2.0;
ytr += (qreal) (paintRect.height() - gheight * scale) / 2.0;
painter.setBackground(QBrush(m_bgColor));
painter.fillRect(paintRect, QBrush(m_bgColor));
if (m_rotate_angle) {
painter.translate(paintRect.width() / 2.0, paintRect.height() / 2.0); // Need to rotate around centre
painter.rotate(m_rotate_angle);
@ -466,6 +462,9 @@ namespace Zint {
painter.translate(xtr, ytr);
painter.scale(scale, scale);
QBrush bgBrush(m_bgColor);
painter.fillRect(QRectF(0, 0, gwidth, gheight), bgBrush);
//Red square for diagnostics
//painter.fillRect(QRect(0, 0, m_zintSymbol->vector->width, m_zintSymbol->vector->height), QBrush(QColor(255,0,0,255)));
@ -488,19 +487,25 @@ namespace Zint {
hex = m_zintSymbol->vector->hexagons;
if (hex) {
painter.setRenderHint(QPainter::Antialiasing);
QBrush brush(m_fgColor);
QBrush fgBrush(m_fgColor);
qreal previous_diameter = 0.0, radius = 0.0, half_radius = 0.0, half_sqrt3_radius = 0.0;
while (hex) {
radius = hex->diameter / 2.0;
if (previous_diameter != hex->diameter) {
previous_diameter = hex->diameter;
radius = 0.5 * previous_diameter;
half_radius = 0.25 * previous_diameter;
half_sqrt3_radius = 0.43301270189221932338 * previous_diameter;
}
QPainterPath pt;
pt.moveTo(hex->x, hex->y + (1.0 * radius));
pt.lineTo(hex->x + (0.86 * radius), hex->y + (0.5 * radius));
pt.lineTo(hex->x + (0.86 * radius), hex->y - (0.5 * radius));
pt.lineTo(hex->x, hex->y - (1.0 * radius));
pt.lineTo(hex->x - (0.86 * radius), hex->y - (0.5 * radius));
pt.lineTo(hex->x - (0.86 * radius), hex->y + (0.5 * radius));
pt.lineTo(hex->x, hex->y + (1.0 * radius));
painter.fillPath(pt, brush);
pt.moveTo(hex->x, hex->y + radius);
pt.lineTo(hex->x + half_sqrt3_radius, hex->y + half_radius);
pt.lineTo(hex->x + half_sqrt3_radius, hex->y - half_radius);
pt.lineTo(hex->x, hex->y - radius);
pt.lineTo(hex->x - half_sqrt3_radius, hex->y - half_radius);
pt.lineTo(hex->x - half_sqrt3_radius, hex->y + half_radius);
pt.lineTo(hex->x, hex->y + radius);
painter.fillPath(pt, fgBrush);
hex = hex->next;
}
@ -511,19 +516,25 @@ namespace Zint {
if (circle) {
painter.setRenderHint(QPainter::Antialiasing);
QPen p;
QBrush fgBrush(m_fgColor);
qreal previous_diameter = 0.0, radius = 0.0;
while (circle) {
if (previous_diameter != circle->diameter) {
previous_diameter = circle->diameter;
radius = 0.5 * previous_diameter;
}
if (circle->colour) { // Set means use background colour
p.setColor(m_bgColor);
p.setWidth(0);
painter.setPen(p);
painter.setBrush(QBrush(m_bgColor));
painter.setBrush(bgBrush);
} else {
p.setColor(m_fgColor);
p.setWidth(0);
painter.setPen(p);
painter.setBrush(QBrush(m_fgColor));
painter.setBrush(fgBrush);
}
painter.drawEllipse(QPointF(circle->x, circle->y), (double) circle->diameter / 2.0, (double) circle->diameter / 2.0);
painter.drawEllipse(QPointF(circle->x, circle->y), radius, radius);
circle = circle->next;
}
}

View File

@ -22,11 +22,11 @@ able to encode data in over 50 barcode symbologies (types of barcode), for each
of which it is possible to translate that data from either Unicode (UTF-8) or a
raw 8-bit data stream. The image can be rendered as either a Portable Network
Graphic (PNG) image, Windows Bitmap (BMP), Graphics Interchange Format (GIF),
ZSoft Paintbrush image (PCX), as Encapsulated Post Script (EPS) or as a
Scalable Vector Graphic (SVG). Many options are available for setting the
characteristics of the output image including the size and colour of the image,
the amount of error correction used in the symbol and, in the case of raster
images, the orientation of the image.
ZSoft Paintbrush image (PCX), Tagged Image File Format (TIF), Enhanced Metafile
Format (EMF), as Encapsulated Post Script (EPS), or as a Scalable Vector Graphic
(SVG). Many options are available for setting the characteristics of the output
image including the size and colour of the image, the amount of error correction
used in the symbol and the orientation of the image.
1.1 Terms of Reference
----------------------
@ -388,8 +388,8 @@ zint --box --border=10 -d "This"
gives a box with a width 10 times the X-dimension of the symbol.
These options are ignored for Code 16k and Codablock-F. Special considerations
apply to ITF-14 - see the specific section for that symbology.
These options are ignored for Code 16k, Code 49 and Codablock-F. Special
considerations apply to ITF-14 - see the specific section for that symbology.
4.7 Using colour
----------------
@ -433,8 +433,7 @@ PNG, GIF, SVG, EMF and EPS files.
4.8 Rotating the Symbol
-----------------------
The symbol can be rotated through four orientations using the --rotate= option
followed by the angle of rotation as shown below. This option does not (yet)
apply to EMF file output.
followed by the angle of rotation as shown below.
--rotate=0 (default)
--rotate=90
@ -627,6 +626,7 @@ supported output file formats are shown in the following table:
Abbreviation | File format
--------------------------------------------------------------
BMP | Windows Bitmap
EMF | Enhanced Metafile Format
EPS | Encapsulated PostScript
GIF | Graphics Interchange Format
PCX | ZSoft Paintbrush image
@ -790,8 +790,8 @@ string. This allows the encoding of NUL (ASCII 0) characters in those
symbologies which allow this. A value of 0 will disable this function and Zint
will encode data up to the first NUL character in the input string.
The "rotate_angle" value can be used to rotate the image when outputting as a
raster image. Valid values are 0, 90, 180 and 270.
The "rotate_angle" value can be used to rotate the image when outputting. Valid
values are 0, 90, 180 and 270.
The ZBarcode_Encode_File() and ZBarcode_Encode_File_and_Print() functions can
be used to encode data read directly from a text file where the filename is
@ -816,10 +816,10 @@ saving the image to file it is placed in an unsigned character array. The
"bitmap" pointer is set to the first memory location in the array and the values
"barcode_width" and "barcode_height" indicate the size of the resulting image
in pixels. Rotation and colour options can be used at the same time as using
the buffer functions in the same way as when saving to a raster image. The
pixel data can be extracted from the array by the method shown in the example
below where render_pixel() is assumed to be a function for drawing a pixel on
the screen implemented by the external application:
the buffer functions in the same way as when saving to a file. The pixel data
can be extracted from the array by the method shown in the example below where
render_pixel() is assumed to be a function for drawing a pixel on the screen
implemented by the external application:
int row, col, i = 0;
int red, blue, green;
@ -2377,7 +2377,7 @@ Input | Symbol Size
24 | 101 x 101
25 | 105 x 105
26 | 109 x 109
28 | 113 x 113
27 | 113 x 113
28 | 117 x 117
29 | 121 x 121
30 | 125 x 125

View File

@ -1,26 +1,36 @@
# (c) 2008 by BogDan Vatra < bogdan@licentia.eu >
# vim: set ts=4 sw=4 et :
project(zint-qt)
include_directories(BEFORE "${CMAKE_SOURCE_DIR}/backend" "${CMAKE_SOURCE_DIR}/backend_qt")
set(zint-qt_SRCS barcodeitem.cpp main.cpp mainwindow.cpp datawindow.cpp sequencewindow.cpp exportwindow.cpp)
QT5_WRAP_CPP(zint-qt_SRCS mainwindow.h datawindow.h sequencewindow.h exportwindow.h)
QT5_WRAP_UI(zint-qt_SRCS mainWindow.ui extData.ui extSequence.ui extExport.ui)
if(USE_QT6)
qt6_wrap_cpp(zint-qt_SRCS mainwindow.h datawindow.h sequencewindow.h exportwindow.h)
qt6_wrap_ui(zint-qt_SRCS mainWindow.ui extData.ui extSequence.ui extExport.ui)
qt6_add_resources(zint-qt_SRCS resources.qrc)
else()
qt5_wrap_cpp(zint-qt_SRCS mainwindow.h datawindow.h sequencewindow.h exportwindow.h)
qt5_wrap_ui(zint-qt_SRCS mainWindow.ui extData.ui extSequence.ui extExport.ui)
qt5_add_resources(zint-qt_SRCS resources.qrc)
endif()
# grpAztec.ui grpC49.ui grpDBExtend.ui grpLOGMARS.ui grpPDF417.ui grpUPCEAN.ui
# grpC11.ui grpChannel.ui grpDM.ui grpMaxicode.ui grpQR.ui grpVIN.ui
# grpC128.ui grpCodabar.ui grpDotCode.ui grpMicroPDF.ui grpRMQR.ui
# grpC16k.ui grpCodablockF.ui grpGrid.ui grpMQR.ui grpUltra.ui
# grpC39.ui grpCodeOne.ui grpHX.ui grpMSICheck.ui grpUPCA.ui
QT5_ADD_RESOURCES(zint-qt_SRCS resources.qrc)
add_executable(zint-qt ${zint-qt_SRCS})
add_dependencies(zint-qt QZint zint)
link_directories( "${CMAKE_BINARY_DIR}/backend" "${CMAKE_BINARY_DIR}/backend_qt" )
if(USE_QT6)
target_link_libraries(zint-qt zint QZint Qt6::UiTools ${QT_QTXML_LIBRARY} Qt6::Gui Qt6::Core)
else()
target_link_libraries(zint-qt zint QZint Qt5::UiTools ${QT_QTXML_LIBRARY} Qt5::Gui Qt5::Core)
endif()
install(TARGETS zint-qt DESTINATION "${BIN_INSTALL_DIR}" RUNTIME)

View File

@ -36,6 +36,8 @@ FORMS += extData.ui \
grpPDF417.ui \
grpQR.ui \
grpRMQR.ui \
grpUPCA.ui \
grpUPCEAN.ui \
grpVIN.ui \
mainWindow.ui

View File

@ -22,7 +22,7 @@
<property name="minimumSize">
<size>
<width>420</width>
<height>500</height>
<height>460</height>
</size>
</property>
<property name="windowTitle">

View File

@ -286,10 +286,10 @@ bool MainWindow::save()
#ifdef NO_PNG
suffix = settings.value("studio/default_suffix", "gif").toString();
save_dialog.setNameFilter(tr("Encapsulated PostScript (*.eps);;Graphics Interchange Format (*.gif);;Scalable Vector Graphic (*.svg);;Windows Bitmap (*.bmp);;ZSoft PC Painter Image (*.pcx);;Extended Metafile (*.emf);;Tagged Image File Format (*.tif)"));
save_dialog.setNameFilter(tr("Encapsulated PostScript (*.eps);;Graphics Interchange Format (*.gif);;Scalable Vector Graphic (*.svg);;Windows Bitmap (*.bmp);;ZSoft PC Painter Image (*.pcx);;Enhanced Metafile (*.emf);;Tagged Image File Format (*.tif)"));
#else
suffix = settings.value("studio/default_suffix", "png").toString();
save_dialog.setNameFilter(tr("Portable Network Graphic (*.png);;Encapsulated PostScript (*.eps);;Graphics Interchange Format (*.gif);;Scalable Vector Graphic (*.svg);;Windows Bitmap (*.bmp);;ZSoft PC Painter Image (*.pcx);;Extended Metafile (*.emf);;Tagged Image File Format (*.tif)"));
save_dialog.setNameFilter(tr("Portable Network Graphic (*.png);;Encapsulated PostScript (*.eps);;Graphics Interchange Format (*.gif);;Scalable Vector Graphic (*.svg);;Windows Bitmap (*.bmp);;ZSoft PC Painter Image (*.pcx);;Enhanced Metafile (*.emf);;Tagged Image File Format (*.tif)"));
#endif
if (QString::compare(suffix, "png", Qt::CaseInsensitive) == 0)
@ -305,7 +305,7 @@ bool MainWindow::save()
if (QString::compare(suffix, "pcx", Qt::CaseInsensitive) == 0)
save_dialog.selectNameFilter("ZSoft PC Painter Image (*.pcx)");
if (QString::compare(suffix, "emf", Qt::CaseInsensitive) == 0)
save_dialog.selectNameFilter("Extended Metafile (*.emf)");
save_dialog.selectNameFilter("Enhanced Metafile (*.emf)");
if (QString::compare(suffix, "tif", Qt::CaseInsensitive) == 0)
save_dialog.selectNameFilter("Tagged Image File Format (*.tif)");