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


Java BitArray.getSizeInBytes方法代码示例

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


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

示例1: terminateBits

import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
static void terminateBits(int numDataBytes, BitArray bits) throws WriterException {
    int capacity = numDataBytes * 8;
    if (bits.getSize() > capacity) {
        throw new WriterException("data bits cannot fit in the QR Code" + bits.getSize() + " " +
                "> " + capacity);
    }
    int i;
    for (i = 0; i < 4 && bits.getSize() < capacity; i++) {
        bits.appendBit(false);
    }
    int numBitsInLastByte = bits.getSize() & 7;
    if (numBitsInLastByte > 0) {
        for (i = numBitsInLastByte; i < 8; i++) {
            bits.appendBit(false);
        }
    }
    int numPaddingBytes = numDataBytes - bits.getSizeInBytes();
    for (i = 0; i < numPaddingBytes; i++) {
        bits.appendBits((i & 1) == 0 ? 236 : 17, 8);
    }
    if (bits.getSize() != capacity) {
        throw new WriterException("Bits size does not equal capacity");
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:25,代码来源:Encoder.java

示例2: terminateBits

import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
/**
 * Terminate bits as described in 8.4.8 and 8.4.9 of JISX0510:2004 (p.24).
 */
static void terminateBits(int numDataBytes, BitArray bits) throws WriterException {
  int capacity = numDataBytes * 8;
  if (bits.getSize() > capacity) {
    throw new WriterException("data bits cannot fit in the QR Code" + bits.getSize() + " > " +
        capacity);
  }
  for (int i = 0; i < 4 && bits.getSize() < capacity; ++i) {
    bits.appendBit(false);
  }
  // Append termination bits. See 8.4.8 of JISX0510:2004 (p.24) for details.
  // If the last byte isn't 8-bit aligned, we'll add padding bits.
  int numBitsInLastByte = bits.getSize() & 0x07;    
  if (numBitsInLastByte > 0) {
    for (int i = numBitsInLastByte; i < 8; i++) {
      bits.appendBit(false);
    }
  }
  // If we have more space, we'll fill the space with padding patterns defined in 8.4.9 (p.24).
  int numPaddingBytes = numDataBytes - bits.getSizeInBytes();
  for (int i = 0; i < numPaddingBytes; ++i) {
    bits.appendBits((i & 0x01) == 0 ? 0xEC : 0x11, 8);
  }
  if (bits.getSize() != capacity) {
    throw new WriterException("Bits size does not equal capacity");
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:30,代码来源:Encoder.java

示例3: interleaveWithECBytes

import com.google.zxing.common.BitArray; //导入方法依赖的package包/类
static BitArray interleaveWithECBytes(BitArray bits, int numTotalBytes, int numDataBytes, int
        numRSBlocks) throws WriterException {
    if (bits.getSizeInBytes() != numDataBytes) {
        throw new WriterException("Number of bits and data bytes does not match");
    }
    int i;
    int dataBytesOffset = 0;
    int maxNumDataBytes = 0;
    int maxNumEcBytes = 0;
    Collection<BlockPair> blocks = new ArrayList(numRSBlocks);
    for (i = 0; i < numRSBlocks; i++) {
        int[] numDataBytesInBlock = new int[1];
        int[] numEcBytesInBlock = new int[1];
        getNumDataBytesAndNumECBytesForBlockID(numTotalBytes, numDataBytes, numRSBlocks, i,
                numDataBytesInBlock, numEcBytesInBlock);
        int size = numDataBytesInBlock[0];
        byte[] dataBytes = new byte[size];
        bits.toBytes(dataBytesOffset * 8, dataBytes, 0, size);
        byte[] ecBytes = generateECBytes(dataBytes, numEcBytesInBlock[0]);
        blocks.add(new BlockPair(dataBytes, ecBytes));
        maxNumDataBytes = Math.max(maxNumDataBytes, size);
        maxNumEcBytes = Math.max(maxNumEcBytes, ecBytes.length);
        dataBytesOffset += numDataBytesInBlock[0];
    }
    if (numDataBytes != dataBytesOffset) {
        throw new WriterException("Data bytes does not match offset");
    }
    BitArray result = new BitArray();
    for (i = 0; i < maxNumDataBytes; i++) {
        for (BlockPair block : blocks) {
            dataBytes = block.getDataBytes();
            if (i < dataBytes.length) {
                result.appendBits(dataBytes[i], 8);
            }
        }
    }
    for (i = 0; i < maxNumEcBytes; i++) {
        for (BlockPair block2 : blocks) {
            ecBytes = block2.getErrorCorrectionBytes();
            if (i < ecBytes.length) {
                result.appendBits(ecBytes[i], 8);
            }
        }
    }
    if (numTotalBytes == result.getSizeInBytes()) {
        return result;
    }
    throw new WriterException("Interleaving error: " + numTotalBytes + " and " + result
            .getSizeInBytes() + " differ.");
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:51,代码来源:Encoder.java


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