The above Visual C# demo code will read all the Code 128 barcodes in the source file "code128-csharp.gif".
How to Achieve Code 128 Better Reading Using C# Demo Code
To improve Code 128 reading, BarcodeLib also provides other ways that are suitable especially when the source image file is in a large size, like 4mb per image.
1. Recognize the Maximum One Code 128 from Image Source
If you need to read the maximum one Code 128 in a image source (per image, page in tiff or pdf document), please set maxOneBarcodePerPage to true.
If so, our C#.NET Code 128 Barcode Reader SDK will stop reading the barcode as soon as it detects one Code 128 barcode.
If this property keeps the default value (false), our C#.NET Code 128 Barcode Reader SDK will use total 5 algorithms and each will read the whole source file from 4 directions.
2. Recognize the Partial Image of a Source File
If the Code 128 barcode is always on specific area in image file, you can customize Code 128 C# Barcode Scanner Component to scan that area only. And this helps to save a lot of reading time, CPU and memory usage.
Please specify the left top point and right bottom point of the area (the point X, Y values are expressed in percentage of the whole image, so image most left top point is (0%, 0%), and most right bottom point is (100%, 100%)).
The free C# demo code below gives an example of scanning Code 128 from a specified area of an source file. (Scanning top 20% and bottom 20% of the image )
OptimizeSetting setting = new OptimizeSetting();
setting.setMaxOneBarcodePerPage(true);
ScanArea top20 = new ScanArea(new PointF(0.0F, 0.0F), new PointF(100.0F, 20.0F));
ScanArea bottom20 = new ScanArea(new PointF(0.0F, 80.0F), new PointF(100.0F, 100.0F));
List<ScanArea> areas = new List<ScanArea>(); areas.Add(top20); areas.Add(bottom20);