Lyo.QRCode
1.0.9
See the version list below for details.
dotnet add package Lyo.QRCode --version 1.0.9
NuGet\Install-Package Lyo.QRCode -Version 1.0.9
<PackageReference Include="Lyo.QRCode" Version="1.0.9" />
<PackageVersion Include="Lyo.QRCode" Version="1.0.9" />
<PackageReference Include="Lyo.QRCode" />
paket add Lyo.QRCode --version 1.0.9
#r "nuget: Lyo.QRCode, 1.0.9"
#:package Lyo.QRCode@1.0.9
#addin nuget:?package=Lyo.QRCode&version=1.0.9
#tool nuget:?package=Lyo.QRCode&version=1.0.9
Lyo.QRCode
QR code generation and reading for Lyo: IQRCodeService, QRCodeBuilder, ISO Model 2 encoding in-box (BuiltInQRCodeService), optional QRCoder adapter package Lyo.QRCode.QRCoder, and typed payload helpers (Lyo.QRCode.Payloads) for Wi-Fi, URLs, vCard, mailto:, etc.
Examples
Quick start (built-in encoder)
using Lyo.QRCode;
using Lyo.QRCode.Models;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
services.AddQRCodeService(o => {
o.DefaultSize = 16; // pixels per module, not total width
o.DefaultFormat = QRCodeFormat.Png;
o.DefaultErrorCorrectionLevel = QRCodeErrorCorrectionLevel.Medium;
});
var qr = services.BuildServiceProvider().GetRequiredService<IQRCodeService>();
var result = await qr.GenerateAsync("https://example.com");
if (result.IsSuccess && result is QRCodeResult r && r.ImageBytes != null)
await File.WriteAllBytesAsync("qr.png", r.ImageBytes);
Typed payload (Wi‑Fi example)
using Lyo.QRCode;
using Lyo.QRCode.Payloads;
var payload = new WifiQrPayload("MySSID", "secret", QrWifiSecurityType.Wpa);
var (_, opts) = QRCodeBuilder.New()
.WithPayload(payload)
.WithFormat(QRCodeFormat.Png)
.WithSize(12)
.Build();
Architecture
| Piece | Role |
|---|---|
IQRCodeService |
Generate to memory, stream, file; batch; ReadFromImageAsync (ZXing). |
BuiltInQRCodeService |
In-library PNG/SVG rasterization. No QRCoder NuGet for encode. JPEG/BMP not supported here (platform / format limits). |
Lyo.QRCode.QRCoder |
Optional QRCoderQRCodeService + AddQRCoderQrCodeService for JPEG/Bitmap on Windows and a QRCoder render path. |
QRCodeBuilder |
QRCodeOptions plus WithData / WithPayload(IQrPayload). |
Payloads |
IQrPayload, QrPayloadKind, WifiQrPayload, HttpUrlPayload, contacts, URI schemes, messaging URLs. All serialize to the string passed to GenerateAsync. |
Optional: QRCoder package
Add a project/package reference to Lyo.QRCode.QRCoder and call AddQRCoderQrCodeService (or AddQRCoderQrCodeServiceFromConfiguration) instead of or in addition to AddQRCodeService, depending on how you register IQRCodeService.
Payload helpers (Lyo.QRCode.Payloads)
- Wi-Fi (
WifiQrPayload). OmitsH:when the SSID is not hidden (better phone compatibility thanH:false). Open networks omitP(notP:;). - SMS (
SmsPayload). Defaults tosms:URI scheme.smsto:is opt-in (some Android SMS apps crash on longsmsto:bodies). Very long URIs throw (MaxSmsQrUriLength) to avoid app crashes.
Key options
QRCodeOptions.Size. Pixels per module (each black/white square), not the image width. Total size ≈ module count per side ×Size. Decoration applied later may grow that further.QRCodeOptions.Icon. Hint only for the encoder. The only field consumed isIconSizePercent, which bumps the effective ECC level so a planned center logo doesn't break scanning.IconBytes,IconFilePath, andDrawIconBorderare metadata for the consumer's overlay call. The QR encoder never composites the icon. Apply the overlay (and any frame/caption/padding) after generation throughLyo.Images.IImageDecorationService(see migration note below).
Migration: decoration moved out of the encoder
QRCodeOptions.Frame, QRCodeBuilder.WithFrame(...), and the optional IImageService / IQrFrameLayoutService constructor parameters on BuiltInQRCodeService are gone.
Compose icons and chrome on the returned bytes with Lyo.Images:
using Lyo.Images;
using Lyo.Images.Builders;
using Lyo.Common.Enums;
var qr = await qrService.GenerateAsync(data, options);
var qrBytes = ((QRCodeResult)qr).ImageBytes!;
var decorated = await decoration.Pipeline(qrBytes)
.Overlay(logoBytes, b => b.WithOverlaySizePercent(18).WithPadColor("#FFFFFF").WithBorder("#000000"))
.AddCaption(b => b.WithText("Scan Me").WithNotch())
.AddOuterPadding(b => b.WithPanelColor("#FFFFFF").WithCornerRadius(16))
.AddFrame(b => b.WithStrokeColor("#1e293b").WithStrokeWidth(2).WithCornerRadius(16))
.ToByteArrayAsync(ImageFormat.Png);
OverlayAsync works on PNG (raster) and SVG (embeds a base64 PNG <image> before </svg>); the other primitives require raster input.
Error correction
QRCodeErrorCorrectionLevel: Low (~7%), Medium (~15%), Quartile (~25%), High (~30%) recovery. Higher levels tolerate damage and logos better but increase symbol version for the same payload.
Blazor UI (optional)
Lyo.QRCode.Web.Components.QrCodeWorkbenchand related MudBlazor components.
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Common(direct, lyo)Lyo.Exceptions(direct, lyo)Lyo.Metrics(direct, lyo)Lyo.Result(direct, lyo)Microsoft.Extensions.Configuration.Binder10.0.5(direct, microsoft)Microsoft.Extensions.DependencyInjection.Abstractions10.0.5(direct, microsoft)Microsoft.Extensions.Logging.Abstractions10.0.5(direct, microsoft)SixLabors.ImageSharp3.1.12(direct, third-party)ZXing.Net0.16.11(direct, third-party)ZXing.Net.Bindings.ImageSharp.V30.16.18(direct, third-party)Microsoft.Extensions.Options.ConfigurationExtensions10.0.5(transitive, microsoft)System.Memory4.6.3(transitive, microsoft, netstandard2.0)System.Text.Json10.0.5(transitive, microsoft, netstandard2.0)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Lyo.Common (>= 1.0.9)
- Lyo.Exceptions (>= 1.0.9)
- Lyo.Metrics (>= 1.0.9)
- Lyo.Result (>= 1.0.9)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.5)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
- SixLabors.ImageSharp (>= 3.1.12)
- ZXing.Net (>= 0.16.11)
- ZXing.Net.Bindings.ImageSharp.V3 (>= 0.16.18)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Lyo.QRCode:
| Package | Downloads |
|---|---|
|
Lyo.QRCode.QRCoder
QRCoder implementation for Lyo.QRCode - QR code generation service using QRCoder library. |
|
|
Lyo.QRCode.Web.Components
Reusable Blazor components for QR code generation and preview workflows. |
|
|
Lyo.Leaderboard.Api
HTTP API for Lyo.Leaderboard. Embed via AddLeaderboardApi / MapLeaderboardApiEndpoints. |
GitHub repositories
This package is not used by any popular GitHub repositories.