use of com.google.zxing.common.BitArray in project zxing by zxing.
the class EncoderTest method testModeMessage.
private static void testModeMessage(boolean compact, int layers, int words, String expected) {
BitArray in = Encoder.generateModeMessage(compact, layers, words);
assertEquals("generateModeMessage() failed", stripSpace(expected), stripSpace(in.toString()));
}
use of com.google.zxing.common.BitArray in project zxing by zxing.
the class EncoderTest method testHighLevelEncodeString.
private static void testHighLevelEncodeString(String s, int expectedReceivedBits) {
BitArray bits = new HighLevelEncoder(s.getBytes(StandardCharsets.ISO_8859_1)).encode();
int receivedBitCount = stripSpace(bits.toString()).length();
assertEquals("highLevelEncode() failed for input string: " + s, expectedReceivedBits, receivedBitCount);
assertEquals(s, Decoder.highLevelDecode(toBooleanArray(bits)));
}
use of com.google.zxing.common.BitArray in project zxing by zxing.
the class State method toBitArray.
BitArray toBitArray(byte[] text) {
// Reverse the tokens, so that they are in the order that they should
// be output
Deque<Token> symbols = new LinkedList<>();
for (Token token = endBinaryShift(text.length).token; token != null; token = token.getPrevious()) {
symbols.addFirst(token);
}
BitArray bitArray = new BitArray();
// Add each token to the result.
for (Token symbol : symbols) {
symbol.appendTo(bitArray, text);
}
//assert bitArray.getSize() == this.bitCount;
return bitArray;
}
Aggregations