mirror of
https://github.com/zxing/zxing.git
synced 2024-09-20 05:27:32 -07:00
Patch some possible runtime exceptions in new PDF417 code and remove some no-longer-unsupported test images
git-svn-id: https://zxing.googlecode.com/svn/trunk@2596 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
cae4e9c19d
commit
921c0178e0
|
@ -113,6 +113,9 @@ public final class BitMatrixParser {
|
||||||
next++;
|
next++;
|
||||||
eraseCount++;
|
eraseCount++;
|
||||||
} else {
|
} else {
|
||||||
|
if (next >= codewords.length) {
|
||||||
|
throw FormatException.getFormatInstance();
|
||||||
|
}
|
||||||
codewords[next++] = cw;
|
codewords[next++] = cw;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.zxing.NotFoundException;
|
||||||
import com.google.zxing.common.BitMatrix;
|
import com.google.zxing.common.BitMatrix;
|
||||||
import com.google.zxing.pdf417.decoder.BitMatrixParser;
|
import com.google.zxing.pdf417.decoder.BitMatrixParser;
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ public final class LinesSampler {
|
||||||
*
|
*
|
||||||
* @return the potentially decodable bit matrix.
|
* @return the potentially decodable bit matrix.
|
||||||
*/
|
*/
|
||||||
public BitMatrix sample() {
|
public BitMatrix sample() throws NotFoundException {
|
||||||
List<Float> symbolWidths = findSymbolWidths();
|
List<Float> symbolWidths = findSymbolWidths();
|
||||||
|
|
||||||
int[][] codewords = new int[linesMatrix.getHeight()][];
|
int[][] codewords = new int[linesMatrix.getHeight()][];
|
||||||
|
@ -176,7 +177,14 @@ public final class LinesSampler {
|
||||||
return symbolWidths;
|
return symbolWidths;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void linesMatrixToCodewords(int[][] codewords, int[][] clusterNumbers, List<Float> symbolWidths) {
|
private void linesMatrixToCodewords(int[][] codewords, int[][] clusterNumbers, List<Float> symbolWidths)
|
||||||
|
throws NotFoundException {
|
||||||
|
|
||||||
|
// Not sure if this is the right way to handle this but avoids an error:
|
||||||
|
if (symbolsPerLine > symbolWidths.size()) {
|
||||||
|
throw NotFoundException.getNotFoundInstance();
|
||||||
|
}
|
||||||
|
|
||||||
for (int y = 0; y < linesMatrix.getHeight(); y++) {
|
for (int y = 0; y < linesMatrix.getHeight(); y++) {
|
||||||
codewords[y] = new int[symbolsPerLine];
|
codewords[y] = new int[symbolsPerLine];
|
||||||
clusterNumbers[y] = new int [symbolsPerLine];
|
clusterNumbers[y] = new int [symbolsPerLine];
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 439 KiB |
Binary file not shown.
Before Width: | Height: | Size: 445 KiB |
Binary file not shown.
Before Width: | Height: | Size: 450 KiB |
Binary file not shown.
Before Width: | Height: | Size: 452 KiB |
Binary file not shown.
Before Width: | Height: | Size: 451 KiB |
Loading…
Reference in a new issue