Skip to content

Commit ddc3158

Browse files
authored
Fix ASCII QR codes being diagonally mirrored
The current implementation of ASCIIQRCode has the X and Y coordinates swapped, resulting in a QR code that is mirrored about the main diagonal. I am not sure why the resulting QR code still scans successfully, but for feature parity with the other formats I propose to correct this.
1 parent dd35a3b commit ddc3158

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

QRCoder/ASCIIQRCode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public string[] GetLineByLineGraphic(int repeatPerModule, string darkColorString
5252
var lineBuilder = new StringBuilder();
5353
for (var x = 0; x < QrCodeData.ModuleMatrix.Count - quietZonesModifier; x++)
5454
{
55-
var module = QrCodeData.ModuleMatrix[x + quietZonesOffset][((y + verticalNumberOfRepeats) / verticalNumberOfRepeats - 1)+quietZonesOffset];
55+
var module = QrCodeData.ModuleMatrix[((y + verticalNumberOfRepeats) / verticalNumberOfRepeats - 1)+quietZonesOffset][x + quietZonesOffset];
5656
for (var i = 0; i < repeatPerModule; i++)
5757
{
5858
lineBuilder.Append(module ? darkColorString : whiteSpaceString);
@@ -75,4 +75,4 @@ public static string GetQRCode(string plainText, int pixelsPerModule, string dar
7575
return qrCode.GetGraphic(pixelsPerModule, darkColorString, whiteSpaceString, drawQuietZones, endOfLine);
7676
}
7777
}
78-
}
78+
}

0 commit comments

Comments
 (0)