BitVector data_bits = new BitVector();
AppendBytes(bytes, mode, data_bits);
// Step 3: Initialize QR code that can contain "data_bits".
BitVector data_bits = new BitVector();
AppendBytes(bytes, mode, data_bits);
// Step 3: Initialize QR code that can contain "data_bits".
InitQRCode(num_input_bytes, ec_level, mode, qr_code);
// Step 4: Build another bit vector that contains header and data.
BitVector header_and_data_bits = new BitVector();
AppendModeInfo(qr_code.mode(), header_and_data_bits);
AppendLengthInfo(bytes.size(), qr_code.version(), qr_code.mode(), header_and_data_bits);
InitQRCode(num_input_bytes, ec_level, mode, qr_code);
// Step 4: Build another bit vector that contains header and data.
BitVector header_and_data_bits = new BitVector();
AppendModeInfo(qr_code.mode(), header_and_data_bits);
AppendLengthInfo(bytes.size(), qr_code.version(), qr_code.mode(), header_and_data_bits);
// Step 5: Terminate the bits properly.
TerminateBits(qr_code.num_data_bytes(), header_and_data_bits);
// Step 5: Terminate the bits properly.
TerminateBits(qr_code.num_data_bytes(), header_and_data_bits);
}
// Append termination bits. See 8.4.8 of JISX0510:2004 (p.24) for details.
for (int i = 0; i < 4 && bits.size() < capacity; ++i) {
}
// Append termination bits. See 8.4.8 of JISX0510:2004 (p.24) for details.
for (int i = 0; i < 4 && bits.size() < capacity; ++i) {
}
final int num_bits_in_last_byte = bits.size() % 8;
// If the last byte isn't 8-bit aligned, we'll add padding bits.
if (num_bits_in_last_byte > 0) {
final int num_padding_bits = 8 - num_bits_in_last_byte;
for (int i = 0; i < num_padding_bits; ++i) {
}
final int num_bits_in_last_byte = bits.size() % 8;
// If the last byte isn't 8-bit aligned, we'll add padding bits.
if (num_bits_in_last_byte > 0) {
final int num_padding_bits = 8 - num_bits_in_last_byte;
for (int i = 0; i < num_padding_bits; ++i) {
throw new WriterException("Number of bits is not a multiple of 8");
}
// If we have more space, we'll fill the space with padding patterns defined in 8.4.9 (p.24).
throw new WriterException("Number of bits is not a multiple of 8");
}
// If we have more space, we'll fill the space with padding patterns defined in 8.4.9 (p.24).
int num_data_bytes, int num_rs_blocks, BitVector result) throws WriterException {
// "bits" must have "num_data_bytes" bytes of data.
int num_data_bytes, int num_rs_blocks, BitVector result) throws WriterException {
// "bits" must have "num_data_bytes" bytes of data.
for (int j = 0; j < blocks.size(); ++j) {
final ByteArray data_bytes = ((BlockPair) blocks.elementAt(j)).getDataBytes();
if (i < data_bytes.size()) {
for (int j = 0; j < blocks.size(); ++j) {
final ByteArray data_bytes = ((BlockPair) blocks.elementAt(j)).getDataBytes();
if (i < data_bytes.size()) {
for (int j = 0; j < blocks.size(); ++j) {
final ByteArray ec_bytes = ((BlockPair) blocks.elementAt(j)).getErrorCorrectionBytes();
if (i < ec_bytes.size()) {
for (int j = 0; j < blocks.size(); ++j) {
final ByteArray ec_bytes = ((BlockPair) blocks.elementAt(j)).getErrorCorrectionBytes();
if (i < ec_bytes.size()) {
- if (num_total_bytes != result.num_bytes()) { // Should be same.
- throw new WriterException("Interleaving error: " + num_total_bytes + " and " + result.num_bytes() +
+ if (num_total_bytes != result.sizeInBytes()) { // Should be same.
+ throw new WriterException("Interleaving error: " + num_total_bytes + " and " + result.sizeInBytes() +
// false.
static void AppendModeInfo(int mode, BitVector bits) throws WriterException {
final int code = QRCode.GetModeCode(mode);
// false.
static void AppendModeInfo(int mode, BitVector bits) throws WriterException {
final int code = QRCode.GetModeCode(mode);
if (num_letters > ((1 << num_bits) - 1)) {
throw new WriterException(num_letters + "is bigger than" + ((1 << num_bits) - 1));
}
if (num_letters > ((1 << num_bits) - 1)) {
throw new WriterException(num_letters + "is bigger than" + ((1 << num_bits) - 1));
}
// Encode three numeric letters in ten bits.
final int num2 = bytes.at(i + 1) - '0';
final int num3 = bytes.at(i + 2) - '0';
// Encode three numeric letters in ten bits.
final int num2 = bytes.at(i + 1) - '0';
final int num3 = bytes.at(i + 2) - '0';
i += 3;
} else if (i + 1 < bytes.size()) {
// Encode two numeric letters in seven bits.
final int num2 = bytes.at(i + 1) - '0';
i += 3;
} else if (i + 1 < bytes.size()) {
// Encode two numeric letters in seven bits.
final int num2 = bytes.at(i + 1) - '0';
// "bits" and return true. On error, return false.
static void Append8BitBytes(final ByteArray bytes, BitVector bits) {
for (int i = 0; i < bytes.size(); ++i) {
// "bits" and return true. On error, return false.
static void Append8BitBytes(final ByteArray bytes, BitVector bits) {
for (int i = 0; i < bytes.size(); ++i) {
throw new WriterException("Invalid byte sequence: " + bytes);
}
final int encoded = ((subtracted >> 8) * 0xc0) + (subtracted & 0xff);
throw new WriterException("Invalid byte sequence: " + bytes);
}
final int encoded = ((subtracted >> 8) * 0xc0) + (subtracted & 0xff);