mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
!722 修复QrCodeUtil对于DATA_MATRIX生成的形状随机不可指定的功能完善
Merge pull request !722 from Husky/v5-dev
This commit is contained in:
@@ -5,6 +5,7 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.datamatrix.encoder.SymbolShapeHint;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
|
||||
import java.awt.Color;
|
||||
@@ -44,6 +45,10 @@ public class QrConfig {
|
||||
protected Image img;
|
||||
/** 二维码中的Logo缩放的比例系数,如5表示长宽最小值的1/5 */
|
||||
protected int ratio = 6;
|
||||
/**
|
||||
* DATA_MATRIX的符号形状
|
||||
*/
|
||||
protected SymbolShapeHint shapeHint = SymbolShapeHint.FORCE_NONE;
|
||||
|
||||
/**
|
||||
* 创建QrConfig
|
||||
@@ -326,6 +331,17 @@ public class QrConfig {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置DATA_MATRIX的符号形状
|
||||
*
|
||||
* @param shapeHint DATA_MATRIX的符号形状
|
||||
* @return this;
|
||||
*/
|
||||
public QrConfig setShapeHint(SymbolShapeHint shapeHint) {
|
||||
this.shapeHint = shapeHint;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Zxing的二维码配置
|
||||
*
|
||||
@@ -357,6 +373,7 @@ public class QrConfig {
|
||||
}
|
||||
|
||||
hints.put(EncodeHintType.ERROR_CORRECTION, value);
|
||||
hints.put(EncodeHintType.DATA_MATRIX_SHAPE, shapeHint);
|
||||
}
|
||||
if (null != this.margin) {
|
||||
hints.put(EncodeHintType.MARGIN, this.margin);
|
||||
|
Reference in New Issue
Block a user