mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Added some comments and fixed up lines over 100 columns.
git-svn-id: https://zxing.googlecode.com/svn/trunk@1134 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
963c449b81
commit
5c627db289
|
@ -42,6 +42,7 @@ public abstract class AbstractOneDReader implements OneDReader {
|
|||
return decode(image, null);
|
||||
}
|
||||
|
||||
// Note that we don't try rotation without the try harder flag, even if rotation was supported.
|
||||
public final Result decode(BinaryBitmap image, Hashtable hints) throws ReaderException {
|
||||
try {
|
||||
return doDecode(image, hints);
|
||||
|
@ -111,7 +112,7 @@ public abstract class AbstractOneDReader implements OneDReader {
|
|||
row = image.getBlackRow(rowNumber, row);
|
||||
} catch (ReaderException re) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// While we have the image data in a BitArray, it's fairly cheap to reverse it in place to
|
||||
// handle decoding upside down barcodes.
|
||||
|
@ -184,7 +185,7 @@ public abstract class AbstractOneDReader implements OneDReader {
|
|||
break;
|
||||
} else {
|
||||
counters[counterPosition] = 1;
|
||||
isWhite ^= true; // isWhite = !isWhite; Is this too clever? shorter byte code, no conditional
|
||||
isWhite = !isWhite;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
|
@ -236,7 +237,7 @@ public abstract class AbstractOneDReader implements OneDReader {
|
|||
if (variance > maxIndividualVariance) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
totalVariance += variance;
|
||||
totalVariance += variance;
|
||||
}
|
||||
return totalVariance / total;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,9 @@ import java.util.Hashtable;
|
|||
*/
|
||||
public abstract class AbstractUPCEANReader extends AbstractOneDReader implements UPCEANReader {
|
||||
|
||||
// These two values are critical for determining how permissive the decoding will be.
|
||||
// We've arrived at these values through a lot of trial and error. Setting them any higher
|
||||
// lets false positives creep in quickly.
|
||||
private static final int MAX_AVG_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.42f);
|
||||
private static final int MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.7f);
|
||||
|
||||
|
@ -172,7 +175,7 @@ public abstract class AbstractUPCEANReader extends AbstractOneDReader implements
|
|||
abstract BarcodeFormat getBarcodeFormat();
|
||||
|
||||
/**
|
||||
* @return {@link #checkStandardUPCEANChecksum(String)}
|
||||
* @return {@link #checkStandardUPCEANChecksum(String)}
|
||||
*/
|
||||
boolean checkChecksum(String s) throws ReaderException {
|
||||
return checkStandardUPCEANChecksum(s);
|
||||
|
@ -274,7 +277,7 @@ public abstract class AbstractUPCEANReader extends AbstractOneDReader implements
|
|||
counterPosition++;
|
||||
}
|
||||
counters[counterPosition] = 1;
|
||||
isWhite ^= true; // isWhite = !isWhite;
|
||||
isWhite = !isWhite;
|
||||
}
|
||||
}
|
||||
throw ReaderException.getInstance();
|
||||
|
|
|
@ -68,7 +68,8 @@ public final class EAN13Reader extends AbstractUPCEANReader {
|
|||
decodeMiddleCounters = new int[4];
|
||||
}
|
||||
|
||||
protected int decodeMiddle(BitArray row, int[] startRange, StringBuffer resultString) throws ReaderException {
|
||||
protected int decodeMiddle(BitArray row, int[] startRange, StringBuffer resultString)
|
||||
throws ReaderException {
|
||||
int[] counters = decodeMiddleCounters;
|
||||
counters[0] = 0;
|
||||
counters[1] = 0;
|
||||
|
@ -111,15 +112,17 @@ public final class EAN13Reader extends AbstractUPCEANReader {
|
|||
}
|
||||
|
||||
/**
|
||||
* Based on pattern of odd-even ('L' and 'G') patterns used to encoded the explicitly-encoded digits
|
||||
* in a barcode, determines the implicitly encoded first digit and adds it to the result string.
|
||||
* Based on pattern of odd-even ('L' and 'G') patterns used to encoded the explicitly-encoded
|
||||
* digits in a barcode, determines the implicitly encoded first digit and adds it to the
|
||||
* result string.
|
||||
*
|
||||
* @param resultString string to insert decoded first digit into
|
||||
* @param lgPatternFound int whose bits indicates the pattern of odd/even L/G patterns used to
|
||||
* encode digits
|
||||
* encode digits
|
||||
* @throws ReaderException if first digit cannot be determined
|
||||
*/
|
||||
private static void determineFirstDigit(StringBuffer resultString, int lgPatternFound) throws ReaderException {
|
||||
private static void determineFirstDigit(StringBuffer resultString, int lgPatternFound)
|
||||
throws ReaderException {
|
||||
for (int d = 0; d < 10; d++) {
|
||||
if (lgPatternFound == FIRST_DIGIT_ENCODINGS[d]) {
|
||||
resultString.insert(0, (char) ('0' + d));
|
||||
|
|
|
@ -34,8 +34,10 @@ public final class MultiFormatOneDReader extends AbstractOneDReader {
|
|||
private final Vector readers;
|
||||
|
||||
public MultiFormatOneDReader(Hashtable hints) {
|
||||
Vector possibleFormats = hints == null ? null : (Vector) hints.get(DecodeHintType.POSSIBLE_FORMATS);
|
||||
boolean useCode39CheckDigit = hints != null && hints.get(DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT) != null;
|
||||
Vector possibleFormats = hints == null ? null :
|
||||
(Vector) hints.get(DecodeHintType.POSSIBLE_FORMATS);
|
||||
boolean useCode39CheckDigit = hints != null &&
|
||||
hints.get(DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT) != null;
|
||||
readers = new Vector();
|
||||
if (possibleFormats != null) {
|
||||
if (possibleFormats.contains(BarcodeFormat.EAN_13) ||
|
||||
|
|
|
@ -37,7 +37,8 @@ public final class MultiFormatUPCEANReader extends AbstractOneDReader {
|
|||
private final Vector readers;
|
||||
|
||||
public MultiFormatUPCEANReader(Hashtable hints) {
|
||||
Vector possibleFormats = hints == null ? null : (Vector) hints.get(DecodeHintType.POSSIBLE_FORMATS);
|
||||
Vector possibleFormats = hints == null ? null :
|
||||
(Vector) hints.get(DecodeHintType.POSSIBLE_FORMATS);
|
||||
readers = new Vector();
|
||||
if (possibleFormats != null) {
|
||||
if (possibleFormats.contains(BarcodeFormat.EAN_13)) {
|
||||
|
@ -82,8 +83,10 @@ public final class MultiFormatUPCEANReader extends AbstractOneDReader {
|
|||
// a UPC-A code. But for efficiency we only run the EAN-13 decoder to also read
|
||||
// UPC-A. So we special case it here, and convert an EAN-13 result to a UPC-A
|
||||
// result if appropriate.
|
||||
if (result.getBarcodeFormat().equals(BarcodeFormat.EAN_13) && result.getText().charAt(0) == '0') {
|
||||
return new Result(result.getText().substring(1), null, result.getResultPoints(), BarcodeFormat.UPC_A);
|
||||
if (result.getBarcodeFormat().equals(BarcodeFormat.EAN_13) &&
|
||||
result.getText().charAt(0) == '0') {
|
||||
return new Result(result.getText().substring(1), null, result.getResultPoints(),
|
||||
BarcodeFormat.UPC_A);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,8 @@ public final class UPCEReader extends AbstractUPCEANReader {
|
|||
decodeMiddleCounters = new int[4];
|
||||
}
|
||||
|
||||
protected int decodeMiddle(BitArray row, int[] startRange, StringBuffer result) throws ReaderException {
|
||||
protected int decodeMiddle(BitArray row, int[] startRange, StringBuffer result)
|
||||
throws ReaderException {
|
||||
int[] counters = decodeMiddleCounters;
|
||||
counters[0] = 0;
|
||||
counters[1] = 0;
|
||||
|
@ -103,7 +104,7 @@ public final class UPCEReader extends AbstractUPCEANReader {
|
|||
}
|
||||
|
||||
BarcodeFormat getBarcodeFormat() {
|
||||
return BarcodeFormat.UPC_E;
|
||||
return BarcodeFormat.UPC_E;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue