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는 모든 파일 형식에 대한 바코드 리더일 뿐만 아니라, 바코드 생성기로도 작동하여 EAN8, Code128 및 Code39와 같은 모든 표준 인코딩 및 포맷을 지원합니다. 바코드 생성기 설정은 단 두 줄의 코드만 필요합니다. 개발자를 위한 많은 커스터마이징 옵션과 낮은 진입 장벽을 가진 IronBarcode는 바코드 관련 모든 상황에서 최고의 선택입니다.
`var myOptionsExample = new BarcodeReaderOptions { /* Options */ };`
바코드 작성기
먼저 IronBarCode 및 System.Drawing와 같은 필수 라이브러리를 가져와서 BarcodeWriter를 인스턴스화하여 12345 문자열 값을 가진 바코드를 EAN8 형식으로 만듭니다. 생성된 바코드를 원하는 형식의 이미지로 저장합니다. IronBarcode는 바코드를 Image 뿐만 아니라 Bitmap로도 생성할 수 있도록 지원합니다.
고급 바코드 작성기
위에서 보았듯이, IronBarcode를 사용하면 바코드를 생성하는 데 두 줄의 코드만 필요하고 이후 사용을 위해 파일로 저장할 수 있습니다. IronBarcode는 개발자에게 상황에 맞는 바코드를 커스터마이즈할 수 있는 다양한 옵션을 제공합니다.
바코드 이미지를 크기 조정하기 위해 높이와 너비를 전달할 수 있는 ResizeTo 메서드를 사용할 수 있습니다.
바코드 리더
위와 마찬가지로 먼저 BarcodeReader를 인스턴스화하고, 파일 경로를 Read 메서드에 전달하여 나중에 사용하고 바코드 객체를 조작할 수 있도록 변수로 저장합니다. PDF와 같은 외부 형식을 읽기 위한 특정 메서드가 있으며 ReadPDF; 그러나 일반 이미지 형식이나 비트맵에 대해서는 Read를 사용합니다.
BarcodeReaderOptions
IronBarcode는 개발자가 표준 파일 형식에서 바코드를 스캔할 수 있도록 합니다. 그러나 개발자가 BarcodeReaderOptions 메서드의 동작을 세밀하게 조정하고자 하는 상황이 있으며, 특히 바코드 파일의 배치를 프로그래밍 방식으로 읽을 때 그렇습니다. 이때 BarcodeReaderOptions가 필요합니다. IronBarcode는 Speed 속도로 읽는 속도, 파일에 여러 바코드가 예상되는지 여부를 ExpectedMultipleBarcodes 그리고 그들이 어떤 종류의 바코드인지 ExpectBarcodeTypes 속성을 통해 완전히 사용자 지정할 수 있습니다. 이는 개발자가 여러 이미지를 병렬로 읽기 위한 여러 스레드를 실행하고 병렬 읽기를 수행할 때 사용할 스레드 수를 제어하도록 합니다.
이것들은 IronBarcode의 강력함을 보여주는 몇 가지 속성들에 불과합니다. 전체 목록은 여기에서 문서를 참조하세요.