com.google.zxing.common.BitMatrix#setRegion ( )源码实例Demo

下面列出了com.google.zxing.common.BitMatrix#setRegion ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ScreenCapture   文件: OneDimensionalCodeWriter.java
/**
 * @return a byte array of horizontal pixels (0 = white, 1 = black)
 */
private static BitMatrix renderResult(boolean[] code, int width, int height, int sidesMargin) {
  int inputWidth = code.length;
  // Add quiet zone on both sides.
  int fullWidth = inputWidth + sidesMargin;
  int outputWidth = Math.max(width, fullWidth);
  int outputHeight = Math.max(1, height);

  int multiple = outputWidth / fullWidth;
  int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;

  BitMatrix output = new BitMatrix(outputWidth, outputHeight);
  for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
    if (code[inputX]) {
      output.setRegion(outputX, 0, multiple, outputHeight);
    }
  }
  return output;
}
 
/**
 * @return a byte array of horizontal pixels (0 = white, 1 = black)
 */
private static BitMatrix renderResult(boolean[] code, int width, int height, int sidesMargin) {
  int inputWidth = code.length;
  // Add quiet zone on both sides.
  int fullWidth = inputWidth + sidesMargin;
  int outputWidth = Math.max(width, fullWidth);
  int outputHeight = Math.max(1, height);

  int multiple = outputWidth / fullWidth;
  int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;

  BitMatrix output = new BitMatrix(outputWidth, outputHeight);
  for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
    if (code[inputX]) {
      output.setRegion(outputX, 0, multiple, outputHeight);
    }
  }
  return output;
}
 
源代码3 项目: weex   文件: AztecWriter.java
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;
}
 
源代码4 项目: QrCodeScanner   文件: OneDimensionalCodeWriter.java
/**
 * @return a byte array of horizontal pixels (0 = white, 1 = black)
 */
private static BitMatrix renderResult(boolean[] code, int width, int height, int sidesMargin) {
  int inputWidth = code.length;
  // Add quiet zone on both sides.
  int fullWidth = inputWidth + sidesMargin;
  int outputWidth = Math.max(width, fullWidth);
  int outputHeight = Math.max(1, height);

  int multiple = outputWidth / fullWidth;
  int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;

  BitMatrix output = new BitMatrix(outputWidth, outputHeight);
  for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
    if (code[inputX]) {
      output.setRegion(outputX, 0, multiple, outputHeight);
    }
  }
  return output;
}
 
源代码5 项目: ZXing-Orient   文件: OneDimensionalCodeWriter.java
/**
 * @return a byte array of horizontal pixels (0 = white, 1 = black)
 */
private static BitMatrix renderResult(boolean[] code, int width, int height, int sidesMargin) {
  int inputWidth = code.length;
  // Add quiet zone on both sides.
  int fullWidth = inputWidth + sidesMargin;
  int outputWidth = Math.max(width, fullWidth);
  int outputHeight = Math.max(1, height);

  int multiple = outputWidth / fullWidth;
  int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;

  BitMatrix output = new BitMatrix(outputWidth, outputHeight);
  for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
    if (code[inputX]) {
      output.setRegion(outputX, 0, multiple, outputHeight);
    }
  }
  return output;
}
 
源代码6 项目: RipplePower   文件: OneDimensionalCodeWriter.java
/**
 * @return a byte array of horizontal pixels (0 = white, 1 = black)
 */
private static BitMatrix renderResult(boolean[] code, int width, int height, int sidesMargin) {
	int inputWidth = code.length;
	// Add quiet zone on both sides.
	int fullWidth = inputWidth + sidesMargin;
	int outputWidth = Math.max(width, fullWidth);
	int outputHeight = Math.max(1, height);

	int multiple = outputWidth / fullWidth;
	int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;

	BitMatrix output = new BitMatrix(outputWidth, outputHeight);
	for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
		if (code[inputX]) {
			output.setRegion(outputX, 0, multiple, outputHeight);
		}
	}
	return output;
}
 
源代码7 项目: Telegram   文件: Version.java
/**
 * See ISO 18004:2006 Annex E
 */
BitMatrix buildFunctionPattern() {
  int dimension = getDimensionForVersion();
  BitMatrix bitMatrix = new BitMatrix(dimension);

  // Top left finder pattern + separator + format
  bitMatrix.setRegion(0, 0, 9, 9);
  // Top right finder pattern + separator + format
  bitMatrix.setRegion(dimension - 8, 0, 8, 9);
  // Bottom left finder pattern + separator + format
  bitMatrix.setRegion(0, dimension - 8, 9, 8);

  // Alignment patterns
  int max = alignmentPatternCenters.length;
  for (int x = 0; x < max; x++) {
    int i = alignmentPatternCenters[x] - 2;
    for (int y = 0; y < max; y++) {
      if ((x != 0 || (y != 0 && y != max - 1)) && (x != max - 1 || y != 0)) {
        bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5);
      }
      // else no o alignment patterns near the three finder patterns
    }
  }

  // Vertical timing pattern
  bitMatrix.setRegion(6, 9, 1, dimension - 17);
  // Horizontal timing pattern
  bitMatrix.setRegion(9, 6, dimension - 17, 1);

  if (versionNumber > 6) {
    // Version info, top right
    bitMatrix.setRegion(dimension - 11, 0, 3, 6);
    // Version info, bottom left
    bitMatrix.setRegion(0, dimension - 11, 6, 3);
  }

  return bitMatrix;
}
 
源代码8 项目: RipplePower   文件: Version.java
/**
 * See ISO 18004:2006 Annex E
 */
BitMatrix buildFunctionPattern() {
	int dimension = getDimensionForVersion();
	BitMatrix bitMatrix = new BitMatrix(dimension);

	// Top left finder pattern + separator + format
	bitMatrix.setRegion(0, 0, 9, 9);
	// Top right finder pattern + separator + format
	bitMatrix.setRegion(dimension - 8, 0, 8, 9);
	// Bottom left finder pattern + separator + format
	bitMatrix.setRegion(0, dimension - 8, 9, 8);

	// Alignment patterns
	int max = alignmentPatternCenters.length;
	for (int x = 0; x < max; x++) {
		int i = alignmentPatternCenters[x] - 2;
		for (int y = 0; y < max; y++) {
			if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) {
				// No alignment patterns near the three finder paterns
				continue;
			}
			bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5);
		}
	}

	// Vertical timing pattern
	bitMatrix.setRegion(6, 9, 1, dimension - 17);
	// Horizontal timing pattern
	bitMatrix.setRegion(9, 6, dimension - 17, 1);

	if (versionNumber > 6) {
		// Version info, top right
		bitMatrix.setRegion(dimension - 11, 0, 3, 6);
		// Version info, bottom left
		bitMatrix.setRegion(0, dimension - 11, 6, 3);
	}

	return bitMatrix;
}
 
源代码9 项目: ScreenCapture   文件: Version.java
/**
 * See ISO 18004:2006 Annex E
 */
BitMatrix buildFunctionPattern() {
  int dimension = getDimensionForVersion();
  BitMatrix bitMatrix = new BitMatrix(dimension);

  // Top left finder pattern + separator + format
  bitMatrix.setRegion(0, 0, 9, 9);
  // Top right finder pattern + separator + format
  bitMatrix.setRegion(dimension - 8, 0, 8, 9);
  // Bottom left finder pattern + separator + format
  bitMatrix.setRegion(0, dimension - 8, 9, 8);

  // Alignment patterns
  int max = alignmentPatternCenters.length;
  for (int x = 0; x < max; x++) {
    int i = alignmentPatternCenters[x] - 2;
    for (int y = 0; y < max; y++) {
      if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) {
        // No alignment patterns near the three finder patterns
        continue;
      }
      bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5);
    }
  }

  // Vertical timing pattern
  bitMatrix.setRegion(6, 9, 1, dimension - 17);
  // Horizontal timing pattern
  bitMatrix.setRegion(9, 6, dimension - 17, 1);

  if (versionNumber > 6) {
    // Version info, top right
    bitMatrix.setRegion(dimension - 11, 0, 3, 6);
    // Version info, bottom left
    bitMatrix.setRegion(0, dimension - 11, 6, 3);
  }

  return bitMatrix;
}
 
源代码10 项目: android-quick-response-code   文件: Version.java
/**
 * See ISO 18004:2006 Annex E
 */
BitMatrix buildFunctionPattern() {
    int dimension = getDimensionForVersion();
    BitMatrix bitMatrix = new BitMatrix(dimension);

    // Top left finder pattern + separator + format
    bitMatrix.setRegion(0, 0, 9, 9);
    // Top right finder pattern + separator + format
    bitMatrix.setRegion(dimension - 8, 0, 8, 9);
    // Bottom left finder pattern + separator + format
    bitMatrix.setRegion(0, dimension - 8, 9, 8);

    // Alignment patterns
    int max = alignmentPatternCenters.length;
    for (int x = 0; x < max; x++) {
        int i = alignmentPatternCenters[x] - 2;
        for (int y = 0; y < max; y++) {
            if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) {
                // No alignment patterns near the three finder paterns
                continue;
            }
            bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5);
        }
    }

    // Vertical timing pattern
    bitMatrix.setRegion(6, 9, 1, dimension - 17);
    // Horizontal timing pattern
    bitMatrix.setRegion(9, 6, dimension - 17, 1);

    if (versionNumber > 6) {
        // Version info, top right
        bitMatrix.setRegion(dimension - 11, 0, 3, 6);
        // Version info, bottom left
        bitMatrix.setRegion(0, dimension - 11, 6, 3);
    }

    return bitMatrix;
}
 
源代码11 项目: Tesseract-OCR-Scanner   文件: QRCodeWriter.java
private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) {
  ByteMatrix input = code.getMatrix();
  if (input == null) {
    throw new IllegalStateException();
  }
  int inputWidth = input.getWidth();
  int inputHeight = input.getHeight();
  int qrWidth = inputWidth + (quietZone * 2);
  int qrHeight = inputHeight + (quietZone * 2);
  int outputWidth = Math.max(width, qrWidth);
  int outputHeight = Math.max(height, qrHeight);

  int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
  // Padding includes both the quiet zone and the extra white pixels to accommodate the requested
  // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.
  // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will
  // handle all the padding from 100x100 (the actual QR) up to 200x160.
  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) == 1) {
        output.setRegion(outputX, outputY, multiple, multiple);
      }
    }
  }

  return output;
}
 
源代码12 项目: Tesseract-OCR-Scanner   文件: Version.java
/**
 * See ISO 18004:2006 Annex E
 */
BitMatrix buildFunctionPattern() {
  int dimension = getDimensionForVersion();
  BitMatrix bitMatrix = new BitMatrix(dimension);

  // Top left finder pattern + separator + format
  bitMatrix.setRegion(0, 0, 9, 9);
  // Top right finder pattern + separator + format
  bitMatrix.setRegion(dimension - 8, 0, 8, 9);
  // Bottom left finder pattern + separator + format
  bitMatrix.setRegion(0, dimension - 8, 9, 8);

  // Alignment patterns
  int max = alignmentPatternCenters.length;
  for (int x = 0; x < max; x++) {
    int i = alignmentPatternCenters[x] - 2;
    for (int y = 0; y < max; y++) {
      if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) {
        // No alignment patterns near the three finder patterns
        continue;
      }
      bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5);
    }
  }

  // Vertical timing pattern
  bitMatrix.setRegion(6, 9, 1, dimension - 17);
  // Horizontal timing pattern
  bitMatrix.setRegion(9, 6, dimension - 17, 1);

  if (versionNumber > 6) {
    // Version info, top right
    bitMatrix.setRegion(dimension - 11, 0, 3, 6);
    // Version info, bottom left
    bitMatrix.setRegion(0, dimension - 11, 6, 3);
  }

  return bitMatrix;
}
 
源代码13 项目: weex   文件: Version.java
/**
 * See ISO 18004:2006 Annex E
 */
BitMatrix buildFunctionPattern() {
  int dimension = getDimensionForVersion();
  BitMatrix bitMatrix = new BitMatrix(dimension);

  // Top left finder pattern + separator + format
  bitMatrix.setRegion(0, 0, 9, 9);
  // Top right finder pattern + separator + format
  bitMatrix.setRegion(dimension - 8, 0, 8, 9);
  // Bottom left finder pattern + separator + format
  bitMatrix.setRegion(0, dimension - 8, 9, 8);

  // Alignment patterns
  int max = alignmentPatternCenters.length;
  for (int x = 0; x < max; x++) {
    int i = alignmentPatternCenters[x] - 2;
    for (int y = 0; y < max; y++) {
      if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) {
        // No alignment patterns near the three finder paterns
        continue;
      }
      bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5);
    }
  }

  // Vertical timing pattern
  bitMatrix.setRegion(6, 9, 1, dimension - 17);
  // Horizontal timing pattern
  bitMatrix.setRegion(9, 6, dimension - 17, 1);

  if (versionNumber > 6) {
    // Version info, top right
    bitMatrix.setRegion(dimension - 11, 0, 3, 6);
    // Version info, bottom left
    bitMatrix.setRegion(0, dimension - 11, 6, 3);
  }

  return bitMatrix;
}
 
源代码14 项目: barcodescanner-lib-aar   文件: QRCodeWriter.java
private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) {
  ByteMatrix input = code.getMatrix();
  if (input == null) {
    throw new IllegalStateException();
  }
  int inputWidth = input.getWidth();
  int inputHeight = input.getHeight();
  int qrWidth = inputWidth + (quietZone * 2);
  int qrHeight = inputHeight + (quietZone * 2);
  int outputWidth = Math.max(width, qrWidth);
  int outputHeight = Math.max(height, qrHeight);

  int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
  // Padding includes both the quiet zone and the extra white pixels to accommodate the requested
  // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.
  // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will
  // handle all the padding from 100x100 (the actual QR) up to 200x160.
  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) == 1) {
        output.setRegion(outputX, outputY, multiple, multiple);
      }
    }
  }

  return output;
}
 
源代码15 项目: ZXing-Orient   文件: Version.java
/**
 * See ISO 18004:2006 Annex E
 */
BitMatrix buildFunctionPattern() {
  int dimension = getDimensionForVersion();
  BitMatrix bitMatrix = new BitMatrix(dimension);

  // Top left finder pattern + separator + format
  bitMatrix.setRegion(0, 0, 9, 9);
  // Top right finder pattern + separator + format
  bitMatrix.setRegion(dimension - 8, 0, 8, 9);
  // Bottom left finder pattern + separator + format
  bitMatrix.setRegion(0, dimension - 8, 9, 8);

  // Alignment patterns
  int max = alignmentPatternCenters.length;
  for (int x = 0; x < max; x++) {
    int i = alignmentPatternCenters[x] - 2;
    for (int y = 0; y < max; y++) {
      if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) {
        // No alignment patterns near the three finder paterns
        continue;
      }
      bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5);
    }
  }

  // Vertical timing pattern
  bitMatrix.setRegion(6, 9, 1, dimension - 17);
  // Horizontal timing pattern
  bitMatrix.setRegion(9, 6, dimension - 17, 1);

  if (versionNumber > 6) {
    // Version info, top right
    bitMatrix.setRegion(dimension - 11, 0, 3, 6);
    // Version info, bottom left
    bitMatrix.setRegion(0, dimension - 11, 6, 3);
  }

  return bitMatrix;
}
 
源代码16 项目: android-quick-response-code   文件: QRCodeWriter.java
private static BitMatrix renderResult(QRCode code, int width, int height) {
    ByteMatrix input = code.getMatrix();
    if (input == null) {
        throw new IllegalStateException();
    }
    int inputWidth = input.getWidth();
    int inputHeight = input.getHeight();
    int qrWidth = inputWidth + (QUIET_ZONE_SIZE << 1);
    int qrHeight = inputHeight + (QUIET_ZONE_SIZE << 1);
    int outputWidth = Math.max(width, qrWidth);
    int outputHeight = Math.max(height, qrHeight);

    int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
    // Padding includes both the quiet zone and the extra white pixels to
    // accommodate the
    // requested
    // dimensions. For example, if input is 25x25 the QR will be 33x33
    // including the quiet zone.
    // If the requested size is 200x160, the multiple will be 4, for a QR of
    // 132x132. These will
    // handle all the padding from 100x100 (the actual QR) up to 200x160.
    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) == 1) {
                output.setRegion(outputX, outputY, multiple, multiple);
            }
        }
    }

    return output;
}
 
private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) {
  ByteMatrix input = code.getMatrix();
  if (input == null) {
    throw new IllegalStateException();
  }
  int inputWidth = input.getWidth();
  int inputHeight = input.getHeight();
  int qrWidth = inputWidth + (quietZone * 2);
  int qrHeight = inputHeight + (quietZone * 2);
  int outputWidth = Math.max(width, qrWidth);
  int outputHeight = Math.max(height, qrHeight);

  int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
  // Padding includes both the quiet zone and the extra white pixels to accommodate the requested
  // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.
  // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will
  // handle all the padding from 100x100 (the actual QR) up to 200x160.
  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) == 1) {
        output.setRegion(outputX, outputY, multiple, multiple);
      }
    }
  }

  return output;
}
 
/**
 * See ISO 18004:2006 Annex E
 */
BitMatrix buildFunctionPattern() {
  int dimension = getDimensionForVersion();
  BitMatrix bitMatrix = new BitMatrix(dimension);

  // Top left finder pattern + separator + format
  bitMatrix.setRegion(0, 0, 9, 9);
  // Top right finder pattern + separator + format
  bitMatrix.setRegion(dimension - 8, 0, 8, 9);
  // Bottom left finder pattern + separator + format
  bitMatrix.setRegion(0, dimension - 8, 9, 8);

  // Alignment patterns
  int max = alignmentPatternCenters.length;
  for (int x = 0; x < max; x++) {
    int i = alignmentPatternCenters[x] - 2;
    for (int y = 0; y < max; y++) {
      if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) {
        // No alignment patterns near the three finder paterns
        continue;
      }
      bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5);
    }
  }

  // Vertical timing pattern
  bitMatrix.setRegion(6, 9, 1, dimension - 17);
  // Horizontal timing pattern
  bitMatrix.setRegion(9, 6, dimension - 17, 1);

  if (versionNumber > 6) {
    // Version info, top right
    bitMatrix.setRegion(dimension - 11, 0, 3, 6);
    // Version info, bottom left
    bitMatrix.setRegion(0, dimension - 11, 6, 3);
  }

  return bitMatrix;
}
 
源代码19 项目: MiBandDecompiled   文件: Version.java
BitMatrix a()
{
    int i = getDimensionForVersion();
    BitMatrix bitmatrix = new BitMatrix(i);
    bitmatrix.setRegion(0, 0, 9, 9);
    bitmatrix.setRegion(i - 8, 0, 8, 9);
    bitmatrix.setRegion(0, i - 8, 9, 8);
    int j = d.length;
    for (int k = 0; k < j; k++)
    {
        int l = -2 + d[k];
        int i1 = 0;
        while (i1 < j) 
        {
            if ((k != 0 || i1 != 0 && i1 != j - 1) && (k != j - 1 || i1 != 0))
            {
                bitmatrix.setRegion(-2 + d[i1], l, 5, 5);
            }
            i1++;
        }
    }

    bitmatrix.setRegion(6, 9, 1, i - 17);
    bitmatrix.setRegion(9, 6, i - 17, 1);
    if (c > 6)
    {
        bitmatrix.setRegion(i - 11, 0, 3, 6);
        bitmatrix.setRegion(0, i - 11, 6, 3);
    }
    return bitmatrix;
}
 
源代码20 项目: ShareBox   文件: QRCodeWriter.java
private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) {
    ByteMatrix input = code.getMatrix();
    if (input == null) {
        throw new IllegalStateException();
    }
    int inputWidth = input.getWidth();
    int inputHeight = input.getHeight();
    int qrWidth = inputWidth;
    int qrHeight = inputHeight;
    int outputWidth = Math.max(width, qrWidth);
    int outputHeight = Math.max(height, qrHeight);

    int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
    // Padding includes both the quiet zone and the extra white pixels to
    // accommodate the requested
    // dimensions. For example, if input is 25x25 the QR will be 33x33
    // including the quiet zone.
    // If the requested size is 200x160, the multiple will be 4, for a QR of
    // 132x132. These will
    // handle all the padding from 100x100 (the actual QR) up to 200x160.

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

    if (leftPadding >= 0) {
        outputWidth = outputWidth - 2 * leftPadding;
        leftPadding = 0;
    }
    if (topPadding >= 0) {
        outputHeight = outputHeight - 2 * topPadding;
        topPadding = 0;
    }

    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) == 1) {
                output.setRegion(outputX, outputY, multiple, multiple);
            }
        }
    }

    return output;
}