Fix bug #1502 that PDF417 barcodes without initial latch to Text compaction mode fail to decode (#1503)

* Fixed bug that barcodes without initial latch to text encoding failed to decode
This commit is contained in:
AlexGeller1 2022-02-27 15:27:24 +01:00 committed by GitHub
parent 87f540f5bd
commit 427ece8ae7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -104,11 +104,10 @@ final class DecodedBitStreamParser {
static DecoderResult decode(int[] codewords, String ecLevel) throws FormatException {
StringBuilder result = new StringBuilder(codewords.length * 2);
Charset encoding = StandardCharsets.ISO_8859_1;
// Get compaction mode
int codeIndex = 1;
int code = codewords[codeIndex++];
int codeIndex = textCompaction(codewords, 1, result);
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata();
while (codeIndex < codewords[0]) {
int code = codewords[codeIndex++];
switch (code) {
case TEXT_COMPACTION_MODE_LATCH:
codeIndex = textCompaction(codewords, codeIndex, result);
@ -154,11 +153,6 @@ final class DecodedBitStreamParser {
codeIndex = textCompaction(codewords, codeIndex, result);
break;
}
if (codeIndex < codewords.length) {
code = codewords[codeIndex++];
} else {
throw FormatException.getFormatInstance();
}
}
if (result.length() == 0 && resultMetadata.getFileId() == null) {
throw FormatException.getFormatInstance();