Our .NET Barcode Reader DLL empowers VB.NET and C#.NET programmers to use well designed barcode decoding APIs to read Data Matrix 2d barcodes from common raster image files, including bmp, gif, jpeg, jpg, png, tif, and tiff, These image files can be loaded in the form of bitmap, local picture or stream. Please note, it's required enough graphs resolution to make the barcode image clear.
Visual C# Data Matrix Scanning
The following APIs can help you to achieve high quality 2d bar code decoding easily. In general, you can use the first three APIs for your Data Matrix reading in C# programs. There may be a group of barcodes in the picture, and can be located in any position of the pictrue, our .net barcode scanner will resolve it easily, can read all the barcode symbol out. If you want to save barcode reading time, you may use the second three APIs to define the barcode type as Data Matrix. Then, our barcode scanner dll component for .NET will only read Data Matrix bar codes from loaded image source. Moreover, to improve barcode recognition accuracy, we provide ScanSingle APIs for one barcode recognition. It is suitable when there's only one barcode on your image.
public static BarcodeResult[] Scan(Bitmap bitmap); public static BarcodeResult[] Scan(Stream stream); public static BarcodeResult[] Scan(string filename); public static BarcodeResult[] Scan(Bitmap bitmap, BarCodeType barType); public static BarcodeResult[] Scan(Stream stream, BarCodeType barType); public static BarcodeResult[] Scan(string filename, BarCodeType barType); public static BarcodeResult ScanSingle(Bitmap bitmap); public static BarcodeResult ScanSingle(Stream stream); public static BarcodeResult ScanSingle(string filename);
In the following code boxes, you will see Visual C# demo codes for defining Data Matrix as target barcode type and read all of them from your load image source (sample: a string value) and reading one Data Matrix from image using ScanSingle method (more accurate).
public void ScanDataMatrixFromFile(string filename) { // Scan and recognize Data Matrix only from loaded image file. BarcodeResult[] results = BarCodeScanner.Scan(filename, BarCodeType.DataMatrix); foreach (BarcodeResult result in results) { Console.WriteLine(result.BarType.ToString() + "-" + result.Data); } }
Bitmap bmp = new Bitmap("YourImagePath"); BarcodeResult barcode = BarCodeScanner.ScanSingle(bmp); Console.WriteLine("barcode data:{0}.", barcode.Data);
Visual Basic Data Matrix Scanning
Here, we also provide robust APIs and Visual Basic demo codes for all barcode types reading from image file including Data Matrix two-dimensional barcode, and single Data Matrix barcode reading from image. For more details of VB.NET barcode reading, please see Barcode Recognition Using VB.NET - Overview
public static BarcodeResult[] Scan(Bitmap bitmap) public static BarcodeResult[] Scan(Stream stream) public static BarcodeResult[] Scan(string filename) public static BarcodeResult[] Scan(Bitmap bitmap, BarCodeType barType) public static BarcodeResult[] Scan(Stream stream, BarCodeType barType) public static BarcodeResult[] Scan(string filename, BarCodeType barType) public static BarcodeResult ScanSingle(Bitmap bitmap) public static BarcodeResult ScanSingle(Stream stream) public static BarcodeResult ScanSingle(string filename)
Public Sub ScanAllFromFile(ByVal filename As String) ' Scan and recognize all barcode types from loaded image file. Dim results() As BarcodeResult = BarCodeScanner.Scan(filename) Dim result As BarcodeResult For Each result In results Console.WriteLine(result.BarType.ToString() + "-" + result.Data) Next End Sub
' Used to improve barcode reader accuracy when there's only one Data Matrix on your image. Dim bmp As Bitmap = New Bitmap("YourImagePath") Dim barcode As BarcodeResult = BarCodeScanner.ScanSingle(bmp) Console.WriteLine("barcode data:{0}.", barcode.Data)