0.11.0
Overview
This release introduces customizable icon rendering with new IconShape support, enabling you to add both images and text to your QR codes. You can now create QR codes with branded logos accompanied by text labels for enhanced visual appeal.
Also QRCodeImageBuilder now accept QRCodeData directly, enabling you to directly render compress/decompress scenario.
Breaking change
Customizable Icon Rendering
The IconData class now supports flexible icon rendering through the new IconShape abstraction:
ImageIconShape- Display images only (replaces directSKBitmapusage)ImageTextIconShape- Combine images with text labels- Future extensibility for custom icon shapes
Breaking Change: IconData.Icon Property
Before (0.10.0 and earlier):
using var bitmap = SKBitmap.Decode(File.ReadAllBytes(iconPath));
var icon = new IconData
{
Icon = bitmap, // Direct SKBitmap
IconSizePercent = 15,
IconBorderWidth = 10
};After (0.11.0):
using var bitmap = SKBitmap.Decode(File.ReadAllBytes(iconPath));
// Option 1: Quick creation with helper method
var icon = IconData.FromImage(bitmap, iconSizePercent: 15, iconBorderWidth: 18);
// Option 2: Image-only icon
var icon = new IconData
{
Icon = new ImageIconShape(bitmap),
IconSizePercent = 15,
IconBorderWidth = 10
};
// Option 3: Image with text label
using var font = new SKFont
{
Size = 18,
Typeface = SKTypeface.FromFamilyName("sans-serif", SKFontStyle.Bold)
};
var icon = new IconData
{
Icon = new ImageTextIconShape(bitmap, "FooBar", SKColors.Black, font, textPadding: 2),
IconSizePercent = 13,
IconBorderWidth = 18
};Enhanced QRCodeData Support
Added QRCodeImageBuilder constructor overload accepting QRCodeData directly, enabling advanced scenarios:
// compression to zstandard ...
var qrCodeData = QRCodeGenerator.CreateQrCode("Hello", ECCLevel.L);
var src = qrCodeData.GetRawData();
var size = qrCodeData.GetRawDataSize();
var maxSize = NativeCompressions.Zstandard.GetMaxCompressedLength(size);
var compressed = new byte[maxSize];
NativeCompressions.Zstandard.Compress(src, compressed, NativeCompressions.ZstandardCompressionOptions.Default);
// decompression from zstandard ...
var decompressed = NativeCompressions.Zstandard.Decompress(compressed);
// render QR code
var qr = new QRCodeData(decompressed, 4);
var pngBytes = QRCodeImageBuilder.GetPngBytes(qr, 512);
File.WriteAllBytes(path, pngBytes);Migration Guide
If you're using IconData in your code, update the Icon property from SKBitmap to IconShape:
- Quick fix: Use
IconData.FromImage()helper method - Image only: Wrap with
ImageIconShape - Image + Text: Use
ImageTextIconShapewith font configuration
⚠️ Note: Always useECCLevel.Hwhen adding icons to ensure QR code readability.
What's Changed
- feat: Add QRCodeData overload for QRCodeImageBuilder by @guitarrapc in #278
- [Breaking change] feat: Add Iconshape to handle QR Icon. by @guitarrapc in #279
Full Changelog: 0.10.0...0.11.0