Java Code Examples for com.google.zxing.aztec.encoder.AztecCode#getMatrix()

The following examples show how to use com.google.zxing.aztec.encoder.AztecCode#getMatrix() . 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 ZXing-Orient with Apache License 2.0 6 votes vote down vote up
private static BitMatrix renderResult(AztecCode code, int width, int height) {
  BitMatrix input = code.getMatrix();
  if (input == null) {
    throw new IllegalStateException();
  }
  int inputWidth = input.getWidth();
  int inputHeight = input.getHeight();
  int outputWidth = Math.max(width, inputWidth);
  int outputHeight = Math.max(height, inputHeight);

  int multiple = Math.min(outputWidth / inputWidth, outputHeight / inputHeight);
  int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
  int topPadding = (outputHeight - (inputHeight * multiple)) / 2;

  BitMatrix output = new BitMatrix(outputWidth, outputHeight);

  for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
    // Write the contents of this row of the barcode
    for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
      if (input.get(inputX, inputY)) {
        output.setRegion(outputX, outputY, multiple, multiple);
      }
    }
  }
  return output;
}
 
Example 2
Source File: AztecWriter.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
private static BitMatrix renderResult(AztecCode code, int width, int height) {
  BitMatrix input = code.getMatrix();
  if (input == null) {
    throw new IllegalStateException();
  }
  int inputWidth = input.getWidth();
  int inputHeight = input.getHeight();
  int outputWidth = Math.max(width, inputWidth);
  int outputHeight = Math.max(height, inputHeight);

  int multiple = Math.min(outputWidth / inputWidth, outputHeight / inputHeight);
  int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
  int topPadding = (outputHeight - (inputHeight * multiple)) / 2;

  BitMatrix output = new BitMatrix(outputWidth, outputHeight);

  for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
    // Write the contents of this row of the barcode
    for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
      if (input.get(inputX, inputY)) {
        output.setRegion(outputX, outputY, multiple, multiple);
      }
    }
  }
  return output;
}
 
Example 3
Source File: AztecWriter.java    From weex with Apache License 2.0 6 votes vote down vote up
private static BitMatrix renderResult(AztecCode code, int width, int height) {
  BitMatrix input = code.getMatrix();
  if (input == null) {
    throw new IllegalStateException();
  }
  int inputWidth = input.getWidth();
  int inputHeight = input.getHeight();
  int outputWidth = Math.max(width, inputWidth);
  int outputHeight = Math.max(height, inputHeight);

  int multiple = Math.min(outputWidth / inputWidth, outputHeight / inputHeight);
  int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
  int topPadding = (outputHeight - (inputHeight * multiple)) / 2;

  BitMatrix output = new BitMatrix(outputWidth, outputHeight);

  for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
    // Write the contents of this row of the barcode
    for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
      if (input.get(inputX, inputY)) {
        output.setRegion(outputX, outputY, multiple, multiple);
      }
    }
  }
  return output;
}
 
Example 4
Source File: AztecWriter.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
private static BitMatrix renderResult(AztecCode code, int width, int height) {
  BitMatrix input = code.getMatrix();
  if (input == null) {
    throw new IllegalStateException();
  }
  int inputWidth = input.getWidth();
  int inputHeight = input.getHeight();
  int outputWidth = Math.max(width, inputWidth);
  int outputHeight = Math.max(height, inputHeight);

  int multiple = Math.min(outputWidth / inputWidth, outputHeight / inputHeight);
  int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
  int topPadding = (outputHeight - (inputHeight * multiple)) / 2;

  BitMatrix output = new BitMatrix(outputWidth, outputHeight);

  for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
    // Write the contents of this row of the barcode
    for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
      if (input.get(inputX, inputY)) {
        output.setRegion(outputX, outputY, multiple, multiple);
      }
    }
  }
  return output;
}