Java 类com.google.zxing.qrcode.encoder.Encoder 实例源码

项目:letv    文件:QRCodeWriter.java   
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints) throws WriterException {
    if (contents.length() == 0) {
        throw new IllegalArgumentException("Found empty contents");
    } else if (format != BarcodeFormat.QR_CODE) {
        throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format);
    } else if (width < 0 || height < 0) {
        throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
    } else {
        ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L;
        int quietZone = 4;
        if (hints != null) {
            ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
            if (requestedECLevel != null) {
                errorCorrectionLevel = requestedECLevel;
            }
            Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
            if (quietZoneInt != null) {
                quietZone = quietZoneInt.intValue();
            }
        }
        return renderResult(Encoder.encode(contents, errorCorrectionLevel, hints), width, height, quietZone);
    }
}
项目:OSCAR-ConCert    文件:QrCodeUtils.java   
public static BufferedImage toSingleQrCodeBufferedImage(String s, ErrorCorrectionLevel ec, int scaleFactor) throws WriterException
{
    QRCode qrCode = new QRCode();
    Encoder.encode(s, ec, qrCode);

    BufferedImage bufferedImage=MatrixToImageWriter.toBufferedImage(qrCode.getMatrix());

    if (scaleFactor!=1)
    {
        int newWidth=bufferedImage.getWidth()*scaleFactor;
        int newHeight=bufferedImage.getHeight()*scaleFactor;
        Image image=bufferedImage.getScaledInstance(newWidth, newHeight, Image.SCALE_FAST);
        bufferedImage=ImageIoUtils.toBufferedImage(image);
    }

    return(bufferedImage);
}
项目:spayd    文件:SpaydQRFactory.java   
/**
 * Generate a QR code with the payment information of a given size, optionally, with branded
 * @param paymentString A SPAYD string with payment information
 * @return An image with the payment QR code
 * @throws SpaydQRException
 */
public BufferedImage createQRCode(String paymentString) {
    notEmpty(paymentString);

    final BitMatrix matrix;
    final int barsize;
    final Writer writer = new MultiFormatWriter();
    try {
        final Map<EncodeHintType, Object> hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
        hints.put(EncodeHintType.CHARACTER_SET, "ISO-8859-1");
        final QRCode code = Encoder.encode(paymentString, ErrorCorrectionLevel.M, hints);
        hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
        barsize = size / (code.getMatrix().getWidth() + 8);
        matrix = writer.encode(paymentString, BarcodeFormat.QR_CODE, size, size, hints);
    } catch (WriterException e) {
        throw new SpaydQRException("Unable to create QR code", e);
    }

    final BufferedImage image = MatrixToImageWriter.toBufferedImage(matrix);

    return isBranded() ? brandImage(image, barsize) : image;
}
项目:oscar-old    文件:QrCodeUtils.java   
public static BufferedImage toSingleQrCodeBufferedImage(String s, ErrorCorrectionLevel ec, int scaleFactor) throws WriterException
{
    QRCode qrCode = new QRCode();
    Encoder.encode(s, ec, qrCode);

    BufferedImage bufferedImage=MatrixToImageWriter.toBufferedImage(qrCode.getMatrix());

    if (scaleFactor!=1)
    {
        int newWidth=bufferedImage.getWidth()*scaleFactor;
        int newHeight=bufferedImage.getHeight()*scaleFactor;
        Image image=bufferedImage.getScaledInstance(newWidth, newHeight, Image.SCALE_FAST);
        bufferedImage=ImageIoUtils.toBufferedImage(image);
    }

    return(bufferedImage);
}
项目:AwesomeQRCode    文件:AwesomeQRCode.java   
/**
 * @param contents             Contents to encode.
 * @param errorCorrectionLevel ErrorCorrectionLevel
 * @return QR code object.
 * @throws WriterException Refer to the messages below.
 */
private static QRCode getProtoQRCode(String contents, ErrorCorrectionLevel errorCorrectionLevel) throws WriterException {
    if (contents.isEmpty()) {
        throw new IllegalArgumentException("Found empty contents");
    }
    Hashtable<EncodeHintType, Object> hintMap = new Hashtable<>();
    hintMap.put(EncodeHintType.CHARACTER_SET, "UTF-8");
    hintMap.put(EncodeHintType.ERROR_CORRECTION, errorCorrectionLevel);
    return Encoder.encode(contents, errorCorrectionLevel, hintMap);
}
项目:weex-3d-map    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:QrCode    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:boohee_v5.6    文件:QRCodeWriter.java   
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height,
                        Map<EncodeHintType, ?> hints) throws WriterException {
    if (contents.isEmpty()) {
        throw new IllegalArgumentException("Found empty contents");
    } else if (format != BarcodeFormat.QR_CODE) {
        throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format);
    } else if (width < 0 || height < 0) {
        throw new IllegalArgumentException("Requested dimensions are too small: " + width +
                'x' + height);
    } else {
        ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L;
        int quietZone = 4;
        if (hints != null) {
            ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get
                    (EncodeHintType.ERROR_CORRECTION);
            if (requestedECLevel != null) {
                errorCorrectionLevel = requestedECLevel;
            }
            Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
            if (quietZoneInt != null) {
                quietZone = quietZoneInt.intValue();
            }
        }
        return renderResult(Encoder.encode(contents, errorCorrectionLevel, hints), width,
                height, quietZone);
    }
}
项目:UniqR    文件:Main.java   
public static void main(String[] args) throws Exception {
    final BufferedImage background = ImageIO.read(Main.class.getResource("nyan_sakamoto.png"));

    Map<EncodeHintType, Object> hints = new HashMap<>();
    hints.put(EncodeHintType.QR_VERSION, 5);
    QRCode qrCode = Encoder.encode("Hello world, UniqR!", ErrorCorrectionLevel.H, hints);
    UniqR<BufferedImage> uniqR = new UniqR<>(new JavaSEPlatform(), background, new QrCodeData(qrCode));
    uniqR.setQrPatternColor(0xFF003366);
    uniqR.setScale(3);
    uniqR.setPadding(100);
    showImage(uniqR.build().produceResult(), "Image");
}
项目:Tesseract-OCR-Scanner    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:QrCodeScanner    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:PortraitZXing    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:PortraitZXing    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:ZXing-Orient    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
    if (requestedECLevel != null) {
      errorCorrectionLevel = requestedECLevel;
    }
    Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
    if (quietZoneInt != null) {
      quietZone = quietZoneInt;
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:event-app    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:weex-analyzer-android    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:weex-3d-map    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:Weex-TestDemo    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:Cardstore    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:QrScan_Demo    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
    if (requestedECLevel != null) {
      errorCorrectionLevel = requestedECLevel;
    }
    Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
    if (quietZoneInt != null) {
      quietZone = quietZoneInt;
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:weex    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:sres-app    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {

  if (contents.length() == 0) {
    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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
    if (requestedECLevel != null) {
      errorCorrectionLevel = requestedECLevel;
    }
    Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
    if (quietZoneInt != null) {
      quietZone = quietZoneInt;
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:TrueTone    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
    int quietZone = QUIET_ZONE_SIZE;
    if (hints != null) {
        ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
        if (requestedECLevel != null) {
            errorCorrectionLevel = requestedECLevel;
        }
        Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
        if (quietZoneInt != null) {
            quietZone = quietZoneInt;
        }
    }

    QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
    return renderResult(code, width, height, quietZone);
}
项目:Discounty    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType, ?> hints) throws WriterException {

    if (contents.length() == 0) {
        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;
    int quietZone = QUIET_ZONE_SIZE;
    if (hints != null) {
        ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
        if (requestedECLevel != null) {
            errorCorrectionLevel = requestedECLevel;
        }
        Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
        if (quietZoneInt != null) {
            quietZone = quietZoneInt;
        }
    }

    QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
    return renderResult(code, width, height, quietZone);
}
项目:bushido-android-app    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
    if (requestedECLevel != null) {
      errorCorrectionLevel = requestedECLevel;
    }
    Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
    if (quietZoneInt != null) {
      quietZone = quietZoneInt;
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:reacteu-app    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {

  if (contents.length() == 0) {
    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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
    if (requestedECLevel != null) {
      errorCorrectionLevel = requestedECLevel;
    }
    Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
    if (quietZoneInt != null) {
      quietZone = quietZoneInt;
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:EternityWallAndroid    文件:QrBitmap.java   
public static Bitmap toBitmap(String data) {
    try {
        return toBitmap(Encoder.encode(data, ErrorCorrectionLevel.M) , Color.BLACK, Color.TRANSPARENT);
    } catch (WriterException e) {
        e.printStackTrace();
    }
    return null;
}
项目:Android-Birdcopy-Application    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
    if (requestedECLevel != null) {
      errorCorrectionLevel = requestedECLevel;
    }
    Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
    if (quietZoneInt != null) {
      quietZone = quietZoneInt;
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:CordovaDemo    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {

  if (contents.length() == 0) {
    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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
    if (requestedECLevel != null) {
      errorCorrectionLevel = requestedECLevel;
    }
    Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
    if (quietZoneInt != null) {
      quietZone = quietZoneInt;
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:AndPlug    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
    if (requestedECLevel != null) {
      errorCorrectionLevel = requestedECLevel;
    }
    Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
    if (quietZoneInt != null) {
      quietZone = quietZoneInt;
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:ng-cordova-demo    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {

  if (contents.length() == 0) {
    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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
    if (requestedECLevel != null) {
      errorCorrectionLevel = requestedECLevel;
    }
    Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
    if (quietZoneInt != null) {
      quietZone = quietZoneInt;
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:RipplePower    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, 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;
    int quietZone = QUIET_ZONE_SIZE;
    if (hints != null) {
        ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
        if (requestedECLevel != null) {
            errorCorrectionLevel = requestedECLevel;
        }
        Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
        if (quietZoneInt != null) {
            quietZone = quietZoneInt;
        }
    }

    QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
    return renderResult(code, width, height, quietZone);
}
项目:Simplicissimus    文件:QRCodeWriter.java   
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height,
    Hashtable hints) throws WriterException {

  if (contents == null || contents.length() == 0) {
    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;
  if (hints != null) {
    ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
    if (requestedECLevel != null) {
      errorCorrectionLevel = requestedECLevel;
    }
  }

  QRCode code = new QRCode();
  Encoder.encode(contents, errorCorrectionLevel, hints, code);
  return renderResult(code, width, height);
}
项目:zxing-bsplus    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:ngCordova-demo    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {

  if (contents.length() == 0) {
    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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
    if (requestedECLevel != null) {
      errorCorrectionLevel = requestedECLevel;
    }
    Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
    if (quietZoneInt != null) {
      quietZone = quietZoneInt;
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:CordovaW8BarcodeDemo    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {

  if (contents.length() == 0) {
    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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
    if (requestedECLevel != null) {
      errorCorrectionLevel = requestedECLevel;
    }
    Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
    if (quietZoneInt != null) {
      quietZone = quietZoneInt;
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:cordova-template    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {

  if (contents.length() == 0) {
    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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
    if (requestedECLevel != null) {
      errorCorrectionLevel = requestedECLevel;
    }
    Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
    if (quietZoneInt != null) {
      quietZone = quietZoneInt;
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
项目:oxPush    文件:QRCodeWriter.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {

  if (contents.length() == 0) {
    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;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
    if (requestedECLevel != null) {
      errorCorrectionLevel = requestedECLevel;
    }
    Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
    if (quietZoneInt != null) {
      quietZone = quietZoneInt;
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}