当前位置: 首页>>代码示例>>Java>>正文


Java BitMatrix.set方法代码示例

本文整理汇总了Java中com.google.zxing.common.BitMatrix.set方法的典型用法代码示例。如果您正苦于以下问题:Java BitMatrix.set方法的具体用法?Java BitMatrix.set怎么用?Java BitMatrix.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.zxing.common.BitMatrix的用法示例。


在下文中一共展示了BitMatrix.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateBit

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
/**
 * Get BitMatrix
 *
 * @param matrix BitMatrix
 * @param margin margin
 * @return BitMatrix
 */
public static BitMatrix updateBit(BitMatrix matrix, int margin) {
    int tempM = margin * 2;
    int[] rec = matrix.getEnclosingRectangle();   //Gets the properties of the two-dimensional code pattern
    int resWidth = rec[2] + tempM;
    int resHeight = rec[3] + tempM;
    BitMatrix resMatrix = new BitMatrix(resWidth, resHeight); //Generates a new BitMatrix according to the custom borders
    resMatrix.clear();
    for (int i = margin; i < resWidth - margin; i++) {   //Loop to draw the 2D code pattern into the new bitMatrix
        for (int j = margin; j < resHeight - margin; j++) {
            if (matrix.get(i - margin + rec[0], j - margin + rec[1])) {
                resMatrix.set(i, j);
            }
        }
    }
    return resMatrix;
}
 
开发者ID:Jusenr,项目名称:androidtools,代码行数:24,代码来源:QRCodeUtils.java

示例2: drawBullsEye

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
private static void drawBullsEye(BitMatrix matrix, int center, int size) {
  for (int i = 0; i < size; i += 2) {
    for (int j = center - i; j <= center + i; j++) {
      matrix.set(j, center - i);
      matrix.set(j, center + i);
      matrix.set(center - i, j);
      matrix.set(center + i, j);
    }
  }
  matrix.set(center - size, center - size);
  matrix.set(center - size + 1, center - size);
  matrix.set(center - size, center - size + 1);
  matrix.set(center + size, center - size);
  matrix.set(center + size, center - size + 1);
  matrix.set(center + size, center + size - 1);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:17,代码来源:Encoder.java

示例3: convertByteMatrixToBitMatrix

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
/**
 * Convert the ByteMatrix to BitMatrix.
 *
 * @param matrix The input matrix.
 * @return The output matrix.
 */
private static BitMatrix convertByteMatrixToBitMatrix(ByteMatrix matrix) {
  int matrixWidgth = matrix.getWidth();
  int matrixHeight = matrix.getHeight();

  BitMatrix output = new BitMatrix(matrixWidgth, matrixHeight);
  output.clear();
  for (int i = 0; i < matrixWidgth; i++) {
    for (int j = 0; j < matrixHeight; j++) {
      // Zero is white in the bytematrix
      if (matrix.get(i, j) == 1) {
        output.set(i, j);
      }
    }
  }

  return output;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:24,代码来源:DataMatrixWriter.java

示例4: extractPureBits

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
/**
 * This method detects a code in a "pure" image -- that is, pure monochrome image
 * which contains only an unrotated, unskewed, image of a code, with some white border
 * around it. This is a specialized method that works exceptionally fast in this special
 * case.
 *
 * @see com.google.zxing.datamatrix.DataMatrixReader#extractPureBits(BitMatrix)
 * @see com.google.zxing.qrcode.QRCodeReader#extractPureBits(BitMatrix)
 */
private static BitMatrix extractPureBits(BitMatrix image) throws NotFoundException {
  
  int[] enclosingRectangle = image.getEnclosingRectangle();
  if (enclosingRectangle == null) {
    throw NotFoundException.getNotFoundInstance();
  }
  
  int left = enclosingRectangle[0];
  int top = enclosingRectangle[1];
  int width = enclosingRectangle[2];
  int height = enclosingRectangle[3];

  // Now just read off the bits
  BitMatrix bits = new BitMatrix(MATRIX_WIDTH, MATRIX_HEIGHT);
  for (int y = 0; y < MATRIX_HEIGHT; y++) {
    int iy = top + (y * height + height / 2) / MATRIX_HEIGHT;
    for (int x = 0; x < MATRIX_WIDTH; x++) {
      int ix = left + (x * width + width / 2 + (y & 0x01) *  width / 2) / MATRIX_WIDTH;
      if (image.get(ix, iy)) {
        bits.set(x, y);
      }
    }
  }
  return bits;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:35,代码来源:MaxiCodeReader.java

示例5: bitMatrixFrombitArray

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
private static BitMatrix bitMatrixFrombitArray(byte[][] input) {
    BitMatrix output = new BitMatrix(input[0].length + 60, input.length + 60);
    output.clear();
    int y = 0;
    int yOutput = output.getHeight() - 30;
    while (y < input.length) {
        for (int x = 0; x < input[0].length; x++) {
            if (input[y][x] == (byte) 1) {
                output.set(x + 30, yOutput);
            }
        }
        y++;
        yOutput--;
    }
    return output;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:17,代码来源:PDF417Writer.java

示例6: bitMatrixFrombitArray

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
private static BitMatrix bitMatrixFrombitArray(byte[][] input, int margin) {
    BitMatrix output = new BitMatrix(input[0].length + (margin * 2), input.length + (margin *
            2));
    output.clear();
    int y = 0;
    int yOutput = (output.getHeight() - margin) - 1;
    while (y < input.length) {
        for (int x = 0; x < input[0].length; x++) {
            if (input[y][x] == (byte) 1) {
                output.set(x + margin, yOutput);
            }
        }
        y++;
        yOutput--;
    }
    return output;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:PDF417Writer.java

示例7: extractPureBits

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
private static BitMatrix extractPureBits(BitMatrix image) throws NotFoundException {
    int[] enclosingRectangle = image.getEnclosingRectangle();
    if (enclosingRectangle == null) {
        throw NotFoundException.getNotFoundInstance();
    }
    int left = enclosingRectangle[0];
    int top = enclosingRectangle[1];
    int width = enclosingRectangle[2];
    int height = enclosingRectangle[3];
    BitMatrix bits = new BitMatrix(30, 33);
    for (int y = 0; y < 33; y++) {
        int iy = top + (((y * height) + (height / 2)) / 33);
        for (int x = 0; x < 30; x++) {
            if (image.get(left + ((((x * width) + (width / 2)) + (((y & 1) * width) / 2)) /
                    30), iy)) {
                bits.set(x, y);
            }
        }
    }
    return bits;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:MaxiCodeReader.java

示例8: bitMatrixFrombitArray

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
/**
 * This takes an array holding the values of the PDF 417
 *
 * @param input a byte array of information with 0 is black, and 1 is white
 * @param margin border around the barcode
 * @return BitMatrix of the input
 */
private static BitMatrix bitMatrixFrombitArray(byte[][] input, int margin) {
  // Creates the bitmatrix with extra space for whitespace
  BitMatrix output = new BitMatrix(input[0].length + 2 * margin, input.length + 2 * margin);
  output.clear();
  for (int y = 0, yOutput = output.getHeight() - margin - 1; y < input.length; y++, yOutput--) {
    for (int x = 0; x < input[0].length; x++) {
      // Zero is white in the bytematrix
      if (input[y][x] == 1) {
        output.set(x + margin, yOutput);
      }
    }
  }
  return output;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:22,代码来源:PDF417Writer.java

示例9: decode

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
/**
 * <p>Convenience method that can decode a QR Code represented as a 2D array of booleans.
 * "true" is taken to mean a black module.</p>
 *
 * @param image booleans representing white/black QR Code modules
 * @param hints decoding hints that should be used to influence decoding
 * @return text and bytes encoded within the QR Code
 * @throws FormatException if the QR Code cannot be decoded
 * @throws ChecksumException if error correction fails
 */
public DecoderResult decode(boolean[][] image, Map<DecodeHintType,?> hints)
    throws ChecksumException, FormatException {
  int dimension = image.length;
  BitMatrix bits = new BitMatrix(dimension);
  for (int i = 0; i < dimension; i++) {
    for (int j = 0; j < dimension; j++) {
      if (image[i][j]) {
        bits.set(j, i);
      }
    }
  }
  return decode(bits, hints);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:24,代码来源:Decoder.java

示例10: extractDataRegion

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
/**
 * <p>Extracts the data region from a {@link BitMatrix} that contains
 * alignment patterns.</p>
 * 
 * @param bitMatrix Original {@link BitMatrix} with alignment patterns
 * @return BitMatrix that has the alignment patterns removed
 */
BitMatrix extractDataRegion(BitMatrix bitMatrix) {
  int symbolSizeRows = version.getSymbolSizeRows();
  int symbolSizeColumns = version.getSymbolSizeColumns();
  
  if (bitMatrix.getHeight() != symbolSizeRows) {
    throw new IllegalArgumentException("Dimension of bitMarix must match the version size");
  }
  
  int dataRegionSizeRows = version.getDataRegionSizeRows();
  int dataRegionSizeColumns = version.getDataRegionSizeColumns();
  
  int numDataRegionsRow = symbolSizeRows / dataRegionSizeRows;
  int numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns;
  
  int sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows;
  int sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns;
  
  BitMatrix bitMatrixWithoutAlignment = new BitMatrix(sizeDataRegionColumn, sizeDataRegionRow);
  for (int dataRegionRow = 0; dataRegionRow < numDataRegionsRow; ++dataRegionRow) {
    int dataRegionRowOffset = dataRegionRow * dataRegionSizeRows;
    for (int dataRegionColumn = 0; dataRegionColumn < numDataRegionsColumn; ++dataRegionColumn) {
      int dataRegionColumnOffset = dataRegionColumn * dataRegionSizeColumns;
      for (int i = 0; i < dataRegionSizeRows; ++i) {
        int readRowOffset = dataRegionRow * (dataRegionSizeRows + 2) + 1 + i;
        int writeRowOffset = dataRegionRowOffset + i;
        for (int j = 0; j < dataRegionSizeColumns; ++j) {
          int readColumnOffset = dataRegionColumn * (dataRegionSizeColumns + 2) + 1 + j;
          if (bitMatrix.get(readColumnOffset, readRowOffset)) {
            int writeColumnOffset = dataRegionColumnOffset + j;
            bitMatrixWithoutAlignment.set(writeColumnOffset, writeRowOffset);
          }
        }
      }
    }
  }
  return bitMatrixWithoutAlignment;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:45,代码来源:BitMatrixParser.java

示例11: decode

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
/**
 * <p>Convenience method that can decode a Data Matrix Code represented as a 2D array of booleans.
 * "true" is taken to mean a black module.</p>
 *
 * @param image booleans representing white/black Data Matrix Code modules
 * @return text and bytes encoded within the Data Matrix Code
 * @throws FormatException if the Data Matrix Code cannot be decoded
 * @throws ChecksumException if error correction fails
 */
public DecoderResult decode(boolean[][] image) throws FormatException, ChecksumException {
  int dimension = image.length;
  BitMatrix bits = new BitMatrix(dimension);
  for (int i = 0; i < dimension; i++) {
    for (int j = 0; j < dimension; j++) {
      if (image[i][j]) {
        bits.set(j, i);
      }
    }
  }
  return decode(bits);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:22,代码来源:Decoder.java

示例12: deleteWhite

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
public static BitMatrix deleteWhite(BitMatrix matrix){
	int[] rec = matrix.getEnclosingRectangle();
	int resWidth = rec[2] + 1;
	int resHeight = rec[3] + 1;

	BitMatrix resMatrix = new BitMatrix(resWidth, resHeight);
	resMatrix.clear();
	for (int i = 0; i < resWidth; i++) {
		for (int j = 0; j < resHeight; j++) {
			if (matrix.get(i + rec[0], j + rec[1]))
				resMatrix.set(i, j);
		}
	}
	return resMatrix;
}
 
开发者ID:thlws,项目名称:payment-wechat,代码行数:16,代码来源:ZxingUtil.java

示例13: decode

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
public DecoderResult decode(boolean[][] image, Map<DecodeHintType, ?> hints) throws
        ChecksumException, FormatException {
    int dimension = image.length;
    BitMatrix bits = new BitMatrix(dimension);
    for (int i = 0; i < dimension; i++) {
        for (int j = 0; j < dimension; j++) {
            if (image[i][j]) {
                bits.set(j, i);
            }
        }
    }
    return decode(bits, (Map) hints);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:Decoder.java

示例14: drawModeMessage

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
private static void drawModeMessage(BitMatrix matrix, boolean compact, int matrixSize,
                                    BitArray modeMessage) {
    int center = matrixSize / 2;
    int i;
    int offset;
    if (compact) {
        for (i = 0; i < 7; i++) {
            offset = (center - 3) + i;
            if (modeMessage.get(i)) {
                matrix.set(offset, center - 5);
            }
            if (modeMessage.get(i + 7)) {
                matrix.set(center + 5, offset);
            }
            if (modeMessage.get(20 - i)) {
                matrix.set(offset, center + 5);
            }
            if (modeMessage.get(27 - i)) {
                matrix.set(center - 5, offset);
            }
        }
        return;
    }
    for (i = 0; i < 10; i++) {
        offset = ((center - 5) + i) + (i / 5);
        if (modeMessage.get(i)) {
            matrix.set(offset, center - 7);
        }
        if (modeMessage.get(i + 10)) {
            matrix.set(center + 7, offset);
        }
        if (modeMessage.get(29 - i)) {
            matrix.set(offset, center + 7);
        }
        if (modeMessage.get(39 - i)) {
            matrix.set(center - 7, offset);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:40,代码来源:Encoder.java

示例15: extractPureBits

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
private static BitMatrix extractPureBits(BitMatrix image) throws NotFoundException {
    int[] leftTopBlack = image.getTopLeftOnBit();
    int[] rightBottomBlack = image.getBottomRightOnBit();
    if (leftTopBlack == null || rightBottomBlack == null) {
        throw NotFoundException.getNotFoundInstance();
    }
    int moduleSize = moduleSize(leftTopBlack, image);
    int top = leftTopBlack[1];
    int bottom = rightBottomBlack[1];
    int left = leftTopBlack[0];
    int matrixWidth = ((rightBottomBlack[0] - left) + 1) / moduleSize;
    int matrixHeight = ((bottom - top) + 1) / moduleSize;
    if (matrixWidth <= 0 || matrixHeight <= 0) {
        throw NotFoundException.getNotFoundInstance();
    }
    int nudge = moduleSize / 2;
    top += nudge;
    left += nudge;
    BitMatrix bits = new BitMatrix(matrixWidth, matrixHeight);
    for (int y = 0; y < matrixHeight; y++) {
        int iOffset = top + (y * moduleSize);
        for (int x = 0; x < matrixWidth; x++) {
            if (image.get((x * moduleSize) + left, iOffset)) {
                bits.set(x, y);
            }
        }
    }
    return bits;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:30,代码来源:DataMatrixReader.java


注:本文中的com.google.zxing.common.BitMatrix.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。