|
|
@ -70,8 +70,7 @@ public final class QrCode {
|
|
|
|
if (version >= maxVersion) // All versions in the range could not fit the given data
|
|
|
|
if (version >= maxVersion) // All versions in the range could not fit the given data
|
|
|
|
throw new IllegalArgumentException("Data too long");
|
|
|
|
throw new IllegalArgumentException("Data too long");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dataUsedBits == -1)
|
|
|
|
assert dataUsedBits != -1;
|
|
|
|
throw new AssertionError();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Increase the error correction level while the data still fits in the current version number
|
|
|
|
// Increase the error correction level while the data still fits in the current version number
|
|
|
|
for (Ecc newEcl : Ecc.values()) {
|
|
|
|
for (Ecc newEcl : Ecc.values()) {
|
|
|
@ -95,8 +94,7 @@ public final class QrCode {
|
|
|
|
// Pad with alternate bytes until data capacity is reached
|
|
|
|
// Pad with alternate bytes until data capacity is reached
|
|
|
|
for (int padByte = 0xEC; bb.bitLength < dataCapacityBits; padByte ^= 0xEC ^ 0x11)
|
|
|
|
for (int padByte = 0xEC; bb.bitLength < dataCapacityBits; padByte ^= 0xEC ^ 0x11)
|
|
|
|
bb.appendBits(padByte, 8);
|
|
|
|
bb.appendBits(padByte, 8);
|
|
|
|
if (bb.bitLength % 8 != 0)
|
|
|
|
assert bb.bitLength % 8 == 0;
|
|
|
|
throw new AssertionError();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create the QR Code symbol
|
|
|
|
// Create the QR Code symbol
|
|
|
|
return new QrCode(version, ecl, bb.getBytes(), mask);
|
|
|
|
return new QrCode(version, ecl, bb.getBytes(), mask);
|
|
|
@ -245,8 +243,7 @@ public final class QrCode {
|
|
|
|
rem = (rem << 1) ^ ((rem >>> 9) * 0x537);
|
|
|
|
rem = (rem << 1) ^ ((rem >>> 9) * 0x537);
|
|
|
|
data = data << 10 | rem;
|
|
|
|
data = data << 10 | rem;
|
|
|
|
data ^= 0x5412; // uint15
|
|
|
|
data ^= 0x5412; // uint15
|
|
|
|
if (data >>> 15 != 0)
|
|
|
|
assert data >>> 15 == 0;
|
|
|
|
throw new AssertionError();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Draw first copy
|
|
|
|
// Draw first copy
|
|
|
|
for (int i = 0; i <= 5; i++)
|
|
|
|
for (int i = 0; i <= 5; i++)
|
|
|
@ -363,8 +360,7 @@ public final class QrCode {
|
|
|
|
applyMask(masks[i]); // Undoes the mask due to XOR
|
|
|
|
applyMask(masks[i]); // Undoes the mask due to XOR
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mask < 0 || mask > 7)
|
|
|
|
assert 0 <= mask && mask <= 7;
|
|
|
|
throw new AssertionError();
|
|
|
|
|
|
|
|
drawFormatBits(mask); // Overwrite old format bits
|
|
|
|
drawFormatBits(mask); // Overwrite old format bits
|
|
|
|
applyMask(masks[mask]); // Apply the final choice of mask
|
|
|
|
applyMask(masks[mask]); // Apply the final choice of mask
|
|
|
|
return mask; // The caller shall assign this value to the final-declared field
|
|
|
|
return mask; // The caller shall assign this value to the final-declared field
|
|
|
|