Search in sources :

Example 66 with BitArray

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

Example 67 with BitArray

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

Example 68 with BitArray

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

Aggregations

BitArray (com.google.zxing.common.BitArray)68 Test (org.junit.Test)28 BinaryBitmap (com.google.zxing.BinaryBitmap)8 Result (com.google.zxing.Result)8 BufferedImageLuminanceSource (com.google.zxing.BufferedImageLuminanceSource)7 WriterException (com.google.zxing.WriterException)7 GlobalHistogramBinarizer (com.google.zxing.common.GlobalHistogramBinarizer)7 BufferedImage (java.awt.image.BufferedImage)7 ResultPoint (com.google.zxing.ResultPoint)6 NotFoundException (com.google.zxing.NotFoundException)5 ReaderException (com.google.zxing.ReaderException)5 BitMatrix (com.google.zxing.common.BitMatrix)4 FinderPattern (com.google.zxing.oned.rss.FinderPattern)4 ArrayList (java.util.ArrayList)4 AbstractExpandedDecoder (com.google.zxing.oned.rss.expanded.decoders.AbstractExpandedDecoder)3 Path (java.nio.file.Path)3 DecodeHintType (com.google.zxing.DecodeHintType)2 CharacterSetECI (com.google.zxing.common.CharacterSetECI)2 ReedSolomonEncoder (com.google.zxing.common.reedsolomon.ReedSolomonEncoder)2 DataCharacter (com.google.zxing.oned.rss.DataCharacter)2