package com;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.Writer;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.google.zxing.qrcode.encoder.ByteMatrix;
import com.google.zxing.qrcode.encoder.Encoder;
import com.google.zxing.qrcode.encoder.QRCode;
import java.util.Map;
/***/
public final class QRCodeWriter implements Writer {
private static final int QUIET_ZONE_SIZE = 4;
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height) throws WriterException {
return encode(contents, format, width, height, null);
}
/**
* 需要白边请调用该方法
* @param contents
* @param format
* @param width 宽度
* @param height 高度
* @param quietZone 白边大小
* @param hints
* @return
* @throws WriterException
*/
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height,int quietZone, Map<EncodeHintType, ?> 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;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.Writer;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.google.zxing.qrcode.encoder.ByteMatrix;
import com.google.zxing.qrcode.encoder.Encoder;
import com.google.zxing.qrcode.encoder.QRCode;
import java.util.Map;
/***/
public final class QRCodeWriter implements Writer {
private static final int QUIET_ZONE_SIZE = 4;
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height) throws WriterException {
return encode(contents, format, width, height, null);
}
/**
* 需要白边请调用该方法
* @param contents
* @param format
* @param width 宽度
* @param height 高度
* @param quietZone 白边大小
* @param hints
* @return
* @throws WriterException
*/
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height,int quietZone, Map<EncodeHintType, ?> 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;