qrcoder和zxing哪个好_聊聊zxing的qrcode

本文主要研究下zxing的qrcode的一些代码。

maven

com.google.zxing

core

3.3.1

com.google.zxing

javase

3.3.1

QRCodeWriter

core-3.3.1-sources.jar!/com/google/zxing/qrcode/QRCodeWriter.java

QRCodeWriter的encode方法进行编码,转换为BitMatrix

@Override

public BitMatrix encode(String contents,

BarcodeFormat format,

int width,

int height,

Map hints) throws WriterException {

if (contents.isEmpty()) {

throw new IllegalArgumentException("Found empty contents");

}

if (format != BarcodeFormat.QR_CODE) {

throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format);

}

if (width < 0 || height < 0) {

throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' +

height);

}

ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L;

int quietZone = QUIET_ZONE_SIZE;

if (hints != null) {

if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {

errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());

}

if (hints.containsKey(EncodeHintType.MARGIN)) {

quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());

}

}

QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);

return renderResult(code, width, height, quietZone);

}

QRCode

core-3.3.1-sources.jar!/com/google/zxing/qrcode/encoder/QRCode.java

public final class QRCode {

public static final int NUM_MASK_PATTERNS = 8;

private Mode mode;

private ErrorCorrectionLevel ecLevel;

private Version version;

private int maskPattern;

private ByteMatrix matrix;

public QRCode() {

maskPattern = -1;

}

public Mode getMode() {

return mode;

}

public ErrorCorrectionLevel getECLevel() {

return ecLevel;

}

public Version getVersion() {

return version;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值