Class QrCode
A QR Code symbol (ISO/IEC 18004) encoded from text or bytes: the module matrix any scanner or authenticator app reads, and an SVG rendering of it.
public sealed class QrCode
- Inheritance
-
QrCode
- Inherited Members
Examples
using LMKit.Graphics;
QrCode code = QrCode.Encode("https://lm-kit.com", QrCode.ErrorCorrection.Medium);
string svg = code.ToSvg(pixelSize: 240);
bool topLeftIsDark = code[0, 0];
Remarks
The encoder writes byte-mode symbols in every version from 1 to 40, at the four standard error-correction levels, with Reed-Solomon codewords, block interleaving, the format and version information fields and the mask pattern the penalty rules select. Text is encoded as UTF-8, which is what every mainstream reader assumes when no character-set indicator is present. The smallest version whose data capacity holds the payload is chosen; a payload no version can hold throws.
The output is deterministic: the same payload at the same level always yields the same matrix, so a rendering can be cached or compared.
Fields
- MaxVersion
Highest supported symbol version.
- MinVersion
Lowest supported symbol version.
Properties
- this[int, int]
Whether the module at column
x, rowyis dark. Coordinates outside the symbol read as light, so a quiet zone can be walked with the same accessor.
- Level
The error-correction level the symbol was encoded at.
- Mask
The mask pattern (0 to 7) applied to the data region.
- Size
Modules per side, quiet zone excluded.
- Version
Symbol version, 1 to 40. The side length is
4 * Version + 17modules.
Methods
- Encode(byte[], ErrorCorrection)
Encodes raw bytes as a byte-mode symbol at the requested error-correction level.
- Encode(string, ErrorCorrection)
Encodes text as a byte-mode symbol at the requested error-correction level.
- ToMatrix()
Copies the module matrix, indexed
[x, y]withtruefor a dark module.
- ToSvg(int, int, string, string)
Renders the symbol as SVG markup: one path of dark modules over a light background, crisp at any scale.