|
|
@ -121,7 +121,7 @@ final class QrTemplate {
|
|
|
|
drawFinderPattern(3, size - 4);
|
|
|
|
drawFinderPattern(3, size - 4);
|
|
|
|
|
|
|
|
|
|
|
|
// Draw numerous alignment patterns
|
|
|
|
// Draw numerous alignment patterns
|
|
|
|
int[] alignPatPos = getAlignmentPatternPositions(version);
|
|
|
|
int[] alignPatPos = getAlignmentPatternPositions();
|
|
|
|
int numAlign = alignPatPos.length;
|
|
|
|
int numAlign = alignPatPos.length;
|
|
|
|
for (int i = 0; i < numAlign; i++) {
|
|
|
|
for (int i = 0; i < numAlign; i++) {
|
|
|
|
for (int j = 0; j < numAlign; j++) {
|
|
|
|
for (int j = 0; j < numAlign; j++) {
|
|
|
@ -276,21 +276,19 @@ final class QrTemplate {
|
|
|
|
|
|
|
|
|
|
|
|
/*---- Private static helper functions ----*/
|
|
|
|
/*---- Private static helper functions ----*/
|
|
|
|
|
|
|
|
|
|
|
|
// Returns a set of positions of the alignment patterns in ascending order. These positions are
|
|
|
|
// Returns an ascending list of positions of alignment patterns for this version number.
|
|
|
|
// used on both the x and y axes. Each value in the resulting array is in the range [0, 177).
|
|
|
|
// Each position is in the range [0,177), and are used on both the x and y axes.
|
|
|
|
// This stateless pure function could be implemented as table of 40 variable-length lists of unsigned bytes.
|
|
|
|
// This could be implemented as lookup table of 40 variable-length lists of unsigned bytes.
|
|
|
|
private static int[] getAlignmentPatternPositions(int ver) {
|
|
|
|
private int[] getAlignmentPatternPositions() {
|
|
|
|
if (ver < MIN_VERSION || ver > MAX_VERSION)
|
|
|
|
if (version == 1)
|
|
|
|
throw new IllegalArgumentException("Version number out of range");
|
|
|
|
|
|
|
|
else if (ver == 1)
|
|
|
|
|
|
|
|
return new int[]{};
|
|
|
|
return new int[]{};
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
int numAlign = ver / 7 + 2;
|
|
|
|
int numAlign = version / 7 + 2;
|
|
|
|
int step = (ver == 32) ? 26 :
|
|
|
|
int step = (version == 32) ? 26 :
|
|
|
|
(ver*4 + numAlign*2 + 1) / (numAlign*2 - 2) * 2;
|
|
|
|
(version*4 + numAlign*2 + 1) / (numAlign*2 - 2) * 2;
|
|
|
|
int[] result = new int[numAlign];
|
|
|
|
int[] result = new int[numAlign];
|
|
|
|
result[0] = 6;
|
|
|
|
result[0] = 6;
|
|
|
|
for (int i = result.length - 1, pos = ver * 4 + 10; i >= 1; i--, pos -= step)
|
|
|
|
for (int i = result.length - 1, pos = size - 7; i >= 1; i--, pos -= step)
|
|
|
|
result[i] = pos;
|
|
|
|
result[i] = pos;
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|