mirror of
https://github.com/zxing/zxing.git
synced 2024-11-09 20:44:03 -08:00
fix(core): do not evaluate out of index as white on qrcode mask evaluation (#1446)
* fix(core): do not evaluate out of index as white on qrcode mask evaluation
This commit is contained in:
parent
7a760c6384
commit
f4f3c2971d
|
@ -104,8 +104,9 @@ final class MaskUtil {
|
|||
}
|
||||
|
||||
private static boolean isWhiteHorizontal(byte[] rowArray, int from, int to) {
|
||||
from = Math.max(from, 0);
|
||||
to = Math.min(to, rowArray.length);
|
||||
if (from < 0 || rowArray.length < to) {
|
||||
return false;
|
||||
}
|
||||
for (int i = from; i < to; i++) {
|
||||
if (rowArray[i] == 1) {
|
||||
return false;
|
||||
|
@ -115,8 +116,9 @@ final class MaskUtil {
|
|||
}
|
||||
|
||||
private static boolean isWhiteVertical(byte[][] array, int col, int from, int to) {
|
||||
from = Math.max(from, 0);
|
||||
to = Math.min(to, array.length);
|
||||
if (from < 0 || array.length < to) {
|
||||
return false;
|
||||
}
|
||||
for (int i = from; i < to; i++) {
|
||||
if (array[i][col] == 1) {
|
||||
return false;
|
||||
|
|
|
@ -100,29 +100,29 @@ public final class EncoderTestCase extends Assert {
|
|||
" mode: ALPHANUMERIC\n" +
|
||||
" ecLevel: H\n" +
|
||||
" version: 1\n" +
|
||||
" maskPattern: 4\n" +
|
||||
" maskPattern: 0\n" +
|
||||
" matrix:\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 1 1 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 0 1 0 0 1 0 1 0 1 1 1 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 0 1 0 1 0 0 1 0 1 1 1 0 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 1 0 0 1 1 0 1 0 0 0 0 0 1\n" +
|
||||
"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0 1 0 0 1 0 0 1 1 0 0 0 1\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 0 1 0 0 1 0 0 0 0 1 1 1\n" +
|
||||
" 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0\n" +
|
||||
" 0 0 1 0 1 1 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1\n" +
|
||||
" 1 0 1 1 1 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0\n" +
|
||||
" 0 0 1 1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 1 0\n" +
|
||||
" 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 0\n" +
|
||||
" 0 0 1 1 0 1 1 1 1 0 0 0 1 0 1 0 1 1 1 1 0\n" +
|
||||
" 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 0 0\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 0 1 0 1 0 1 1 0 0 0 0 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 1 1 1 1 0 1 0 1 1 1 1 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 0 1 1 0 1 0 1 0 0 0 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 0 1 0\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 1 1 0 1 1 0 1 0 0 0 1 1\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1\n" +
|
||||
">>\n";
|
||||
assertEquals(expected, qrCode.toString());
|
||||
}
|
||||
|
@ -151,29 +151,29 @@ public final class EncoderTestCase extends Assert {
|
|||
" mode: BYTE\n" +
|
||||
" ecLevel: H\n" +
|
||||
" version: 1\n" +
|
||||
" maskPattern: 6\n" +
|
||||
" maskPattern: 3\n" +
|
||||
" matrix:\n" +
|
||||
" 1 1 1 1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\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 1 1 0\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 1 0 1 1 1 0 1 1 0 0 0 0\n" +
|
||||
">>\n";
|
||||
assertEquals(expected, qrCode.toString());
|
||||
}
|
||||
|
@ -188,29 +188,29 @@ public final class EncoderTestCase extends Assert {
|
|||
" mode: KANJI\n" +
|
||||
" ecLevel: M\n" +
|
||||
" version: 1\n" +
|
||||
" maskPattern: 0\n" +
|
||||
" maskPattern: 4\n" +
|
||||
" matrix:\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 1 1 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 1 1 0 0 0 0 1 0 0 0 0 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 0 1 1 1 1 0 1 0 1 1 1 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 0 0 0 0 1 0 1 0 1 1 1 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 1 1 1 1 0 1 0 1 1 1 0 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 1 1 1 0 0 1 0 0 0 0 0 1\n" +
|
||||
" 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 0 0 0 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 0 1 1 1 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 1 0 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 1\n" +
|
||||
" 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" +
|
||||
" 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 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||
" 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 0 1 0 0 0\n" +
|
||||
" 1 1 1 1 1 1 1 0 1 1 0 1 0 0 1 1 1 1 1 1 0\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 1 0 1 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 0 1 0 1 1 1 0 0 0 1 1 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 0 1 0 0 1 1 1 0 0 0 1 1 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 0 1 1 0 1 1 0 0 0 1 0 0 0\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 0 1 1 1 0 0 1 0 1 0 0 0\n" +
|
||||
" 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 0 1 1 0\n" +
|
||||
">>\n";
|
||||
assertEquals(expected, qrCode.toString());
|
||||
}
|
||||
|
@ -224,29 +224,29 @@ public final class EncoderTestCase extends Assert {
|
|||
" mode: NUMERIC\n" +
|
||||
" ecLevel: M\n" +
|
||||
" version: 1\n" +
|
||||
" maskPattern: 2\n" +
|
||||
" maskPattern: 0\n" +
|
||||
" matrix:\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 1 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 0 1 1 1 0 1\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 0 0 0 1 0 1 1 1 1 1 1 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 1 1 0 1 0 0 1 0 0 0 0 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 0 1 1 1 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 1 1 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0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0\n" +
|
||||
" 0 0 0 0 0 0 0 1 1 0 1 1 0 1 0 1 0 1 0 1 0\n" +
|
||||
" 0 1 0 1 0 1 1 1 1 0 0 1 0 1 1 1 0 1 0 1 0\n" +
|
||||
" 0 1 1 1 0 0 0 0 0 0 1 1 1 1 0 1 1 1 0 1 0\n" +
|
||||
" 0 0 0 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 0 1\n" +
|
||||
" 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 1 1 0\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 1 0 0 1 0 0 0 1 0 0 0 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 0 0\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 1 0 0 1 0 1 0 1 0 1 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 0 1 1 1 0 1 0 1 0 1 0 1 0\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 0 1 1 0 1 1 1 0 1 1 0 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 0 1 1 1 1 0 1 1 1 0 0 0\n" +
|
||||
" 1 1 1 1 1 1 1 0 1 0 1 1 0 1 1 1 0 1 1 0 1\n" +
|
||||
">>\n";
|
||||
assertEquals(expected, qrCode.toString());
|
||||
}
|
||||
|
@ -293,29 +293,29 @@ public final class EncoderTestCase extends Assert {
|
|||
" mode: BYTE\n" +
|
||||
" ecLevel: H\n" +
|
||||
" version: 1\n" +
|
||||
" maskPattern: 5\n" +
|
||||
" maskPattern: 6\n" +
|
||||
" matrix:\n" +
|
||||
" 1 1 1 1 1 1 1 0 1 0 1 1 0 0 1 1 1 1 1 1 1\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 1 1 0 0 0 1 0 0 0 0 0 1\n" +
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0 0 0 1 1 1 1 1 0 1 0 1 0 0 1 0\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 0 1 1 0 0 1 0 0 0 1 1 0\n" +
|
||||
" 1 0 0 0 0 0 1 0 1 1 0 0 0 0 1 0 1 1 1 0 0\n" +
|
||||
" 1 0 1 1 1 0 1 0 0 1 0 0 1 0 1 0 1 0 0 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 0 0 0 0 1 1 1 0 1 1 1 1 0\n" +
|
||||
" 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 1 0 0 0 1\n" +
|
||||
" 1 1 1 1 1 1 1 0 1 0 0 1 0 1 1 0 1 0 1 0 0\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 1 1 1 0 0\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 1 0 1 1 0 0 0 1 1 0 0 0\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 0 1 1 1 1 1 0 0 0 1 1 0\n" +
|
||||
" 1 0 1 1 1 0 1 0 0 0 1 0 0 1 0 0 1 0 1 1 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 0 1 1 1 1\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 1 1 1 0 1 1 0 1 0 0 1 0\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0\n" +
|
||||
">>\n";
|
||||
assertEquals(expected, qrCode.toString());
|
||||
}
|
||||
|
@ -859,33 +859,33 @@ public final class EncoderTestCase extends Assert {
|
|||
" mode: ALPHANUMERIC\n" +
|
||||
" ecLevel: H\n" +
|
||||
" version: 2\n" +
|
||||
" maskPattern: 4\n" +
|
||||
" maskPattern: 2\n" +
|
||||
" matrix:\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 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0 0 0 1 0 1 1 1 0 0 1 0 0 1\n" +
|
||||
" 0 0 1 1 0 1 0 1 1 1 1 0 0 1 1 1 1 0 0 0 1 1 0 1 1\n" +
|
||||
" 0 0 1 0 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 1 1 0 1 0\n" +
|
||||
" 1 1 1 0 1 1 0 1 0 0 0 0 0 0 0 1 1 0 1 1 0 1 0 0 0\n" +
|
||||
" 1 0 1 0 1 0 1 1 0 1 0 1 0 1 1 0 0 0 0 0 1 1 0 0 1\n" +
|
||||
" 1 0 0 1 0 1 0 1 0 0 0 1 1 1 1 0 1 0 1 0 0 1 0 0 1\n" +
|
||||
" 1 0 1 0 0 1 1 1 0 1 1 0 0 1 0 0 1 1 1 1 1 1 0 0 0\n" +
|
||||
" 0 0 0 0 0 0 0 0 1 0 0 1 0 1 1 0 1 0 0 0 1 0 0 1 0\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 1 1 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 1 1 1 1 1 0 1 1 0 0 0 1 0 0 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 0 1 0 0 1 1 1 1 1 1 1 1 0 0 0 1\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 0 0 0 1 1 0 1 0 0 1 1 1 0 1 0 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 1 0 1 0 1 1 1 0 1 0 0 1 1 1 1 1\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 0 0 0 1 0 1 1\n" +
|
||||
">>\n";
|
||||
assertEquals(expected, qrCode.toString());
|
||||
}
|
||||
|
@ -895,29 +895,29 @@ public final class EncoderTestCase extends Assert {
|
|||
" mode: ALPHANUMERIC\n" +
|
||||
" ecLevel: H\n" +
|
||||
" version: 1\n" +
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 1 1 0 1 0 1 0\n" +
|
||||
" 1 0 1 1 1 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 1\n" +
|
||||
" 1 0 0 0 0 0 1 0 0 1 1 0 1 1 0 1 0 0 0 1 1\n" +
|
||||
" 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1\n" +
|
||||
">>\n";
|
||||
assertEquals(expected, qrCode.toString());
|
||||
}
|
||||
|
|
|
@ -118,6 +118,16 @@ public final class MaskUtilTestCase extends Assert {
|
|||
matrix.set(9, 0, 0);
|
||||
matrix.set(10, 0, 0);
|
||||
assertEquals(40, MaskUtil.applyMaskPenaltyRule3(matrix));
|
||||
// Horizontal 1011101.
|
||||
matrix = new ByteMatrix(7, 1);
|
||||
matrix.set(0, 0, 1);
|
||||
matrix.set(1, 0, 0);
|
||||
matrix.set(2, 0, 1);
|
||||
matrix.set(3, 0, 1);
|
||||
matrix.set(4, 0, 1);
|
||||
matrix.set(5, 0, 0);
|
||||
matrix.set(6, 0, 1);
|
||||
assertEquals(0, MaskUtil.applyMaskPenaltyRule3(matrix));
|
||||
// Vertical 00001011101.
|
||||
matrix = new ByteMatrix(1, 11);
|
||||
matrix.set(0, 0, 0);
|
||||
|
@ -145,7 +155,16 @@ public final class MaskUtilTestCase extends Assert {
|
|||
matrix.set(0, 8, 0);
|
||||
matrix.set(0, 9, 0);
|
||||
matrix.set(0, 10, 0);
|
||||
assertEquals(40, MaskUtil.applyMaskPenaltyRule3(matrix));
|
||||
// Vertical 1011101.
|
||||
matrix = new ByteMatrix(1, 7);
|
||||
matrix.set(0, 0, 1);
|
||||
matrix.set(0, 1, 0);
|
||||
matrix.set(0, 2, 1);
|
||||
matrix.set(0, 3, 1);
|
||||
matrix.set(0, 4, 1);
|
||||
matrix.set(0, 5, 0);
|
||||
matrix.set(0, 6, 1);
|
||||
assertEquals(0, MaskUtil.applyMaskPenaltyRule3(matrix));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in a new issue