Search in sources :

Example 1 with ReedSolomonEncoder

use of com.google.zxing.common.reedsolomon.ReedSolomonEncoder in project weex-example by KalicyZhou.

the class Encoder method generateCheckWords.

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;
}
Also used : ReedSolomonEncoder(com.google.zxing.common.reedsolomon.ReedSolomonEncoder) BitArray(com.google.zxing.common.BitArray)

Example 2 with ReedSolomonEncoder

use of com.google.zxing.common.reedsolomon.ReedSolomonEncoder in project weex-example by KalicyZhou.

the class Encoder method generateECBytes.

static byte[] generateECBytes(byte[] dataBytes, int numEcBytesInBlock) {
    int numDataBytes = dataBytes.length;
    int[] toEncode = new int[numDataBytes + numEcBytesInBlock];
    for (int i = 0; i < numDataBytes; i++) {
        toEncode[i] = dataBytes[i] & 0xFF;
    }
    new ReedSolomonEncoder(GenericGF.QR_CODE_FIELD_256).encode(toEncode, numEcBytesInBlock);
    byte[] ecBytes = new byte[numEcBytesInBlock];
    for (int i = 0; i < numEcBytesInBlock; i++) {
        ecBytes[i] = (byte) toEncode[numDataBytes + i];
    }
    return ecBytes;
}
Also used : ReedSolomonEncoder(com.google.zxing.common.reedsolomon.ReedSolomonEncoder)

Example 3 with ReedSolomonEncoder

use of com.google.zxing.common.reedsolomon.ReedSolomonEncoder in project zxing by zxing.

the class Encoder method generateCheckWords.

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;
}
Also used : ReedSolomonEncoder(com.google.zxing.common.reedsolomon.ReedSolomonEncoder) BitArray(com.google.zxing.common.BitArray)

Example 4 with ReedSolomonEncoder

use of com.google.zxing.common.reedsolomon.ReedSolomonEncoder in project zxing by zxing.

the class Encoder method generateECBytes.

static byte[] generateECBytes(byte[] dataBytes, int numEcBytesInBlock) {
    int numDataBytes = dataBytes.length;
    int[] toEncode = new int[numDataBytes + numEcBytesInBlock];
    for (int i = 0; i < numDataBytes; i++) {
        toEncode[i] = dataBytes[i] & 0xFF;
    }
    new ReedSolomonEncoder(GenericGF.QR_CODE_FIELD_256).encode(toEncode, numEcBytesInBlock);
    byte[] ecBytes = new byte[numEcBytesInBlock];
    for (int i = 0; i < numEcBytesInBlock; i++) {
        ecBytes[i] = (byte) toEncode[numDataBytes + i];
    }
    return ecBytes;
}
Also used : ReedSolomonEncoder(com.google.zxing.common.reedsolomon.ReedSolomonEncoder)

Aggregations

ReedSolomonEncoder (com.google.zxing.common.reedsolomon.ReedSolomonEncoder)4 BitArray (com.google.zxing.common.BitArray)2