當前位置: 首頁>>代碼示例>>Java>>正文


Java BitMatrix.setRegion方法代碼示例

本文整理匯總了Java中com.google.zxing.common.BitMatrix.setRegion方法的典型用法代碼示例。如果您正苦於以下問題:Java BitMatrix.setRegion方法的具體用法?Java BitMatrix.setRegion怎麽用?Java BitMatrix.setRegion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.zxing.common.BitMatrix的用法示例。


在下文中一共展示了BitMatrix.setRegion方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: renderResult

import com.google.zxing.common.BitMatrix; //導入方法依賴的package包/類
/**
 * @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;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:22,代碼來源:OneDimensionalCodeWriter.java

示例2: renderResult

import com.google.zxing.common.BitMatrix; //導入方法依賴的package包/類
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;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:27,代碼來源:AztecWriter.java

示例3: renderResult

import com.google.zxing.common.BitMatrix; //導入方法依賴的package包/類
private static BitMatrix renderResult(boolean[] code, int width, int height, int sidesMargin) {
    int inputWidth = code.length;
    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);
    int inputX = 0;
    int outputX = leftPadding;
    while (inputX < inputWidth) {
        if (code[inputX]) {
            output.setRegion(outputX, 0, multiple, outputHeight);
        }
        inputX++;
        outputX += multiple;
    }
    return output;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:20,代碼來源:OneDimensionalCodeWriter.java

示例4: renderResult

import com.google.zxing.common.BitMatrix; //導入方法依賴的package包/類
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;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:34,代碼來源:QRCodeWriter.java

示例5: buildFunctionPattern

import com.google.zxing.common.BitMatrix; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:42,代碼來源:Version.java

示例6: buildFunctionPattern

import com.google.zxing.common.BitMatrix; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:10045125,項目名稱:QrCode,代碼行數:42,代碼來源:Version.java

示例7: renderResult

import com.google.zxing.common.BitMatrix; //導入方法依賴的package包/類
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 << 1);
    int qrHeight = inputHeight + (quietZone << 1);
    int outputWidth = Math.max(width, qrWidth);
    int outputHeight = Math.max(height, qrHeight);
    int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
    int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
    int topPadding = (outputHeight - (inputHeight * multiple)) / 2;
    BitMatrix output = new BitMatrix(outputWidth, outputHeight);
    int inputY = 0;
    int outputY = topPadding;
    while (inputY < inputHeight) {
        int inputX = 0;
        int outputX = leftPadding;
        while (inputX < inputWidth) {
            if (input.get(inputX, inputY) == (byte) 1) {
                output.setRegion(outputX, outputY, multiple, multiple);
            }
            inputX++;
            outputX += multiple;
        }
        inputY++;
        outputY += multiple;
    }
    return output;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:33,代碼來源:QRCodeWriter.java

示例8: renderResult

import com.google.zxing.common.BitMatrix; //導入方法依賴的package包/類
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);
    int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
    int topPadding = (outputHeight - (inputHeight * multiple)) / 2;
    BitMatrix output = new BitMatrix(outputWidth, outputHeight);
    int inputY = 0;
    int outputY = topPadding;
    while (inputY < inputHeight) {
        int inputX = 0;
        int outputX = leftPadding;
        while (inputX < inputWidth) {
            if (input.get(inputX, inputY) == (byte) 1) {
                output.setRegion(outputX, outputY, multiple, multiple);
            }
            inputX++;
            outputX += multiple;
        }
        inputY++;
        outputY += multiple;
    }
    return output;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:33,代碼來源:QRCodeWriter.java

示例9: buildFunctionPattern

import com.google.zxing.common.BitMatrix; //導入方法依賴的package包/類
BitMatrix buildFunctionPattern() {
    int dimension = getDimensionForVersion();
    BitMatrix bitMatrix = new BitMatrix(dimension);
    bitMatrix.setRegion(0, 0, 9, 9);
    bitMatrix.setRegion(dimension - 8, 0, 8, 9);
    bitMatrix.setRegion(0, dimension - 8, 9, 8);
    int max = this.alignmentPatternCenters.length;
    int x = 0;
    while (x < max) {
        int i = this.alignmentPatternCenters[x] - 2;
        int y = 0;
        while (y < max) {
            if (!((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0))) {
                bitMatrix.setRegion(this.alignmentPatternCenters[y] - 2, i, 5, 5);
            }
            y++;
        }
        x++;
    }
    bitMatrix.setRegion(6, 9, 1, dimension - 17);
    bitMatrix.setRegion(9, 6, dimension - 17, 1);
    if (this.versionNumber > 6) {
        bitMatrix.setRegion(dimension - 11, 0, 3, 6);
        bitMatrix.setRegion(0, dimension - 11, 6, 3);
    }
    return bitMatrix;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:28,代碼來源:Version.java

示例10: renderResult

import com.google.zxing.common.BitMatrix; //導入方法依賴的package包/類
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);
    int inputY = 0;
    int outputY = topPadding;
    while (inputY < inputHeight) {
        int inputX = 0;
        int outputX = leftPadding;
        while (inputX < inputWidth) {
            if (input.get(inputX, inputY)) {
                output.setRegion(outputX, outputY, multiple, multiple);
            }
            inputX++;
            outputX += multiple;
        }
        inputY++;
        outputY += multiple;
    }
    return output;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:31,代碼來源:AztecWriter.java


注:本文中的com.google.zxing.common.BitMatrix.setRegion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。