Android生成二维码、去除白边的工具类

本文介绍了一个在Android平台上生成二维码并去除白边的实用工具类,使用了core-3.0.0.jar库,适用于Android应用开发中的二维码生成需求。
摘要由CSDN通过智能技术生成
//在这里插入代码片
public class QrCodeGenerator {
   
    public static Bitmap generateBitmap(String content, int width, int height, boolean needDeleteWhiteBorder) {
   
        try {
   
            Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
            hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
            hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
            hints.put(EncodeHintType.MARGIN, 1);

            BitMatrix matrix = new QRCodeWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
            if (needDeleteWhiteBorder) {
   
                matrix = deleteWhite
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值