This project has moved. For the latest updates, please go here.

BarcodeReaderGeneric Class

Oct 20, 2012 at 11:04 PM

Looking at the constructor that takes no parameters, I can see it calls the constructor passing in null for the createLuminanceSource delegate.

Please correct me if I'm wrong but instances of this class can't set createLuminanceSource after instantiation. So why is there a constructor for this class that can take no parameters and passes null to the other constructor?

There is no real issue I'm having, I'm only asking to see if I am understanding the code properly.


Oct 23, 2012 at 6:40 PM

I looked at the source and I found the following: for the class BarcodeReader it isn't true. The current source looks like the following:

      /// <summary>
      /// Initializes a new instance of the <see cref="BarcodeReader"/> class.
      /// </summary>
      public BarcodeReader()
         : this(new MultiFormatReader(), defaultCreateLuminanceSource, null)

There is no null passed to the base class. So I think you talk about BarcodeReaderGeneric.
If so you are right. The constructor of BarcodeReaderGeneric:

      /// <summary>
      /// Initializes a new instance of the <see cref="BarcodeReaderGeneric"/> class.
      /// </summary>
      public BarcodeReaderGeneric()
         : this(new MultiFormatReader(), null, defaultCreateBinarizer)

That doesn't make sense at the first look.
But there is a function Decode(byte[] rawRGB, ...). That method uses a default luminance source for byte-arrays with
RGB values. It doesn't use the createLuminanceSource delegate. So it can be null.
If it is null you should not call the method Decode(T barcodeBitmap) which results to an exception.

The code isn't fully clean and clear, I know. But it works. :)

Oct 23, 2012 at 6:42 PM

Sorry, I didn't read the caption of the thread. You really did only speak about the BarcodeReaderGeneric class.