Inverted some if-else statements in getPenaltyScore().

pull/134/head
Project Nayuki 6 years ago
parent b2671166ce
commit f4f971f384

@ -492,15 +492,15 @@ public final class QrCode {
// Adjacent modules having same color // Adjacent modules having same color
int c = getBit(modules[index >>> 5], index); int c = getBit(modules[index >>> 5], index);
if (c != color) { if (c == color) {
color = c;
runX = 1;
} else {
runX++; runX++;
if (runX == 5) if (runX == 5)
result += PENALTY_N1; result += PENALTY_N1;
else if (runX > 5) else if (runX > 5)
result++; result++;
} else {
color = c;
runX = 1;
} }
black += c; black += c;
@ -527,15 +527,15 @@ public final class QrCode {
// Adjacent modules having same color // Adjacent modules having same color
int c = getBit(modules[index >>> 5], index); int c = getBit(modules[index >>> 5], index);
if (c != color) { if (c == color) {
color = c;
runY = 1;
} else {
runY++; runY++;
if (runY == 5) if (runY == 5)
result += PENALTY_N1; result += PENALTY_N1;
else if (runY > 5) else if (runY > 5)
result++; result++;
} else {
color = c;
runY = 1;
} }
// Finder-like pattern // Finder-like pattern

Loading…
Cancel
Save