二维码读取之ecc200_simple.dev


*在这个实例中,演示了如何读取Data Matrix ECC 200的条码,第一步呢就是,创建一个二维码读取器,在图形窗口中显示结果

  • This example program demonstrates how to read 2d data codes
  • of the symbol type ‘Data Matrix ECC 200’. In the first step
  • a data code model is created. In the next step the data codes
  • are read and the results are displayed in the graphics window.

*注意!
*用默认的参数设置,有些可能读取不到,原因可能是:
*对比度太低
*有些黑色背景,白色条码
*标准模板不包含
*条码区域太大
*打印点阵不连续

  • ******************* Attention **********************
  • Note that there are symbols that cannot be found with the
  • standard default parameters. The reasons for that could be:
    • the contrast is too low
    • some symbols are printed light on dark,
  • which is not covered by the standard model
    • the symbols are too big (>48x48 modules)<
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 Java 中生成二维码,可以使用第三方库Zxing。首先需要在项目中引入该库,可以通过 Maven 或 Gradle 进行引入。 生成二维码的代码如下: ```java import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import com.google.zxing.BarcodeFormat; import com.google.zxing.EncodeHintType; import com.google.zxing.WriterException; import com.google.zxing.client.j2se.MatrixToImageWriter; import com.google.zxing.common.BitMatrix; import com.google.zxing.qrcode.QRCodeWriter; public class QRCodeGenerator { public static void main(String[] args) { String qrCodeData = "R2022121200000027"; String filePath = "qr_code.png"; int size = 250; String fileType = "png"; File qrFile = new File(filePath); try { createQRCode(qrFile, qrCodeData, size, fileType); System.out.println("QR Code generated successfully!"); } catch (WriterException e) { System.out.println("Error generating QR Code: " + e.getMessage()); } catch (Exception e) { System.out.println("Error: " + e.getMessage()); } } private static void createQRCode(File qrFile, String qrCodeData, int size, String fileType) throws WriterException, Exception { // Set QR code parameters Map<EncodeHintType, Object> hintMap = new HashMap<EncodeHintType, Object>(); hintMap.put(EncodeHintType.CHARACTER_SET, "UTF-8"); hintMap.put(EncodeHintType.MARGIN, 2); hintMap.put(EncodeHintType.QR_VERSION, 4); // Create QR code writer and encode the data QRCodeWriter qrCodeWriter = new QRCodeWriter(); BitMatrix byteMatrix = qrCodeWriter.encode(qrCodeData, BarcodeFormat.QR_CODE, size, size, hintMap); // Create QR code image Path path = Paths.get(qrFile.getAbsolutePath()); MatrixToImageWriter.writeToPath(byteMatrix, fileType, path); } } ``` 在上面的代码中,我们首先定义了要生成的二维码的内容、文件路径、大小和文件类型。然后使用 QRCodeWriter 对象将内容编码为二维码,再使用 MatrixToImageWriter 将其写入文件中。运行该代码,会在项目根目录下生成一个名为 qr_code.png 的二维码文件,包含订单号 R2022121200000027。 你也可以根据自己的需求修改代码中的参数,比如大小、文件类型等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值