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());
}
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));
}
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);
}
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);
}
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);
}
Aggregations