IronBarcode标识

从图像读取条形码 C#

  • 从图像中提取条形码
  • 支持多种条形码类型
  • 条形码读取精度高。
  • 只需集成到 C# 应用程序即可。
  • 从数据流中读取条形码
可信
作者:
美国国家航空航天局标志赫兹标志3M标志特斯拉标志

立即免费开始

No credit card or account creation required
Test Icon

在实际环境中测试

在生产中测试无水印。
随时随地为您服务。

Functional Icon

全面功能产品

获取30天的完全功能产品。
几分钟内即可启动和运行。

Support Icon

24/5 技术支持

在您的产品试用期间,全面访问我们的支持工程团队。

条码快速入门

using IronBarCode;
using System.Drawing;

// Creating a barcode is as simple as:
var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);

// And save our barcode as in image:
myBarcode.SaveAsImage("EAN8.jpeg");

Image myBarcodeImage = myBarcode.Image; // Can be used as Image
Bitmap myBarcodeBitmap = myBarcode.ToBitmap(); // Can be used as Bitmap

// Reading a barcode is easy with IronBarcode:
var resultFromFile = BarcodeReader.Read(@"file/barcode.png"); // From a file
var resultFromBitMap = BarcodeReader.Read(new Bitmap("barcode.bmp")); // From a bitmap
var resultFromImage = BarcodeReader.Read(Image.FromFile("barcode.jpg")); // From an image
var resultFromPdf = BarcodeReader.ReadPdf(@"file/mydocument.pdf"); // From PDF use ReadPdf

// After creating a barcode, we may choose to resize and save which is easily done with:
var myNewBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);
myNewBarcode.ResizeTo(400, 100);
myNewBarcode.SaveAsImage("myBarcodeResized.jpeg");

// To set more options and optimization with your Barcode Reading,
// Please utilize the BarcodeReaderOptions paramter of read:
var myOptionsExample = new BarcodeReaderOptions
{
    // Choose a speed from: Faster, Balanced, Detailed, ExtremeDetail
    // There is a tradeoff in performance as more Detail is set
    Speed = ReadingSpeed.Balanced,

    // Reader will stop scanning once a barcode is found, unless set to true
    ExpectMultipleBarcodes = true,

    // By default, all barcode formats are scanned for.
    // Specifying one or more, performance will increase.
    ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,

    // Utilizes multiple threads to reads barcodes from multiple images in parallel.
    Multithreaded = true,

    // Maximum threads for parallel. Default is 4
    MaxParallelThreads = 2,

    // The area of each image frame in which to scan for barcodes.
    // Will improve performance significantly and avoid unwanted results and avoid noisy parts of the image.
    CropArea = new Rectangle(),

    // Special Setting for Code39 Barcodes.
    // If a Code39 barcode is detected. Try to use extended mode for the full ASCII Character Set
    UseCode39ExtendedMode = true
};

// And, apply:
var results = BarcodeReader.Read("barcode.png", myOptionsExample);
Imports IronBarCode
Imports System.Drawing

' Creating a barcode is as simple as:
Private myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8)

' And save our barcode as in image:
myBarcode.SaveAsImage("EAN8.jpeg")

Dim myBarcodeImage As Image = myBarcode.Image ' Can be used as Image
Dim myBarcodeBitmap As Bitmap = myBarcode.ToBitmap() ' Can be used as Bitmap

' Reading a barcode is easy with IronBarcode:
Dim resultFromFile = BarcodeReader.Read("file/barcode.png") ' From a file
Dim resultFromBitMap = BarcodeReader.Read(New Bitmap("barcode.bmp")) ' From a bitmap
Dim resultFromImage = BarcodeReader.Read(Image.FromFile("barcode.jpg")) ' From an image
Dim resultFromPdf = BarcodeReader.ReadPdf("file/mydocument.pdf") ' From PDF use ReadPdf

' After creating a barcode, we may choose to resize and save which is easily done with:
Dim myNewBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8)
myNewBarcode.ResizeTo(400, 100)
myNewBarcode.SaveAsImage("myBarcodeResized.jpeg")

' To set more options and optimization with your Barcode Reading,
' Please utilize the BarcodeReaderOptions paramter of read:
Dim myOptionsExample = New BarcodeReaderOptions With {
	.Speed = ReadingSpeed.Balanced,
	.ExpectMultipleBarcodes = True,
	.ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,
	.Multithreaded = True,
	.MaxParallelThreads = 2,
	.CropArea = New Rectangle(),
	.UseCode39ExtendedMode = True
}

' And, apply:
Dim results = BarcodeReader.Read("barcode.png", myOptionsExample)
Install-Package BarCode

探索代码并运行它以查看示例。

世界级工程,
24小时支持