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


Java BitMatrix.getTopLeftOnBit方法代码示例

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


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

示例1: 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

示例2: 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.qrcode.QRCodeReader#extractPureBits(BitMatrix)
 */
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 right = rightBottomBlack[0];

  int matrixWidth = (right - left + 1) / moduleSize;
  int matrixHeight = (bottom - top + 1) / moduleSize;
  if (matrixWidth <= 0 || matrixHeight <= 0) {
    throw NotFoundException.getNotFoundInstance();
  }

  // Push in the "border" by half the module width so that we start
  // sampling in the middle of the module. Just in case the image is a
  // little off, this will help recover.
  int nudge = moduleSize / 2;
  top += nudge;
  left += nudge;

  // Now just read off the bits
  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(left + x * moduleSize, iOffset)) {
        bits.set(x, y);
      }
    }
  }
  return bits;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:49,代码来源:DataMatrixReader.java

示例3: 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();
    }
    float moduleSize = moduleSize(leftTopBlack, image);
    int top = leftTopBlack[1];
    int bottom = rightBottomBlack[1];
    int left = leftTopBlack[0];
    int right = rightBottomBlack[0];
    if (left >= right || top >= bottom) {
        throw NotFoundException.getNotFoundInstance();
    }
    if (bottom - top != right - left) {
        right = left + (bottom - top);
    }
    int matrixWidth = Math.round(((float) ((right - left) + 1)) / moduleSize);
    int matrixHeight = Math.round(((float) ((bottom - top) + 1)) / moduleSize);
    if (matrixWidth <= 0 || matrixHeight <= 0) {
        throw NotFoundException.getNotFoundInstance();
    } else if (matrixHeight != matrixWidth) {
        throw NotFoundException.getNotFoundInstance();
    } else {
        int nudge = (int) (moduleSize / 2.0f);
        top += nudge;
        left += nudge;
        int nudgedTooFarRight = (((int) (((float) (matrixWidth - 1)) * moduleSize)) + left) -
                right;
        if (nudgedTooFarRight > 0) {
            if (nudgedTooFarRight > nudge) {
                throw NotFoundException.getNotFoundInstance();
            }
            left -= nudgedTooFarRight;
        }
        int nudgedTooFarDown = (((int) (((float) (matrixHeight - 1)) * moduleSize)) + top) -
                bottom;
        if (nudgedTooFarDown > 0) {
            if (nudgedTooFarDown > nudge) {
                throw NotFoundException.getNotFoundInstance();
            }
            top -= nudgedTooFarDown;
        }
        BitMatrix bits = new BitMatrix(matrixWidth, matrixHeight);
        for (int y = 0; y < matrixHeight; y++) {
            int iOffset = top + ((int) (((float) y) * moduleSize));
            for (int x = 0; x < matrixWidth; x++) {
                if (image.get(((int) (((float) x) * moduleSize)) + left, iOffset)) {
                    bits.set(x, y);
                }
            }
        }
        return bits;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:56,代码来源:QRCodeReader.java


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