Java Code Examples for com.google.zxing.common.reedsolomon.ReedSolomonEncoder#encode()
The following examples show how to use
com.google.zxing.common.reedsolomon.ReedSolomonEncoder#encode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Encoder.java From ZXing-Orient with Apache License 2.0 | 5 votes |
private static BitArray generateCheckWords(BitArray bitArray, int totalBits, int wordSize) { // bitArray is guaranteed to be a multiple of the wordSize, so no padding needed int messageSizeInWords = bitArray.getSize() / wordSize; ReedSolomonEncoder rs = new ReedSolomonEncoder(getGF(wordSize)); int totalWords = totalBits / wordSize; int[] messageWords = bitsToWords(bitArray, wordSize, totalWords); rs.encode(messageWords, totalWords - messageSizeInWords); int startPad = totalBits % wordSize; BitArray messageBits = new BitArray(); messageBits.appendBits(0, startPad); for (int messageWord : messageWords) { messageBits.appendBits(messageWord, wordSize); } return messageBits; }
Example 2
Source File: ReedSolomonUtil.java From qart4j with GNU General Public License v3.0 | 5 votes |
public static byte[] generateECBytes(ReedSolomonEncoder encoder, byte[] dataBytes, int position, int length, int numEcBytesInBlock) { int numDataBytes = length; int[] toEncode = new int[numDataBytes + numEcBytesInBlock]; for (int i = 0; i < numDataBytes; i++) { toEncode[i] = dataBytes[position + i] & 0xFF; } encoder.encode(toEncode, numEcBytesInBlock); byte[] ecBytes = new byte[numEcBytesInBlock]; for (int i = 0; i < numEcBytesInBlock; i++) { ecBytes[i] = (byte) toEncode[numDataBytes + i]; } return ecBytes; }
Example 3
Source File: Encoder.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 5 votes |
private static BitArray generateCheckWords(BitArray bitArray, int totalBits, int wordSize) { // bitArray is guaranteed to be a multiple of the wordSize, so no padding needed int messageSizeInWords = bitArray.getSize() / wordSize; ReedSolomonEncoder rs = new ReedSolomonEncoder(getGF(wordSize)); int totalWords = totalBits / wordSize; int[] messageWords = bitsToWords(bitArray, wordSize, totalWords); rs.encode(messageWords, totalWords - messageSizeInWords); int startPad = totalBits % wordSize; BitArray messageBits = new BitArray(); messageBits.appendBits(0, startPad); for (int messageWord : messageWords) { messageBits.appendBits(messageWord, wordSize); } return messageBits; }
Example 4
Source File: Encoder.java From weex with Apache License 2.0 | 5 votes |
private static BitArray generateCheckWords(BitArray bitArray, int totalBits, int wordSize) { // bitArray is guaranteed to be a multiple of the wordSize, so no padding needed int messageSizeInWords = bitArray.getSize() / wordSize; ReedSolomonEncoder rs = new ReedSolomonEncoder(getGF(wordSize)); int totalWords = totalBits / wordSize; int[] messageWords = bitsToWords(bitArray, wordSize, totalWords); rs.encode(messageWords, totalWords - messageSizeInWords); int startPad = totalBits % wordSize; BitArray messageBits = new BitArray(); messageBits.appendBits(0, startPad); for (int messageWord : messageWords) { messageBits.appendBits(messageWord, wordSize); } return messageBits; }
Example 5
Source File: Encoder.java From barcodescanner-lib-aar with MIT License | 5 votes |
private static BitArray generateCheckWords(BitArray bitArray, int totalBits, int wordSize) { // bitArray is guaranteed to be a multiple of the wordSize, so no padding needed int messageSizeInWords = bitArray.getSize() / wordSize; ReedSolomonEncoder rs = new ReedSolomonEncoder(getGF(wordSize)); int totalWords = totalBits / wordSize; int[] messageWords = bitsToWords(bitArray, wordSize, totalWords); rs.encode(messageWords, totalWords - messageSizeInWords); int startPad = totalBits % wordSize; BitArray messageBits = new BitArray(); messageBits.appendBits(0, startPad); for (int messageWord : messageWords) { messageBits.appendBits(messageWord, wordSize); } return messageBits; }