Package org.aoju.bus.extra.qrcode
Class QrConfig
java.lang.Object
org.aoju.bus.extra.qrcode.QrConfig
二维码设置
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
FieldsModifier and TypeFieldDescription背景色编码com.google.zxing.qrcode.decoder.ErrorCorrectionLevel纠错级别int前景色(二维码颜色)int长二维码中的Logo边距1~4protected Integer设置二维码中的信息量,可设置1-40的整数int二维码中的Logo缩放的比例系数,如5表示长宽最小值的1/5protected com.google.zxing.datamatrix.encoder.SymbolShapeHintDATA_MATRIX的符号形状int宽 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic QrConfigcreate()创建QrConfigint获取背景色获取编码com.google.zxing.qrcode.decoder.ErrorCorrectionLevel获取纠错级别int获取前景色int获取高度getImg()获取二维码中的Logo获取边距设置二维码中的信息量,可设置0-40的整数,二维码图片也会根据qrVersion而变化,0表示根据传入信息自动变化intgetRatio()获取二维码中的Logo缩放的比例系数,如5表示长宽最小值的1/5intgetWidth()获取宽度setBackColor(Color backColor) 设置背景色,例如:Color.BLUEsetCharset(Charset charset) 设置编码setErrorCorrection(com.google.zxing.qrcode.decoder.ErrorCorrectionLevel errorCorrection) 设置纠错级别setForeColor(Color foreColor) 设置前景色,例如:Color.BLUE.getRGB()setHeight(int height) 设置高度设置二维码中的Logo设置二维码中的Logo文件设置二维码中的Logo文件设置边距setQrVersion(Integer qrVersion) 设置二维码中的信息量,可设置0-40的整数,二维码图片也会根据qrVersion而变化,0表示根据传入信息自动变化setRatio(int ratio) 设置二维码中的Logo缩放的比例系数,如5表示长宽最小值的1/5setShapeHint(com.google.zxing.datamatrix.encoder.SymbolShapeHint shapeHint) 设置DATA_MATRIX的符号形状setWidth(int width) 设置宽度toHints()转换为Zxing的二维码配置toHints(com.google.zxing.BarcodeFormat format) 转换为Zxing的二维码配置
-
Field Details
-
width
public int width宽 -
height
public int height长 -
foreColor
public int foreColor前景色(二维码颜色) -
backColor
背景色 -
margin
边距1~4 -
errorCorrection
public com.google.zxing.qrcode.decoder.ErrorCorrectionLevel errorCorrection纠错级别 -
charset
编码 -
img
二维码中的Logo -
ratio
public int ratio二维码中的Logo缩放的比例系数,如5表示长宽最小值的1/5 -
qrVersion
设置二维码中的信息量,可设置1-40的整数 -
shapeHint
protected com.google.zxing.datamatrix.encoder.SymbolShapeHint shapeHintDATA_MATRIX的符号形状
-
-
Constructor Details
-
QrConfig
public QrConfig()构造,默认长宽为300 -
QrConfig
public QrConfig(int width, int height) 构造- Parameters:
width- 宽height- 长
-
-
Method Details
-
create
创建QrConfig- Returns:
- QrConfig
-
getWidth
public int getWidth()获取宽度- Returns:
- 宽度
-
setWidth
设置宽度- Parameters:
width- 宽度- Returns:
- this
-
getHeight
public int getHeight()获取高度- Returns:
- 高度
-
setHeight
设置高度- Parameters:
height- 高度- Returns:
- this;
-
getForeColor
public int getForeColor()获取前景色- Returns:
- 前景色
-
setForeColor
设置前景色,例如:Color.BLUE.getRGB()- Parameters:
foreColor- 前景色- Returns:
- this
-
getBackColor
public int getBackColor()获取背景色- Returns:
- 背景色
-
setBackColor
设置背景色,例如:Color.BLUE- Parameters:
backColor- 背景色,null表示透明背景- Returns:
- this
-
getMargin
获取边距- Returns:
- 边距
-
setMargin
设置边距- Parameters:
margin- 边距- Returns:
- this
-
getErrorCorrection
public com.google.zxing.qrcode.decoder.ErrorCorrectionLevel getErrorCorrection()获取纠错级别- Returns:
- 纠错级别
-
setErrorCorrection
public QrConfig setErrorCorrection(com.google.zxing.qrcode.decoder.ErrorCorrectionLevel errorCorrection) 设置纠错级别- Parameters:
errorCorrection- 纠错级别- Returns:
- this
-
getCharset
获取编码- Returns:
- 编码
-
setCharset
设置编码- Parameters:
charset- 编码- Returns:
- this
-
getImg
获取二维码中的Logo- Returns:
- Logo图片
-
setImg
设置二维码中的Logo文件- Parameters:
imgPath- 二维码中的Logo路径- Returns:
- this;
-
setImg
设置二维码中的Logo文件- Parameters:
imgFile- 二维码中的Logo- Returns:
- this;
-
setImg
设置二维码中的Logo- Parameters:
img- 二维码中的Logo- Returns:
- this;
-
getRatio
public int getRatio()获取二维码中的Logo缩放的比例系数,如5表示长宽最小值的1/5- Returns:
- 二维码中的Logo缩放的比例系数, 如5表示长宽最小值的1/5
-
setRatio
设置二维码中的Logo缩放的比例系数,如5表示长宽最小值的1/5- Parameters:
ratio- 二维码中的Logo缩放的比例系数,如5表示长宽最小值的1/5- Returns:
- this;
-
setShapeHint
设置DATA_MATRIX的符号形状- Parameters:
shapeHint- DATA_MATRIX的符号形状- Returns:
- this;
-
getQrVersion
设置二维码中的信息量,可设置0-40的整数,二维码图片也会根据qrVersion而变化,0表示根据传入信息自动变化- Returns:
- 二维码中的信息量
-
setQrVersion
设置二维码中的信息量,可设置0-40的整数,二维码图片也会根据qrVersion而变化,0表示根据传入信息自动变化- Parameters:
qrVersion- 二维码中的信息量- Returns:
- this
-
toHints
转换为Zxing的二维码配置- Returns:
- 配置
-
toHints
public HashMap<com.google.zxing.EncodeHintType,Object> toHints(com.google.zxing.BarcodeFormat format) 转换为Zxing的二维码配置- Parameters:
format- 格式,根据格式不同,errorCorrection的值类型有所不同- Returns:
- 配置
-