com.google.zxing.aztec.encoder.Encoder Java Examples

The following examples show how to use com.google.zxing.aztec.encoder.Encoder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AztecWriter.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {
  Charset charset = DEFAULT_CHARSET;
  int eccPercent = Encoder.DEFAULT_EC_PERCENT;
  int layers = Encoder.DEFAULT_AZTEC_LAYERS;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      charset = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      eccPercent = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.AZTEC_LAYERS)) {
      layers = Integer.parseInt(hints.get(EncodeHintType.AZTEC_LAYERS).toString());
    }
  }
  return encode(contents, format, width, height, charset, eccPercent, layers);
}
 
Example #2
Source File: AztecWriter.java    From weex with Apache License 2.0 6 votes vote down vote up
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {
  Charset charset = DEFAULT_CHARSET;
  int eccPercent = Encoder.DEFAULT_EC_PERCENT;
  int layers = Encoder.DEFAULT_AZTEC_LAYERS;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      charset = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      eccPercent = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.AZTEC_LAYERS)) {
      layers = Integer.parseInt(hints.get(EncodeHintType.AZTEC_LAYERS).toString());
    }
  }
  return encode(contents, format, width, height, charset, eccPercent, layers);
}
 
Example #3
Source File: AztecWriter.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {
  Charset charset = DEFAULT_CHARSET;
  int eccPercent = Encoder.DEFAULT_EC_PERCENT;
  int layers = Encoder.DEFAULT_AZTEC_LAYERS;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      charset = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      eccPercent = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.AZTEC_LAYERS)) {
      layers = Integer.parseInt(hints.get(EncodeHintType.AZTEC_LAYERS).toString());
    }
  }
  return encode(contents, format, width, height, charset, eccPercent, layers);
}
 
Example #4
Source File: AztecWriter.java    From ZXing-Orient with Apache License 2.0 5 votes vote down vote up
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {
  String charset = hints == null ? null : (String) hints.get(EncodeHintType.CHARACTER_SET);
  Number eccPercent = hints == null ? null : (Number) hints.get(EncodeHintType.ERROR_CORRECTION);
  Number layers = hints == null ? null : (Number) hints.get(EncodeHintType.AZTEC_LAYERS);
  return encode(contents, 
                format, 
                width,
                height,
                charset == null ? DEFAULT_CHARSET : Charset.forName(charset),
                eccPercent == null ? Encoder.DEFAULT_EC_PERCENT : eccPercent.intValue(),
                layers == null ? Encoder.DEFAULT_AZTEC_LAYERS : layers.intValue());
}
 
Example #5
Source File: AztecWriter.java    From ZXing-Orient with Apache License 2.0 5 votes vote down vote up
private static BitMatrix encode(String contents, BarcodeFormat format,
                                int width, int height,
                                Charset charset, int eccPercent, int layers) {
  if (format != BarcodeFormat.AZTEC) {
    throw new IllegalArgumentException("Can only encode AZTEC, but got " + format);
  }
  AztecCode aztec = Encoder.encode(contents.getBytes(charset), eccPercent, layers);
  return renderResult(aztec, width, height);
}
 
Example #6
Source File: AztecWriter.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
private static BitMatrix encode(String contents, BarcodeFormat format,
                                int width, int height,
                                Charset charset, int eccPercent, int layers) {
  if (format != BarcodeFormat.AZTEC) {
    throw new IllegalArgumentException("Can only encode AZTEC, but got " + format);
  }
  AztecCode aztec = Encoder.encode(contents.getBytes(charset), eccPercent, layers);
  return renderResult(aztec, width, height);
}
 
Example #7
Source File: AztecWriter.java    From weex with Apache License 2.0 5 votes vote down vote up
private static BitMatrix encode(String contents, BarcodeFormat format,
                                int width, int height,
                                Charset charset, int eccPercent, int layers) {
  if (format != BarcodeFormat.AZTEC) {
    throw new IllegalArgumentException("Can only encode AZTEC, but got " + format);
  }
  AztecCode aztec = Encoder.encode(contents.getBytes(charset), eccPercent, layers);
  return renderResult(aztec, width, height);
}
 
Example #8
Source File: AztecWriter.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
private static BitMatrix encode(String contents, BarcodeFormat format,
                                int width, int height,
                                Charset charset, int eccPercent, int layers) {
  if (format != BarcodeFormat.AZTEC) {
    throw new IllegalArgumentException("Can only encode AZTEC, but got " + format);
  }
  AztecCode aztec = Encoder.encode(contents.getBytes(charset), eccPercent, layers);
  return renderResult(aztec, width, height);
}