diff --git a/QRCoder/ASCIIQRCode.cs b/QRCoder/ASCIIQRCode.cs index bffe7cd0..f18d7266 100644 --- a/QRCoder/ASCIIQRCode.cs +++ b/QRCoder/ASCIIQRCode.cs @@ -52,7 +52,7 @@ public string[] GetLineByLineGraphic(int repeatPerModule, string darkColorString var lineBuilder = new StringBuilder(); for (var x = 0; x < QrCodeData.ModuleMatrix.Count - quietZonesModifier; x++) { - var module = QrCodeData.ModuleMatrix[x + quietZonesOffset][((y + verticalNumberOfRepeats) / verticalNumberOfRepeats - 1)+quietZonesOffset]; + var module = QrCodeData.ModuleMatrix[((y + verticalNumberOfRepeats) / verticalNumberOfRepeats - 1)+quietZonesOffset][x + quietZonesOffset]; for (var i = 0; i < repeatPerModule; i++) { lineBuilder.Append(module ? darkColorString : whiteSpaceString); @@ -75,4 +75,4 @@ public static string GetQRCode(string plainText, int pixelsPerModule, string dar return qrCode.GetGraphic(pixelsPerModule, darkColorString, whiteSpaceString, drawQuietZones, endOfLine); } } -} \ No newline at end of file +} diff --git a/QRCoderTests/AsciiQRCodeRendererTests.cs b/QRCoderTests/AsciiQRCodeRendererTests.cs index 7ac2656b..b74bee07 100644 --- a/QRCoderTests/AsciiQRCodeRendererTests.cs +++ b/QRCoderTests/AsciiQRCodeRendererTests.cs @@ -14,8 +14,8 @@ public class AsciiQRCodeRendererTests [Category("QRRenderer/AsciiQRCode")] public void can_render_ascii_qrcode() { - var targetCode = " \n \n \n \n ██████████████ ██ ██ ██████████████ \n ██ ██ ██ ████ ██ ██ \n ██ ██████ ██ ██ ██ ██ ██ ██████ ██ \n ██ ██████ ██ ██ ██ ██████ ██ \n ██ ██████ ██ ██ ██ ██████ ██ \n ██ ██ ████████ ██ ██ \n ██████████████ ██ ██ ██ ██████████████ \n ██ ████ \n ██████████ ████ ████████ ██ ████ \n ████ ██ ██ ████ ████████ ██ \n ██ ██ ██████████ ██ ██ ██ ████ \n ██ ██ ████ ████ ████ \n ████████ ██████ ████ ██ ██ \n ████████ \n ██████████████ ████ ████ ██ ████ ████ \n ██ ██ ████████ \n ██ ██████ ██ ██ ██ ██ ██ ██ ██ \n ██ ██████ ██ ██████ ██ ██ \n ██ ██████ ██ ██ ██ ██ ██ ████ ████ \n ██ ██ ████ ████ ██ ██ \n ██████████████ ██████ ██ ██████ \n \n \n \n "; - + var targetCode = " \n \n \n \n ██████████████ ████ ██ ██████████████ \n ██ ██ ████ ██ ██ ██ \n ██ ██████ ██ ██ ██ ██ ██ ██████ ██ \n ██ ██████ ██ ██ ██ ██ ██████ ██ \n ██ ██████ ██ ██████████ ██ ██████ ██ \n ██ ██ ██ ██ \n ██████████████ ██ ██ ██ ██████████████ \n ██████████ \n ████ ██ ████ ██████ ██ ██████████ \n ██ ██ ██ ██ ██ ████ \n ████ ██████ ██████ ██████ ██ \n ████ ██ ██████ ██ ██ ██ \n ████ ████ ██ ██ ██ ██ ████ \n ██ ██ ██ ██ ██ \n ██████████████ ██ ████ ██████ ██ \n ██ ██ ██ ████ ██████ \n ██ ██████ ██ ██████ ████████ ██ ██ \n ██ ██████ ██ ██ ██ ████ \n ██ ██████ ██ ██████ ██ ██ ██ \n ██ ██ ██ ██ ██ ██████ \n ██████████████ ██ ██ ██ ██ ██ ██ \n \n \n \n "; + //Create QR code var gen = new QRCodeGenerator(); var data = gen.CreateQrCode("A05", QRCodeGenerator.ECCLevel.Q); @@ -28,8 +28,8 @@ public void can_render_ascii_qrcode() [Category("QRRenderer/AsciiQRCode")] public void can_render_ascii_qrcode_without_quietzones() { - var targetCode = "██████████████ ██ ██ ██████████████\n██ ██ ██ ████ ██ ██\n██ ██████ ██ ██ ██ ██ ██ ██████ ██\n██ ██████ ██ ██ ██ ██████ ██\n██ ██████ ██ ██ ██ ██████ ██\n██ ██ ████████ ██ ██\n██████████████ ██ ██ ██ ██████████████\n ██ ████ \n██████████ ████ ████████ ██ ████ \n████ ██ ██ ████ ████████ ██\n ██ ██ ██████████ ██ ██ ██ ████ \n██ ██ ████ ████ ████ \n ████████ ██████ ████ ██ ██\n ████████ \n██████████████ ████ ████ ██ ████ ████\n██ ██ ████████ \n██ ██████ ██ ██ ██ ██ ██ ██ ██\n██ ██████ ██ ██████ ██ ██ \n██ ██████ ██ ██ ██ ██ ██ ████ ████\n██ ██ ████ ████ ██ ██ \n██████████████ ██████ ██ ██████"; - + var targetCode = "██████████████ ████ ██ ██████████████\n██ ██ ████ ██ ██ ██\n██ ██████ ██ ██ ██ ██ ██ ██████ ██\n██ ██████ ██ ██ ██ ██ ██████ ██\n██ ██████ ██ ██████████ ██ ██████ ██\n██ ██ ██ ██\n██████████████ ██ ██ ██ ██████████████\n ██████████ \n ████ ██ ████ ██████ ██ ██████████\n██ ██ ██ ██ ██ ████\n ████ ██████ ██████ ██████ ██\n████ ██ ██████ ██ ██ ██ \n ████ ████ ██ ██ ██ ██ ████ \n ██ ██ ██ ██ ██ \n██████████████ ██ ████ ██████ ██ \n██ ██ ██ ████ ██████ \n██ ██████ ██ ██████ ████████ ██ ██\n██ ██████ ██ ██ ██ ████ \n██ ██████ ██ ██████ ██ ██ ██\n██ ██ ██ ██ ██ ██████\n██████████████ ██ ██ ██ ██ ██ ██"; + //Create QR code var gen = new QRCodeGenerator(); var data = gen.CreateQrCode("A05", QRCodeGenerator.ECCLevel.Q); @@ -42,7 +42,7 @@ public void can_render_ascii_qrcode_without_quietzones() [Category("QRRenderer/AsciiQRCode")] public void can_render_ascii_qrcode_with_custom_symbols() { - var targetCode = " \n \n \n \n \n \n \n \n XXXXXXXXXXXXXX XXXX XXXXXXXXXXXXXX \n XXXXXXXXXXXXXX XXXX XXXXXXXXXXXXXX \n XX XX XXXXXX XX XX XX \n XX XX XXXXXX XX XX XX \n XX XXXXXX XX XXXXXXXX XX XXXXXX XX \n XX XXXXXX XX XXXXXXXX XX XXXXXX XX \n XX XXXXXX XX XXXX XX XXXXXX XX \n XX XXXXXX XX XXXX XX XXXXXX XX \n XX XXXXXX XX XX XX XX XXXXXX XX \n XX XXXXXX XX XX XX XX XXXXXX XX \n XX XX XX XX XX \n XX XX XX XX XX \n XXXXXXXXXXXXXX XX XX XX XXXXXXXXXXXXXX \n XXXXXXXXXXXXXX XX XX XX XXXXXXXXXXXXXX \n XXXXXXXX \n XXXXXXXX \n XX XXXXXX XXXXXX XX XX XX \n XX XXXXXX XXXXXX XX XX XX \n XX XXXXXX XXXX XXXXXXXX XXXXXX XX \n XX XXXXXX XXXX XXXXXXXX XXXXXX XX \n XX XX XX XX XX XX \n XX XX XX XX XX XX \n XX XX XX XX XXXXXX \n XX XX XX XX XXXXXX \n XX XXXXXXXX XXXX XX XXXXXXXX XX \n XX XXXXXXXX XXXX XX XXXXXXXX XX \n XX XXXXXXXX XXXX \n XX XXXXXXXX XXXX \n XXXXXXXXXXXXXX XXXXXXXX XX XXXXXX \n XXXXXXXXXXXXXX XXXXXXXX XX XXXXXX \n XX XX XXXXXX XXXXXXXX \n XX XX XXXXXX XXXXXXXX \n XX XXXXXX XX XX XXXX XX XXXX \n XX XXXXXX XX XX XXXX XX XXXX \n XX XXXXXX XX XXXX XXXXXXXX \n XX XXXXXX XX XXXX XXXXXXXX \n XX XXXXXX XX XX XXXXXXXX XX XXXXXX \n XX XXXXXX XX XX XXXXXXXX XX XXXXXX \n XX XX XX XXXX XX \n XX XX XX XXXX XX \n XXXXXXXXXXXXXX XX XXXXXX XXXX XXXX \n XXXXXXXXXXXXXX XX XXXXXX XXXX XXXX \n \n \n \n \n \n \n \n "; + var targetCode = " \n \n \n \n \n \n \n \n XXXXXXXXXXXXXX XX XXXXXXXXXXXXXX \n XXXXXXXXXXXXXX XX XXXXXXXXXXXXXX \n XX XX XXXX XX XX \n XX XX XXXX XX XX \n XX XXXXXX XX XXXX XX XXXXXX XX \n XX XXXXXX XX XXXX XX XXXXXX XX \n XX XXXXXX XX XX XX XX XXXXXX XX \n XX XXXXXX XX XX XX XX XXXXXX XX \n XX XXXXXX XX XXXX XX XX XXXXXX XX \n XX XXXXXX XX XXXX XX XX XXXXXX XX \n XX XX XX XX XX XX \n XX XX XX XX XX XX \n XXXXXXXXXXXXXX XX XX XX XXXXXXXXXXXXXX \n XXXXXXXXXXXXXX XX XX XX XXXXXXXXXXXXXX \n XX XX \n XX XX \n XX XX XX XXXXXX XXXX XXXX XX \n XX XX XX XXXXXX XXXX XXXX XX \n XXXXXX XX XXXX XX XX XX XXXX \n XXXXXX XX XXXX XX XX XX XXXX \n XXXXXX XXXXXXXXXX XXXXXXXXXX \n XXXXXX XXXXXXXXXX XXXXXXXXXX \n XX XX XX XX XX XXXXXX XX XX \n XX XX XX XX XX XXXXXX XX XX \n XXXXXX XXXX XX XX XXXX XX XX \n XXXXXX XXXX XX XX XXXX XX XX \n XXXXXX XXXX XX XX \n XXXXXX XXXX XX XX \n XXXXXXXXXXXXXX XXXXXX XX \n XXXXXXXXXXXXXX XXXXXX XX \n XX XX XX XX XX \n XX XX XX XX XX \n XX XXXXXX XX XXXXXXXXXX XXXXXXXXXXXXXX \n XX XXXXXX XX XXXXXXXXXX XXXXXXXXXXXXXX \n XX XXXXXX XX XX XXXX XX XX XXXX \n XX XXXXXX XX XX XXXX XX XX XXXX \n XX XXXXXX XX XXXXXX XXXXXXXXXX \n XX XXXXXX XX XXXXXX XXXXXXXXXX \n XX XX XX XXXX XX XX XX \n XX XX XX XXXX XX XX XX \n XXXXXXXXXXXXXX XX XXXXXX XXXXXX \n XXXXXXXXXXXXXX XX XXXXXX XXXXXX \n \n \n \n \n \n \n \n "; //Create QR code var gen = new QRCodeGenerator(); @@ -65,7 +65,7 @@ public void can_instantate_parameterless() [Category("QRRenderer/AsciiQRCode")] public void can_render_ascii_qrcode_from_helper() { - var targetCode = " \n \n \n \n \n \n \n \n XXXXXXXXXXXXXX XXXX XXXXXXXXXXXXXX \n XXXXXXXXXXXXXX XXXX XXXXXXXXXXXXXX \n XX XX XXXXXX XX XX XX \n XX XX XXXXXX XX XX XX \n XX XXXXXX XX XXXXXXXX XX XXXXXX XX \n XX XXXXXX XX XXXXXXXX XX XXXXXX XX \n XX XXXXXX XX XXXX XX XXXXXX XX \n XX XXXXXX XX XXXX XX XXXXXX XX \n XX XXXXXX XX XX XX XX XXXXXX XX \n XX XXXXXX XX XX XX XX XXXXXX XX \n XX XX XX XX XX \n XX XX XX XX XX \n XXXXXXXXXXXXXX XX XX XX XXXXXXXXXXXXXX \n XXXXXXXXXXXXXX XX XX XX XXXXXXXXXXXXXX \n XXXXXXXX \n XXXXXXXX \n XX XXXXXX XXXXXX XX XX XX \n XX XXXXXX XXXXXX XX XX XX \n XX XXXXXX XXXX XXXXXXXX XXXXXX XX \n XX XXXXXX XXXX XXXXXXXX XXXXXX XX \n XX XX XX XX XX XX \n XX XX XX XX XX XX \n XX XX XX XX XXXXXX \n XX XX XX XX XXXXXX \n XX XXXXXXXX XXXX XX XXXXXXXX XX \n XX XXXXXXXX XXXX XX XXXXXXXX XX \n XX XXXXXXXX XXXX \n XX XXXXXXXX XXXX \n XXXXXXXXXXXXXX XXXXXXXX XX XXXXXX \n XXXXXXXXXXXXXX XXXXXXXX XX XXXXXX \n XX XX XXXXXX XXXXXXXX \n XX XX XXXXXX XXXXXXXX \n XX XXXXXX XX XX XXXX XX XXXX \n XX XXXXXX XX XX XXXX XX XXXX \n XX XXXXXX XX XXXX XXXXXXXX \n XX XXXXXX XX XXXX XXXXXXXX \n XX XXXXXX XX XX XXXXXXXX XX XXXXXX \n XX XXXXXX XX XX XXXXXXXX XX XXXXXX \n XX XX XX XXXX XX \n XX XX XX XXXX XX \n XXXXXXXXXXXXXX XX XXXXXX XXXX XXXX \n XXXXXXXXXXXXXX XX XXXXXX XXXX XXXX \n \n \n \n \n \n \n \n "; + var targetCode = " \n \n \n \n \n \n \n \n XXXXXXXXXXXXXX XX XXXXXXXXXXXXXX \n XXXXXXXXXXXXXX XX XXXXXXXXXXXXXX \n XX XX XXXX XX XX \n XX XX XXXX XX XX \n XX XXXXXX XX XXXX XX XXXXXX XX \n XX XXXXXX XX XXXX XX XXXXXX XX \n XX XXXXXX XX XX XX XX XXXXXX XX \n XX XXXXXX XX XX XX XX XXXXXX XX \n XX XXXXXX XX XXXX XX XX XXXXXX XX \n XX XXXXXX XX XXXX XX XX XXXXXX XX \n XX XX XX XX XX XX \n XX XX XX XX XX XX \n XXXXXXXXXXXXXX XX XX XX XXXXXXXXXXXXXX \n XXXXXXXXXXXXXX XX XX XX XXXXXXXXXXXXXX \n XX XX \n XX XX \n XX XX XX XXXXXX XXXX XXXX XX \n XX XX XX XXXXXX XXXX XXXX XX \n XXXXXX XX XXXX XX XX XX XXXX \n XXXXXX XX XXXX XX XX XX XXXX \n XXXXXX XXXXXXXXXX XXXXXXXXXX \n XXXXXX XXXXXXXXXX XXXXXXXXXX \n XX XX XX XX XX XXXXXX XX XX \n XX XX XX XX XX XXXXXX XX XX \n XXXXXX XXXX XX XX XXXX XX XX \n XXXXXX XXXX XX XX XXXX XX XX \n XXXXXX XXXX XX XX \n XXXXXX XXXX XX XX \n XXXXXXXXXXXXXX XXXXXX XX \n XXXXXXXXXXXXXX XXXXXX XX \n XX XX XX XX XX \n XX XX XX XX XX \n XX XXXXXX XX XXXXXXXXXX XXXXXXXXXXXXXX \n XX XXXXXX XX XXXXXXXXXX XXXXXXXXXXXXXX \n XX XXXXXX XX XX XXXX XX XX XXXX \n XX XXXXXX XX XX XXXX XX XX XXXX \n XX XXXXXX XX XXXXXX XXXXXXXXXX \n XX XXXXXX XX XXXXXX XXXXXXXXXX \n XX XX XX XXXX XX XX XX \n XX XX XX XXXX XX XX XX \n XXXXXXXXXXXXXX XX XXXXXX XXXXXX \n XXXXXXXXXXXXXX XX XXXXXX XXXXXX \n \n \n \n \n \n \n \n "; //Create QR code var asciiCode = AsciiQRCodeHelper.GetQRCode("A", 2, "X", " ", QRCodeGenerator.ECCLevel.Q);