I am using the ZXing.Net library(0.16.4) to encode and decode a QR Code. I got the reference of how to decode the qr code from here: C# with ZXing.Net: Decoding the QR code
Code:
Bitmap image = (Bitmap)Bitmap.FromFile(@"file.png");
byte[] bytes = File.ReadAllBytes(@"file.png");
try
{
using (image)
{
LuminanceSource source;
source = new BitmapLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Result result = new MultiFormatReader().decode(bitmap);
if (result != null)
{
//... code found
var data = result.Text.Split(Environment.NewLine);
}
else
{
//... no code found
}
}
}
catch (Exception exception)
{
throw new Exception("Cannot decode the QR code " + exception.Message);
}
Here the code throws the compile time error on BitmapLuminanceSource
The type or namespace name 'BitmapLuminanceSource' could not be found (are you missing a using directive or an assembly reference?
I have already installed ZXing.Net package here, I am not able to understand, why this class reference is not working here.
To make the code work, I have copied this class from git from here: https://github.com/micjahn/ZXing.Net/blob/master/Source/lib/BitmapLuminanceSource.cs