Class BarcodeReaderGeneric
- Namespace
- ZXing
- Assembly
- zxing.dll
A smart class to decode the barcode inside a bitmap object
public class BarcodeReaderGeneric : IBarcodeReaderGeneric
- Inheritance
-
BarcodeReaderGeneric
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
BarcodeReaderGeneric()
Initializes a new instance of the BarcodeReaderGeneric class.
public BarcodeReaderGeneric()
BarcodeReaderGeneric(Reader, Func<LuminanceSource, Binarizer>, Func<byte[], int, int, BitmapFormat, LuminanceSource>)
Initializes a new instance of the BarcodeReaderGeneric class.
public BarcodeReaderGeneric(Reader reader, Func<LuminanceSource, Binarizer> createBinarizer, Func<byte[], int, int, RGBLuminanceSource.BitmapFormat, LuminanceSource> createRGBLuminanceSource)
Parameters
reader
ReaderSets the reader which should be used to find and decode the barcode. If null then MultiFormatReader is used
createBinarizer
Func<LuminanceSource, Binarizer>Sets the function to create a binarizer object for a luminance source. If null then HybridBinarizer is used
createRGBLuminanceSource
Func<byte[], int, int, RGBLuminanceSource.BitmapFormat, LuminanceSource>Sets the function to create a luminance source object for a rgb array. If null the RGBLuminanceSource is used. The handler is only called when Decode with a byte[] array is called.
Fields
defaultCreateRGBLuminanceSource
represents the default function which is called to get a RGBLuminanceSource instance from a raw byte array
protected static readonly Func<byte[], int, int, RGBLuminanceSource.BitmapFormat, LuminanceSource> defaultCreateRGBLuminanceSource
Field Value
Properties
AutoRotate
Gets or sets a value indicating whether the image should be automatically rotated. Rotation is supported for 90, 180 and 270 degrees
public bool AutoRotate { get; set; }
Property Value
- bool
true
if image should be rotated; otherwise,false
.
CreateBinarizer
Optional: Gets or sets the function to create a binarizer object for a luminance source. If null then HybridBinarizer is used
protected Func<LuminanceSource, Binarizer> CreateBinarizer { get; }
Property Value
- Func<LuminanceSource, Binarizer>
The function to create a binarizer object.
Options
Gets or sets the options.
public DecodingOptions Options { get; set; }
Property Value
- DecodingOptions
The options.
Reader
Gets the reader which should be used to find and decode the barcode.
protected Reader Reader { get; }
Property Value
- Reader
The reader.
TryInverted
Gets or sets a value indicating whether the image should be automatically inverted if no result is found in the original image. ATTENTION: Please be carefully because it slows down the decoding process if it is used
[Obsolete("Please use Options.TryInverted")]
public bool TryInverted { get; set; }
Property Value
- bool
true
if image should be inverted; otherwise,false
.
Methods
Decode(byte[], int, int, BitmapFormat)
Decodes the specified barcode bitmap.
public Result Decode(byte[] rawRGB, int width, int height, RGBLuminanceSource.BitmapFormat format)
Parameters
rawRGB
byte[]The image as byte[] array.
width
intThe width.
height
intThe height.
format
RGBLuminanceSource.BitmapFormatThe format.
Returns
- Result
the result data or null
Decode(LuminanceSource)
Tries to decode a barcode within an image which is given by a luminance source. That method gives a chance to prepare a luminance source completely before calling the time consuming decoding method. On the other hand there is a chance to create a luminance source which is independent from external resources (like Bitmap objects) and the decoding call can be made in a background thread.
public virtual Result Decode(LuminanceSource luminanceSource)
Parameters
luminanceSource
LuminanceSourceThe luminance source.
Returns
DecodeMultiple(byte[], int, int, BitmapFormat)
Decodes the specified barcode bitmap.
public Result[] DecodeMultiple(byte[] rawRGB, int width, int height, RGBLuminanceSource.BitmapFormat format)
Parameters
rawRGB
byte[]The image as byte[] array.
width
intThe width.
height
intThe height.
format
RGBLuminanceSource.BitmapFormatThe format.
Returns
- Result[]
the result data or null
DecodeMultiple(LuminanceSource)
Tries to decode barcodes within an image which is given by a luminance source. That method gives a chance to prepare a luminance source completely before calling the time consuming decoding method. On the other hand there is a chance to create a luminance source which is independent from external resources (like Bitmap objects) and the decoding call can be made in a background thread.
public virtual Result[] DecodeMultiple(LuminanceSource luminanceSource)
Parameters
luminanceSource
LuminanceSourceThe luminance source.
Returns
- Result[]
OnResultFound(Result)
raises the ResultFound event
protected void OnResultFound(Result result)
Parameters
result
Result
OnResultPointFound(ResultPoint)
calls the explicitResultPointFound action
protected void OnResultPointFound(ResultPoint resultPoint)
Parameters
resultPoint
ResultPoint
OnResultsFound(IEnumerable<Result>)
raises the ResultFound event
protected void OnResultsFound(IEnumerable<Result> results)
Parameters
results
IEnumerable<Result>
Events
ResultFound
event is executed if a result was found via decode
public event Action<Result> ResultFound
Event Type
ResultPointFound
Gets or sets a method which is called if an important point is found
public event Action<ResultPoint> ResultPointFound
Event Type
- Action<ResultPoint>
The result point callback.