DecodeBitmapRect Method
Description
Reads barcode from a specified area on an image in buffer.
Syntax
public BarcodeResult[] DecodeBitmapRect(Bitmap bitmap, Rectangle rect);
Parameters
-
bitmap
- An image loaded in the physical memory (application buffer).
-
rect
- The specified area on the file which is a rectangle.
Return Value
All barcodes have been read. If no barcodes are read, null is returned.
Example
ReaderOptions option = new ReaderOptions();
option.BarcodeFormats = (
BarcodeFormat.OneD |
BarcodeFormat.QR_CODE |
BarcodeFormat.PDF417 |
BarcodeFormat.DATAMATRIX
);
option.MaxBarcodesToReadPerPage = 1;
BarcodeReader reader = new BarcodeReader();
reader.ReaderOptions = option;
try
{
Bitmap bBMP = new Bitmap("C:\\test.bmp");
BarcodeResult[] results = reader.DecodeBitmapRect(bBMP, rect);
for(int i = 0; i < results.Length; ++i)
{
BarcodeResult barcode = results[i];
Console.WriteLine("{0}: {1}", i, barcode.BarcodeText);
}
}
catch(BarcodeReaderException exp)
{
Console.WriteLine("Error: {0}, {1}", exp.Code.ToString(), exp.Message);
}
See Also
.NET > Classes > BarcodeReader > DecodeBitmap
.NET > Classes > ReaderOptions > BarcodeFormats
.NET > Classes > ReaderOptions > MaxBarcodesToReadPerPage
.NET > Classes > BarcodeReaderException
.NET > Enumeration > BarcodeFormat
.NET > Enumeration > ErrorCode