} else if (mode.equals(Mode.ECI)) { int value = parseECIValue(bits); currentCharacterSetECI = CharacterSetECI.getCharacterSetECIByValue(value); if (currentCharacterSetECI == null) { decodeNumericSegment(bits, result, count); } else if (mode.equals(Mode.ALPHANUMERIC)) { decodeAlphanumericSegment(bits, result, count, fc1InEffect); } else if (mode.equals(Mode.BYTE)) { decodeByteSegment(bits, result, count, currentCharacterSetECI, byteSegments, hints); } else if (mode.equals(Mode.KANJI)) { decodeKanjiSegment(bits, result, count); } else { throw FormatException.getFormatInstance();
while (count > 1) { int nextTwoCharsBits = bits.readBits(11); result.append(toAlphaNumericChar(nextTwoCharsBits / 45)); result.append(toAlphaNumericChar(nextTwoCharsBits % 45)); count -= 2; result.append(toAlphaNumericChar(bits.readBits(6)));
private DecoderResult decode(BitMatrixParser parser, Map<DecodeHintType,?> hints) throws FormatException, ChecksumException { Version version = parser.readVersion(); ErrorCorrectionLevel ecLevel = parser.readFormatInformation().getErrorCorrectionLevel(); // Read codewords byte[] codewords = parser.readCodewords(); // Separate into data blocks DataBlock[] dataBlocks = DataBlock.getDataBlocks(codewords, version, ecLevel); // Count total number of data bytes int totalBytes = 0; for (DataBlock dataBlock : dataBlocks) { totalBytes += dataBlock.getNumDataCodewords(); } byte[] resultBytes = new byte[totalBytes]; int resultOffset = 0; // Error-correct and copy data blocks together into a stream of bytes for (DataBlock dataBlock : dataBlocks) { byte[] codewordBytes = dataBlock.getCodewords(); int numDataCodewords = dataBlock.getNumDataCodewords(); correctErrors(codewordBytes, numDataCodewords); for (int i = 0; i < numDataCodewords; i++) { resultBytes[resultOffset++] = codewordBytes[i]; } } // Decode the contents of that stream of bytes return DecodedBitStreamParser.decode(resultBytes, version, ecLevel, hints); }
private DecoderResult decode(BitMatrixParser parser, Map<DecodeHintType,?> hints) throws FormatException, ChecksumException { Version version = parser.readVersion(); ErrorCorrectionLevel ecLevel = parser.readFormatInformation().getErrorCorrectionLevel(); // Read codewords byte[] codewords = parser.readCodewords(); // Separate into data blocks DataBlock[] dataBlocks = DataBlock.getDataBlocks(codewords, version, ecLevel); // Count total number of data bytes int totalBytes = 0; for (DataBlock dataBlock : dataBlocks) { totalBytes += dataBlock.getNumDataCodewords(); } byte[] resultBytes = new byte[totalBytes]; int resultOffset = 0; // Error-correct and copy data blocks together into a stream of bytes for (DataBlock dataBlock : dataBlocks) { byte[] codewordBytes = dataBlock.getCodewords(); int numDataCodewords = dataBlock.getNumDataCodewords(); correctErrors(codewordBytes, numDataCodewords); for (int i = 0; i < numDataCodewords; i++) { resultBytes[resultOffset++] = codewordBytes[i]; } } // Decode the contents of that stream of bytes return DecodedBitStreamParser.decode(resultBytes, version, ecLevel, hints); }
case ECI: int value = parseECIValue(bits); currentCharacterSetECI = CharacterSetECI.getCharacterSetECIByValue(value); if (currentCharacterSetECI == null) { int countHanzi = bits.readBits(mode.getCharacterCountBits(version)); if (subset == GB2312_SUBSET) { decodeHanziSegment(bits, result, countHanzi); switch (mode) { case NUMERIC: decodeNumericSegment(bits, result, count); break; case ALPHANUMERIC: decodeAlphanumericSegment(bits, result, count, fc1InEffect); break; case BYTE: decodeByteSegment(bits, result, count, currentCharacterSetECI, byteSegments, hints); break; case KANJI: decodeKanjiSegment(bits, result, count); break; default:
throw FormatException.getFormatInstance(); result.append(toAlphaNumericChar(threeDigitsBits / 100)); result.append(toAlphaNumericChar((threeDigitsBits / 10) % 10)); result.append(toAlphaNumericChar(threeDigitsBits % 10)); count -= 3; throw FormatException.getFormatInstance(); result.append(toAlphaNumericChar(twoDigitsBits / 10)); result.append(toAlphaNumericChar(twoDigitsBits % 10)); } else if (count == 1) { throw FormatException.getFormatInstance(); result.append(toAlphaNumericChar(digitBits));
return DecodedBitStreamParser.decode(resultBytes, version, ecLevel, hints);
case ECI: int value = parseECIValue(bits); currentCharacterSetECI = CharacterSetECI.getCharacterSetECIByValue(value); if (currentCharacterSetECI == null) { int countHanzi = bits.readBits(mode.getCharacterCountBits(version)); if (subset == GB2312_SUBSET) { decodeHanziSegment(bits, result, countHanzi); switch (mode) { case NUMERIC: decodeNumericSegment(bits, result, count); break; case ALPHANUMERIC: decodeAlphanumericSegment(bits, result, count, fc1InEffect); break; case BYTE: decodeByteSegment(bits, result, count, currentCharacterSetECI, byteSegments, hints); break; case KANJI: decodeKanjiSegment(bits, result, count); break; default:
result.append(toAlphaNumericChar(nextTwoCharsBits / 45)); result.append(toAlphaNumericChar(nextTwoCharsBits % 45)); count -= 2; throw FormatException.getFormatInstance(); result.append(toAlphaNumericChar(bits.readBits(6)));
result.append(toAlphaNumericChar(nextTwoCharsBits / 45)); result.append(toAlphaNumericChar(nextTwoCharsBits % 45)); count -= 2; throw FormatException.getFormatInstance(); result.append(toAlphaNumericChar(bits.readBits(6)));
throw FormatException.getFormatInstance(); result.append(toAlphaNumericChar(threeDigitsBits / 100)); result.append(toAlphaNumericChar((threeDigitsBits / 10) % 10)); result.append(toAlphaNumericChar(threeDigitsBits % 10)); count -= 3; throw FormatException.getFormatInstance(); result.append(toAlphaNumericChar(twoDigitsBits / 10)); result.append(toAlphaNumericChar(twoDigitsBits % 10)); } else if (count == 1) { throw FormatException.getFormatInstance(); result.append(toAlphaNumericChar(digitBits));
throw FormatException.getFormatInstance(); result.append(toAlphaNumericChar(threeDigitsBits / 100)); result.append(toAlphaNumericChar((threeDigitsBits / 10) % 10)); result.append(toAlphaNumericChar(threeDigitsBits % 10)); count -= 3; throw FormatException.getFormatInstance(); result.append(toAlphaNumericChar(twoDigitsBits / 10)); result.append(toAlphaNumericChar(twoDigitsBits % 10)); } else if (count == 1) { throw FormatException.getFormatInstance(); result.append(toAlphaNumericChar(digitBits));