mirror of
https://github.com/zxing/zxing.git
synced 2025-01-27 11:01:00 -08:00
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:
parent
c8d74f359f
commit
038f113274
|
@ -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);
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -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.</p>
|
||||
*
|
||||
* <p>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.</p>
|
||||
* <p>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.</p>
|
||||
*
|
||||
* <p>That is, instead of passing a {@link Reader} a caller might pass
|
||||
* <code>new ByQuadrantReader(reader)</code>.</p>
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue