mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
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:
parent
87f540f5bd
commit
427ece8ae7
|
@ -104,11 +104,10 @@ final class DecodedBitStreamParser {
|
||||||
static DecoderResult decode(int[] codewords, String ecLevel) throws FormatException {
|
static DecoderResult decode(int[] codewords, String ecLevel) throws FormatException {
|
||||||
StringBuilder result = new StringBuilder(codewords.length * 2);
|
StringBuilder result = new StringBuilder(codewords.length * 2);
|
||||||
Charset encoding = StandardCharsets.ISO_8859_1;
|
Charset encoding = StandardCharsets.ISO_8859_1;
|
||||||
// Get compaction mode
|
int codeIndex = textCompaction(codewords, 1, result);
|
||||||
int codeIndex = 1;
|
|
||||||
int code = codewords[codeIndex++];
|
|
||||||
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata();
|
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata();
|
||||||
while (codeIndex < codewords[0]) {
|
while (codeIndex < codewords[0]) {
|
||||||
|
int code = codewords[codeIndex++];
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case TEXT_COMPACTION_MODE_LATCH:
|
case TEXT_COMPACTION_MODE_LATCH:
|
||||||
codeIndex = textCompaction(codewords, codeIndex, result);
|
codeIndex = textCompaction(codewords, codeIndex, result);
|
||||||
|
@ -154,11 +153,6 @@ final class DecodedBitStreamParser {
|
||||||
codeIndex = textCompaction(codewords, codeIndex, result);
|
codeIndex = textCompaction(codewords, codeIndex, result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (codeIndex < codewords.length) {
|
|
||||||
code = codewords[codeIndex++];
|
|
||||||
} else {
|
|
||||||
throw FormatException.getFormatInstance();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (result.length() == 0 && resultMetadata.getFileId() == null) {
|
if (result.length() == 0 && resultMetadata.getFileId() == null) {
|
||||||
throw FormatException.getFormatInstance();
|
throw FormatException.getFormatInstance();
|
||||||
|
|
Loading…
Reference in a new issue