guitarrapc / SkiaSharp.QrCode

Qr Code Generator with Skia. (no System.Drawing)
https://www.nuget.org/packages/SkiaSharp.QrCode
MIT License
189 stars 40 forks source link

Icons have black borders in linux #54

Open EwenGao opened 2 years ago

EwenGao commented 2 years ago

Linux: image

Windows: image

code: var icon = new IconData { Icon = SKBitmap.Decode(byteIcon), IconSizePercent = 10, };

        using var generator = new QRCodeGenerator();
        var qr = generator.CreateQrCode(url, ECCLevel.L);
        var info = new SKImageInfo(512, 512);
        using var surface = SKSurface.Create(info);
        var canvas = surface.Canvas;
        canvas.Render(qr, info.Width, info.Height, SKColor.Parse("ffffff"), SKColor.Parse("000000"), icon);
        using var image = surface.Snapshot();
        using var data = image.Encode(SKEncodedImageFormat.Png, 100);
guitarrapc commented 2 years ago

Hi @EwenGao, I've tried reproduce issue but I couldn't. Could you provide reproduceable example for further deep dive?

Here's my code based on what you provided. https://gist.github.com/guitarrapc/bc11f8d7c2ae3ce4e481aa391b5e0c88

Environment was Windows 11 and WSL2 (Ubuntu 22.04).

EwenGao commented 2 years ago

Thank your answer

I think it's the environment, my environment was Windows 11 and CentOS 7.9