Search in sources :

Example 11 with BitArray

use of com.google.zxing.common.BitArray in project zxing by zxing.

the class RSSExpandedStackedInternalTestCase method testDecodingRowByRow.

@Test
public void testDecodingRowByRow() throws Exception {
    RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
    BinaryBitmap binaryMap = TestCaseUtil.getBinaryBitmap("src/test/resources/blackbox/rssexpandedstacked-2/1000.png");
    int firstRowNumber = binaryMap.getHeight() / 3;
    BitArray firstRow = binaryMap.getBlackRow(firstRowNumber, null);
    try {
        rssExpandedReader.decodeRow2pairs(firstRowNumber, firstRow);
        fail(NotFoundException.class.getName() + " expected");
    } catch (NotFoundException nfe) {
    // ok
    }
    assertEquals(1, rssExpandedReader.getRows().size());
    ExpandedRow firstExpandedRow = rssExpandedReader.getRows().get(0);
    assertEquals(firstRowNumber, firstExpandedRow.getRowNumber());
    assertEquals(2, firstExpandedRow.getPairs().size());
    firstExpandedRow.getPairs().get(1).getFinderPattern().getStartEnd()[1] = 0;
    int secondRowNumber = 2 * binaryMap.getHeight() / 3;
    BitArray secondRow = binaryMap.getBlackRow(secondRowNumber, null);
    secondRow.reverse();
    List<ExpandedPair> totalPairs = rssExpandedReader.decodeRow2pairs(secondRowNumber, secondRow);
    Result result = RSSExpandedReader.constructResult(totalPairs);
    assertEquals("(01)98898765432106(3202)012345(15)991231", result.getText());
}
Also used : NotFoundException(com.google.zxing.NotFoundException) BitArray(com.google.zxing.common.BitArray) BinaryBitmap(com.google.zxing.BinaryBitmap) Result(com.google.zxing.Result) Test(org.junit.Test)

Example 12 with BitArray

use of com.google.zxing.common.BitArray in project zxing by zxing.

the class BitVectorTestCase method testToString.

@Test
public void testToString() {
    BitArray v = new BitArray();
    // 1101 1110 1010 1101
    v.appendBits(0xdead, 16);
    assertEquals(" XX.XXXX. X.X.XX.X", v.toString());
}
Also used : BitArray(com.google.zxing.common.BitArray) Test(org.junit.Test)

Example 13 with BitArray

use of com.google.zxing.common.BitArray in project zxing by zxing.

the class BitVectorTestCase method testAppendBits.

@Test
public void testAppendBits() {
    BitArray v = new BitArray();
    v.appendBits(0x1, 1);
    assertEquals(1, v.getSize());
    assertEquals(0x80000000L, getUnsignedInt(v, 0));
    v = new BitArray();
    v.appendBits(0xff, 8);
    assertEquals(8, v.getSize());
    assertEquals(0xff000000L, getUnsignedInt(v, 0));
    v = new BitArray();
    v.appendBits(0xff7, 12);
    assertEquals(12, v.getSize());
    assertEquals(0xff700000L, getUnsignedInt(v, 0));
}
Also used : BitArray(com.google.zxing.common.BitArray) Test(org.junit.Test)

Example 14 with BitArray

use of com.google.zxing.common.BitArray in project zxing by zxing.

the class BitVectorTestCase method testAt.

@Test
public void testAt() {
    BitArray v = new BitArray();
    // 1101 1110 1010 1101
    v.appendBits(0xdead, 16);
    assertTrue(v.get(0));
    assertTrue(v.get(1));
    assertFalse(v.get(2));
    assertTrue(v.get(3));
    assertTrue(v.get(4));
    assertTrue(v.get(5));
    assertTrue(v.get(6));
    assertFalse(v.get(7));
    assertTrue(v.get(8));
    assertFalse(v.get(9));
    assertTrue(v.get(10));
    assertFalse(v.get(11));
    assertTrue(v.get(12));
    assertTrue(v.get(13));
    assertFalse(v.get(14));
    assertTrue(v.get(15));
}
Also used : BitArray(com.google.zxing.common.BitArray) Test(org.junit.Test)

Example 15 with BitArray

use of com.google.zxing.common.BitArray in project zxing by zxing.

the class EncoderTestCase method testAppendKanjiBytes.

// Numbers are from page 21 of JISX0510:2004
@Test
public void testAppendKanjiBytes() throws WriterException {
    BitArray bits = new BitArray();
    Encoder.appendKanjiBytes(shiftJISString(new byte[] { (byte) 0x93, 0x5f }), bits);
    assertEquals(" .XX.XX.. XXXXX", bits.toString());
    Encoder.appendKanjiBytes(shiftJISString(new byte[] { (byte) 0xe4, (byte) 0xaa }), bits);
    assertEquals(" .XX.XX.. XXXXXXX. X.X.X.X. X.", bits.toString());
}
Also used : BitArray(com.google.zxing.common.BitArray) Test(org.junit.Test)

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