Barcodes & QRs in C# & VB.NET Applications
C# ve diğer tüm .NET dillerinde BarCode okuma ve yazma, IronBarcode kütüphanemizle kolay bir işlemdir.
IronBarcode'u yükleyin
Bu yolculuğun ilk adımı, IronBarcode'u yüklemek olacaktır. Bu, NuGet'ten indirerek veya DLL dosyasını indirerek yapılabilir.
IronBarcode NuGet paketini yüklemek için Visual Studio için NuGet Paket Yöneticisi'ni kullanabilirsiniz:
Install-Package BarCode
Alternatif olarak, .NET CLI ile de yükleyebilirsiniz:
dotnet add package IronBarCode
BarCode veya QR Kodu Okuma
IronBarcode ile bir BarCode'u okumak sadece 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 tek satırlık kodla, giriş belgesindeki tüm BarCode türlerini olağanüstü bir performansla algılayabilir ve tarayabilirsiniz — ihtiyacınız olan her şey tek adımda! Bu yöntem, JPEG, PNG ve BMP gibi çok çeşitli görüntü formatlarının yanı sıra PDF'ler ve GIF ve TIFF gibi çok kareli formatları da destekler. Daha iyi performans için özelleştirilebilir yapılandırma seçenekleri mevcuttur.
Okuma hızını artırmak için, daha iyi performans elde etmek üzere Speed ayarı yapılandırılmış bir BarcodeReaderOptions nesnesi oluşturabilirsiniz. Varsayılan ayar Balanced'dir, ancak belirli denetimleri atlamak için Faster seçeneği de 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 sürecini optimize etmek için ScanMode ile OnlyBasicScan arasında bir ayar da yapabilirsiniz.
: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 arasında, taranacak BarCode formatlarının belirtilmesi de yer alır; bu, gereksiz taramaları azaltarak işleme hızını artırmaya yardımcı olabilir.
: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
})
BarCode Yazma
Using IronBarcode, we use the BarcodeWriter class to write barcodes.
: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")
BarCode Stilini Belirleme
IronBarcode, BarCode görsel sunumunu değiştirmek 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")
BarCodes'u HTML Olarak Dışa Aktarma
IronBarcode, BarCode'ları 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ı Oluşturma
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 BarCode Biçimleri
IronBarcode, hem okuma hem de yazma için yaygın olarak kullanılan çok çeşitli BarCode formatlarını destekler:
- QR, Mikro QR ve Dikdörtgen Mikro QR (rMQR) kodları.
- Aztec, Data Matrix, MaxiCode ve PDF417 gibi diğer iki boyutlu BARCODE'lar.
- Databar gibi yığılmış doğrusal BARCODE'lar.
- UPC-A, UPC-E, EAN-8, EAN-13, Codabar, ITF, MSI ve Plessey gibi geleneksel tek boyutlu BARCODE formatları.
Neden IronBarcode'u Seçmelisiniz?
IronBarcode, geliştiricilere .NET için Barkodları okumak ve yazmak üzere, gerçek kullanım senaryolarında doğruluk, hassasiyet ve hız açısından optimize edilmiş, kullanıcı dostu ve kullanımı kolay bir API sunar.
Örneğin, BarcodeWriter sınıfı, UPCA ve UPCE BarCode'lerindeki 'sağlama toplamlarını' otomatik olarak doğrular ve düzeltir, ayrıca sayısal biçim kısıtlamalarını yönetir. IronBarcode, geliştiricilerin verileri için en uygun BarCode formatını seçmelerine yardımcı olur.
Kütüphane, BarCode algılama başarı oranlarını en üst düzeye çıkarmak için otomatik döndürme ve görüntü gürültüsünü giderme gibi görüntü ön işleme tekniklerine sahip, sağlam bir kütüphanedir.
İleriye Dönük Planlar
IronBarcode'dan en iyi şekilde yararlanmak için, bu belgeler bölümündeki öğreticileri okumanızı ve GitHub'da bizi ziyaret etmenizi öneririz.

