Barcodes & QRs in C# & VB.NET Applications
C# ve diğer tüm .NET dillerinde barkod okumak ve yazmak, IronBarcode yazılım kütüphanemizle kolay bir işlemdir.
IronBarcode Yükleme
Seyahatin ilk adımı, IronBarcode'u yüklemek olacak ve bu, NuGet'ten indirerek veya DLL'i indirerek yapılabilir.
IronBarcode NuGet paketini yüklemek için Visual Studio için NuGet Paket Yöneticisini kullanabilirsiniz:
Install-Package BarCode
Alternatif olarak, dotnet CLI ile de yükleyebilirsiniz:
dotnet add package IronBarCode
Barkod veya QR Kod Okuma
IronBarcode ile bir barkodu okumak yalnızca bir satır kod gerektirir.
:path=/static-assets/barcode/content-code-examples/get-started/get-started-1.cs
using IronBarCode;
BarcodeResults results = BarcodeReader.Read("QuickStart.jpg");
if (results != null)
{
foreach (BarcodeResult result in results)
{
Console.WriteLine(result.Text);
}
}
Imports IronBarCode
Private results As BarcodeResults = BarcodeReader.Read("QuickStart.jpg")
If results IsNot Nothing Then
For Each result As BarcodeResult In results
Console.WriteLine(result.Text)
Next result
End If
Bu bir satır kod ile, giriş belgesinden tüm barkod türlerini tespit etme ve tarama yeteneğine sahip olursunuz, tek adımda ihtiyaçınız olan her şey! Bu yöntem, JPEG, PNG ve BMP gibi geniş bir görüntü formatını ve PDF'ler ve GIF ve TIFF gibi çoklu kare formatlarını destekler. Gelişmiş performans için özelleştirilebilir yapılandırma seçenekleri mevcuttur.
Okuma hızını artırmak için, BarcodeReaderOptions nesnesi oluşturabilir ve daha iyi performans için yapılandırılmış Speed ayarını kullanabilirsiniz. Varsayılan Balanced'dir, ancak belirli kontrolleri atlamak için Faster seçeneği mevcuttur.
:path=/static-assets/barcode/content-code-examples/get-started/get-started-2.cs
using IronBarCode;
BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
ExpectMultipleBarcodes = false,
ExpectBarcodeTypes = BarcodeEncoding.QRCode | BarcodeEncoding.Code128,
CropArea = new System.Drawing.Rectangle(100, 200, 300, 400),
};
BarcodeResults result = BarcodeReader.Read("QuickStart.jpg", myOptionsExample);
if (result != null)
{
Console.WriteLine(result.First().Text);
}
Imports IronBarCode
Private myOptionsExample As New BarcodeReaderOptions() With {
.ExpectMultipleBarcodes = False,
.ExpectBarcodeTypes = BarcodeEncoding.QRCode Or BarcodeEncoding.Code128,
.CropArea = New System.Drawing.Rectangle(100, 200, 300, 400)
}
Private result As BarcodeResults = BarcodeReader.Read("QuickStart.jpg", myOptionsExample)
If result IsNot Nothing Then
Console.WriteLine(result.First().Text)
End If
Okuma işlemini optimize etmek için ScanMode'ı OnlyBasicScan olarak ayarlayabilirsiniz.
:path=/static-assets/barcode/content-code-examples/get-started/get-started-3.cs
using IronBarCode;
BarcodeResults results = BarcodeReader.Read("MultipleBarcodes.png");
// Loop through the results
foreach (BarcodeResult result in results)
{
string value = result.Value;
Bitmap img = result.BarcodeImage;
BarcodeEncoding barcodeType = result.BarcodeType;
byte[] binary = result.BinaryValue;
Console.WriteLine(result.Value);
}
Imports IronBarCode
Private results As BarcodeResults = BarcodeReader.Read("MultipleBarcodes.png")
' Loop through the results
For Each result As BarcodeResult In results
Dim value As String = result.Value
Dim img As Bitmap = result.BarcodeImage
Dim barcodeType As BarcodeEncoding = result.BarcodeType
Dim binary() As Byte = result.BinaryValue
Console.WriteLine(result.Value)
Next result
Diğer yapılandırmalar, taranacak barkod formatlarını belirtilmeyi içerir, bu da gereksiz taramaları azaltarak işlemeyi hızlandırabilir.
:path=/static-assets/barcode/content-code-examples/get-started/get-started-4.cs
using IronBarCode;
BarcodeResults pagedResults = BarcodeReader.Read("MultipleBarcodes.pdf");
// Loop through the results
foreach (BarcodeResult result in pagedResults)
{
int pageNumber = result.PageNumber;
string value = result.Value;
Bitmap img = result.BarcodeImage;
BarcodeEncoding barcodeType = result.BarcodeType;
byte[] binary = result.BinaryValue;
Console.WriteLine(result.Value);
}
// or from a multi-page TIFF scan with image correction:
BarcodeResults multiFrameResults = BarcodeReader.Read(inputImage: "Multiframe.tiff", new BarcodeReaderOptions
{
Speed = ReadingSpeed.Detailed,
ExpectMultipleBarcodes = true,
ExpectBarcodeTypes = BarcodeEncoding.Code128,
Multithreaded = false,
RemoveFalsePositive = false,
ImageFilters = null
});
Imports IronBarCode
Private pagedResults As BarcodeResults = BarcodeReader.Read("MultipleBarcodes.pdf")
' Loop through the results
For Each result As BarcodeResult In pagedResults
Dim pageNumber As Integer = result.PageNumber
Dim value As String = result.Value
Dim img As Bitmap = result.BarcodeImage
Dim barcodeType As BarcodeEncoding = result.BarcodeType
Dim binary() As Byte = result.BinaryValue
Console.WriteLine(result.Value)
Next result
' or from a multi-page TIFF scan with image correction:
Dim multiFrameResults As BarcodeResults = BarcodeReader.Read(inputImage:= "Multiframe.tiff", New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Detailed,
.ExpectMultipleBarcodes = True,
.ExpectBarcodeTypes = BarcodeEncoding.Code128,
.Multithreaded = False,
.RemoveFalsePositive = False,
.ImageFilters = Nothing
})
Barkod Yazma
Barcod'ları IronBarcode kullanarak yazmak için, BarcodeWriter sınıfını kullanırız.
:path=/static-assets/barcode/content-code-examples/get-started/get-started-5.cs
using IronBarCode;
GeneratedBarcode myBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeEncoding.Code128);
myBarcode.SaveAsImage("myBarcode.png");
Imports IronBarCode
Private myBarcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeEncoding.Code128)
myBarcode.SaveAsImage("myBarcode.png")
Barkod Tarzı
IronBarcode, bir barkodun görsel açıdan manipüle edilmesi için çeşitli seçenekler sunar.
:path=/static-assets/barcode/content-code-examples/get-started/get-started-7.cs
using IronBarCode;
GeneratedBarcode myBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeEncoding.Code128);
myBarcode.AddAnnotationTextAboveBarcode("Product URL:");
myBarcode.AddBarcodeValueTextBelowBarcode();
myBarcode.SetMargins(100);
myBarcode.ChangeBarCodeColor(IronSoftware.Drawing.Color.Purple);
// All major image formats supported as well as PDF and HTML
myBarcode.SaveAsPng("myBarcode.png");
Imports IronBarCode
Private myBarcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeEncoding.Code128)
myBarcode.AddAnnotationTextAboveBarcode("Product URL:")
myBarcode.AddBarcodeValueTextBelowBarcode()
myBarcode.SetMargins(100)
myBarcode.ChangeBarCodeColor(IronSoftware.Drawing.Color.Purple)
' All major image formats supported as well as PDF and HTML
myBarcode.SaveAsPng("myBarcode.png")
Barkodları HTML Olarak Dışa Aktarma
IronBarcode, barkodları HTML belgeleri olarak veya HTML içeriğinin bir parçası olarak dışa aktarabilir.
:path=/static-assets/barcode/content-code-examples/get-started/get-started-8.cs
using IronBarCode;
QRCodeWriter.CreateQrCode("https://ironsoftware.com", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPdf("MyQR.pdf");
Imports IronBarCode
QRCodeWriter.CreateQrCode("https://ironsoftware.com", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPdf("MyQR.pdf")
QR Kodları Üretme
QR kodları için, hata düzeltme gibi QR'ye özgü özellikler için ek yapılandırma sağlayan QRCodeWriter sınıfını kullanın.
:path=/static-assets/barcode/content-code-examples/get-started/get-started-9.cs
using IronBarCode;
using IronSoftware.Drawing;
QRCodeLogo qrCodeLogo = new QRCodeLogo("visual-studio-logo.png");
GeneratedBarcode myQRCodeWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", qrCodeLogo);
myQRCodeWithLogo.ChangeBarCodeColor(Color.DarkGreen).SaveAsPdf("MyQRWithLogo.pdf");
Imports IronBarCode
Imports IronSoftware.Drawing
Private qrCodeLogo As New QRCodeLogo("visual-studio-logo.png")
Private myQRCodeWithLogo As GeneratedBarcode = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", qrCodeLogo)
myQRCodeWithLogo.ChangeBarCodeColor(Color.DarkGreen).SaveAsPdf("MyQRWithLogo.pdf")
Desteklenen Barkod Formatları
IronBarcode, hem okuma hem de yazma için yaygın olarak kullanılan barkod formatlarının geniş bir yelpazesini destekler:
- QR, Micro QR ve Dikdörtgen Micro QR (rMQR) kodları.
- Aztec, Data Matrix, MaxiCode ve PDF417 gibi diğer iki boyutlu barkodlar.
- Databar gibi istiflenmiş çizgisel barkodlar.
- UPC-A, UPC-E, EAN-8, EAN-13, Codabar, ITF, MSI ve Plessey gibi geleneksel bir boyutlu barkod formatları.
Neden IronBarcode'i Secmelisiniz?
IronBarcode, geliştiricilerin .NET için barkodları okuyup yazması için kullanıcı dostu, kullanımı kolay bir API sunar ve doğruluk, hassasiyet ve hız için optimize edilmiştir, gerçek dünya kullanım senaryolarında.
Örneğin, BarcodeWriter sınıfı, UPCA ve UPCE barcodları üzerinde otomatik olarak 'checksums' doğrulayıp düzeltir ve sayısal format kısıtlamalarını yönetir. IronBarcode, geliştiricilere verileri için en uygun barkod formatını seçmelerine yardımcı olur.
Kütüphane, barkod algılama başarı oranlarını maksimize etmek için otomatik döndürme ve görüntü gürültü azaltma gibi görüntü ön işleme teknikleri ile sağlamdır.
İlerleme
IronBarcode'un en iyi şekilde yararlanılması için, bu dokümantasyon bölümündeki eğitimleri okumanızı ve GitHub ziyaret etmenizi tavsiye ediyoruz.

