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


Java Version.getTotalCodewords方法代码示例

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


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

示例1: chooseVersion

import com.google.zxing.qrcode.decoder.Version; //导入方法依赖的package包/类
private static Version chooseVersion(int numInputBits, ErrorCorrectionLevel ecLevel) throws WriterException {
  // In the following comments, we use numbers of Version 7-H.
  for (int versionNum = 1; versionNum <= 40; versionNum++) {
    Version version = Version.getVersionForNumber(versionNum);
    // numBytes = 196
    int numBytes = version.getTotalCodewords();
    // getNumECBytes = 130
    Version.ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel);
    int numEcBytes = ecBlocks.getTotalECCodewords();
    // getNumDataBytes = 196 - 130 = 66
    int numDataBytes = numBytes - numEcBytes;
    int totalInputBytes = (numInputBits + 7) / 8;
    if (numDataBytes >= totalInputBytes) {
      return version;
    }
  }
  throw new WriterException("Data too big");
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:19,代码来源:Encoder.java

示例2: willFit

import com.google.zxing.qrcode.decoder.Version; //导入方法依赖的package包/类
/**
 * @return true if the number of input bits will fit in a code with the specified version and
 * error correction level.
 */
private static boolean willFit(int numInputBits, Version version, ErrorCorrectionLevel ecLevel) {
    // In the following comments, we use numbers of Version 7-H.
    // numBytes = 196
    int numBytes = version.getTotalCodewords();
    // getNumECBytes = 130
    Version.ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel);
    int numEcBytes = ecBlocks.getTotalECCodewords();
    // getNumDataBytes = 196 - 130 = 66
    int numDataBytes = numBytes - numEcBytes;
    int totalInputBytes = (numInputBits + 7) / 8;
    return numDataBytes >= totalInputBytes;
}
 
开发者ID:10045125,项目名称:QrCode,代码行数:17,代码来源:Encoder.java

示例3: chooseVersion

import com.google.zxing.qrcode.decoder.Version; //导入方法依赖的package包/类
private static Version chooseVersion(int numInputBits, ErrorCorrectionLevel ecLevel) throws
        WriterException {
    for (int versionNum = 1; versionNum <= 40; versionNum++) {
        Version version = Version.getVersionForNumber(versionNum);
        if (version.getTotalCodewords() - version.getECBlocksForLevel(ecLevel)
                .getTotalECCodewords() >= (numInputBits + 7) / 8) {
            return version;
        }
    }
    throw new WriterException("Data too big");
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:Encoder.java

示例4: willFit

import com.google.zxing.qrcode.decoder.Version; //导入方法依赖的package包/类
/**
 * @return true if the number of input bits will fit in a code with the specified version and
 * error correction level.
 */
private static boolean willFit(int numInputBits, Version version, ErrorCorrectionLevel ecLevel) {
  // In the following comments, we use numbers of Version 7-H.
    // numBytes = 196
    int numBytes = version.getTotalCodewords();
    // getNumECBytes = 130
    Version.ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel);
    int numEcBytes = ecBlocks.getTotalECCodewords();
    // getNumDataBytes = 196 - 130 = 66
    int numDataBytes = numBytes - numEcBytes;
    int totalInputBytes = (numInputBits + 7) / 8;
  return numDataBytes >= totalInputBytes;
}
 
开发者ID:SpeedyFireCyclone,项目名称:Cardstore,代码行数:17,代码来源:Encoder.java

示例5: 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.getTotalCodewords方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。