From ad1b091ed1df2950f56335ed7646c20bbd442255 Mon Sep 17 00:00:00 2001 From: gitlost Date: Mon, 5 Dec 2022 10:11:36 +0000 Subject: [PATCH] QROCDE/UPNQR: add FAST_MODE (try 4 not 8 masks automatically) --- backend/qr.c | 50 ++++--- backend/tests/test_big5.c | 5 +- backend/tests/test_gb18030.c | 7 +- backend/tests/test_gb2312.c | 5 +- backend/tests/test_hanxin.c | 6 +- backend/tests/test_imail.c | 4 +- backend/tests/test_ksx1001.c | 5 +- backend/tests/test_qr.c | 245 +++++++++++++++++++++++++++++++++-- backend/tests/test_sjis.c | 5 +- backend/zint.h | 4 +- docs/manual.pmd | 12 +- docs/manual.txt | 16 ++- docs/zint.1 | 4 +- docs/zint.1.pmd | 3 +- frontend/main.c | 2 +- frontend_qt/grpQR.ui | 14 ++ frontend_qt/grpUPNQR.ui | 14 ++ frontend_qt/mainwindow.cpp | 12 ++ 18 files changed, 356 insertions(+), 57 deletions(-) diff --git a/backend/qr.c b/backend/qr.c index e4525cbd..5e5d9c81 100644 --- a/backend/qr.c +++ b/backend/qr.c @@ -1281,7 +1281,7 @@ static void qr_add_format_info(unsigned char *grid, const int size, const int ec } static int qr_apply_bitmask(unsigned char *grid, const int size, const int ecc_level, const int user_mask, - const int debug_print) { + const int fast_encode, const int debug_print) { int x, y; int r, k; int bit; @@ -1302,23 +1302,29 @@ static int qr_apply_bitmask(unsigned char *grid, const int size, const int ecc_l if (((y + x) & 1) == 0) { mask[r + x] |= 0x01; } - if ((y & 1) == 0) { - mask[r + x] |= 0x02; + if (!fast_encode) { + if ((y & 1) == 0) { + mask[r + x] |= 0x02; + } } if ((x % 3) == 0) { mask[r + x] |= 0x04; } - if (((y + x) % 3) == 0) { - mask[r + x] |= 0x08; + if (!fast_encode) { + if (((y + x) % 3) == 0) { + mask[r + x] |= 0x08; + } } if ((((y / 2) + (x / 3)) & 1) == 0) { mask[r + x] |= 0x10; } - if ((y * x) % 6 == 0) { /* Equivalent to (y * x) % 2 + (y * x) % 3 == 0 */ - mask[r + x] |= 0x20; - } - if (((((y * x) & 1) + ((y * x) % 3)) & 1) == 0) { - mask[r + x] |= 0x40; + if (!fast_encode) { + if ((y * x) % 6 == 0) { /* Equivalent to (y * x) % 2 + (y * x) % 3 == 0 */ + mask[r + x] |= 0x20; + } + if (((((y * x) & 1) + ((y * x) % 3)) & 1) == 0) { + mask[r + x] |= 0x40; + } } if (((((y + x) & 1) + ((y * x) % 3)) & 1) == 0) { mask[r + x] |= 0x80; @@ -1335,7 +1341,9 @@ static int qr_apply_bitmask(unsigned char *grid, const int size, const int ecc_l * desired pattern.*/ best_pattern = 0; for (pattern = 0; pattern < 8; pattern++) { - + if (fast_encode && pattern != 0 && pattern != 2 && pattern != 4 && pattern != 7) { + continue; + } bit = 1 << pattern; for (k = 0; k < size_squared; k++) { if (mask[k] & bit) { @@ -1355,9 +1363,13 @@ static int qr_apply_bitmask(unsigned char *grid, const int size, const int ecc_l } if (debug_print) { - printf("Mask: %d (%s)", best_pattern, user_mask ? "specified" : "automatic"); + printf("Mask: %d (%s)", best_pattern, user_mask ? "specified" : fast_encode ? "fast automatic": "automatic"); if (!user_mask) { - for (pattern = 0; pattern < 8; pattern++) printf(" %d:%d", pattern, penalty[pattern]); + if (fast_encode) { + printf(" 0:%d 2:%d 4:%d 7:%d", penalty[0], penalty[2], penalty[4], penalty[7]); + } else { + for (pattern = 0; pattern < 8; pattern++) printf(" %d:%d", pattern, penalty[pattern]); + } } printf("\n"); } @@ -1365,7 +1377,7 @@ static int qr_apply_bitmask(unsigned char *grid, const int size, const int ecc_l #ifdef ZINTLOG char str[15]; sprintf(str, "%d", best_val); - write_log("choosed pattern:"); + write_log("chose pattern:"); write_log(str); #endif @@ -1586,6 +1598,7 @@ INTERNAL int qrcode(struct zint_symbol *symbol, struct zint_seg segs[], const in int size_squared; const struct zint_structapp *p_structapp = NULL; const int gs1 = ((symbol->input_mode & 0x07) == GS1_MODE); + const int fast_encode = symbol->input_mode & FAST_MODE; const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; const int eci_length_segs = get_eci_length_segs(segs, seg_count); struct zint_seg *local_segs = (struct zint_seg *) z_alloca(sizeof(struct zint_seg) * seg_count); @@ -1835,7 +1848,7 @@ INTERNAL int qrcode(struct zint_symbol *symbol, struct zint_seg segs[], const in qr_add_version_info(grid, size, version); } - bitmask = qr_apply_bitmask(grid, size, ecc_level, user_mask, debug_print); + bitmask = qr_apply_bitmask(grid, size, ecc_level, user_mask, fast_encode, debug_print); qr_add_format_info(grid, size, ecc_level, bitmask); @@ -2767,6 +2780,7 @@ INTERNAL int upnqr(struct zint_symbol *symbol, unsigned char source[], int lengt int size_squared; struct zint_seg segs[1]; const int seg_count = 1; + const int fast_encode = symbol->input_mode & FAST_MODE; const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; unsigned char *datastream; unsigned char *fullstream; @@ -2811,8 +2825,8 @@ INTERNAL int upnqr(struct zint_symbol *symbol, unsigned char source[], int lengt segs[0].length = length; segs[0].eci = 4; - est_binlen = qr_calc_binlen_segs(15, mode, ddata, segs, seg_count, NULL /*p_structapp*/, 1 /*mode_preset*/, 0, - debug_print); + est_binlen = qr_calc_binlen_segs(15, mode, ddata, segs, seg_count, NULL /*p_structapp*/, 1 /*mode_preset*/, + 0 /*gs1*/, debug_print); ecc_level = QR_LEVEL_M; @@ -2847,7 +2861,7 @@ INTERNAL int upnqr(struct zint_symbol *symbol, unsigned char source[], int lengt qr_add_version_info(grid, size, version); - bitmask = qr_apply_bitmask(grid, size, ecc_level, user_mask, debug_print); + bitmask = qr_apply_bitmask(grid, size, ecc_level, user_mask, fast_encode, debug_print); qr_add_format_info(grid, size, ecc_level, bitmask); diff --git a/backend/tests/test_big5.c b/backend/tests/test_big5.c index 15c4c29a..c64c13bc 100644 --- a/backend/tests/test_big5.c +++ b/backend/tests/test_big5.c @@ -32,7 +32,9 @@ #include "testcommon.h" #include "test_big5_tab.h" /* For local "private" testing using previous libiconv adaptation, not included for licensing reasons */ -/* #define TEST_JUST_SAY_GNO */ +#if 0 +#define TEST_JUST_SAY_GNO +#endif #ifdef TEST_JUST_SAY_GNO #include "../just_say_gno/big5_gnu.h" #endif @@ -105,6 +107,7 @@ static void test_u_big5_int(const testCtx *const p_ctx) { if (i >= 0xD800 && i < 0xE000) { /* UTF-16 surrogates */ continue; } + if (testContinue(p_ctx, i)) continue; val = val2 = 0; ret = u_big5_int(i, &val); ret2 = u_big5_int2(i, &val2); diff --git a/backend/tests/test_gb18030.c b/backend/tests/test_gb18030.c index 9bfa9239..8ddb642b 100644 --- a/backend/tests/test_gb18030.c +++ b/backend/tests/test_gb18030.c @@ -34,7 +34,9 @@ #include "test_gbk_tab.h" #include "../eci.h" /* For local "private" testing using previous libiconv adaptation, not included for licensing reasons */ -/* #define TEST_JUST_SAY_GNO */ +#if 0 +#define TEST_JUST_SAY_GNO */ +#endif #ifdef TEST_JUST_SAY_GNO #include "../just_say_gno/gb18030_gnu.c" #include "../just_say_gno/gb2312_gnu.c" @@ -183,6 +185,7 @@ static void test_u_gb18030_int(const testCtx *const p_ctx) { if (i >= 0xD800 && i <= 0xDFFF) { /* UTF-16 surrogates */ continue; } + if (testContinue(p_ctx, i)) continue; val1_1 = val1_2 = val2_1 = val2_2 = 0; ret = u_gb18030_int_test(i, &val1_1, &val1_2); ret2 = u_gb18030_int2(i, &val2_1, &val2_2); @@ -525,7 +528,7 @@ static void test_u_gbk_int(const testCtx *const p_ctx) { testFinish(); } -#define TEST_PERF_ITER_MILLES 50 +#define TEST_PERF_ITER_MILLES 100 #define TEST_PERF_ITERATIONS (TEST_PERF_ITER_MILLES * 1000) /* Not a real test, just performance indicator */ diff --git a/backend/tests/test_gb2312.c b/backend/tests/test_gb2312.c index 976ac0f3..6bd41200 100644 --- a/backend/tests/test_gb2312.c +++ b/backend/tests/test_gb2312.c @@ -33,7 +33,9 @@ #include "test_gb2312_tab.h" #include "../eci.h" /* For local "private" testing using previous libiconv adaptation, not included for licensing reasons */ -/* #define TEST_JUST_SAY_GNO */ +#if 0 +#define TEST_JUST_SAY_GNO +#endif #ifdef TEST_JUST_SAY_GNO #include "../just_say_gno/gb2312_gnu.c" #endif @@ -102,6 +104,7 @@ static void test_u_gb2312_int(const testCtx *const p_ctx) { if (i >= 0xD800 && i <= 0xDFFF) { /* UTF-16 surrogates */ continue; } + if (testContinue(p_ctx, i)) continue; val = val2 = 0; ret = u_gb2312_int_test(i, &val); ret2 = u_gb2312_int2(i, &val2); diff --git a/backend/tests/test_hanxin.c b/backend/tests/test_hanxin.c index d183952c..f3703f92 100644 --- a/backend/tests/test_hanxin.c +++ b/backend/tests/test_hanxin.c @@ -3644,7 +3644,7 @@ static void test_perf(const testCtx *const p_ctx) { struct item data[] = { /* 0*/ { BARCODE_HANXIN, UNICODE_MODE, -1, -1, "汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。", - 0, 43, 43, "98 chars, Region One and Text" }, + ZINT_WARN_NONCOMPLIANT, 43, 43, "98 chars, Region One and Text" }, /* 1*/ { BARCODE_HANXIN, UNICODE_MODE, -1, -1, "汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。" "汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。" @@ -3656,7 +3656,7 @@ static void test_perf(const testCtx *const p_ctx) { "汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。" "汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。" "汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。", - 0, 121, 121, "980 chars, Region One and Text" }, + ZINT_WARN_NONCOMPLIANT, 121, 121, "980 chars, Region One and Text" }, /* 2*/ { BARCODE_HANXIN, UNICODE_MODE, -1, -1, "汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。" "汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。" @@ -3673,7 +3673,7 @@ static void test_perf(const testCtx *const p_ctx) { "汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。" "汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。" "汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。", - 0, 147, 147, "1470 chars, Region One and Text" }, + ZINT_WARN_NONCOMPLIANT, 147, 147, "1470 chars, Region One and Text" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_imail.c b/backend/tests/test_imail.c index c5a63874..e4ca1754 100644 --- a/backend/tests/test_imail.c +++ b/backend/tests/test_imail.c @@ -41,7 +41,9 @@ #define TEST_CSV_PERF_ITERATIONS 100 -/* #define TEST_IMAIL_CSV_MAX 300 */ +#if 0 +#define TEST_IMAIL_CSV_MAX 300 +#endif static void test_csv(const testCtx *const p_ctx) { int debug = p_ctx->debug; diff --git a/backend/tests/test_ksx1001.c b/backend/tests/test_ksx1001.c index 1010f8a1..f8a55656 100644 --- a/backend/tests/test_ksx1001.c +++ b/backend/tests/test_ksx1001.c @@ -33,7 +33,9 @@ #include "test_ksx1001_tab.h" #include "../ksx1001.h" /* For local "private" testing using previous libiconv adaptation, not included for licensing reasons */ -/* #define TEST_JUST_SAY_GNO */ +#if 0 +#define TEST_JUST_SAY_GNO +#endif #ifdef TEST_JUST_SAY_GNO #include "../just_say_gno/ksx1001_gnu.h" #endif @@ -121,6 +123,7 @@ static void test_u_ksx1001_int(const testCtx *const p_ctx) { if (i >= 0xD800 && i <= 0xDFFF) { /* UTF-16 surrogates */ continue; } + if (testContinue(p_ctx, i)) continue; val = val2 = 0; ret = u_ksx1001_int(i, &val); ret2 = u_ksx1001_int2(i, &val2); diff --git a/backend/tests/test_qr.c b/backend/tests/test_qr.c index 8006ac1b..87e1b622 100644 --- a/backend/tests/test_qr.c +++ b/backend/tests/test_qr.c @@ -3974,6 +3974,52 @@ static void test_qr_encode(const testCtx *const p_ctx) { "100000101111111000011" "111111101000010110101" }, + /*126*/ { BARCODE_QRCODE, UNICODE_MODE, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEFGHI", 9, 0, 21, 21, 1, "Automatic mask 3", + "111111100000001111111" + "100000100111101000001" + "101110100000001011101" + "101110100110001011101" + "101110101100101011101" + "100000100011001000001" + "111111101010101111111" + "000000001101100000000" + "001100111101111010000" + "100111011101100101110" + "010011111000101001010" + "110100001001011011010" + "011101110001100101111" + "000000001011110001011" + "111111101100111110111" + "100000100100101110000" + "101110100111101011111" + "101110101111110010010" + "101110101000100101100" + "100000100001111110000" + "111111100101000111010" + }, + /*127*/ { BARCODE_QRCODE, UNICODE_MODE | FAST_MODE, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEFGHI", 9, 0, 21, 21, 1, "Fast automatic mask 2", + "111111101000001111111" + "100000101010001000001" + "101110101110101011101" + "101110100110001011101" + "101110100001001011101" + "100000101101101000001" + "111111101010101111111" + "000000001000000000000" + "001110101011011100111" + "100111011101100101110" + "111110110101000100111" + "000010011111101101100" + "011101110001100101111" + "000000001110011100110" + "111111100010001000001" + "100000100100101110000" + "101110101010000110010" + "101110101001000100100" + "101110101000100101100" + "100000100100010011101" + "111111100011110001100" + }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -4398,7 +4444,9 @@ static void test_qr_encode_segs(const testCtx *const p_ctx) { #include -#define TEST_PERF_ITERATIONS 1000 +#define TEST_PERF_ITER_MILLES 5 +#define TEST_PERF_ITERATIONS (TEST_PERF_ITER_MILLES * 1000) +#define TEST_PERF_TIME(arg) (((arg) * 1000.0) / CLOCKS_PER_SEC) /* Not a real test, just performance indicator */ static void test_qr_perf(const testCtx *const p_ctx) { @@ -4417,10 +4465,23 @@ static void test_qr_perf(const testCtx *const p_ctx) { char *comment; }; struct item data[] = { - /* 0*/ { BARCODE_QRCODE, UNICODE_MODE, -1, -1, + /* 0*/ { BARCODE_QRCODE, UNICODE_MODE, -1, -1, "12345678901234", 0, 21, 21, "14 chars, Numeric mode" }, + /* 1*/ { BARCODE_QRCODE, UNICODE_MODE, -1, -1, "ABC 123 ABC 123 ABCD", 0, 21, 21, "20 chars, Alphanumeric" }, + /* 2*/ { BARCODE_QRCODE, UNICODE_MODE, -1, -1, "ABCde fG H 123456 IJKlmn, 1234567890 opQ Rst uvwxyz. 1234", 0, 29, 29, "57 chars, Alphanumeric" }, + /* 3*/ { BARCODE_QRCODE, UNICODE_MODE, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点", ZINT_WARN_NONCOMPLIANT, 37, 37, "107 chars, Mixed modes" }, - /* 1*/ { BARCODE_QRCODE, UNICODE_MODE, -1, -1, + /* 4*/ { BARCODE_QRCODE, UNICODE_MODE, -1, -1, + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点", + ZINT_WARN_NONCOMPLIANT, 53, 53, "214 chars, Mixed modes" }, + /* 5*/ { BARCODE_QRCODE, UNICODE_MODE, -1, -1, + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点", + ZINT_WARN_NONCOMPLIANT, 73, 73, "428 chars, Mixed modes" }, + /* 6*/ { BARCODE_QRCODE, UNICODE_MODE, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" @@ -4431,25 +4492,99 @@ static void test_qr_perf(const testCtx *const p_ctx) { "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点", ZINT_WARN_NONCOMPLIANT, 105, 105, "963 chars, Mixed modes" }, + /* 7*/ { BARCODE_QRCODE, UNICODE_MODE, -1, -1, + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 12345678901234567890123456 点点点点点点点点点点点点点点点点点点点点点点点点点点", + ZINT_WARN_NONCOMPLIANT, 133, 133, "1498 chars, Mixed modes" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; + struct zint_symbol *symbol; - clock_t start, total_encode = 0, total_buffer = 0, diff_encode, diff_buffer; + clock_t start; + clock_t total_create = 0, total_encode = 0, total_buffer = 0; + clock_t diff_create, diff_encode, diff_buffer; + int comment_max = 0; if (!(debug & ZINT_DEBUG_TEST_PERFORMANCE)) { /* -d 256 */ return; } + for (i = 0; i < data_size; i++) if ((int) strlen(data[i].comment) > comment_max) comment_max = (int) strlen(data[i].comment); + + printf("Iterations %d\n", TEST_PERF_ITERATIONS); + + printf("FAST_MODE\n"); for (i = 0; i < data_size; i++) { int j; if (testContinue(p_ctx, i)) continue; - diff_encode = diff_buffer = 0; + diff_create = diff_encode = diff_buffer = 0; for (j = 0; j < TEST_PERF_ITERATIONS; j++) { - struct zint_symbol *symbol = ZBarcode_Create(); + int input_mode = data[i].input_mode == -1 ? FAST_MODE : (data[i].input_mode | FAST_MODE); + start = clock(); + symbol = ZBarcode_Create(); + diff_create += clock() - start; + assert_nonnull(symbol, "Symbol not created\n"); + + length = testUtilSetSymbol(symbol, data[i].symbology, input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); + + start = clock(); + ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); + diff_encode += clock() - start; + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + + #if 0 + 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); + #endif + + start = clock(); + ret = ZBarcode_Buffer(symbol, 0 /*rotate_angle*/); + diff_buffer += clock() - start; + assert_zero(ret, "i:%d ZBarcode_Buffer ret %d != 0 (%s)\n", i, ret, symbol->errtxt); + + ZBarcode_Delete(symbol); + } + + printf("%*s: encode % 8gms, buffer % 8gms, create % 8gms\n", comment_max, data[i].comment, + TEST_PERF_TIME(diff_encode), TEST_PERF_TIME(diff_buffer), TEST_PERF_TIME(diff_create)); + + total_create += diff_create; + total_encode += diff_encode; + total_buffer += diff_buffer; + } + if (p_ctx->index != -1) { + printf("%*s: encode % 8gms, buffer % 8gms, create % 8gms\n", comment_max, "totals", + TEST_PERF_TIME(total_encode), TEST_PERF_TIME(total_buffer), TEST_PERF_TIME(total_create)); + } + + printf("OPTIMIZED\n"); + for (i = 0; i < data_size; i++) { + int j; + + if (testContinue(p_ctx, i)) continue; + + diff_create = diff_encode = diff_buffer = 0; + + for (j = 0; j < TEST_PERF_ITERATIONS; j++) { + start = clock(); + symbol = ZBarcode_Create(); + diff_create += clock() - start; assert_nonnull(symbol, "Symbol not created\n"); length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); @@ -4470,13 +4605,16 @@ static void test_qr_perf(const testCtx *const p_ctx) { ZBarcode_Delete(symbol); } - printf("%s: diff_encode %gms, diff_buffer %gms\n", data[i].comment, diff_encode * 1000.0 / CLOCKS_PER_SEC, diff_buffer * 1000.0 / CLOCKS_PER_SEC); + printf("%*s: encode % 8gms, buffer % 8gms, create % 8gms\n", comment_max, data[i].comment, + TEST_PERF_TIME(diff_encode), TEST_PERF_TIME(diff_buffer), TEST_PERF_TIME(diff_create)); + total_create += diff_create; total_encode += diff_encode; total_buffer += diff_buffer; } if (p_ctx->index != -1) { - printf("totals: encode %gms, buffer %gms\n", total_encode * 1000.0 / CLOCKS_PER_SEC, total_buffer * 1000.0 / CLOCKS_PER_SEC); + printf("%*s: encode % 8gms, buffer % 8gms, create % 8gms\n", comment_max, "totals", + TEST_PERF_TIME(total_encode), TEST_PERF_TIME(total_buffer), TEST_PERF_TIME(total_create)); } } @@ -6222,7 +6360,7 @@ static void test_upnqr_encode(const testCtx *const p_ctx) { "10111010111000101010000010001111001111011001010101101001101011001000001000101" "10000010001101100100010110101010010010001110010010010010110010010010100101001" "11111110100011011001111101001100101100000010111001100000111111111001000100010" - }, + }, /* 1*/ { UNICODE_MODE, -1, -1, -1, "UPNQR\012SI56020170014356205\012\012\012SI003528-990\012Združenje bank Slovenije\012Šubičeva 2\0121000 Ljubljana\01200000128067\012\012\012ADVA\012Plačilo avansa-ponudba 2016/12\012\012SI56051008010486080\012SI00123456-67890-12345\012Novo podjetje d.o.o.\012Lepa cesta 15\0123698 Loški Potok\012238\012 ", 0, 77, 77, "Example B", "11111110000111011101000010011000101001000000001000111011101100110000001111111" "10000010110011111100001100011111010101001001100001010101010101110010101000001" @@ -6301,7 +6439,7 @@ static void test_upnqr_encode(const testCtx *const p_ctx) { "10111010111111010100110001101100110100111010111110001010001010100101101010001" "10000010001110111011101001101101010101011101110100110101010001000101100000101" "11111110101101000011101011000010100010000010001101101110011110100111001110011" - }, + }, /* 2*/ { UNICODE_MODE, -1, -1, -1, "UPNQR\012\012\012\012\012Janez Novak\012Dunajska 1\0121000 Ljubljana\01200000008105\012\012\012RENT\012Plačilo najemnine 10/2016\01215.11.2016\012SI56051008010486080\012RF45SBO2010\012Novo podjetje d.o.o.\012Lepa cesta 15\0123698 Loški Potok\012188\012 ", 0, 77, 77, "Example H", "11111110000111000010011001010010001001000000101010111011100111100000001111111" "10000010110011101110001010110101010101001111000101010101010110110010101000001" @@ -6380,7 +6518,7 @@ static void test_upnqr_encode(const testCtx *const p_ctx) { "10111010111011000101100001101100101100111011100110001010001010100111101111001" "10000010001010100100100001101101010101001000000101010101110011011111100111001" "11111110101101000110111011000010100010001100001111101110110001100111001110111" - }, + }, /* 3*/ { UNICODE_MODE, -1, -1, 2 << 8, "UPNQR\012\012\012\012\012Janez Novak\012Dunajska 1\0121000 Ljubljana\01200000008105\012\012\012RENT\012Plačilo najemnine 10/2016\01215.11.2016\012SI56051008010486080\012RF45SBO2010\012Novo podjetje d.o.o.\012Lepa cesta 15\0123698 Loški Potok\012188\012 ", 0, 77, 77, "Example H with explicit mask 001 (auto-mask 000)", "11111110110010010111001100000111011100010101111111101110110010110100001111111" "10000010000110111011011111100000000000011010010000000000000011100110101000001" @@ -6459,7 +6597,7 @@ static void test_upnqr_encode(const testCtx *const p_ctx) { "10111010101110010000110100111001111001101110110011011111011111110010111010011" "10000010011111110001110100111000000000011101010000000000100110001010110010011" "11111110111000010011101110010111110111011001011010111011100100110010011011101" - }, + }, /* 4*/ { UNICODE_MODE, -1, -1, -1, "Ą˘Ł¤ĽŚ§¨ŠŞŤŹŽŻ°ą˛ł´ľśˇ¸šşťź˝žżŔÁÂĂÄĹĆÇČÉĘËĚÍÎĎĐŃŇÓÔŐÖ×ŘŮÚŰÜÝŢßŕáâăäĺćçčéęëěíîďđńňóôőö÷řůúűüýţ˙", 0, 77, 77, "ISO 8859-2", "11111110000111101001000110101100101001111110111011001111111000110000001111111" "10000010001011100100110111111011110100001011110000100001001110011010101000001" @@ -6538,7 +6676,86 @@ static void test_upnqr_encode(const testCtx *const p_ctx) { "10111010101011111111010111011111110100001010011011000001111000110011100101010" "10000010011100010001111111000000001011100000001000111111100001011101111000001" "11111110110101111101111001011101111100101101111101100101000101100100011101000" - }, + }, + /* 5*/ { UNICODE_MODE, -1, -1, -1, "UPNQR\012\012\012\012\012Janez Novak\012Dunajska 1\0121000 Ljubljana\01200000008105\012\012\012COST\012Plačilo obveznosti 10/2016\012\012SI56051008010486080\012SI0598765432100\012Novo podjetje d.o.o.\012Lepa cesta 15\0123698 Loški Potok\012183\012 ", 0, 77, 77, "Example A fast automatic mask 0 (not 3)", + "11111110111111111100010011100010110001111000010010000011011111010000001111111" + "10000010100011011111111001110100100100111110110100100100100111100010101000001" + "10111010001000100000110111010001001000001000001101001001001001011000101011101" + "10111010101000111111100101110000011010110100010001010110010010111000101011101" + "10111010001000001001001011111100000110101100001111110101110011110111101011101" + "10000010001111111001010010001001001000001000001000101001011001101010001000001" + "11111110101010101010101010101010101010101010101010101010101010101010101111111" + "00000000110100001001111110001101011101000100101000100100100100100100100000000" + "10110111001011100111111111111011000001101011011111101101010000000101001001011" + "11001001101111111100011011010011101000111100110110000001000110000010011010010" + "10010011010011001101011011110101100100100110100110100100111100100101100100000" + "10100000010000010100110110001000001001001001001101011011000001011001001001000" + "11000110111001011001100000101001001011110000000011000110001011000111110000010" + "01100000001000001010001010000101000110101100000100100111110000100100001100100" + "11011010001110100011010100011001011001001001001001001011001001001000001001101" + "01100101000011101111001001011100110111010010010110011000011010010010010010011" + "01011011110011001110010110000111101100100110110101001010110101100001100110100" + "00000101101101100110100111101110101010100001101001010000001101011001100001011" + "00000011000011011001011001010011010110010010010000011000110010010011010110110" + "11100101110001011000111101110100110110100100100000001101000100100100100000101" + "00011010011000100011111101110011011011101011000011000110011000001011011111011" + "11101000111110111101100000101011110010011010110111000001110110000000000010010" + "10001011110111101111111001111100111100100100101101100110000100100001100000101" + "00100000001000110101001110010000001111000001001011011000101001001001101101010" + "11111111110101101000100011111000011100111000001111100111000011010100111111010" + "11101000100100011011011010001101100110100100001000100101000000110000100011101" + "00111010110010001010010010101001001101001001001010101001101011001111101011100" + "01101000100011111100011110001010010000011010001000101010010110010010100010101" + "10001111100101011010000111111110101110010110111111101001110000100001111110010" + "00011000010101110110101111110001101001010001110000010001101110011010011110001" + "01101010101101011001000100111010010010010010010110110010010011010011011010101" + "01100101110001010010111010111100100000110101011000100100100010100110111011000" + "10111010001110111000010101110011000001101010100001101100111010001100001001111" + "01001001001010111000000101001010110110011010110011100011010100100001000100010" + "00000110111010100100111010001100100100110101110101100100100100100100111001010" + "01011001111110011000100111110001001001010100000000001000001111001011011010001" + "00111011010010000010110111001110011010111000000110010111101001010110110011100" + "01111100011111110001111011111100000110101111000101110101010000010010100110100" + "01001010110110000011110111100101001001011011001001101001010001001001010101101" + "00100000000111011011011101101110010010010110010010010010010010010000000110011" + "10001110000101001100110001011100101101100001101000000000110110001000000000100" + "00110001010111011000100111010011101011001000000000011000000100011001001101001" + "01010010001111001110110101011100010011010011010010010010010011111010010110110" + "11010101111000010110001010111000100100100100001100100100100000111100101100101" + "10100010001001000010001100110101000001101110101101001011001100111101100001001" + "01101001011100010101001101101110110000011110110011000111000001000010010000010" + "11101111111001110000001011111010100100100101101111100010110101000100111110000" + "00111000110101111110000010001100001000001101001000101001001001111001100011000" + "01111010100010111010110010101011000010110000001010110110000011000110101010010" + "11011000101011001011011010001100000110001010001000110111100000100100100010100" + "10001111111100100100000111111010011000001111001111100001001001001001111111101" + "11100001001110110011111000111010010010010010010010000010010010000011011010011" + "11000111010101101011000010000110111101000110100100110000110101110000100100100" + "10110001010110000001010000001010101011100001111101010010001101001001001001001" + "01010011111110111110111010111100010010010010010011011100010010010010010000110" + "01111101011001100100101010011110010101100100100100101100100100100101101100101" + "10010010101001000111101010111011000001101011001001001111011000001101101001001" + "01011101011000111010101001000010101101011010100110001111010110000011010010010" + "11110111111011001000011101001001111001100100100101100000100100100100000110010" + "00101101100110101001001100001011011001001001001001001001001001001000000001010" + "01001110101000011100110000011010010010110000010100011100100011010010110010000" + "01011001110011001100010011101001001010101100010000110000000000110001100100010" + "11011110101100100101101111110111011001001001001010000111001001001101101010000" + "10110000001001111010001001110000000010011010010000011000010010010011011010001" + "00011011010000111010011010100101001010011110100100101000010101100010000100100" + "01100101010110100001100110001101101011000001110111011000101101011001001000011" + "01001111100111100110111110110101101110010010011011111010110000010011010001100" + "00001001111101000000101011011110100000100100101101111101100100100111001101101" + "01111010101101000011101111111001000001100011011111111101111111001101111110011" + "00000000101101101110101110001110110100001010111000101010110111000000100011010" + "11111110110001001100010110101010100100100100111010100100100011100101101010000" + "10000010110110110101000110001011001001001001101000101001001111001001100010100" + "10111010010110001000101011111010011100101001101111110110100111010111111111110" + "10111010111111011111010010100000000110101100000111110101100010010110000000100" + "10111010111000101010000010001111001111011001010101101001101011001000001000101" + "10000010001101100100010110101010010010001110010010010010110010010010100101001" + "11111110100011011001111101001100101100000010111001100000111111111001000100010" + }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -6574,7 +6791,7 @@ static void test_upnqr_encode(const testCtx *const p_ctx) { testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); testUtilModulesPrint(symbol, " ", "\n"); - printf(" },\n"); + printf(" },\n"); } else { if (ret < ZINT_ERROR) { int width, row; diff --git a/backend/tests/test_sjis.c b/backend/tests/test_sjis.c index a66998c3..947bbe5b 100644 --- a/backend/tests/test_sjis.c +++ b/backend/tests/test_sjis.c @@ -33,7 +33,9 @@ #include "test_sjis_tab.h" #include "../eci.h" /* For local "private" testing using previous libiconv adaptation, not included for licensing reasons */ -/* #define TEST_JUST_SAY_GNO */ +#if 0 +#define TEST_JUST_SAY_GNO +#endif #ifdef TEST_JUST_SAY_GNO #include "../just_say_gno/sjis_gnu.c" #endif @@ -127,7 +129,6 @@ static void test_u_sjis_int(const testCtx *const p_ctx) { continue; } if (testContinue(p_ctx, i)) continue; - val = val2 = 0; ret = u_sjis_int_test(i, &val); ret2 = u_sjis_int2(i, &val2); diff --git a/backend/zint.h b/backend/zint.h index 3777ed34..4e4c09a7 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -295,8 +295,8 @@ extern "C" { #define GS1PARENS_MODE 0x0010 /* Process parentheses as GS1 AI delimiters (instead of square brackets) */ #define GS1NOCHECK_MODE 0x0020 /* Do not check validity of GS1 data (except that printable ASCII only) */ #define HEIGHTPERROW_MODE 0x0040 /* Interpret `height` as per-row rather than as overall height */ -#define FAST_MODE 0x0080 /* Use faster if less optimal encodation for symbologies that support it */ - /* Note: only DATAMATRIX, MICROPDF417 & PDF417 currently */ +#define FAST_MODE 0x0080 /* Use faster if less optimal encodation or other shortcuts if available */ + /* Note: affects DATAMATRIX, MICROPDF417, PDF417, QRCODE & UPNQR only */ /* Data Matrix specific options (`symbol->option_3`) */ #define DM_SQUARE 100 /* Only consider square versions on automatic symbol size selection */ diff --git a/docs/manual.pmd b/docs/manual.pmd index 7ef9370f..7f6e09f9 100644 --- a/docs/manual.pmd +++ b/docs/manual.pmd @@ -2097,9 +2097,9 @@ Value Effect `HEIGHTPERROW_MODE` Interpret the `height` variable as per-row rather than as overall height. -`FAST_MODE` Use faster if less optimal encodation for symbologies that - support it (currently `DATAMATRIX`, `MICROPDF417` and - `PDF417` only). +`FAST_MODE` Use faster if less optimal encodation or other shortcuts if + available (affects `DATAMATRIX`, `MICROPDF417`, `PDF417`, + `QRCODE` and `UPNQR` only). -------------------------------------------------------------------------------- Table: API `input_mode` Values {#tbl:api_input_mode tag="$ $"} @@ -3608,6 +3608,10 @@ by using the `--mask` switch with values 0-7, or in the API by setting option_3 = ZINT_FULL_MULTIBYTE | (N + 1) << 8 ``` +The `--fast` option (API `input_mode |= FAST_MODE`) may be used when leaving +Zint to automatically select a mask to reduce the number of masks to try to four +(0, 2, 4, 7). + QR Code supports Structured Append of up to 16 symbols and a numeric ID (parity), which can be set by using the `--structapp` option (see [4.16 Structured Append]) (API `structapp`). The parity ID ranges from 0 (default) to @@ -3738,6 +3742,8 @@ The following example creates a symbol from data saved as a Latin-2 file: zint -o upnqr.png -b 143 --scale=3 --binary -i upn.txt ``` +A mask may be manually specified or the `--fast` option used as with QRCODE. + ### 6.6.6 MaxiCode (ISO 16023) ![`zint -b MAXICODE -d "1Z00004951\GUPSN\G06X610\G159\G1234567\G1/1\G\GY\G1 MAIN diff --git a/docs/manual.txt b/docs/manual.txt index 855b87b4..5d1cf5f6 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -2101,9 +2101,9 @@ property. Valid values are shown in the table below. HEIGHTPERROW_MODE Interpret the height variable as per-row rather than as overall height. - FAST_MODE Use faster if less optimal encodation for symbologies that - support it (currently DATAMATRIX, MICROPDF417 and PDF417 - only). + FAST_MODE Use faster if less optimal encodation or other shortcuts if + available (affects DATAMATRIX, MICROPDF417, PDF417, QRCODE + and UPNQR only). ------------------------------------------------------------------------------- : Table  : API input_mode Values @@ -3501,6 +3501,10 @@ option_3 = (N + 1) << 8 where N is 0-7. To use with ZINT_FULL_MULTIBYTE set option_3 = ZINT_FULL_MULTIBYTE | (N + 1) << 8 +The --fast option (API input_mode |= FAST_MODE) may be used when leaving Zint to +automatically select a mask to reduce the number of masks to try to four (0, 2, +4, 7). + QR Code supports Structured Append of up to 16 symbols and a numeric ID (parity), which can be set by using the --structapp option (see 4.16 Structured Append) (API structapp). The parity ID ranges from 0 (default) to 255, and for @@ -3627,6 +3631,8 @@ The following example creates a symbol from data saved as a Latin-2 file: zint -o upnqr.png -b 143 --scale=3 --binary -i upn.txt +A mask may be manually specified or the --fast option used as with QRCODE. + 6.6.6 MaxiCode (ISO 16023) [zint -b MAXICODE -d "1Z00004951\GUPSN\G06X610\G159\G1234567\G1/1\G\GY\G1 MAIN ST\GNY\GNY\R\E" --esc --primary="152382802000000" --scmvv=96] @@ -4421,8 +4427,8 @@ OPTIONS --fast - Use faster if less optimal encodation (currently affects Data Matrix, - MicroPDF417 & PDF417 only). + Use faster if less optimal encodation or other shortcuts (affects Data + Matrix, MicroPDF417, PDF417, QRCODE & UPNQR only). --fg=COLOUR diff --git a/docs/zint.1 b/docs/zint.1 index fa112e46..ad5b54fe 100644 --- a/docs/zint.1 +++ b/docs/zint.1 @@ -198,8 +198,8 @@ The escape sequences are: .RE .TP \f[V]--fast\f[R] -Use faster if less optimal encodation (currently affects Data Matrix, -MicroPDF417 & PDF417 only). +Use faster if less optimal encodation or other shortcuts (affects Data +Matrix, MicroPDF417, PDF417, QRCODE & UPNQR only). .TP \f[V]--fg=COLOUR\f[R] Specify a foreground (ink) colour where \f[I]COLOUR\f[R] is in hex diff --git a/docs/zint.1.pmd b/docs/zint.1.pmd index ed3dfad9..a99a32db 100644 --- a/docs/zint.1.pmd +++ b/docs/zint.1.pmd @@ -148,7 +148,8 @@ Paintbrush (`PCX`), Portable Network Format (`PNG`), Scalable Vector Graphic (`S `--fast` -: Use faster if less optimal encodation (currently affects Data Matrix, MicroPDF417 & PDF417 only). +: Use faster if less optimal encodation or other shortcuts (affects Data Matrix, MicroPDF417, PDF417, QRCODE & UPNQR + only). `--fg=COLOUR` diff --git a/frontend/main.c b/frontend/main.c index d6a0f9e8..d398a387 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -164,7 +164,7 @@ static void usage(int no_png) { " -e, --ecinos Display ECI (Extended Channel Interpretation) table\n", stdout); fputs( " --eci=NUMBER Set the ECI code for the data (segment 0)\n" " --esc Process escape characters in input data\n" - " --fast Use faster encodation (Data Matrix)\n" + " --fast Use faster encodation or other shortcuts if available\n" " --fg=COLOUR Specify a foreground colour (in hex RGB/RGBA)\n", stdout); printf(" --filetype=TYPE Set output file type BMP/EMF/EPS/GIF/PCX%s/SVG/TIF/TXT\n", no_png_type); fputs( " --fullmultibyte Use multibyte for binary/Latin (QR/Han Xin/Grid Matrix)\n" diff --git a/frontend_qt/grpQR.ui b/frontend_qt/grpQR.ui index 565cbc66..b6d662c1 100644 --- a/frontend_qt/grpQR.ui +++ b/frontend_qt/grpQR.ui @@ -430,6 +430,20 @@ and Latin data + + + + &Fast mode + + + Only try four masks (0, 2, 4, 7) not eight +when automatically selecting a mask + + + false + + + diff --git a/frontend_qt/grpUPNQR.ui b/frontend_qt/grpUPNQR.ui index 22377620..5df9d908 100644 --- a/frontend_qt/grpUPNQR.ui +++ b/frontend_qt/grpUPNQR.ui @@ -89,6 +89,20 @@ + + + + &Fast mode + + + Only try four masks (0, 2, 4, 7) not eight +when automatically selecting a mask + + + false + + + diff --git a/frontend_qt/mainwindow.cpp b/frontend_qt/mainwindow.cpp index 8e15ad5a..888b7b92 100644 --- a/frontend_qt/mainwindow.cpp +++ b/frontend_qt/mainwindow.cpp @@ -1858,6 +1858,7 @@ void MainWindow::change_options() connect(get_widget(QSL("radQRGS1")), SIGNAL(toggled( bool )), SLOT(update_preview())); connect(get_widget(QSL("radQRHIBC")), SIGNAL(toggled( bool )), SLOT(update_preview())); connect(get_widget(QSL("chkQRFullMultibyte")), SIGNAL(toggled( bool )), SLOT(update_preview())); + connect(get_widget(QSL("chkQRFast")), SIGNAL(toggled( bool )), SLOT(update_preview())); connect(get_widget(QSL("cmbQRStructAppCount")), SIGNAL(currentIndexChanged( int )), SLOT(update_preview())); connect(get_widget(QSL("cmbQRStructAppCount")), SIGNAL(currentIndexChanged( int )), SLOT(structapp_ui_set())); connect(get_widget(QSL("cmbQRStructAppIndex")), SIGNAL(currentIndexChanged( int )), SLOT(update_preview())); @@ -1871,6 +1872,7 @@ void MainWindow::change_options() load_sub_settings(settings, symbology); tabMain->insertTab(1, m_optionWidget, tr("UP&NQR")); connect(get_widget(QSL("cmbUPNQRMask")), SIGNAL(currentIndexChanged( int )), SLOT(update_preview())); + connect(get_widget(QSL("chkUPNQRFast")), SIGNAL(toggled( bool )), SLOT(update_preview())); } } else if (symbology == BARCODE_RMQR) { @@ -2843,6 +2845,9 @@ void MainWindow::update_preview() if (get_chk_val(QSL("chkQRFullMultibyte"))) { m_bc.bc.setOption3(ZINT_FULL_MULTIBYTE | m_bc.bc.option3()); } + if (get_chk_val(QSL("chkQRFast"))) { + m_bc.bc.setInputMode(FAST_MODE | m_bc.bc.inputMode()); + } if ((item_val = get_cmb_index(QSL("cmbQRStructAppCount"))) != 0) { QString id; int id_val = get_spn_val(QSL("spnQRStructAppID")); @@ -2872,6 +2877,9 @@ void MainWindow::update_preview() if ((item_val = get_cmb_index(QSL("cmbUPNQRMask"))) != 0) { m_bc.bc.setOption3((item_val << 8) | m_bc.bc.option3()); } + if (get_chk_val(QSL("chkUPNQRFast"))) { + m_bc.bc.setInputMode(FAST_MODE | m_bc.bc.inputMode()); + } break; case BARCODE_RMQR: @@ -4010,6 +4018,7 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology) settings.setValue(QSL("studio/bc/qrcode/encoding_mode"), get_rad_grp_index( QStringList() << QSL("radDM200Stand") << QSL("radQRGS1") << QSL("radQRHIBC"))); settings.setValue(QSL("studio/bc/qrcode/chk_full_multibyte"), get_chk_val(QSL("chkQRFullMultibyte"))); + settings.setValue(QSL("studio/bc/qrcode/chk_fast_mode"), get_chk_val(QSL("chkQRFast"))); settings.setValue(QSL("studio/bc/qrcode/structapp_count"), get_cmb_index(QSL("cmbQRStructAppCount"))); settings.setValue(QSL("studio/bc/qrcode/structapp_index"), get_cmb_index(QSL("cmbQRStructAppIndex"))); settings.setValue(QSL("studio/bc/qrcode/structapp_id"), get_spn_val(QSL("spnQRStructAppID"))); @@ -4017,6 +4026,7 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology) case BARCODE_UPNQR: settings.setValue(QSL("studio/bc/upnqr/mask"), get_cmb_index(QSL("cmbUPNQRMask"))); + settings.setValue(QSL("studio/bc/upnqr/chk_fast_mode"), get_chk_val(QSL("chkUPNQRFast"))); break; case BARCODE_RMQR: @@ -4411,6 +4421,7 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology) set_rad_from_setting(settings, QSL("studio/bc/qrcode/encoding_mode"), QStringList() << QSL("radDM200Stand") << QSL("radQRGS1") << QSL("radQRHIBC")); set_chk_from_setting(settings, QSL("studio/bc/qrcode/chk_full_multibyte"), QSL("chkQRFullMultibyte")); + set_chk_from_setting(settings, QSL("studio/bc/qrcode/chk_fast_mode"), QSL("chkQRFast")); set_cmb_from_setting(settings, QSL("studio/bc/qrcode/structapp_count"), QSL("cmbQRStructAppCount")); set_cmb_from_setting(settings, QSL("studio/bc/qrcode/structapp_index"), QSL("cmbQRStructAppIndex")); set_spn_from_setting(settings, QSL("studio/bc/qrcode/structapp_id"), QSL("spnQRStructAppID"), 0); @@ -4418,6 +4429,7 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology) case BARCODE_UPNQR: set_cmb_from_setting(settings, QSL("studio/bc/upnqr/mask"), QSL("cmbUPNQRMask")); + set_chk_from_setting(settings, QSL("studio/bc/upnqr/chk_fast_mode"), QSL("chkUPNQRFast")); break; case BARCODE_RMQR: