com.google.zxing.common.BitArray#appendBit ( )源码实例Demo

下面列出了com.google.zxing.common.BitArray#appendBit ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ScreenCapture   文件: Encoder.java
/**
 * 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");
  }
}
 
源代码2 项目: Tesseract-OCR-Scanner   文件: Encoder.java
/**
 * 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");
  }
}
 
源代码3 项目: QrCodeScanner   文件: Encoder.java
/**
 * 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");
  }
}
 
源代码4 项目: ZXing-Orient   文件: Encoder.java
/**
 * 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");
  }
}
 
/**
 * 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");
  }
}
 
源代码6 项目: weex   文件: Encoder.java
/**
 * 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");
  }
}
 
源代码7 项目: barcodescanner-lib-aar   文件: Encoder.java
/**
 * 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");
  }
}
 
源代码8 项目: reacteu-app   文件: Encoder.java
/**
 * 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 << 3;
  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");
  }
}
 
源代码9 项目: RipplePower   文件: Encoder.java
/**
 * 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");
	}
}
 
源代码10 项目: Telegram-FOSS   文件: Encoder.java
/**
 * 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");
  }
}
 
源代码11 项目: barterli_android   文件: Encoder.java
/**
 * 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 << 3;
    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");
    }
}
 
源代码12 项目: android-quick-response-code   文件: Encoder.java
/**
 * 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 << 3;
    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");
    }
}
 
源代码13 项目: Telegram   文件: Encoder.java
/**
 * 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");
  }
}
 
源代码14 项目: MiBandDecompiled   文件: Encoder.java
static void a(int i, BitArray bitarray)
{
    int j = i << 3;
    if (bitarray.getSize() > j)
    {
        throw new WriterException((new StringBuilder()).append("data bits cannot fit in the QR Code").append(bitarray.getSize()).append(" > ").append(j).toString());
    }
    for (int k = 0; k < 4 && bitarray.getSize() < j; k++)
    {
        bitarray.appendBit(false);
    }

    int l = 7 & bitarray.getSize();
    if (l > 0)
    {
        for (; l < 8; l++)
        {
            bitarray.appendBit(false);
        }

    }
    int i1 = i - bitarray.getSizeInBytes();
    int j1 = 0;
    while (j1 < i1) 
    {
        char c1;
        if ((j1 & 1) == 0)
        {
            c1 = '\354';
        } else
        {
            c1 = '\021';
        }
        bitarray.appendBits(c1, 8);
        j1++;
    }
    if (bitarray.getSize() != j)
    {
        throw new WriterException("Bits size does not equal capacity");
    } else
    {
        return;
    }
}