Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

QrLite

A tiny QR Code encoder in a single, dependency-free C# file. Drop it in and you get a scannable QR from a string - no NuGet packages, no native bits, no Unity or platform types, so it runs anywhere (including Unity IL2CPP and Mono).

🛟 Need help or found a bug? Get support at support.doodesch.de/qrlite.

Install

Copy QrLite.cs into your project. That's the whole library.

The class is internal, so you can copy it into several assemblies without a CS0436 duplicate-type clash. If you'd rather reference it as a shared library, change internal static class QrLite to public.

Use

using DooDesch.QrLite;

bool[,] m = QrLite.Encode("https://example.com");   // m[row, col] == true means a dark module, or null if too big

// Quick monospace preview (great for a console):
Console.WriteLine(QrLite.ToText(m));

Encode gives you the raw matrix so you can render it however you like. For the common case there's a helper that rasterises it to ARGB pixels - scaled, with the all-important light quiet zone already included (forget the quiet zone and scanners can't find the code):

// matrix -> a scaled ARGB (0xAARRGGBB) pixel buffer, white background + black modules + 4-module quiet zone
uint[] px = QrLite.ToArgb(m, out int dim);            // px is dim x dim, row-major
// hand px to any image API - e.g. Unity: tex.SetPixels32(...), or write a PNG

ToArgb takes optional scale, quiet, dark and light (ARGB) arguments. It uses no platform types, so it stays portable; if you want full control you can still walk the bool[,] matrix yourself.

Scope

Intentionally small - enough for URLs and pairing codes, not a full QR toolkit:

  • Byte mode (UTF-8 input)
  • Error-correction level L
  • Versions 1-10 (up to about 271 bytes)
  • Automatic smallest-fitting version and best data mask

Encode returns null if the text needs more than version 10 at level L. Every output is verified module-for-module by decoding it with a reference decoder, across all supported versions.

License

MIT - see LICENSE.

About

A tiny, dependency-free single-file C# QR Code encoder (byte mode, ECC L, versions 1-10).

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages