public class QrConfig extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected Integer |
backColor
背景色,默认白色,null表示透明
|
protected Charset |
charset
编码
|
protected com.google.zxing.qrcode.decoder.ErrorCorrectionLevel |
errorCorrection
纠错级别
|
protected Integer |
foreColor
前景色(二维码颜色)
|
protected com.google.zxing.BarcodeFormat |
format
生成码的格式,默认为二维码
|
protected int |
height
高度
|
protected Image |
img
二维码中的Logo
|
protected Integer |
margin
边距0~4
|
protected Integer |
qrVersion
设置二维码中的信息量,可设置0-40的整数
|
protected int |
ratio
二维码中的Logo缩放的比例系数,如5表示长宽最小值的1/5
|
protected com.google.zxing.datamatrix.encoder.SymbolShapeHint |
shapeHint
DATA_MATRIX的符号形状
|
protected int |
width
宽度
|
| 限定符和类型 | 方法和说明 |
|---|---|
int |
getBackColor()
获取背景色
|
Charset |
getCharset()
获取编码
|
com.google.zxing.qrcode.decoder.ErrorCorrectionLevel |
getErrorCorrection()
获取纠错级别
|
int |
getForeColor()
获取前景色
|
com.google.zxing.BarcodeFormat |
getFormat()
获取码格式
|
int |
getHeight()
获取高度
|
Image |
getImg()
获取二维码中的Logo
|
Integer |
getMargin()
获取边距
|
Integer |
getQrVersion()
设置二维码中的信息量,可设置0-40的整数,二维码图片也会根据qrVersion而变化,0表示根据传入信息自动变化
|
int |
getRatio()
获取二维码中的Logo缩放的比例系数,如5表示长宽最小值的1/5
|
int |
getWidth()
获取宽度
|
static QrConfig |
of()
创建QrConfig
|
static QrConfig |
of(int width,
int height)
创建QrConfig
|
QrConfig |
setBackColor(Color backColor)
设置背景色,例如:Color.BLUE
|
QrConfig |
setCharset(Charset charset)
设置编码
|
QrConfig |
setErrorCorrection(com.google.zxing.qrcode.decoder.ErrorCorrectionLevel errorCorrection)
设置纠错级别
|
QrConfig |
setForeColor(Color foreColor)
设置前景色,例如:Color.BLUE.getRGB()
|
QrConfig |
setFormat(com.google.zxing.BarcodeFormat format)
设置码格式,默认二维码
|
QrConfig |
setHeight(int height)
设置高度
|
QrConfig |
setImg(byte[] imageBytes)
设置二维码中的Logo文件
|
QrConfig |
setImg(File imgFile)
设置二维码中的Logo文件
|
QrConfig |
setImg(Image img)
设置二维码中的Logo
|
QrConfig |
setImg(String imgPath)
设置二维码中的Logo文件
|
QrConfig |
setMargin(Integer margin)
设置边距
|
QrConfig |
setQrVersion(Integer qrVersion)
设置二维码中的信息量,可设置0-40的整数,二维码图片也会根据qrVersion而变化,0表示根据传入信息自动变化
|
QrConfig |
setRatio(int ratio)
设置二维码中的Logo缩放的比例系数,如5表示长宽最小值的1/5
|
QrConfig |
setShapeHint(com.google.zxing.datamatrix.encoder.SymbolShapeHint shapeHint)
设置DATA_MATRIX的符号形状
|
QrConfig |
setWidth(int width)
设置宽度
|
HashMap<com.google.zxing.EncodeHintType,Object> |
toHints()
转换为Zxing的二维码配置
|
protected int width
protected int height
protected Integer foreColor
protected Integer backColor
protected Integer margin
protected Integer qrVersion
protected com.google.zxing.qrcode.decoder.ErrorCorrectionLevel errorCorrection
protected Charset charset
protected Image img
protected int ratio
protected com.google.zxing.datamatrix.encoder.SymbolShapeHint shapeHint
protected com.google.zxing.BarcodeFormat format
public QrConfig()
public QrConfig(int width,
int height)
width - 宽height - 高public static QrConfig of()
public static QrConfig of(int width, int height)
width - 宽height - 高public int getWidth()
public QrConfig setWidth(int width)
width - 宽度public int getHeight()
public QrConfig setHeight(int height)
height - 高度public int getForeColor()
public QrConfig setForeColor(Color foreColor)
foreColor - 前景色public int getBackColor()
public QrConfig setBackColor(Color backColor)
backColor - 背景色,null表示透明背景public Integer getMargin()
public Integer getQrVersion()
public QrConfig setQrVersion(Integer qrVersion)
qrVersion - 二维码中的信息量public com.google.zxing.qrcode.decoder.ErrorCorrectionLevel getErrorCorrection()
public QrConfig setErrorCorrection(com.google.zxing.qrcode.decoder.ErrorCorrectionLevel errorCorrection)
errorCorrection - 纠错级别public Charset getCharset()
public Image getImg()
public QrConfig setImg(byte[] imageBytes)
imageBytes - 二维码中的Logo图片bytes表示形式public int getRatio()
public QrConfig setRatio(int ratio)
ratio - 二维码中的Logo缩放的比例系数,如5表示长宽最小值的1/5public QrConfig setShapeHint(com.google.zxing.datamatrix.encoder.SymbolShapeHint shapeHint)
shapeHint - DATA_MATRIX的符号形状public com.google.zxing.BarcodeFormat getFormat()
public QrConfig setFormat(com.google.zxing.BarcodeFormat format)
format - 码格式Copyright © 2023. All rights reserved.