using IronBarCode;
using System.Drawing;
// 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 file
var resultFromPdf = BarcodeReader.ReadPdf(@"file/mydocument.pdf"); // From PDF use ReadPdf
// To configure and fine-tune barcode reading, utilize the BarcodeReaderOptions class
var myOptionsExample = new BarcodeReaderOptions
{
// Choose a reading 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 single barcode is found (if set to true)
ExpectMultipleBarcodes = true,
// By default, all barcode formats are scanned for
// Specifying a subset of barcode types to search for would improve performance
ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,
// Utilize multiple threads to read barcodes from multiple images in parallel
Multithreaded = true,
// Maximum threads for parallelized barcode reading
// Default is 4
MaxParallelThreads = 2,
// The area of each image frame in which to scan for barcodes
// Specifying a crop area will significantly improve performance and avoid noisy parts of the image
CropArea = new Rectangle(),
// Special setting for Code39 barcodes
// If a Code39 barcode is detected, try to read with both the base and extended ASCII character sets
UseCode39ExtendedMode = true
};
// Read with the options applied
var results = BarcodeReader.Read("barcode.png", myOptionsExample);
// Create a barcode with one line of code
var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);
// After creating a barcode, we may choose to resize
myBarcode.ResizeTo(400, 100);
// Save our newly-created barcode as an image
myBarcode.SaveAsImage("EAN8.jpeg");
// Get the barcode as an image for further processing
var myBarcodeImage = myBarcode.Image;
Imports IronBarCode
Imports System.Drawing
' 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 file
Dim resultFromPdf = BarcodeReader.ReadPdf("file/mydocument.pdf") ' From PDF use ReadPdf
' To configure and fine-tune barcode reading, utilize the BarcodeReaderOptions class
Dim myOptionsExample As New BarcodeReaderOptions With {
' Choose a reading 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 single barcode is found (if set to true)
.ExpectMultipleBarcodes = True,
' By default, all barcode formats are scanned for
' Specifying a subset of barcode types to search for would improve performance
.ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,
' Utilize multiple threads to read barcodes from multiple images in parallel
.Multithreaded = True,
' Maximum threads for parallelized barcode reading
' Default is 4
.MaxParallelThreads = 2,
' The area of each image frame in which to scan for barcodes
' Specifying a crop area will significantly improve performance and avoid noisy parts of the image
.CropArea = New Rectangle(),
' Special setting for Code39 barcodes
' If a Code39 barcode is detected, try to read with both the base and extended ASCII character sets
.UseCode39ExtendedMode = True
}
' Read with the options applied
Dim results = BarcodeReader.Read("barcode.png", myOptionsExample)
' Create a barcode with one line of code
Dim myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8)
' After creating a barcode, we may choose to resize
myBarcode.ResizeTo(400, 100)
' Save our newly-created barcode as an image
myBarcode.SaveAsImage("EAN8.jpeg")
' Get the barcode as an image for further processing
Dim myBarcodeImage = myBarcode.Image
Install-Package BarCode
바코드 빠른 시작
IronBarcode는 이미지 파일(jpeg, png 및 jpg)부터 변수 전달을 원하는 경우의 비트맵과 같은 점진적 형식에 이르기까지 다양한 표준 형식을 지원합니다. 게다가 PDF 등의 외부 형식도 지원하여 IronBarcode가 모든 코드베이스에 원활하게 통합되도록 하여 개발자에게 파일 형식과 변수에 대한 유연성을 제공합니다.
IronBarcode는 모든 파일 형식의 BARCODE 리더일 뿐만 아니라, EAN8, Code128, Code39와 같은 모든 표준 인코딩 및 서식을 지원하는 BARCODE 생성기 역할도 합니다. 바코드 생성기 설정은 단 두 줄의 코드만 필요합니다. 개발자를 위한 많은 커스터마이징 옵션과 낮은 진입 장벽을 가진 IronBarcode는 바코드 관련 모든 상황에서 최고의 선택입니다.
`var myOptionsExample = new BarcodeReaderOptions { /* Options */ };`
바코드 작성기
먼저 IronBarCode 및 System.Drawing와 같은 필수 라이브러리를 임포트하고, BarcodeWriter를 인스턴스화하여 12345의 문자열 값을 EAN8 형식으로 BARCODE로 생성합니다. 생성된 바코드를 원하는 형식의 이미지로 저장합니다. IronBarcode는 Image 및 Bitmap 형식의 BARCODE 생성을 모두 지원하므로, 이에 대한 다양한 옵션이 있습니다.
고급 바코드 작성기
위에서 보았듯이, IronBarcode를 사용하면 바코드를 생성하는 데 두 줄의 코드만 필요하고 이후 사용을 위해 파일로 저장할 수 있습니다. IronBarcode는 개발자에게 상황에 맞는 바코드를 커스터마이즈할 수 있는 다양한 옵션을 제공합니다.
ResizeTo 메서드를 사용하고 높이와 너비를 전달하여 BarCode 이미지의 크기를 조정할 수 있습니다.
바코드 리더
위와 같이, 먼저 BarcodeReader를 인스턴스화하고, Read 메서드에 파일 경로를 전달한 다음, 나중에 BARCODE 객체를 조작할 때 사용할 수 있도록 변수에 저장합니다. ReadPDF을 사용하여 PDF와 같은 외부 형식을 읽는 데 사용되는 지정된 메서드가 있습니다; 단, 일반적인 이미지 형식 및 비트맵의 경우 Read을 사용합니다.
BarcodeReaderOptions
IronBarcode는 개발자가 표준 파일 형식에서 바코드를 스캔할 수 있도록 합니다. 그러나 개발자가 BarcodeReaderOptions 메서드의 동작을 미세 조정하고자 하는 경우가 있으며, 특히 프로그래밍 방식으로 일괄 BarCode 파일을 읽는 경우 그러합니다. 이때 BarcodeReaderOptions가 필요합니다. IronBarcode를 사용하면 Speed을 통해 판독 속도, ExpectedMultipleBarcodes을 통해 파일에 여러 BarCode가 포함될지 여부, 그리고 ExpectBarcodeTypes 속성을 통해 BarCode의 종류 등을 완전히 사용자 지정할 수 있습니다. 이는 개발자가 여러 이미지를 병렬로 읽기 위한 여러 스레드를 실행하고 병렬 읽기를 수행할 때 사용할 스레드 수를 제어하도록 합니다.
이것들은 IronBarcode의 강력함을 보여주는 몇 가지 속성들에 불과합니다. 전체 목록은 여기에서 문서를 참조하세요.