QRCoder
QRCoder copied to clipboard
Improve QRCode output sharpness
Hi there,
[ ] Bug
[X] Question (e.g. about handling/usage)
[ ] Request for new feature/improvement
I am looking at using this package in place of calling Google's Chart API to generate QRCodes, the implementation I've followed uses the basic example in Wiki. What I see is that the image output of the library is noticeably blurred / pixelated when compared to the output from Google Chart.

What can I do to improve on the image sharpness?
var url = "https://github.com/codebude/QRCoder/issues/new";
QRCodeGenerator _qrCode = new QRCodeGenerator();
QRCodeData _qrCodeData = _qrCode.CreateQrCode(url, QRCodeGenerator.ECCLevel.L);
PngByteQRCode qrCode = new PngByteQRCode(_qrCodeData);
byte[] qrAsPngByteArray = qrCode.GetGraphic(20);
using(var ms = new MemoryStream(qrAsPngByteArray))
{
testQRCode.Image = new Bitmap(ms);
}
- Version used: 1.4.3
- Compiled from source or NuGet package?: Nuget
- Payload/Encoded text: "https://github.com/codebude/QRCoder/issues/new"
- Used payload generator: QRCodeGenerator
- Used ECC-level: L
- Used renderer class: PngByteQRCode
- Environment (.NET 3.5, .NET 4.X, .NETCore, ...): .NET 4.7.2
@DanielHolland
Official responses from the maintainer:
- https://github.com/codebude/QRCoder/issues/152#issuecomment-437800025
- https://github.com/codebude/QRCoder/issues/152#issuecomment-438461685
- https://github.com/codebude/QRCoder/issues/299#issuecomment-910415076
I believe you want to raise the pixelsPerModule value in this line:
byte[] qrAsPngByteArray = qrCode.GetGraphic(20);
| Parameter name | Type | Default | Description |
|---|---|---|---|
| pixelsPerModule | int | The pixel size each b/w module is drawn |
Alternative
SvgQRCode This one is vector based so it can be resized without loss of quality but it may not fit your requirements.
Hi @DanielHolland the solution to your problem was perfectly summarized by @digitaldirk thus I'm closing the issue. In case you have any further questions just reopen the issue. :-)