mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Fixed same ResultPoint bug in Code 128 and Code 39 reader; added convenient toString() to Result and GenericResultPoint; added arg checking for Result constructor too
git-svn-id: https://zxing.googlecode.com/svn/trunk@336 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
f299f413e0
commit
012a8c0ce7
|
@ -35,6 +35,9 @@ public final class Result {
|
||||||
byte[] rawBytes,
|
byte[] rawBytes,
|
||||||
ResultPoint[] resultPoints,
|
ResultPoint[] resultPoints,
|
||||||
BarcodeFormat format) {
|
BarcodeFormat format) {
|
||||||
|
if (text == null && rawBytes == null) {
|
||||||
|
throw new IllegalArgumentException("Text and bytes are null");
|
||||||
|
}
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.rawBytes = rawBytes;
|
this.rawBytes = rawBytes;
|
||||||
this.resultPoints = resultPoints;
|
this.resultPoints = resultPoints;
|
||||||
|
@ -87,4 +90,12 @@ public final class Result {
|
||||||
resultMetadata.put(type, value);
|
resultMetadata.put(type, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
if (text == null) {
|
||||||
|
return "[" + rawBytes.length + " bytes]";
|
||||||
|
} else {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,4 +42,14 @@ public final class GenericResultPoint implements ResultPoint {
|
||||||
return posY;
|
return posY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer result = new StringBuffer();
|
||||||
|
result.append('(');
|
||||||
|
result.append(posX);
|
||||||
|
result.append(',');
|
||||||
|
result.append(posY);
|
||||||
|
result.append(')');
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -405,12 +405,14 @@ public final class Code128Reader extends AbstractOneDReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
String resultString = result.toString();
|
String resultString = result.toString();
|
||||||
|
float left = (float) (startPatternInfo[1] + startPatternInfo[0]) / 2.0f;
|
||||||
|
float right = (float) (nextStart + lastStart) / 2.0f;
|
||||||
return new Result(
|
return new Result(
|
||||||
resultString,
|
resultString,
|
||||||
null,
|
null,
|
||||||
new ResultPoint[]{
|
new ResultPoint[]{
|
||||||
new GenericResultPoint((float) (startPatternInfo[1] - startPatternInfo[0]) / 2.0f, (float) rowNumber),
|
new GenericResultPoint(left, (float) rowNumber),
|
||||||
new GenericResultPoint((float) (nextStart - lastStart) / 2.0f, (float) rowNumber)},
|
new GenericResultPoint(right, (float) rowNumber)},
|
||||||
BarcodeFormat.CODE_128);
|
BarcodeFormat.CODE_128);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,12 +138,14 @@ public final class Code39Reader extends AbstractOneDReader {
|
||||||
if (extendedMode) {
|
if (extendedMode) {
|
||||||
resultString = decodeExtended(resultString);
|
resultString = decodeExtended(resultString);
|
||||||
}
|
}
|
||||||
|
float left = (float) (start[1] + start[0]) / 2.0f;
|
||||||
|
float right = (float) (nextStart + lastStart) / 2.0f;
|
||||||
return new Result(
|
return new Result(
|
||||||
resultString,
|
resultString,
|
||||||
null,
|
null,
|
||||||
new ResultPoint[]{
|
new ResultPoint[]{
|
||||||
new GenericResultPoint((float) (start[1] - start[0]) / 2.0f, (float) rowNumber),
|
new GenericResultPoint(left, (float) rowNumber),
|
||||||
new GenericResultPoint((float) (nextStart - lastStart) / 2.0f, (float) rowNumber)},
|
new GenericResultPoint(right, (float) rowNumber)},
|
||||||
BarcodeFormat.CODE_39);
|
BarcodeFormat.CODE_39);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue