manuelbl / QrCodeGenerator

QR Code Generator for .NET
MIT License
306 stars 77 forks source link

Skia Extensions don't allow Transparent Images to be rendered #23

Closed PaulFarry closed 9 months ago

PaulFarry commented 11 months ago

In the Extensions file for Skia

The creation of the Bitmap doesn't allow for a transparent colour to be used for the background.

If it is replaced with the following you can use a colour that includes transparency for the background.

SKBitmap bitmap = new SKBitmap(dim, dim, SKColorType.Rgba8888, SKAlphaType.Premul);

I haven't tested for all cases, but seems to be the minimum required to get transparency.

I did also test using canvas.Clear(background) instead of canvas.DrawRect(0, 0, dim, dim, paint);which also seemed to work

manuelbl commented 10 months ago

Thanks for the input.

I've updated the extension for Skia to support fully or partially transparent backgrounds. If the background color is not fully opaque, a bitmap with alpha channel will be used.