Skip to content

Commit 95bd124

Browse files
Shane32coderabbitai[bot]gfoidl
authored
Rewrite README.md (#660)
* Rewrite README.md * Add QRCoderSamples project and sample code for generating QR codes * Update README.md to include renderer requirements and notes for better clarity * Add example for accessing QRCodeData module matrix and rendering as ASCII * Update README.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update README.md Co-authored-by: Günther Foidl <[email protected]> * Add link to upcoming features in README.md * Clarify Micro QR code storage capacity and link to specification in README.md * Clarify storage capacity details for Micro QR codes in README.md * Update README.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Günther Foidl <[email protected]>
1 parent 161aa5f commit 95bd124

File tree

4 files changed

+266
-101
lines changed

4 files changed

+266
-101
lines changed

QRCoder.sln

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
2929
global.json = global.json
3030
EndProjectSection
3131
EndProject
32+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QRCoderSamples", "QRCoderSamples\QRCoderSamples.csproj", "{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}"
33+
EndProject
3234
Global
3335
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3436
Debug|Any CPU = Debug|Any CPU
@@ -183,6 +185,22 @@ Global
183185
{F046136A-7BEA-49F3-9415-70CE50AD533B}.Release|x64.Build.0 = Release|Any CPU
184186
{F046136A-7BEA-49F3-9415-70CE50AD533B}.Release|x86.ActiveCfg = Release|Any CPU
185187
{F046136A-7BEA-49F3-9415-70CE50AD533B}.Release|x86.Build.0 = Release|Any CPU
188+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
189+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
190+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Debug|ARM.ActiveCfg = Debug|Any CPU
191+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Debug|ARM.Build.0 = Debug|Any CPU
192+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Debug|x64.ActiveCfg = Debug|Any CPU
193+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Debug|x64.Build.0 = Debug|Any CPU
194+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Debug|x86.ActiveCfg = Debug|Any CPU
195+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Debug|x86.Build.0 = Debug|Any CPU
196+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
197+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Release|Any CPU.Build.0 = Release|Any CPU
198+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Release|ARM.ActiveCfg = Release|Any CPU
199+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Release|ARM.Build.0 = Release|Any CPU
200+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Release|x64.ActiveCfg = Release|Any CPU
201+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Release|x64.Build.0 = Release|Any CPU
202+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Release|x86.ActiveCfg = Release|Any CPU
203+
{61ED615B-C22C-5E3E-DAAD-A77A820E16DF}.Release|x86.Build.0 = Release|Any CPU
186204
EndGlobalSection
187205
GlobalSection(SolutionProperties) = preSolution
188206
HideSolutionNode = FALSE
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0-windows</TargetFramework>
5+
<NoWarn>$(NoWarn);CA1707</NoWarn>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<ProjectReference Include="..\QRCoder\QRCoder.csproj" />
10+
</ItemGroup>
11+
12+
</Project>

QRCoderSamples/ReadmeSamples.cs

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
using QRCoder;
2+
3+
namespace QRCoderSamples;
4+
5+
/// <summary>
6+
/// Sample code from the README.md file
7+
/// </summary>
8+
public static class ReadmeSamples
9+
{
10+
/// <summary>
11+
/// Quick Start - Generate a simple black and white PNG QR code
12+
/// </summary>
13+
public static void QuickStart_SimplePng()
14+
{
15+
// Generate a simple black and white PNG QR code
16+
byte[] qrCodeImage = PngByteQRCodeHelper.GetQRCode("Hello World", QRCodeGenerator.ECCLevel.Q, 20);
17+
}
18+
19+
/// <summary>
20+
/// Quick Start - Generate a scalable black and white SVG QR code
21+
/// </summary>
22+
public static void QuickStart_SimpleSvg()
23+
{
24+
// Generate a scalable black and white SVG QR code
25+
using var qrCodeData = QRCodeGenerator.GenerateQrCode("Hello World", QRCodeGenerator.ECCLevel.Q);
26+
using var svgRenderer = new SvgQRCode(qrCodeData);
27+
string svg = svgRenderer.GetGraphic();
28+
}
29+
30+
/// <summary>
31+
/// Payload Generator - Create a bookmark payload
32+
/// </summary>
33+
public static void PayloadGenerator_Bookmark()
34+
{
35+
// Create a bookmark payload
36+
var bookmarkPayload = new PayloadGenerator.Bookmark("https://github.com/Shane32/QRCoder", "QRCoder Repository");
37+
38+
// Generate the QR code data from the payload
39+
using var qrCodeData = QRCodeGenerator.GenerateQrCode(bookmarkPayload);
40+
41+
// Or override the ECC level
42+
using var qrCodeData2 = QRCodeGenerator.GenerateQrCode(bookmarkPayload, QRCodeGenerator.ECCLevel.H);
43+
44+
// Render the QR code
45+
using var pngRenderer = new PngByteQRCode(qrCodeData);
46+
byte[] qrCodeImage = pngRenderer.GetGraphic(20);
47+
}
48+
49+
/// <summary>
50+
/// Micro QR Code - Generate a Micro QR code
51+
/// </summary>
52+
public static void MicroQRCode_Simple()
53+
{
54+
// Generate a Micro QR code (versions M1-M4, represented as -1 to -4)
55+
using var qrCodeData = QRCodeGenerator.GenerateMicroQrCode("Hello", QRCodeGenerator.ECCLevel.L, requestedVersion: -2);
56+
using var qrCode = new PngByteQRCode(qrCodeData);
57+
byte[] qrCodeImage = qrCode.GetGraphic(20);
58+
}
59+
60+
/// <summary>
61+
/// Working with QRCodeData - Access the module matrix directly
62+
/// </summary>
63+
public static void QRCodeData_ModuleMatrix()
64+
{
65+
// Generate QR code data
66+
using var qrCodeData = QRCodeGenerator.GenerateQrCode("Hello World", QRCodeGenerator.ECCLevel.Q);
67+
68+
// Access the module matrix
69+
var moduleMatrix = qrCodeData.ModuleMatrix;
70+
int size = moduleMatrix.Count; // Size of the QR code (includes quiet zone)
71+
72+
// Manually render as ASCII (versus the included ASCII renderer)
73+
for (int y = 0; y < size; y++)
74+
{
75+
for (int x = 0; x < size; x++)
76+
{
77+
// Check if module is dark (true) or light (false)
78+
bool isDark = moduleMatrix[y][x];
79+
Console.Write(isDark ? "██" : " ");
80+
}
81+
Console.WriteLine();
82+
}
83+
}
84+
}

0 commit comments

Comments
 (0)