当我使用zxing创建条形码时,无法使用移动设备读取条形码。我能够使用https://zxing.org/w/decode.jspx来阅读它。看起来问题在于高度和宽度。这是我的代码
@Test
public void create(){
String data = "Employee Id : 3581834364,Department Id : 13949, Student Id : 35818";
String format = "jpg";
ByteArrayOutputStream outParticipant = new ByteArrayOutputStream();
int width = 778;
int height = 60;
try {
MultiFormatWriter writer = new MultiFormatWriter();
BitMatrix matrix = writer.encode(data, BarcodeFormat.CODE_128, width, height);
System.out.println(matrix.getHeight());
System.out.println(matrix.getWidth());
MatrixToImageWriter.writeToStream(matrix, format, outParticipant);
} catch (WriterException e) {
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}
}