title: C# - Using ZXing.Net to Decode png QR Code
body: <p>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:
  <a href="https://stackoverflow.com/questions/28561772/c-sharp-with-zxing-net-decoding-the-qr-code">C# with ZXing.Net: Decoding the QR code</a></p>
  
  <p>Code:</p>
  
  <pre><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);
     }
  </code></pre>
  
  <p>Here the code throws the compile time error on BitmapLuminanceSource</p>
  
  <blockquote>
    <p>The type or namespace name 'BitmapLuminanceSource' could not be found
    (are you missing a using directive or an assembly reference?</p>
  </blockquote>
  
  <p>I have already installed ZXing.Net package here, I am not able to understand, why this class reference is not working here.</p>
  
  <p>To make the code work, I have copied this class from git from here:
  <a href="https://github.com/micjahn/ZXing.Net/blob/master/Source/lib/BitmapLuminanceSource.cs" rel="nofollow noreferrer">https://github.com/micjahn/ZXing.Net/blob/master/Source/lib/BitmapLuminanceSource.cs</a></p>