Skip to content

QR Code with Logo Cut Off Issue #296

@ben1234456

Description

@ben1234456

Hi,

Refer to the code below. When I assign a string to the QR content and generate the QR code, you can see that QR code has a cut-off issue (the logo is blocking some of the data). This only happens when the QR content is not an URL, if the content is an URL, it looks completely fine like the examples in the sample.

Not sure I missed out the configuration of this. Can you please advise on this?

Thanks!

PS: Seems like there is a policy where I cannot upload image here, I will use image link instead.

QR Code With String

Image

QR Code With URL

Image
using SkiaSharp;
using SkiaSharp.QrCode;
using SkiaSharp.QrCode.Image;

Console.OutputEncoding = System.Text.Encoding.UTF8;

var content = "abc";
var outputDir = "qr.png";
var iconPath = "insta.png";

// For this example, we'll use the test icon
using var logo = SKBitmap.Decode(File.ReadAllBytes(iconPath));
var icon = IconData.FromImage(logo, iconSizePercent: 14, iconBorderWidth: 1);

var qrBuilder = new QRCodeImageBuilder(content)
    .WithSize(1024, 1024)
    .WithErrorCorrection(ECCLevel.H)
    .WithQuietZone(4)
    .WithColors(
        codeColor: SKColor.Parse("ff6000"),     
        backgroundColor: SKColors.White, 
        clearColor: SKColors.White
    )
    .WithModuleShape(CircleModuleShape.Default, sizePercent: 1.0f)
    .WithFinderPatternShape(RoundedRectangleCircleFinderPatternShape.Default)
    .WithIcon(icon);

var pngBytes = qrBuilder.ToByteArray();
File.WriteAllBytes(outputDir, pngBytes);

Console.WriteLine($"  ✓ Saved to: {outputDir}");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions