Tweaked logic in QrCode.getPenaltyScore() for future expansion, without changing behavior, in all languages.

This commit is contained in:
Project Nayuki
2018-10-26 05:21:34 +00:00
parent a14de3d959
commit 111b20b2b9
7 changed files with 42 additions and 24 deletions
+6 -4
View File
@@ -431,8 +431,9 @@ long QrCode::getPenaltyScore() const {
// Adjacent modules in row having same color
for (int y = 0; y < size; y++) {
bool color = false;
for (int x = 0, runX = -1; x < size; x++) {
if (x == 0 || module(x, y) != color) {
int runX = 0;
for (int x = 0; x < size; x++) {
if (module(x, y) != color) {
color = module(x, y);
runX = 1;
} else {
@@ -447,8 +448,9 @@ long QrCode::getPenaltyScore() const {
// Adjacent modules in column having same color
for (int x = 0; x < size; x++) {
bool color = false;
for (int y = 0, runY = -1; y < size; y++) {
if (y == 0 || module(x, y) != color) {
int runY = 0;
for (int y = 0; y < size; y++) {
if (module(x, y) != color) {
color = module(x, y);
runY = 1;
} else {