From 038f1132744be5b3c459f3980cc9df12fe1d11e9 Mon Sep 17 00:00:00 2001 From: dswitkin Date: Thu, 21 May 2009 18:46:53 +0000 Subject: [PATCH] Moved CroppedMonochromeBitmapSource into the common package and fixed some more 100 column issues. git-svn-id: https://zxing.googlecode.com/svn/trunk@944 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../CroppedMonochromeBitmapSource.java | 11 +++++--- .../google/zxing/multi/ByQuadrantReader.java | 18 +++++++----- .../multi/GenericMultipleBarcodeReader.java | 28 ++++++++++--------- 3 files changed, 33 insertions(+), 24 deletions(-) rename core/src/com/google/zxing/{ => common}/CroppedMonochromeBitmapSource.java (90%) diff --git a/core/src/com/google/zxing/CroppedMonochromeBitmapSource.java b/core/src/com/google/zxing/common/CroppedMonochromeBitmapSource.java similarity index 90% rename from core/src/com/google/zxing/CroppedMonochromeBitmapSource.java rename to core/src/com/google/zxing/common/CroppedMonochromeBitmapSource.java index 92ec3d614..c7d625d5e 100644 --- a/core/src/com/google/zxing/CroppedMonochromeBitmapSource.java +++ b/core/src/com/google/zxing/common/CroppedMonochromeBitmapSource.java @@ -14,12 +14,14 @@ * limitations under the License. */ -package com.google.zxing; +package com.google.zxing.common; -import com.google.zxing.common.BitArray; +import com.google.zxing.BlackPointEstimationMethod; +import com.google.zxing.MonochromeBitmapSource; +import com.google.zxing.ReaderException; /** - * Encapulates a cropped region, a subset, of another {@link MonochromeBitmapSource}. + * Encapulates a cropped region of another {@link com.google.zxing.MonochromeBitmapSource}. * * @author Sean Owen */ @@ -70,7 +72,8 @@ public final class CroppedMonochromeBitmapSource implements MonochromeBitmapSour return right - left; } - public void estimateBlackPoint(BlackPointEstimationMethod method, int argument) throws ReaderException { + public void estimateBlackPoint(BlackPointEstimationMethod method, int argument) + throws ReaderException { // Hmm, the delegate will probably base this on the whole image though... delegate.estimateBlackPoint(method, argument); } diff --git a/core/src/com/google/zxing/multi/ByQuadrantReader.java b/core/src/com/google/zxing/multi/ByQuadrantReader.java index e874e862c..be112d8f5 100644 --- a/core/src/com/google/zxing/multi/ByQuadrantReader.java +++ b/core/src/com/google/zxing/multi/ByQuadrantReader.java @@ -20,7 +20,7 @@ import com.google.zxing.Reader; import com.google.zxing.Result; import com.google.zxing.MonochromeBitmapSource; import com.google.zxing.ReaderException; -import com.google.zxing.CroppedMonochromeBitmapSource; +import com.google.zxing.common.CroppedMonochromeBitmapSource; import java.util.Hashtable; @@ -28,8 +28,8 @@ import java.util.Hashtable; * This class attempts to decode a barcode from an image, not by scanning the whole image, * but by scanning subsets of the image. This is important when there may be multiple barcodes in * an image, and detecting a barcode may find parts of multiple barcode and fail to decode - * (e.g. QR Codes). Instead this scans the four quadrants of the image -- and also the center 'quadrant' - * to cover the case where a barcode is found in the center. + * (e.g. QR Codes). Instead this scans the four quadrants of the image -- and also the center + * 'quadrant' to cover the case where a barcode is found in the center. * * @see GenericMultipleBarcodeReader */ @@ -52,28 +52,32 @@ public final class ByQuadrantReader implements Reader { int halfWidth = width / 2; int halfHeight = height / 2; - MonochromeBitmapSource topLeft = new CroppedMonochromeBitmapSource(image, 0, 0, halfWidth, halfHeight); + MonochromeBitmapSource topLeft = new CroppedMonochromeBitmapSource(image, 0, 0, halfWidth, + halfHeight); try { return delegate.decode(topLeft, hints); } catch (ReaderException re) { // continue } - MonochromeBitmapSource topRight = new CroppedMonochromeBitmapSource(image, halfWidth, 0, width, halfHeight); + MonochromeBitmapSource topRight = new CroppedMonochromeBitmapSource(image, halfWidth, 0, width, + halfHeight); try { return delegate.decode(topRight, hints); } catch (ReaderException re) { // continue } - MonochromeBitmapSource bottomLeft = new CroppedMonochromeBitmapSource(image, 0, halfHeight, halfWidth, height); + MonochromeBitmapSource bottomLeft = new CroppedMonochromeBitmapSource(image, 0, halfHeight, + halfWidth, height); try { return delegate.decode(bottomLeft, hints); } catch (ReaderException re) { // continue } - MonochromeBitmapSource bottomRight = new CroppedMonochromeBitmapSource(image, halfWidth, halfHeight, width, height); + MonochromeBitmapSource bottomRight = new CroppedMonochromeBitmapSource(image, halfWidth, + halfHeight, width, height); try { return delegate.decode(bottomRight, hints); } catch (ReaderException re) { diff --git a/core/src/com/google/zxing/multi/GenericMultipleBarcodeReader.java b/core/src/com/google/zxing/multi/GenericMultipleBarcodeReader.java index d69e61490..946869107 100644 --- a/core/src/com/google/zxing/multi/GenericMultipleBarcodeReader.java +++ b/core/src/com/google/zxing/multi/GenericMultipleBarcodeReader.java @@ -21,7 +21,7 @@ import com.google.zxing.Result; import com.google.zxing.MonochromeBitmapSource; import com.google.zxing.ReaderException; import com.google.zxing.ResultPoint; -import com.google.zxing.CroppedMonochromeBitmapSource; +import com.google.zxing.common.CroppedMonochromeBitmapSource; import java.util.Hashtable; import java.util.Vector; @@ -31,9 +31,9 @@ import java.util.Vector; * After one barcode is found, the areas left, above, right and below the barcode's * {@link com.google.zxing.ResultPoint}s are scanned, recursively.

* - *

A caller may want to also employ {@link ByQuadrantReader} when attempting to - * find multiple 2D barcodes, like QR Codes, in an image, where the presence of multiple barcodes might - * prevent detecting any one of them.

+ *

A caller may want to also employ {@link ByQuadrantReader} when attempting to find multiple + * 2D barcodes, like QR Codes, in an image, where the presence of multiple barcodes might prevent + * detecting any one of them.

* *

That is, instead of passing a {@link Reader} a caller might pass * new ByQuadrantReader(reader).

@@ -52,7 +52,8 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader return decodeMultiple(image, null); } - public Result[] decodeMultiple(MonochromeBitmapSource image, Hashtable hints) throws ReaderException { + public Result[] decodeMultiple(MonochromeBitmapSource image, Hashtable hints) + throws ReaderException { Vector results = new Vector(); doDecodeMultiple(image, hints, results, 0, 0); if (results.isEmpty()) { @@ -107,20 +108,20 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader } if (minX > 0) { - doDecodeMultiple(new CroppedMonochromeBitmapSource(image, 0, 0, (int) minX - 1, height), - hints, results, 0, 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); + 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), + 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); + doDecodeMultiple(new CroppedMonochromeBitmapSource(image, 0, (int) maxY, width, height), + hints, results, 0, (int) maxY); } } @@ -131,7 +132,8 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader ResultPoint oldPoint = oldResultPoints[i]; newResultPoints[i] = new ResultPoint(oldPoint.getX() + xOffset, oldPoint.getY() + yOffset); } - return new Result(result.getText(), result.getRawBytes(), newResultPoints, result.getBarcodeFormat()); + return new Result(result.getText(), result.getRawBytes(), newResultPoints, + result.getBarcodeFormat()); } }