I'm trying to create a simple library for my project where I can read multiple QR codes from a single image.
So far, I have a simple BMP reader:
var bytes = File.ReadAllBytes(@"C:\\test qr\\testowa bitmapa.bmp");
var result = Decrypt.DecryptQRs(bytes, 771, 454);
result.ForEach(Console.WriteLine);
And here's the library part:
public static List<string> DecryptQRs(byte[] imageBytes, int bitmapWidth, int bitmapHeight)
{
LuminanceSource ls = new RGBLuminanceSource(imageBytes, bitmapWidth, bitmapHeight);
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(ls));
var reader = new QRCodeMultiReader();
var results = reader.decodeMultiple(binaryBitmap);
return results.Select(x=>x.Text).ToList();
}
This is a really simple attempt without any error handling or additional features.
In this version, everything is working smoothly up until the decoding of multiple QR codes:
var results = reader.decodeMultiple(binaryBitmap);
The results variable is null, even though the luminance source and binary bitmap are generated correctly.
Do any of you have experience with this library and decoding multiple QR codes?
If your file "testowa bitmapa.bmp" really contains true bitmap file data then you can't read it this way. There is a file header at the beginning which RGBLuminanceSource doesn't handle. It takes the header as pixel data which wouldn't work. Please try the following code snippet: