【发布时间】:2014-03-11 06:53:53
【问题描述】:
以下代码保存大小为 12x12 的图像,而我定义的 BitMatrix 宽度为 500,高度为 500。我的代码有什么问题?
DataMatrixWriter dmw = new DataMatrixWriter();
BitMatrix bm = dmw.encode(code, BarcodeFormat.DATA_MATRIX, 500, 500);
try {
FileOutputStream fos = new FileOutputStream(new File("C:/test2.jpg"));
MatrixToImageWriter.writeToStream(bm, "jpg", fos);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
【问题讨论】:
-
因为你正在编码的数据不需要比这个大。