Tweaked small pieces of code.
This commit is contained in:
parent
4ede209d9a
commit
9c670453a8
|
@ -61,7 +61,7 @@ testable void appendBitsToBuffer(unsigned int val, int numBits, uint8_t buffer[]
|
|||
|
||||
testable void addEccAndInterleave(uint8_t data[], int version, enum qrcodegen_Ecc ecl, uint8_t result[]);
|
||||
testable int getNumDataCodewords(int version, enum qrcodegen_Ecc ecl);
|
||||
testable int getNumRawDataModules(int version);
|
||||
testable int getNumRawDataModules(int ver);
|
||||
|
||||
testable void calcReedSolomonGenerator(int degree, uint8_t result[]);
|
||||
testable void calcReedSolomonRemainder(const uint8_t data[], int dataLen,
|
||||
|
@ -242,13 +242,13 @@ testable int getNumDataCodewords(int version, enum qrcodegen_Ecc ecl) {
|
|||
// Returns the number of data bits that can be stored in a QR Code of the given version number, after
|
||||
// all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
|
||||
// The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
|
||||
testable int getNumRawDataModules(int version) {
|
||||
assert(qrcodegen_VERSION_MIN <= version && version <= qrcodegen_VERSION_MAX);
|
||||
int result = (16 * version + 128) * version + 64;
|
||||
if (version >= 2) {
|
||||
int numAlign = version / 7 + 2;
|
||||
testable int getNumRawDataModules(int ver) {
|
||||
assert(qrcodegen_VERSION_MIN <= ver && ver <= qrcodegen_VERSION_MAX);
|
||||
int result = (16 * ver + 128) * ver + 64;
|
||||
if (ver >= 2) {
|
||||
int numAlign = ver / 7 + 2;
|
||||
result -= (25 * numAlign - 10) * numAlign - 55;
|
||||
if (version >= 7)
|
||||
if (ver >= 7)
|
||||
result -= 36;
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -297,13 +297,10 @@ public final class QrCode {
|
|||
size + brd * 2))
|
||||
.append("\t<rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\"/>\n")
|
||||
.append("\t<path d=\"");
|
||||
boolean head = true;
|
||||
for (int y = 0; y < size; y++) {
|
||||
for (int x = 0; x < size; x++) {
|
||||
if (getModule(x, y)) {
|
||||
if (head)
|
||||
head = false;
|
||||
else
|
||||
if (x != 0 || y != 0)
|
||||
sb.append(" ");
|
||||
sb.append(String.format("M%d,%dh1v1h-1z", x + brd, y + brd));
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public final class QrSegmentAdvanced {
|
|||
// Check arguments
|
||||
Objects.requireNonNull(text);
|
||||
Objects.requireNonNull(ecl);
|
||||
if (!(1 <= minVersion && minVersion <= maxVersion && maxVersion <= 40))
|
||||
if (!(QrCode.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= QrCode.MAX_VERSION))
|
||||
throw new IllegalArgumentException("Invalid value");
|
||||
|
||||
// Iterate through version numbers, and make tentative segments
|
||||
|
@ -253,7 +253,7 @@ public final class QrSegmentAdvanced {
|
|||
throw new IllegalArgumentException("String contains non-kanji-mode characters");
|
||||
bb.appendBits(val, 13);
|
||||
}
|
||||
return new QrSegment(QrSegment.Mode.KANJI, text.length(), bb);
|
||||
return new QrSegment(Mode.KANJI, text.length(), bb);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue