Our Customers
Contact Us Email: support@barcodelib.com
Home > .NET Barcode Reader > C#.NET Barcode Recognition Guide > How to Reader Code 128 Barcodes fro C#.NET Project
Download Barcode Reader for .NET Trial

How to Read Code 128 1D Barcodes Using C#

Tutorial for Code 128 C# barcode reading & decoding
  • Simple to implement C#.NET Code 128 barcode scanning task in Visual Sutdio .NET Framework
  • Provide free C# sample code to recognize Code 128 barcode data for .NET developers
  • Quickly read Code 128 from .NET WinForms, ASP.NET, .NET Class Library and Console Application
  • Support Code 128 (Code Set A, B, C) barcode reading & scanning using C# class library
  • Capable of reading Code 128 linear barcodes from multiple image source files
  • Recognise other linear (1d) barcodes in C#, like Codabar, Code 128, EAN/UPC, Interleaved 2 of 5, etc
  • Reliable C# Barcode Reader Component for .NET having been in use since 2003
How to Install C# Code 128 Scanner Library to .NET Project
  1. The first step is to add BarcodeLib.BarcodeReader.dll to your C#.NET project reference.
How to Recognize Code 128 Barcode Using C# Demo Code
One line C# demo code will accomplish this task. Please directly use these free C# demo codes for Code 128 barcode recognition.
     string[] results = BarcodeReader.read("c:/code128-csharp.gif", BarcodeReader.CODE128);
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.
  1. If so, our C#.NET Code 128 Barcode Reader SDK will stop reading the barcode as soon as it detects one Code 128 barcode.
  2. 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.
  1. 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);

setting.setAreas(areas);

string[] results = BarcodeReader.read("c:/code128-csharp.gif", BarcodeReader.CODE128, setting);
Other Related Code 128 Barcode Recognition Guide
Scan 1D Barcode Images:
Scan 2D Barcode Images: