本文整理汇总了Java中com.google.zxing.common.BitArray.appendBit方法的典型用法代码示例。如果您正苦于以下问题:Java BitArray.appendBit方法的具体用法?Java BitArray.appendBit怎么用?Java BitArray.appendBit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.zxing.common.BitArray
的用法示例。
在下文中一共展示了BitArray.appendBit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
}
示例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");
}
}