diff --git a/backend/qr.c b/backend/qr.c index 68bc633a..4d8840f7 100644 --- a/backend/qr.c +++ b/backend/qr.c @@ -1069,6 +1069,7 @@ static int evaluate(unsigned char *local, const int size) { } /* Horizontal */ + dark_mods = 0; /* Count dark mods simultaneously (see Test 4 below) */ for (y = 0; y < size; y++) { r = y * size; block = 0; @@ -1083,6 +1084,9 @@ static int evaluate(unsigned char *local, const int size) { block = 1; state = local[r + x]; } + if (state) { + dark_mods++; + } } if (block >= 5) { result += block - 2; @@ -1097,7 +1101,6 @@ static int evaluate(unsigned char *local, const int size) { #endif /* Test 2: Block of modules in same color */ - dark_mods = 0; /* Count dark mods simultaneously (see Test 4 below) */ for (x = 0; x < size - 1; x++) { for (y = 0; y < size - 1; y++) { k = local[(y * size) + x]; @@ -1106,9 +1109,6 @@ static int evaluate(unsigned char *local, const int size) { (k == local[((y + 1) * size) + (x + 1)])) { result += 3; } - if (k) { - dark_mods++; - } } } @@ -1215,11 +1215,7 @@ static int evaluate(unsigned char *local, const int size) { /* Test 4: Proportion of dark modules in entire symbol */ percentage = (100.0 * dark_mods) / (size * size); - if (percentage < 50.0) { - k = (int) ceil(((100.0 - percentage) - 50.0) / 5.0); - } else { - k = (int) ceil((percentage - 50.0) / 5.0); - } + k = (int) (fabs(percentage - 50.0) / 5.0); result += 10 * k; diff --git a/backend/tests/data/print/bmp/qr_v1_m.bmp b/backend/tests/data/print/bmp/qr_v1_m.bmp index 8a43eacf..c5da1ff5 100644 Binary files a/backend/tests/data/print/bmp/qr_v1_m.bmp and b/backend/tests/data/print/bmp/qr_v1_m.bmp differ diff --git a/backend/tests/data/print/emf/qr_v1_m.emf b/backend/tests/data/print/emf/qr_v1_m.emf index eefe3b04..069c0641 100644 Binary files a/backend/tests/data/print/emf/qr_v1_m.emf and b/backend/tests/data/print/emf/qr_v1_m.emf differ diff --git a/backend/tests/data/print/eps/qr_v1_m.eps b/backend/tests/data/print/eps/qr_v1_m.eps index 5c138d3e..07313119 100644 --- a/backend/tests/data/print/eps/qr_v1_m.eps +++ b/backend/tests/data/print/eps/qr_v1_m.eps @@ -17,9 +17,9 @@ TE 0.00 0.00 0.00 setrgbcolor 2.00 40.00 TB 0.00 14.00 TR TE -2.00 40.00 TB 20.00 2.00 TR +2.00 40.00 TB 16.00 2.00 TR TE -2.00 40.00 TB 24.00 2.00 TR +2.00 40.00 TB 22.00 4.00 TR TE 2.00 40.00 TB 28.00 14.00 TR TE @@ -27,147 +27,147 @@ TE TE 10.00 30.00 TB 12.00 2.00 TR TE +2.00 38.00 TB 18.00 2.00 TR +TE +2.00 38.00 TB 24.00 2.00 TR +TE 10.00 30.00 TB 28.00 2.00 TR TE 10.00 30.00 TB 40.00 2.00 TR TE 6.00 32.00 TB 4.00 6.00 TR TE -10.00 28.00 TB 16.00 2.00 TR +2.00 36.00 TB 16.00 2.00 TR TE -2.00 36.00 TB 20.00 2.00 TR +2.00 36.00 TB 22.00 2.00 TR TE 6.00 32.00 TB 32.00 6.00 TR TE -2.00 34.00 TB 22.00 2.00 TR +2.00 34.00 TB 18.00 2.00 TR TE -2.00 32.00 TB 20.00 2.00 TR +6.00 30.00 TB 22.00 4.00 TR TE -2.00 32.00 TB 24.00 2.00 TR -TE -2.00 30.00 TB 22.00 2.00 TR +2.00 30.00 TB 16.00 4.00 TR TE 2.00 28.00 TB 0.00 14.00 TR TE +2.00 28.00 TB 16.00 2.00 TR +TE 2.00 28.00 TB 20.00 2.00 TR TE -2.00 28.00 TB 24.00 2.00 TR +4.00 26.00 TB 24.00 2.00 TR TE 2.00 28.00 TB 28.00 14.00 TR TE -2.00 26.00 TB 16.00 4.00 TR +4.00 22.00 TB 0.00 2.00 TR TE -2.00 24.00 TB 0.00 2.00 TR +4.00 22.00 TB 4.00 2.00 TR TE -2.00 24.00 TB 4.00 10.00 TR +2.00 24.00 TB 12.00 4.00 TR TE -2.00 24.00 TB 22.00 2.00 TR +2.00 24.00 TB 20.00 2.00 TR TE -2.00 24.00 TB 28.00 10.00 TR +2.00 24.00 TB 30.00 2.00 TR TE -2.00 22.00 TB 4.00 6.00 TR +2.00 24.00 TB 36.00 2.00 TR TE -2.00 22.00 TB 16.00 2.00 TR +2.00 24.00 TB 40.00 2.00 TR TE -2.00 22.00 TB 20.00 10.00 TR +4.00 20.00 TB 8.00 2.00 TR TE -2.00 22.00 TB 34.00 8.00 TR +2.00 22.00 TB 16.00 8.00 TR TE -2.00 20.00 TB 0.00 2.00 TR +2.00 22.00 TB 26.00 6.00 TR TE -2.00 20.00 TB 10.00 6.00 TR +2.00 22.00 TB 34.00 2.00 TR TE -2.00 20.00 TB 18.00 4.00 TR +2.00 22.00 TB 38.00 4.00 TR TE -2.00 20.00 TB 24.00 2.00 TR +2.00 20.00 TB 0.00 6.00 TR TE -2.00 20.00 TB 28.00 4.00 TR +2.00 20.00 TB 12.00 2.00 TR TE -2.00 20.00 TB 34.00 2.00 TR +2.00 20.00 TB 16.00 4.00 TR TE -2.00 20.00 TB 40.00 2.00 TR +2.00 20.00 TB 22.00 6.00 TR TE -2.00 18.00 TB 2.00 2.00 TR +2.00 20.00 TB 30.00 4.00 TR TE -2.00 18.00 TB 8.00 4.00 TR +2.00 20.00 TB 38.00 2.00 TR +TE +4.00 16.00 TB 0.00 4.00 TR +TE +2.00 18.00 TB 6.00 6.00 TR TE 2.00 18.00 TB 14.00 2.00 TR TE -2.00 18.00 TB 22.00 8.00 TR +4.00 16.00 TB 18.00 2.00 TR TE -2.00 18.00 TB 36.00 6.00 TR +2.00 18.00 TB 22.00 2.00 TR TE -2.00 16.00 TB 0.00 2.00 TR +2.00 18.00 TB 26.00 6.00 TR TE -2.00 16.00 TB 4.00 4.00 TR +2.00 18.00 TB 38.00 4.00 TR TE -2.00 16.00 TB 12.00 2.00 TR +2.00 16.00 TB 6.00 10.00 TR TE -4.00 14.00 TB 16.00 6.00 TR +2.00 16.00 TB 22.00 14.00 TR TE -4.00 14.00 TB 24.00 2.00 TR +2.00 16.00 TB 40.00 2.00 TR TE -4.00 14.00 TB 30.00 2.00 TR +2.00 14.00 TB 16.00 2.00 TR TE -2.00 16.00 TB 38.00 2.00 TR -TE -2.00 14.00 TB 36.00 2.00 TR +2.00 14.00 TB 20.00 2.00 TR TE 2.00 12.00 TB 0.00 14.00 TR TE -2.00 12.00 TB 18.00 2.00 TR +2.00 12.00 TB 16.00 6.00 TR TE -2.00 12.00 TB 22.00 2.00 TR +2.00 12.00 TB 28.00 2.00 TR TE -2.00 12.00 TB 26.00 2.00 TR -TE -2.00 12.00 TB 32.00 4.00 TR -TE -4.00 10.00 TB 40.00 2.00 TR +2.00 12.00 TB 38.00 2.00 TR TE 10.00 2.00 TB 0.00 2.00 TR TE 10.00 2.00 TB 12.00 2.00 TR TE -4.00 8.00 TB 16.00 4.00 TR +2.00 10.00 TB 24.00 2.00 TR TE -2.00 10.00 TB 30.00 4.00 TR +2.00 10.00 TB 32.00 2.00 TR TE -2.00 10.00 TB 36.00 2.00 TR +2.00 10.00 TB 40.00 2.00 TR TE 6.00 4.00 TB 4.00 6.00 TR TE -2.00 8.00 TB 22.00 2.00 TR +2.00 8.00 TB 18.00 4.00 TR TE -2.00 8.00 TB 26.00 2.00 TR +2.00 8.00 TB 28.00 2.00 TR TE -2.00 8.00 TB 32.00 6.00 TR +2.00 8.00 TB 36.00 6.00 TR TE -2.00 6.00 TB 16.00 2.00 TR +2.00 6.00 TB 18.00 6.00 TR TE -2.00 6.00 TB 20.00 12.00 TR +2.00 6.00 TB 26.00 4.00 TR TE -4.00 4.00 TB 34.00 4.00 TR +2.00 6.00 TB 34.00 2.00 TR TE -2.00 4.00 TB 16.00 6.00 TR +2.00 4.00 TB 16.00 4.00 TR TE -2.00 4.00 TB 24.00 2.00 TR +2.00 4.00 TB 22.00 6.00 TR TE -2.00 4.00 TB 28.00 4.00 TR +2.00 4.00 TB 30.00 4.00 TR TE -2.00 2.00 TB 18.00 2.00 TR +2.00 4.00 TB 36.00 6.00 TR TE -2.00 2.00 TB 22.00 10.00 TR +2.00 2.00 TB 22.00 2.00 TR TE -2.00 2.00 TB 36.00 4.00 TR +2.00 2.00 TB 26.00 4.00 TR +TE +2.00 2.00 TB 38.00 2.00 TR TE 2.00 0.00 TB 0.00 14.00 TR TE 2.00 0.00 TB 16.00 2.00 TR TE -2.00 0.00 TB 24.00 2.00 TR -TE -2.00 0.00 TB 30.00 2.00 TR -TE -2.00 0.00 TB 36.00 2.00 TR +2.00 0.00 TB 20.00 22.00 TR TE diff --git a/backend/tests/data/print/gif/qr_v1_m.gif b/backend/tests/data/print/gif/qr_v1_m.gif index e8385883..6e61e093 100644 Binary files a/backend/tests/data/print/gif/qr_v1_m.gif and b/backend/tests/data/print/gif/qr_v1_m.gif differ diff --git a/backend/tests/data/print/pcx/qr_v1_m.pcx b/backend/tests/data/print/pcx/qr_v1_m.pcx index ba1f2d12..2da2ec68 100644 Binary files a/backend/tests/data/print/pcx/qr_v1_m.pcx and b/backend/tests/data/print/pcx/qr_v1_m.pcx differ diff --git a/backend/tests/data/print/png/qr_v1_m.png b/backend/tests/data/print/png/qr_v1_m.png index c150041b..aa017053 100644 Binary files a/backend/tests/data/print/png/qr_v1_m.png and b/backend/tests/data/print/png/qr_v1_m.png differ diff --git a/backend/tests/data/print/svg/qr_v1_m.svg b/backend/tests/data/print/svg/qr_v1_m.svg index 79c56a1f..653abe14 100644 --- a/backend/tests/data/print/svg/qr_v1_m.svg +++ b/backend/tests/data/print/svg/qr_v1_m.svg @@ -9,82 +9,82 @@ - - + + + + - - + + - - - - + + + + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + - - - - - + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + + - - - + diff --git a/backend/tests/data/print/tif/qr_v1_m.tif b/backend/tests/data/print/tif/qr_v1_m.tif index 0b21536e..6ebd18e5 100644 Binary files a/backend/tests/data/print/tif/qr_v1_m.tif and b/backend/tests/data/print/tif/qr_v1_m.tif differ diff --git a/backend/tests/data/print/txt/qr_v1_m.txt b/backend/tests/data/print/txt/qr_v1_m.txt index d805bbe1..13815713 100644 --- a/backend/tests/data/print/txt/qr_v1_m.txt +++ b/backend/tests/data/print/txt/qr_v1_m.txt @@ -1,21 +1,21 @@ -FE 2B F8 -82 02 08 -BA A2 E8 +FE 9B F8 +82 4A 08 BA 92 E8 -BA AA E8 -82 92 08 +BA 5A E8 +BA 1A E8 +82 DA 08 FE AB F8 -00 C0 00 -BE 13 E0 -38 BE 78 -87 6B 48 -4D 1E 38 -B2 E9 10 -00 E9 20 -FE 54 C8 -82 C1 A8 -BA D4 E0 -BA BF 60 -BA EB 60 -82 5F 30 -FE 89 20 +00 08 00 +A3 21 28 +A8 F7 58 +EA DD 90 +DD 57 18 +DF 5F C8 +00 A0 00 +FE E2 10 +82 08 88 +BA 62 38 +BA 76 40 +BA DD B8 +82 16 10 +FE BF F8 diff --git a/backend/tests/test_qr.c b/backend/tests/test_qr.c index 961cc06b..cca27946 100644 --- a/backend/tests/test_qr.c +++ b/backend/tests/test_qr.c @@ -87,6 +87,7 @@ static void test_qr_options(int index, int debug) { for (int i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; + if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d\n", i); struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); @@ -242,6 +243,7 @@ static void test_qr_input(int index, int generate, int debug) { for (int i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; + if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d\n", i); struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); @@ -302,6 +304,7 @@ static void test_qr_gs1(int index, int generate, int debug) { for (int i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; + if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d\n", i); struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); @@ -380,6 +383,7 @@ static void test_qr_optimize(int index, int generate, int debug) { for (int i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; + if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d\n", i); struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); @@ -1195,12 +1199,36 @@ static void test_qr_encode(int index, int generate, int debug) { "100000100100111010000" "111111100011001000110" }, + /* 19*/ { BARCODE_QRCODE, UNICODE_MODE, 2, 1, -1, "1234567890", 0, 21, 21, "test_print example, automatic mask 001 (same score as mask 010)", + "111111101001101111111" + "100000100100101000001" + "101110101001001011101" + "101110100101101011101" + "101110100001101011101" + "100000101101101000001" + "111111101010101111111" + "000000000000100000000" + "101000110010000100101" + "101010001111011101011" + "111010101101110110010" + "110111010101011100011" + "110111110101111111001" + "000000001010000000000" + "111111101110001000010" + "100000100000100010001" + "101110100110001000111" + "101110100111011001000" + "101110101101110110111" + "100000100001011000010" + "111111101011111111111" + }, }; int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; + if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d\n", i); struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n");