|
|
@ -402,10 +402,10 @@ public final class QrCode {
|
|
|
|
// Draws a 9*9 finder pattern including the border separator,
|
|
|
|
// Draws a 9*9 finder pattern including the border separator,
|
|
|
|
// with the center module at (x, y). Modules can be out of bounds.
|
|
|
|
// with the center module at (x, y). Modules can be out of bounds.
|
|
|
|
private void drawFinderPattern(int x, int y) {
|
|
|
|
private void drawFinderPattern(int x, int y) {
|
|
|
|
for (int i = -4; i <= 4; i++) {
|
|
|
|
for (int dy = -4; dy <= 4; dy++) {
|
|
|
|
for (int j = -4; j <= 4; j++) {
|
|
|
|
for (int dx = -4; dx <= 4; dx++) {
|
|
|
|
int dist = Math.max(Math.abs(i), Math.abs(j)); // Chebyshev/infinity norm
|
|
|
|
int dist = Math.max(Math.abs(dy), Math.abs(dx)); // Chebyshev/infinity norm
|
|
|
|
int xx = x + j, yy = y + i;
|
|
|
|
int xx = x + dx, yy = y + dy;
|
|
|
|
if (0 <= xx && xx < size && 0 <= yy && yy < size)
|
|
|
|
if (0 <= xx && xx < size && 0 <= yy && yy < size)
|
|
|
|
setFunctionModule(xx, yy, dist != 2 && dist != 4);
|
|
|
|
setFunctionModule(xx, yy, dist != 2 && dist != 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -416,9 +416,9 @@ public final class QrCode {
|
|
|
|
// Draws a 5*5 alignment pattern, with the center module
|
|
|
|
// Draws a 5*5 alignment pattern, with the center module
|
|
|
|
// at (x, y). All modules must be in bounds.
|
|
|
|
// at (x, y). All modules must be in bounds.
|
|
|
|
private void drawAlignmentPattern(int x, int y) {
|
|
|
|
private void drawAlignmentPattern(int x, int y) {
|
|
|
|
for (int i = -2; i <= 2; i++) {
|
|
|
|
for (int dy = -2; dy <= 2; dy++) {
|
|
|
|
for (int j = -2; j <= 2; j++)
|
|
|
|
for (int dx = -2; dx <= 2; dx++)
|
|
|
|
setFunctionModule(x + j, y + i, Math.max(Math.abs(i), Math.abs(j)) != 1);
|
|
|
|
setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dy), Math.abs(dx)) != 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|