QR Codes with images losing data when converting to byte[]
See original GitHub issueType of issue
[x ] Bug
[ ] Question (e.g. about handling/usage)
[ ] Request for new feature/improvement
Expected Behavior
I expect the generated QR code to look like this but have the logo in the middle.
Current Behavior
This is currently what is output if adding a logo.
Steps to Reproduce (for bugs)
Here is my code for generating a QR Code with a logo
private async Task<byte[]> GetLogoQRCode(string url, string darkColorHex, string logoUrl)
{
PayloadGenerator.Url generator = new PayloadGenerator.Url(url);
string payload = generator.ToString();
using (var qrGenerator = new QRCodeGenerator())
using (var qrCodeData = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q))
using (var qrCode = new QRCode(qrCodeData))
using (var stream = new MemoryStream())
{
// Grab an image from the internet and convert it to a Bitmap
var logo = await _webHelper.GetImageFromWeb(logoUrl);
// Convert a Hex string into a Color
var darkColor = ColorTranslator.FromHtml(darkColorHex);
var qrCodeImage = qrCode.GetGraphic(20, darkColor, Color.White, logo, 20);
qrCodeImage.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
var result = stream.ToArray();
return result;
}
}
Your Environment
- OS: macOS Mojave Version 10.14.6
- Version used: 1.3.5
- Compiled from source or NuGet package?: Nuget
- Payload/Encoded text: payload
- Used payload generator: yes
- Used ECC-level:
- Used renderer class:
- Environment (.NET 3.5, .NET 4.X, .NETCore, …): .NET 2.2
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Storing binary data in QR codes
I used System.Convert.ToBase64String to convert the supplied sample byte array into a Base64-encoded string, then I used ZXing to create a ...
Read more >Decoding a Broken QR Code
A QR code's data is layed out in a very particular manner which means that ... I recommend converting each byte you read...
Read more >Transfer Data with Animated QR codes
The article talks about how to transfer data with animated QR codes.
Read more >QR Code Size: Minimum Size, Maximum Size & More [2023]
A QR code is capable of encoding a maximum of 2953 bytes of data, ... such as brand logos & images, graphics, shapes,...
Read more >Color Can Triple QR Code Capacity
There are quite a few variations of rMQR, but the largest can hold 361 bytes. The basic idea is to generate three different...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @Sdraugel , @manikata0 , @Simon311 @johnboker , @abrari - thanks for you support and pushing me again and again to merge this. I really apologize for the long response times. That’s not how it should work out usually. Thus thanks again for being patient! 😃
Waiting this fix to be released to nuget