mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
添加qrVersion属性
可手动设置二维码中的信息量,可设置0-40的整数,二维码图片也会根据qrVersion而变化,0表示根据传入信息自动变化,若设置的值不足以存储信息,会抛出WriterException
This commit is contained in:
parent
24c9d354e9
commit
be11ecc817
@ -34,6 +34,8 @@ public class QrConfig {
|
||||
protected Integer backColor = WHITE;
|
||||
/** 边距1~4 */
|
||||
protected Integer margin = 2;
|
||||
/** 设置二维码中的信息量,可设置0-40的整数,二维码图片也会根据qrVersion而变化,0表示根据传入信息自动变化 */
|
||||
protected Integer qrVersion = 0;
|
||||
/** 纠错级别 */
|
||||
protected ErrorCorrectionLevel errorCorrection = ErrorCorrectionLevel.M;
|
||||
/** 编码 */
|
||||
@ -204,6 +206,26 @@ public class QrConfig {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置二维码中的信息量,可设置0-40的整数,二维码图片也会根据qrVersion而变化,0表示根据传入信息自动变化
|
||||
*
|
||||
* @return 二维码中的信息量
|
||||
*/
|
||||
public Integer getQrVersion() {
|
||||
return qrVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置二维码中的信息量,可设置0-40的整数,二维码图片也会根据qrVersion而变化,0表示根据传入信息自动变化
|
||||
*
|
||||
* @param qrVersion 二维码中的信息量
|
||||
* @return this
|
||||
*/
|
||||
public QrConfig setQrVersion(Integer qrVersion) {
|
||||
this.qrVersion = qrVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取纠错级别
|
||||
*
|
||||
@ -321,6 +343,9 @@ public class QrConfig {
|
||||
if (null != this.margin) {
|
||||
hints.put(EncodeHintType.MARGIN, this.margin);
|
||||
}
|
||||
if (null != this.qrVersion){
|
||||
hints.put(EncodeHintType.QR_VERSION, this.qrVersion);
|
||||
}
|
||||
return hints;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user