decode static method
Implementation
static DecoderResult decode(List<int> codewords, String ecLevel) {
final result = ECIStringBuilder();
// Get compaction mode
int codeIndex = _textCompaction(codewords, 1, result);
final resultMetadata = PDF417ResultMetadata();
while (codeIndex < codewords[0]) {
final code = codewords[codeIndex++];
switch (code) {
case _textCompactionModeLatch:
codeIndex = _textCompaction(codewords, codeIndex, result);
break;
case _byteCompactionModeLatch:
case _byteCompactionModeLatch6:
codeIndex = _byteCompaction(code, codewords, codeIndex, result);
break;
case _modeShiftToByteCompactionMode:
result.writeCharCode(codewords[codeIndex++]);
break;
case _numericCompactionModeLatch:
codeIndex = _numericCompaction(codewords, codeIndex, result);
break;
case _eciCharset:
result.appendECI(codewords[codeIndex++]);
break;
case _eciGeneralPurpose:
// Can't do anything with generic ECI; skip its 2 characters
codeIndex += 2;
break;
case _eciUserDefined:
// Can't do anything with user ECI; skip its 1 character
codeIndex++;
break;
case _beginMacroPdf417ControlBlock:
codeIndex = decodeMacroBlock(codewords, codeIndex, resultMetadata);
break;
case _beginMacroPdf417OptionalField:
case _macroPdf417Terminator:
// Should not see these outside a macro block
throw FormatsException.instance;
default:
// Default to text compaction. During testing numerous barcodes
// appeared to be missing the starting mode. In these cases defaulting
// to text compaction seems to work.
codeIndex--;
codeIndex = _textCompaction(codewords, codeIndex, result);
break;
}
}
if (result.isEmpty && resultMetadata.fileId == null) {
throw FormatsException.instance;
}
final decoderResult = DecoderResult(null, result.toString(), null, ecLevel);
decoderResult.other = resultMetadata;
return decoderResult;
}