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
This commit is contained in:
dswitkin 2009-05-21 18:46:53 +00:00
parent c8d74f359f
commit 038f113274
3 changed files with 33 additions and 24 deletions

View file

@ -14,12 +14,14 @@
* limitations under the License. * 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 * @author Sean Owen
*/ */
@ -70,7 +72,8 @@ public final class CroppedMonochromeBitmapSource implements MonochromeBitmapSour
return right - left; 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... // Hmm, the delegate will probably base this on the whole image though...
delegate.estimateBlackPoint(method, argument); delegate.estimateBlackPoint(method, argument);
} }

View file

@ -20,7 +20,7 @@ import com.google.zxing.Reader;
import com.google.zxing.Result; import com.google.zxing.Result;
import com.google.zxing.MonochromeBitmapSource; import com.google.zxing.MonochromeBitmapSource;
import com.google.zxing.ReaderException; import com.google.zxing.ReaderException;
import com.google.zxing.CroppedMonochromeBitmapSource; import com.google.zxing.common.CroppedMonochromeBitmapSource;
import java.util.Hashtable; 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, * 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 * 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 * 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' * (e.g. QR Codes). Instead this scans the four quadrants of the image -- and also the center
* to cover the case where a barcode is found in the center. * 'quadrant' to cover the case where a barcode is found in the center.
* *
* @see GenericMultipleBarcodeReader * @see GenericMultipleBarcodeReader
*/ */
@ -52,28 +52,32 @@ public final class ByQuadrantReader implements Reader {
int halfWidth = width / 2; int halfWidth = width / 2;
int halfHeight = height / 2; int halfHeight = height / 2;
MonochromeBitmapSource topLeft = new CroppedMonochromeBitmapSource(image, 0, 0, halfWidth, halfHeight); MonochromeBitmapSource topLeft = new CroppedMonochromeBitmapSource(image, 0, 0, halfWidth,
halfHeight);
try { try {
return delegate.decode(topLeft, hints); return delegate.decode(topLeft, hints);
} catch (ReaderException re) { } catch (ReaderException re) {
// continue // continue
} }
MonochromeBitmapSource topRight = new CroppedMonochromeBitmapSource(image, halfWidth, 0, width, halfHeight); MonochromeBitmapSource topRight = new CroppedMonochromeBitmapSource(image, halfWidth, 0, width,
halfHeight);
try { try {
return delegate.decode(topRight, hints); return delegate.decode(topRight, hints);
} catch (ReaderException re) { } catch (ReaderException re) {
// continue // continue
} }
MonochromeBitmapSource bottomLeft = new CroppedMonochromeBitmapSource(image, 0, halfHeight, halfWidth, height); MonochromeBitmapSource bottomLeft = new CroppedMonochromeBitmapSource(image, 0, halfHeight,
halfWidth, height);
try { try {
return delegate.decode(bottomLeft, hints); return delegate.decode(bottomLeft, hints);
} catch (ReaderException re) { } catch (ReaderException re) {
// continue // continue
} }
MonochromeBitmapSource bottomRight = new CroppedMonochromeBitmapSource(image, halfWidth, halfHeight, width, height); MonochromeBitmapSource bottomRight = new CroppedMonochromeBitmapSource(image, halfWidth,
halfHeight, width, height);
try { try {
return delegate.decode(bottomRight, hints); return delegate.decode(bottomRight, hints);
} catch (ReaderException re) { } catch (ReaderException re) {

View file

@ -21,7 +21,7 @@ import com.google.zxing.Result;
import com.google.zxing.MonochromeBitmapSource; import com.google.zxing.MonochromeBitmapSource;
import com.google.zxing.ReaderException; import com.google.zxing.ReaderException;
import com.google.zxing.ResultPoint; import com.google.zxing.ResultPoint;
import com.google.zxing.CroppedMonochromeBitmapSource; import com.google.zxing.common.CroppedMonochromeBitmapSource;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; 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 * After one barcode is found, the areas left, above, right and below the barcode's
* {@link com.google.zxing.ResultPoint}s are scanned, recursively.</p> * {@link com.google.zxing.ResultPoint}s are scanned, recursively.</p>
* *
* <p>A caller may want to also employ {@link ByQuadrantReader} when attempting to * <p>A caller may want to also employ {@link ByQuadrantReader} when attempting to find multiple
* find multiple 2D barcodes, like QR Codes, in an image, where the presence of multiple barcodes might * 2D barcodes, like QR Codes, in an image, where the presence of multiple barcodes might prevent
* prevent detecting any one of them.</p> * detecting any one of them.</p>
* *
* <p>That is, instead of passing a {@link Reader} a caller might pass * <p>That is, instead of passing a {@link Reader} a caller might pass
* <code>new ByQuadrantReader(reader)</code>.</p> * <code>new ByQuadrantReader(reader)</code>.</p>
@ -52,7 +52,8 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
return decodeMultiple(image, null); 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(); Vector results = new Vector();
doDecodeMultiple(image, hints, results, 0, 0); doDecodeMultiple(image, hints, results, 0, 0);
if (results.isEmpty()) { if (results.isEmpty()) {
@ -131,7 +132,8 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
ResultPoint oldPoint = oldResultPoints[i]; ResultPoint oldPoint = oldResultPoints[i];
newResultPoints[i] = new ResultPoint(oldPoint.getX() + xOffset, oldPoint.getY() + yOffset); 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());
} }
} }