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


Java Version.getDimensionForVersion方法代码示例

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


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

示例1: processFinderPatternInfo

import com.google.zxing.qrcode.decoder.Version; //导入方法依赖的package包/类
protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info) throws
        NotFoundException, FormatException {
    ResultPoint topLeft = info.getTopLeft();
    ResultPoint topRight = info.getTopRight();
    FinderPattern bottomLeft = info.getBottomLeft();
    float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
    if (moduleSize < 1.0f) {
        throw NotFoundException.getNotFoundInstance();
    }
    int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
    Version provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
    int modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;
    AlignmentPattern alignmentPattern = null;
    if (provisionalVersion.getAlignmentPatternCenters().length > 0) {
        float correctionToTopLeft = 1.0f - (IPhotoView.DEFAULT_MAX_SCALE / ((float)
                modulesBetweenFPCenters));
        int estAlignmentX = (int) (topLeft.getX() + ((((topRight.getX() - topLeft.getX()) +
                bottomLeft.getX()) - topLeft.getX()) * correctionToTopLeft));
        int estAlignmentY = (int) (topLeft.getY() + ((((topRight.getY() - topLeft.getY()) +
                bottomLeft.getY()) - topLeft.getY()) * correctionToTopLeft));
        int i = 4;
        while (i <= 16) {
            try {
                alignmentPattern = findAlignmentInRegion(moduleSize, estAlignmentX,
                        estAlignmentY, (float) i);
                break;
            } catch (NotFoundException e) {
                i <<= 1;
            }
        }
    }
    return new DetectorResult(sampleGrid(this.image, createTransform(topLeft, topRight,
            bottomLeft, alignmentPattern, dimension), dimension), alignmentPattern == null ?
            new ResultPoint[]{bottomLeft, topLeft, topRight} : new ResultPoint[]{bottomLeft,
            topLeft, topRight, alignmentPattern});
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:37,代码来源:Detector.java

示例2: processFinderPatternInfo

import com.google.zxing.qrcode.decoder.Version; //导入方法依赖的package包/类
protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info)
    throws NotFoundException, FormatException {

  FinderPattern topLeft = info.getTopLeft();
  FinderPattern topRight = info.getTopRight();
  FinderPattern bottomLeft = info.getBottomLeft();

  float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
  if (moduleSize < 1.0f) {
    throw NotFoundException.getNotFoundInstance();
  }
  int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
  Version provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
  int modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;

  AlignmentPattern alignmentPattern = null;
  // Anything above version 1 has an alignment pattern
  if (provisionalVersion.getAlignmentPatternCenters().length > 0) {

    // Guess where a "bottom right" finder pattern would have been
    float bottomRightX = topRight.getX() - topLeft.getX() + bottomLeft.getX();
    float bottomRightY = topRight.getY() - topLeft.getY() + bottomLeft.getY();

    // Estimate that alignment pattern is closer by 3 modules
    // from "bottom right" to known top left location
    float correctionToTopLeft = 1.0f - 3.0f / (float) modulesBetweenFPCenters;
    int estAlignmentX = (int) (topLeft.getX() + correctionToTopLeft * (bottomRightX - topLeft.getX()));
    int estAlignmentY = (int) (topLeft.getY() + correctionToTopLeft * (bottomRightY - topLeft.getY()));

    // Kind of arbitrary -- expand search radius before giving up
    for (int i = 4; i <= 16; i <<= 1) {
      try {
        alignmentPattern = findAlignmentInRegion(moduleSize,
            estAlignmentX,
            estAlignmentY,
            (float) i);
        break;
      } catch (NotFoundException re) {
        // try next round
      }
    }
    // If we didn't find alignment pattern... well try anyway without it
  }

  PerspectiveTransform transform =
      createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);

  BitMatrix bits = sampleGrid(image, transform, dimension);

  ResultPoint[] points;
  if (alignmentPattern == null) {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight};
  } else {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight, alignmentPattern};
  }
  return new DetectorResult(bits, points);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:58,代码来源:Detector.java

示例3: processFinderPatternInfo

import com.google.zxing.qrcode.decoder.Version; //导入方法依赖的package包/类
protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info)
    throws NotFoundException, FormatException {

  FinderPattern topLeft = info.getTopLeft();
  FinderPattern topRight = info.getTopRight();
  FinderPattern bottomLeft = info.getBottomLeft();

  float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
  if (moduleSize < 1.0f) {
    throw NotFoundException.getNotFoundInstance();
  }
  int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
  Version provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
  int modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;

  AlignmentPattern alignmentPattern = null;
  // Anything above version 1 has an alignment pattern
  if (provisionalVersion.getAlignmentPatternCenters().length > 0) {

    // Guess where a "bottom right" finder pattern would have been
    float bottomRightX = topRight.getX() - topLeft.getX() + bottomLeft.getX();
    float bottomRightY = topRight.getY() - topLeft.getY() + bottomLeft.getY();

    // Estimate that alignment pattern is closer by 3 modules
    // from "bottom right" to known top left location
    float correctionToTopLeft = 1.0f - 3.0f / modulesBetweenFPCenters;
    int estAlignmentX = (int) (topLeft.getX() + correctionToTopLeft * (bottomRightX - topLeft.getX()));
    int estAlignmentY = (int) (topLeft.getY() + correctionToTopLeft * (bottomRightY - topLeft.getY()));

    // Kind of arbitrary -- expand search radius before giving up
    for (int i = 4; i <= 16; i <<= 1) {
      try {
        alignmentPattern = findAlignmentInRegion(moduleSize,
            estAlignmentX,
            estAlignmentY,
            i);
        break;
      } catch (NotFoundException re) {
        // try next round
      }
    }
    // If we didn't find alignment pattern... well try anyway without it
  }

  PerspectiveTransform transform =
      createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);

  BitMatrix bits = sampleGrid(image, transform, dimension);

  ResultPoint[] points;
  if (alignmentPattern == null) {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight};
  } else {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight, alignmentPattern};
  }
  return new DetectorResult(bits, points);
}
 
开发者ID:10045125,项目名称:QrCode,代码行数:58,代码来源:Detector.java

示例4: encode

import com.google.zxing.qrcode.decoder.Version; //导入方法依赖的package包/类
public static QRCode encode(String content, ErrorCorrectionLevel ecLevel, Map<EncodeHintType,
        ?> hints) throws WriterException {
    String encoding;
    if (hints == null) {
        encoding = null;
    } else {
        encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
    }
    if (encoding == null) {
        encoding = DEFAULT_BYTE_MODE_ENCODING;
    }
    Mode mode = chooseMode(content, encoding);
    BitArray headerBits = new BitArray();
    if (mode == Mode.BYTE && !DEFAULT_BYTE_MODE_ENCODING.equals(encoding)) {
        CharacterSetECI eci = CharacterSetECI.getCharacterSetECIByName(encoding);
        if (eci != null) {
            appendECI(eci, headerBits);
        }
    }
    appendModeInfo(mode, headerBits);
    BitArray dataBits = new BitArray();
    appendBytes(content, mode, dataBits, encoding);
    Version version = chooseVersion((headerBits.getSize() + mode.getCharacterCountBits
            (chooseVersion((headerBits.getSize() + mode.getCharacterCountBits(Version
                    .getVersionForNumber(1))) + dataBits.getSize(), ecLevel))) + dataBits
            .getSize(), ecLevel);
    BitArray headerAndDataBits = new BitArray();
    headerAndDataBits.appendBitArray(headerBits);
    appendLengthInfo(mode == Mode.BYTE ? dataBits.getSizeInBytes() : content.length(),
            version, mode, headerAndDataBits);
    headerAndDataBits.appendBitArray(dataBits);
    ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel);
    int numDataBytes = version.getTotalCodewords() - ecBlocks.getTotalECCodewords();
    terminateBits(numDataBytes, headerAndDataBits);
    BitArray finalBits = interleaveWithECBytes(headerAndDataBits, version.getTotalCodewords()
            , numDataBytes, ecBlocks.getNumBlocks());
    QRCode qrCode = new QRCode();
    qrCode.setECLevel(ecLevel);
    qrCode.setMode(mode);
    qrCode.setVersion(version);
    int dimension = version.getDimensionForVersion();
    ByteMatrix matrix = new ByteMatrix(dimension, dimension);
    int maskPattern = chooseMaskPattern(finalBits, ecLevel, version, matrix);
    qrCode.setMaskPattern(maskPattern);
    MatrixUtil.buildMatrix(finalBits, ecLevel, version, maskPattern, matrix);
    qrCode.setMatrix(matrix);
    return qrCode;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:49,代码来源:Encoder.java


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