diff --git a/core/src/com/google/zxing/pdf417/detector/Detector.java b/core/src/com/google/zxing/pdf417/detector/Detector.java index aa21c162f..b59bd535d 100644 --- a/core/src/com/google/zxing/pdf417/detector/Detector.java +++ b/core/src/com/google/zxing/pdf417/detector/Detector.java @@ -132,7 +132,7 @@ public final class Detector { int[] loc = null; // Top Left for (int i = 0; i < height; i++) { - loc = findGuardPattern(matrix, 0, i, halfWidth, START_PATTERN); + loc = findGuardPattern(matrix, 0, i, halfWidth, false, START_PATTERN); if (loc != null) { result[0] = new ResultPoint(loc[0], i); result[4] = new ResultPoint(loc[1], i); @@ -144,7 +144,7 @@ public final class Detector { if (found) { // Found the Top Left vertex found = false; for (int i = height - 1; i > 0; i--) { - loc = findGuardPattern(matrix, 0, i, halfWidth, START_PATTERN); + loc = findGuardPattern(matrix, 0, i, halfWidth, false, START_PATTERN); if (loc != null) { result[1] = new ResultPoint(loc[0], i); result[5] = new ResultPoint(loc[1], i); @@ -157,7 +157,7 @@ public final class Detector { if (found) { // Found the Bottom Left vertex found = false; for (int i = 0; i < height; i++) { - loc = findGuardPattern(matrix, halfWidth, i, halfWidth, STOP_PATTERN); + loc = findGuardPattern(matrix, halfWidth, i, halfWidth, false, STOP_PATTERN); if (loc != null) { result[2] = new ResultPoint(loc[1], i); result[6] = new ResultPoint(loc[0], i); @@ -170,7 +170,7 @@ public final class Detector { if (found) { // Found the Top right vertex found = false; for (int i = height - 1; i > 0; i--) { - loc = findGuardPattern(matrix, halfWidth, i, halfWidth, STOP_PATTERN); + loc = findGuardPattern(matrix, halfWidth, i, halfWidth, false, STOP_PATTERN); if (loc != null) { result[3] = new ResultPoint(loc[1], i); result[7] = new ResultPoint(loc[0], i); @@ -212,7 +212,7 @@ public final class Detector { int[] loc = null; // Top Left for (int i = height - 1; i > 0; i--) { - loc = findGuardPattern(matrix, halfWidth, i, halfWidth, START_PATTERN_REVERSE); + loc = findGuardPattern(matrix, halfWidth, i, halfWidth, true, START_PATTERN_REVERSE); if (loc != null) { result[0] = new ResultPoint(loc[1], i); result[4] = new ResultPoint(loc[0], i); @@ -224,7 +224,7 @@ public final class Detector { if (found) { // Found the Top Left vertex found = false; for (int i = 0; i < height; i++) { - loc = findGuardPattern(matrix, halfWidth, i, halfWidth, START_PATTERN_REVERSE); + loc = findGuardPattern(matrix, halfWidth, i, halfWidth, true, START_PATTERN_REVERSE); if (loc != null) { result[1] = new ResultPoint(loc[1], i); result[5] = new ResultPoint(loc[0], i); @@ -237,7 +237,7 @@ public final class Detector { if (found) { // Found the Bottom Left vertex found = false; for (int i = height - 1; i > 0; i--) { - loc = findGuardPattern(matrix, 0, i, halfWidth, STOP_PATTERN_REVERSE); + loc = findGuardPattern(matrix, 0, i, halfWidth, false, STOP_PATTERN_REVERSE); if (loc != null) { result[2] = new ResultPoint(loc[0], i); result[6] = new ResultPoint(loc[1], i); @@ -250,7 +250,7 @@ public final class Detector { if (found) { // Found the Top Right vertex found = false; for (int i = 0; i < height; i++) { - loc = findGuardPattern(matrix, 0, i, halfWidth, STOP_PATTERN_REVERSE); + loc = findGuardPattern(matrix, 0, i, halfWidth, false, STOP_PATTERN_REVERSE); if (loc != null) { result[3] = new ResultPoint(loc[0], i); result[7] = new ResultPoint(loc[1], i); @@ -357,12 +357,13 @@ public final class Detector { * being searched for as a pattern * @return start/end horizontal offset of guard pattern, as an array of two ints. */ - static int[] findGuardPattern(BitMatrix matrix, int column, int row, int width, int[] pattern) { + static int[] findGuardPattern(BitMatrix matrix, int column, int row, int width, + boolean whiteFirst, int[] pattern) { int patternLength = pattern.length; // TODO: Find a way to cache this array, as this method is called hundreds of times // per image, and we want to allocate as seldom as possible. int[] counters = new int[patternLength]; - boolean isWhite = false; + boolean isWhite = whiteFirst; int counterPosition = 0; int patternStart = column; diff --git a/core/test/src/com/google/zxing/pdf417/PDF417BlackBox1TestCase.java b/core/test/src/com/google/zxing/pdf417/PDF417BlackBox1TestCase.java index 9d78ec2c0..2acb0137e 100644 --- a/core/test/src/com/google/zxing/pdf417/PDF417BlackBox1TestCase.java +++ b/core/test/src/com/google/zxing/pdf417/PDF417BlackBox1TestCase.java @@ -34,9 +34,7 @@ public final class PDF417BlackBox1TestCase extends AbstractBlackBoxTestCase { public PDF417BlackBox1TestCase() { super("test/data/blackbox/pdf417", new MultiFormatReader(), BarcodeFormat.PDF417); addTest(3, 3, 0.0f); - //addTest(1, 1, 90.0f); - //addTest(1, 1, 180.0f); - //addTest(1, 1, 270.0f); + addTest(3, 3, 180.0f); } @Override diff --git a/core/test/src/com/google/zxing/pdf417/PDF417BlackBox2TestCase.java b/core/test/src/com/google/zxing/pdf417/PDF417BlackBox2TestCase.java index eb8b59db6..d63f1f94e 100644 --- a/core/test/src/com/google/zxing/pdf417/PDF417BlackBox2TestCase.java +++ b/core/test/src/com/google/zxing/pdf417/PDF417BlackBox2TestCase.java @@ -34,9 +34,7 @@ public final class PDF417BlackBox2TestCase extends AbstractBlackBoxTestCase { public PDF417BlackBox2TestCase() { super("test/data/blackbox/pdf417-2", new MultiFormatReader(), BarcodeFormat.PDF417); addTest(8, 8, 0.0f); - //addTest(1, 1, 90.0f); - //addTest(1, 1, 180.0f); - //addTest(1, 1, 270.0f); + addTest(9, 9, 180.0f); } @Override