diff --git a/c/qrcodegen.c b/c/qrcodegen.c index ee785c9..84986f2 100644 --- a/c/qrcodegen.c +++ b/c/qrcodegen.c @@ -668,7 +668,7 @@ static void drawCodewords(const uint8_t data[], int dataLen, uint8_t qrcode[], i for (int vert = 0; vert < size; vert++) { // Vertical counter for (int j = 0; j < 2; j++) { int x = right - j; // Actual x coordinate - bool upward = ((right & 2) == 0) ^ (x < 6); + bool upward = ((right + 1) & 2) == 0; int y = upward ? size - 1 - vert : vert; // Actual y coordinate if (!getModule(qrcode, size, x, y) && i < dataLen * 8) { bool black = ((data[i >> 3] >> (7 - (i & 7))) & 1) != 0; diff --git a/cpp/QrCode.cpp b/cpp/QrCode.cpp index 7db7941..bca9b3e 100644 --- a/cpp/QrCode.cpp +++ b/cpp/QrCode.cpp @@ -348,7 +348,7 @@ void qrcodegen::QrCode::drawCodewords(const std::vector &data) { for (int vert = 0; vert < size; vert++) { // Vertical counter for (int j = 0; j < 2; j++) { int x = right - j; // Actual x coordinate - bool upward = ((right & 2) == 0) ^ (x < 6); + bool upward = ((right + 1) & 2) == 0; int y = upward ? size - 1 - vert : vert; // Actual y coordinate if (!isFunction.at(y).at(x) && i < data.size() * 8) { modules.at(y).at(x) = ((data.at(i >> 3) >> (7 - (i & 7))) & 1) != 0; diff --git a/java/io/nayuki/qrcodegen/QrCode.java b/java/io/nayuki/qrcodegen/QrCode.java index b62d42a..fafd225 100644 --- a/java/io/nayuki/qrcodegen/QrCode.java +++ b/java/io/nayuki/qrcodegen/QrCode.java @@ -504,7 +504,7 @@ public final class QrCode { for (int vert = 0; vert < size; vert++) { // Vertical counter for (int j = 0; j < 2; j++) { int x = right - j; // Actual x coordinate - boolean upward = ((right & 2) == 0) ^ (x < 6); + boolean upward = ((right + 1) & 2) == 0; int y = upward ? size - 1 - vert : vert; // Actual y coordinate if (!isFunction[y][x] && i < data.length * 8) { modules[y][x] = ((data[i >>> 3] >>> (7 - (i & 7))) & 1) != 0; diff --git a/javascript/qrcodegen.js b/javascript/qrcodegen.js index 11d32f0..73c67b0 100644 --- a/javascript/qrcodegen.js +++ b/javascript/qrcodegen.js @@ -405,7 +405,7 @@ var qrcodegen = new function() { for (var vert = 0; vert < size; vert++) { // Vertical counter for (var j = 0; j < 2; j++) { var x = right - j; // Actual x coordinate - var upward = ((right & 2) == 0) ^ (x < 6); + var upward = ((right + 1) & 2) == 0; var y = upward ? size - 1 - vert : vert; // Actual y coordinate if (!isFunction[y][x] && i < data.length * 8) { modules[y][x] = ((data[i >>> 3] >>> (7 - (i & 7))) & 1) != 0; diff --git a/python/qrcodegen.py b/python/qrcodegen.py index c101f1c..be72451 100644 --- a/python/qrcodegen.py +++ b/python/qrcodegen.py @@ -404,7 +404,7 @@ class QrCode(object): for vert in range(self._size): # Vertical counter for j in range(2): x = right - j # Actual x coordinate - upward = ((right & 2) == 0) ^ (x < 6) + upward = ((right + 1) & 2) == 0 y = (self._size - 1 - vert) if upward else vert # Actual y coordinate if not self._isfunction[y][x] and i < len(data) * 8: self._modules[y][x] = ((data[i >> 3] >> (7 - (i & 7))) & 1) != 0