Added and updated comments.

pull/134/head
Project Nayuki 6 years ago
parent 4cddfddb66
commit 6d5164fa0e

@ -197,9 +197,8 @@ public final class QrCode {
/**
* Based on the specified number of border modules to add as padding, this returns a
* string whose contents represents an SVG XML file that depicts this QR Code symbol.
* Note that Unix newlines (\n) are always used, regardless of the platform.
* Returns a string of SVG XML code representing an image of this QR Code symbol with the specified
* number of border modules. Note that Unix newlines (\n) are always used, regardless of the platform.
* @param border the number of border modules to add, which must be non-negative
* @return a string representing this QR Code as an SVG document
* @throws IllegalArgumentException if the border is negative
@ -259,7 +258,7 @@ public final class QrCode {
setModule(size - 1 - i, 8, (bits >>> i) & 1);
for (int i = 8; i < 15; i++)
setModule(8, size - 15 + i, (bits >>> i) & 1);
setModule(8, size - 8, 1);
setModule(8, size - 8, 1); // Always black
}

@ -165,19 +165,20 @@ public final class QrSegment {
}
// Package-private helper function.
// Calculates the number of bits needed to encode the given segments at the given version.
// Returns a non-negative number if successful. Otherwise returns -1 if a segment has too
// many characters to fit its length field, or the total bits exceeds Integer.MAX_VALUE.
static int getTotalBits(List<QrSegment> segs, int version) {
Objects.requireNonNull(segs);
long result = 0;
for (QrSegment seg : segs) {
Objects.requireNonNull(seg);
int ccbits = seg.mode.numCharCountBits(version);
// Fail if segment length value doesn't fit in the length field's bit-width
if (seg.numChars >= (1 << ccbits))
return -1;
return -1; // The segment's length doesn't fit the field's bit width
result += 4L + ccbits + seg.bitLength;
if (result > Integer.MAX_VALUE)
return -1;
return -1; // The sum will overflow an int type
}
return (int)result;
}

Loading…
Cancel
Save