From bd73aebc733ed9d5f75868f717afe44209b43c13 Mon Sep 17 00:00:00 2001 From: srowen Date: Thu, 21 May 2009 14:26:29 +0000 Subject: [PATCH] Be smarter about recursion to avoid infinite loop git-svn-id: https://zxing.googlecode.com/svn/trunk@940 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../multi/GenericMultipleBarcodeReader.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/core/src/com/google/zxing/multi/GenericMultipleBarcodeReader.java b/core/src/com/google/zxing/multi/GenericMultipleBarcodeReader.java index c1118591d..d69e61490 100644 --- a/core/src/com/google/zxing/multi/GenericMultipleBarcodeReader.java +++ b/core/src/com/google/zxing/multi/GenericMultipleBarcodeReader.java @@ -106,14 +106,22 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader } } - doDecodeMultiple(new CroppedMonochromeBitmapSource(image, 0, 0, (int) minX, height), - hints, results, 0, 0); - doDecodeMultiple(new CroppedMonochromeBitmapSource(image, 0, 0, width, (int) minY), - hints, results, 0, 0); - doDecodeMultiple(new CroppedMonochromeBitmapSource(image, (int) maxX, 0, width, height), - hints, results, (int) maxX, 0); - doDecodeMultiple(new CroppedMonochromeBitmapSource(image, 0, (int) maxY, width, height), - hints, results, 0, (int) maxY); + if (minX > 0) { + doDecodeMultiple(new CroppedMonochromeBitmapSource(image, 0, 0, (int) minX - 1, height), + hints, results, 0, 0); + } + if (minY > 0) { + doDecodeMultiple(new CroppedMonochromeBitmapSource(image, 0, 0, width, (int) minY - 1), + hints, results, 0, 0); + } + if (maxX < width - 1) { + doDecodeMultiple(new CroppedMonochromeBitmapSource(image, (int) maxX, 0, width, height), + hints, results, (int) maxX, 0); + } + if (maxY < height - 1) { + doDecodeMultiple(new CroppedMonochromeBitmapSource(image, 0, (int) maxY, width, height), + hints, results, 0, (int) maxY); + } } private static Result translateResultPoints(Result result, int xOffset, int yOffset) {