mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Minor changes to support EAN-13.
git-svn-id: https://zxing.googlecode.com/svn/trunk@101 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
34c8f125ce
commit
776c3db869
|
@ -25,10 +25,10 @@ public final class UPCParsedResult extends ParsedReaderResult {
|
||||||
|
|
||||||
public UPCParsedResult(String rawText) {
|
public UPCParsedResult(String rawText) {
|
||||||
super(ParsedReaderResultType.UPC);
|
super(ParsedReaderResultType.UPC);
|
||||||
if (rawText.length() != 12) {
|
if (rawText.length() != 12 && rawText.length() != 13) {
|
||||||
throw new IllegalArgumentException("Wrong number of digits for UPC");
|
throw new IllegalArgumentException("Wrong number of digits for UPC");
|
||||||
}
|
}
|
||||||
for (int x = 0; x < 12; x++) {
|
for (int x = 0; x < rawText.length(); x++) {
|
||||||
char c = rawText.charAt(x);
|
char c = rawText.charAt(x);
|
||||||
if (c < '0' || c > '9') {
|
if (c < '0' || c > '9') {
|
||||||
throw new IllegalArgumentException("Invalid character found in UPC");
|
throw new IllegalArgumentException("Invalid character found in UPC");
|
||||||
|
|
|
@ -236,12 +236,12 @@ final class UPCDecoder {
|
||||||
private int decodeOneSide(BitArray rowData, int rowOffset, boolean checkBothParities) {
|
private int decodeOneSide(BitArray rowData, int rowOffset, boolean checkBothParities) {
|
||||||
int[] counters = new int[4];
|
int[] counters = new int[4];
|
||||||
byte firstDigitPattern = 0;
|
byte firstDigitPattern = 0;
|
||||||
|
CharResult foundChar = new CharResult();
|
||||||
for (int x = 0; x < 6 && rowOffset < width; x++) {
|
for (int x = 0; x < 6 && rowOffset < width; x++) {
|
||||||
recordPattern(rowData, rowOffset, counters, 4);
|
recordPattern(rowData, rowOffset, counters, 4);
|
||||||
for (int y = 0; y < 4; y++) {
|
for (int y = 0; y < 4; y++) {
|
||||||
rowOffset += counters[y];
|
rowOffset += counters[y];
|
||||||
}
|
}
|
||||||
CharResult foundChar = new CharResult();
|
|
||||||
findDigit(counters, foundChar, checkBothParities);
|
findDigit(counters, foundChar, checkBothParities);
|
||||||
if (foundChar.parity == UNKNOWN_PARITY) {
|
if (foundChar.parity == UNKNOWN_PARITY) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in a new issue