Search in sources :

Example 16 with BitMatrix

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

the class DataMatrixWriterTestCase method testDataMatrixImageWriter.

@Test
public void testDataMatrixImageWriter() {
    Map<EncodeHintType, Object> hints = new EnumMap<>(EncodeHintType.class);
    hints.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE);
    int bigEnough = 64;
    DataMatrixWriter writer = new DataMatrixWriter();
    BitMatrix matrix = writer.encode("Hello Google", BarcodeFormat.DATA_MATRIX, bigEnough, bigEnough, hints);
    assertNotNull(matrix);
    assertTrue(bigEnough >= matrix.getWidth());
    assertTrue(bigEnough >= matrix.getHeight());
}
Also used : EncodeHintType(com.google.zxing.EncodeHintType) BitMatrix(com.google.zxing.common.BitMatrix) EnumMap(java.util.EnumMap) SymbolShapeHint(com.google.zxing.datamatrix.encoder.SymbolShapeHint) Test(org.junit.Test)

Example 17 with BitMatrix

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

the class CodaBarWriterTestCase method doTest.

private static void doTest(String input, CharSequence expected) throws WriterException {
    BitMatrix result = encode(input);
    assertEquals(expected, BitMatrixTestCase.matrixToString(result));
}
Also used : BitMatrix(com.google.zxing.common.BitMatrix)

Example 18 with BitMatrix

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

the class Code128WriterTestCase method testEncodeWithFunc1.

@Test
public void testEncodeWithFunc1() throws WriterException {
    String toEncode = "ñ" + "123";
    //                                                       "12"                           "3"          check digit 92
    String expected = QUIET_SPACE + START_CODE_C + FNC1 + "10110011100" + SWITCH_CODE_B + "11001011100" + "10101111000" + STOP + QUIET_SPACE;
    BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0);
    String actual = BitMatrixTestCase.matrixToString(result);
    assertEquals(expected, actual);
}
Also used : BitMatrix(com.google.zxing.common.BitMatrix) Test(org.junit.Test)

Example 19 with BitMatrix

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

the class Code128WriterTestCase method testEncodeWithFunc4.

@Test
public void testEncodeWithFunc4() throws WriterException {
    String toEncode = "ô" + "123";
    //                                                       "1"            "2"             "3"          check digit 59
    String expected = QUIET_SPACE + START_CODE_B + FNC4 + "10011100110" + "11001110010" + "11001011100" + "11100011010" + STOP + QUIET_SPACE;
    BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0);
    String actual = BitMatrixTestCase.matrixToString(result);
    assertEquals(expected, actual);
}
Also used : BitMatrix(com.google.zxing.common.BitMatrix) Test(org.junit.Test)

Example 20 with BitMatrix

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

the class DecoderTest method testDecodeTooManyErrors.

@Test(expected = FormatException.class)
public void testDecodeTooManyErrors() throws FormatException {
    BitMatrix matrix = BitMatrix.parse("" + "X X . X . . . X X . . . X . . X X X . X . X X X X X . \n" + "X X . . X X . . . . . X X . . . X X . . . X . X . . X \n" + "X . . . X X . . X X X . X X . X X X X . X X . . X . . \n" + ". . . . X . X X . . X X . X X . X . X X X X . X . . X \n" + "X X X . . X X X X X . . . . . X X . . . X . X . X . X \n" + "X X . . . . . . . . X . . . X . X X X . X . . X . . . \n" + "X X . . X . . . . . X X . . . . . X . . . . X . . X X \n" + ". . . X . X . X . . . . . X X X X X X . . . . . . X X \n" + "X . . . X . X X X X X X . . X X X . X . X X X X X X . \n" + "X . . X X X . X X X X X X X X X X X X X . . . X . X X \n" + ". . . . X X . . . X . . . . . . . X X . . . X X . X . \n" + ". . . X X X . . X X . X X X X X . X . . X . . . . . . \n" + "X . . . . X . X . X . X . . . X . X . X X . X X . X X \n" + "X . X . . X . X . X . X . X . X . X . . . . . X . X X \n" + "X . X X X . . X . X . X . . . X . X . X X X . . . X X \n" + "X X X X X X X X . X . X X X X X . X . X . X . X X X . \n" + ". . . . . . . X . X . . . . . . . X X X X . . . X X X \n" + "X X . . X . . X . X X X X X X X X X X X X X . . X . X \n" + "X X X . X X X X . . X X X X . . X . . . . X . . X X X \n" + ". . . . X . X X X . . . . X X X X . . X X X X . . . . \n" + ". . X . . X . X . . . X . X X . X X . X . . . X . X . \n" + "X X . . X . . X X X X X X X . . X . X X X X X X X . . \n" + "X . X X . . X X . . . . . X . . . . . . X X . X X X . \n" + "X . . X X . . X X . X . X . . . . X . X . . X . . X . \n" + "X . X . X . . X . X X X X X X X X . X X X X . . X X . \n" + "X X X X . . . X . . X X X . X X . . X . . . . X X X . \n" + "X X . X . X . . . X . X . . . . X X . X . . X X . . . \n", "X ", ". ");
    AztecDetectorResult r = new AztecDetectorResult(matrix, NO_POINTS, true, 16, 4);
    new Decoder().decode(r);
}
Also used : BitMatrix(com.google.zxing.common.BitMatrix) AztecDetectorResult(com.google.zxing.aztec.AztecDetectorResult) Test(org.junit.Test)

Aggregations

BitMatrix (com.google.zxing.common.BitMatrix)119 EncodeHintType (com.google.zxing.EncodeHintType)27 ResultPoint (com.google.zxing.ResultPoint)26 Test (org.junit.Test)20 Bitmap (android.graphics.Bitmap)18 QRCodeWriter (com.google.zxing.qrcode.QRCodeWriter)17 WriterException (com.google.zxing.WriterException)14 DecoderResult (com.google.zxing.common.DecoderResult)12 EnumMap (java.util.EnumMap)11 MultiFormatWriter (com.google.zxing.MultiFormatWriter)10 DetectorResult (com.google.zxing.common.DetectorResult)10 Hashtable (java.util.Hashtable)10 AztecDetectorResult (com.google.zxing.aztec.AztecDetectorResult)8 Result (com.google.zxing.Result)7 Point (com.google.zxing.aztec.detector.Detector.Point)5 SymbolShapeHint (com.google.zxing.datamatrix.encoder.SymbolShapeHint)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 NotFoundException (com.google.zxing.NotFoundException)4