Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/docs/specs/qrcode-symbologies.md
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,7 @@ The library can change some of this and not the rest:
- `SKBitmap.Decode(Stream)` disposes the stream it is given, which a probe found unreadable afterwards (2026-10-25). The stream reads make their own codec over the bytes and leave the stream open.
- `SKBitmap.DecodeBounds` and `SKBitmap.Decode` each make a codec over the bytes, so a read that called both parsed the file twice: 393 ms against 195 on an icon file of 65,535 images of 1 × 1 pixels. One codec gives the bounds and the pixels, and gave the same bitmaps on the 613 images under the tests, `docs/images` and `samples` (SkiaSharp 4.148.0, 2026-10-26).
- SkiaSharp 4.148.0 encodes PNG, JPEG and WebP and returns no data for the other formats, which every raster output turned into a `NullReferenceException`. They throw `NotSupportedException` now, the async write by faulting its task.
- The same missing data and missing surface had two more causes (2026-11-26). The WebP encoder returns no data past 16,383 pixels a side, which the message had reported as a missing encoder, so it now names both causes. `SKSurface.Create` returns no surface over 2,147,483,647 bytes, whatever memory the machine has, so `WithSize(100000, 100000)` or a module size of 20,000 pixels turned every raster output into a `NullReferenceException`. They throw `InvalidOperationException` with the size now, like the other layouts that cannot be drawn, and so does `ToBitmap` when its copy cannot be allocated. SVG has no surface and is still written.
- Skia reports a PNG header's size without its pixels, so a header followed by one row of data tests a pixel limit at any size. The test asserts the declared size in the exception's message: one that asserts the type alone passes when the decode fails some other way.
- The synchronous `SaveToSvg` writes in small pieces, 5,523 writes for a 16 KB document and 196,373 for version 40's 578 KB, and leaves part of a document behind when an icon is refused while the symbol is drawn. The async write renders into pooled memory, sends one write, and leaves nothing.
- `SKBitmap.Copy` draws the pixels and cleared the colour of an unpremultiplied pixel with no alpha, so an SVG written under a context differed from the synchronous one. The icon's copy reads the pixels instead: 9 to 17 ms at 4,096 × 4,096 where `Copy` took 43 to 54. A bitmap that draws nothing, with no pixel memory or of zero area, gives an empty copy, which the render refuses as it refuses the bitmap, where a copy drawn from it had been drawn blank.
Expand Down
8 changes: 4 additions & 4 deletions src/FeatherQR.SkiaSharp/MicroQRCodeImageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static byte[] GetPngBytes(MicroQRCodeData microQrCodeData, int size = 512
/// <param name="eccLevel">Error correction level. Default is M.</param>
/// <param name="size">Image side length in pixels.</param>
/// <param name="quality">Quality from 0 to 100, for formats that are lossy.</param>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>.</exception>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>, or cannot encode an image this large in it.</exception>
public static byte[] GetImageBytes(string content, SKEncodedImageFormat format, MicroQREccLevel eccLevel = MicroQREccLevel.M, int size = 512, int quality = 100)
{
return new MicroQRCodeImageBuilder(content)
Expand All @@ -101,7 +101,7 @@ public static byte[] GetImageBytes(string content, SKEncodedImageFormat format,
/// <param name="format">The format to encode as. Skia encodes PNG, JPEG and WebP.</param>
/// <param name="size">Image side length in pixels.</param>
/// <param name="quality">Quality from 0 to 100, for formats that are lossy.</param>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>.</exception>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>, or cannot encode an image this large in it.</exception>
public static byte[] GetImageBytes(MicroQRCodeData microQrCodeData, SKEncodedImageFormat format, int size = 512, int quality = 100)
{
return new MicroQRCodeImageBuilder(microQrCodeData)
Expand Down Expand Up @@ -358,7 +358,7 @@ public static void WritePng(MicroQRCodeData microQrCodeData, IBufferWriter<byte>
/// <param name="eccLevel">Error correction level. Default is M.</param>
/// <param name="size">Image side length in pixels.</param>
/// <param name="quality">Quality from 0 to 100, for formats that are lossy.</param>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>.</exception>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>, or cannot encode an image this large in it.</exception>
public static void WriteImage(string content, IBufferWriter<byte> writer, SKEncodedImageFormat format, MicroQREccLevel eccLevel = MicroQREccLevel.M, int size = 512, int quality = 100)
{
new MicroQRCodeImageBuilder(content)
Expand All @@ -376,7 +376,7 @@ public static void WriteImage(string content, IBufferWriter<byte> writer, SKEnco
/// <param name="format">The format to encode as. Skia encodes PNG, JPEG and WebP.</param>
/// <param name="size">Image side length in pixels.</param>
/// <param name="quality">Quality from 0 to 100, for formats that are lossy.</param>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>.</exception>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>, or cannot encode an image this large in it.</exception>
public static void WriteImage(MicroQRCodeData microQrCodeData, IBufferWriter<byte> writer, SKEncodedImageFormat format, int size = 512, int quality = 100)
{
new MicroQRCodeImageBuilder(microQrCodeData)
Expand Down
8 changes: 4 additions & 4 deletions src/FeatherQR.SkiaSharp/QRCodeImageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static byte[] GetPngBytes(QRCodeData qrCodeData, int size = 512)
/// <param name="eccLevel">How much damage the QR code should survive.</param>
/// <param name="size">Image side length in pixels.</param>
/// <param name="quality">Quality from 0 to 100, for formats that are lossy.</param>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>.</exception>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>, or cannot encode an image this large in it.</exception>
public static byte[] GetImageBytes(string content, SKEncodedImageFormat format, QREccLevel eccLevel = QREccLevel.M, int size = 512, int quality = 100)
{
return new QRCodeImageBuilder(content)
Expand All @@ -104,7 +104,7 @@ public static byte[] GetImageBytes(string content, SKEncodedImageFormat format,
/// <param name="format">The format to encode as. Skia encodes PNG, JPEG and WebP.</param>
/// <param name="size">Image side length in pixels.</param>
/// <param name="quality">Quality from 0 to 100, for formats that are lossy.</param>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>.</exception>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>, or cannot encode an image this large in it.</exception>
public static byte[] GetImageBytes(QRCodeData qrCodeData, SKEncodedImageFormat format, int size = 512, int quality = 100)
{
return new QRCodeImageBuilder(qrCodeData)
Expand Down Expand Up @@ -361,7 +361,7 @@ public static void WritePng(QRCodeData qrCodeData, IBufferWriter<byte> writer, i
/// <param name="eccLevel">How much damage the QR code should survive.</param>
/// <param name="size">Image side length in pixels.</param>
/// <param name="quality">Quality from 0 to 100, for formats that are lossy.</param>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>.</exception>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>, or cannot encode an image this large in it.</exception>
public static void WriteImage(string content, IBufferWriter<byte> writer, SKEncodedImageFormat format, QREccLevel eccLevel = QREccLevel.M, int size = 512, int quality = 100)
{
new QRCodeImageBuilder(content)
Expand All @@ -379,7 +379,7 @@ public static void WriteImage(string content, IBufferWriter<byte> writer, SKEnco
/// <param name="format">The format to encode as. Skia encodes PNG, JPEG and WebP.</param>
/// <param name="size">Image side length in pixels.</param>
/// <param name="quality">Quality from 0 to 100, for formats that are lossy.</param>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>.</exception>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>, or cannot encode an image this large in it.</exception>
public static void WriteImage(QRCodeData qrCodeData, IBufferWriter<byte> writer, SKEncodedImageFormat format, int size = 512, int quality = 100)
{
new QRCodeImageBuilder(qrCodeData)
Expand Down
8 changes: 4 additions & 4 deletions src/FeatherQR.SkiaSharp/RmQRCodeImageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static byte[] GetPngBytes(RmQRCodeData rmQrCodeData, int size = DefaultWi
/// <param name="eccLevel">Error correction level. Default is M.</param>
/// <param name="size">Image width in pixels (height follows the rMQR code aspect ratio). Default is 512.</param>
/// <param name="quality">Quality from 0 to 100, for formats that are lossy.</param>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>.</exception>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>, or cannot encode an image this large in it.</exception>
public static byte[] GetImageBytes(string content, SKEncodedImageFormat format, RmQREccLevel eccLevel = RmQREccLevel.M, int size = DefaultWidth, int quality = 100)
{
return new RmQRCodeImageBuilder(content)
Expand All @@ -107,7 +107,7 @@ public static byte[] GetImageBytes(string content, SKEncodedImageFormat format,
/// <param name="format">The format to encode as. Skia encodes PNG, JPEG and WebP.</param>
/// <param name="size">Image width in pixels (height follows the rMQR code aspect ratio). Default is 512.</param>
/// <param name="quality">Quality from 0 to 100, for formats that are lossy.</param>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>.</exception>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>, or cannot encode an image this large in it.</exception>
public static byte[] GetImageBytes(RmQRCodeData rmQrCodeData, SKEncodedImageFormat format, int size = DefaultWidth, int quality = 100)
{
return new RmQRCodeImageBuilder(rmQrCodeData)
Expand Down Expand Up @@ -364,7 +364,7 @@ public static void WritePng(RmQRCodeData rmQrCodeData, IBufferWriter<byte> write
/// <param name="eccLevel">Error correction level. Default is M.</param>
/// <param name="size">Image width in pixels (height follows the rMQR code aspect ratio). Default is 512.</param>
/// <param name="quality">Quality from 0 to 100, for formats that are lossy.</param>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>.</exception>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>, or cannot encode an image this large in it.</exception>
public static void WriteImage(string content, IBufferWriter<byte> writer, SKEncodedImageFormat format, RmQREccLevel eccLevel = RmQREccLevel.M, int size = DefaultWidth, int quality = 100)
{
new RmQRCodeImageBuilder(content)
Expand All @@ -382,7 +382,7 @@ public static void WriteImage(string content, IBufferWriter<byte> writer, SKEnco
/// <param name="format">The format to encode as. Skia encodes PNG, JPEG and WebP.</param>
/// <param name="size">Image width in pixels (height follows the rMQR code aspect ratio). Default is 512.</param>
/// <param name="quality">Quality from 0 to 100, for formats that are lossy.</param>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>.</exception>
/// <exception cref="NotSupportedException">Thrown when Skia has no encoder for <paramref name="format"/>, or cannot encode an image this large in it.</exception>
public static void WriteImage(RmQRCodeData rmQrCodeData, IBufferWriter<byte> writer, SKEncodedImageFormat format, int size = DefaultWidth, int quality = 100)
{
new RmQRCodeImageBuilder(rmQrCodeData)
Expand Down
Loading
Loading