【问题标题】:Data Matrix Code always 12x12数据矩阵代码始终为 12x12
【发布时间】: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();
        }
    }
}

【问题讨论】:

  • 因为你正在编码的数据不需要比这个大。

标签: java zxing


【解决方案1】:

正如我在 DataMatrixWriter.encode() 方法的源代码中看到的,参数 widthheight 根本不用于条码生成。它们只是检查为非负数,因此它们显然没有任何意义。

【讨论】:

    猜你喜欢
    • 2016-11-01
    • 2018-10-06
    • 1970-01-01
    • 1970-01-01
    • 2020-11-14
    • 2021-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多