# 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](https://www.nuget.org/packages/Barcode/) yapılabilir.
IronBarcode NuGet paketini yüklemek için Visual Studio için NuGet Paket Yöneticisi'ni kullanabilirsiniz:
```shell
:ProductInstall
```
Alternatif olarak, .NET CLI ile de yükleyebilirsiniz:
```shell
:InstallCmd dotnet add package IronBarCode
```
## BarCode veya QR Kodu Okuma
IronBarcode ile bir BarCode'u okumak sadece bir satır kod gerektirir.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-1.cs
```
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.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-2.cs
```
Okuma sürecini optimize etmek için `ScanMode` ile `OnlyBasicScan` arasında bir ayar da yapabilirsiniz.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-3.cs
```
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.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-4.cs
```
## BarCode Yazma
Using IronBarcode, we use the `BarcodeWriter` class to write barcodes.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-5.cs
```
## BarCode Stilini Belirleme
IronBarcode, BarCode görsel sunumunu değiştirmek için çeşitli seçenekler sunar.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-7.cs
```
## 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.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-8.cs
```
## 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.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-9.cs
```
## 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](https://github.com/iron-software)'da bizi ziyaret etmenizi öneririz.
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:
PM > Install-Package BarCode
Install-Package BarCode
Alternatif olarak, .NET CLI ile de yükleyebilirsiniz:
> dotnet add package IronBarCode
dotnet add package IronBarCode
BarCode veya QR Kodu Okuma
IronBarcode ile bir BarCode'u okumak sadece bir satır kod gerektirir.
using IronBarCode;BarcodeResults results = BarcodeReader.Read("QuickStart.jpg");if (results != null){ foreach (BarcodeResult result in results) {Console.WriteLine(result.Text); }}
using IronBarCode;
BarcodeResults results = BarcodeReader.Read("QuickStart.jpg");
if (results != null)
{
foreach (BarcodeResult result in results)
{
Console.WriteLine(result.Text);
}
}
ImportsIronBarCodePrivate results AsBarcodeResults = BarcodeReader.Read("QuickStart.jpg")If results IsNot Nothing Then For Each result AsBarcodeResultIn resultsConsole.WriteLine(result.Text) Next resultEnd If
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.
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);}
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);
}
ImportsIronBarCodePrivate myOptionsExample As New BarcodeReaderOptions() With { .ExpectMultipleBarcodes = False, .ExpectBarcodeTypes = BarcodeEncoding.QRCodeOrBarcodeEncoding.Code128, .CropArea = New System.Drawing.Rectangle(100, 200, 300, 400)}Private result AsBarcodeResults = BarcodeReader.Read("QuickStart.jpg", myOptionsExample)If result IsNot Nothing ThenConsole.WriteLine(result.First().Text)End If
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.
using IronBarCode;BarcodeResults results = BarcodeReader.Read("MultipleBarcodes.png");// Loop through the resultsforeach (BarcodeResult result in results){ string value = result.Value; Bitmap img = result.BarcodeImage; BarcodeEncoding barcodeType = result.BarcodeType; byte[] binary = result.BinaryValue;Console.WriteLine(result.Value);}
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);
}
ImportsIronBarCodePrivate results AsBarcodeResults = BarcodeReader.Read("MultipleBarcodes.png")' Loop through the resultsFor Each result AsBarcodeResultIn results Dim value AsString = result.Value Dim img AsBitmap = result.BarcodeImage Dim barcodeType AsBarcodeEncoding = result.BarcodeType Dim binary() AsByte = result.BinaryValueConsole.WriteLine(result.Value)Next result
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.
using IronBarCode;BarcodeResults pagedResults = BarcodeReader.Read("MultipleBarcodes.pdf");// Loop through the resultsforeach (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});
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
});
ImportsIronBarCodePrivate pagedResults AsBarcodeResults = BarcodeReader.Read("MultipleBarcodes.pdf")' Loop through the resultsFor Each result AsBarcodeResultIn pagedResults Dim pageNumber AsInteger = result.PageNumber Dim value AsString = result.Value Dim img AsBitmap = result.BarcodeImage Dim barcodeType AsBarcodeEncoding = result.BarcodeType Dim binary() AsByte = result.BinaryValueConsole.WriteLine(result.Value)Next result' or from a multi-page TIFF scan with image correction:Dim multiFrameResults AsBarcodeResults = BarcodeReader.Read(inputImage:= "Multiframe.tiff", New BarcodeReaderOptionsWith { .Speed = ReadingSpeed.Detailed, .ExpectMultipleBarcodes = True, .ExpectBarcodeTypes = BarcodeEncoding.Code128, .Multithreaded = False, .RemoveFalsePositive = False, .ImageFilters = Nothing})
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.
using IronBarCode;GeneratedBarcode myBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeEncoding.Code128);myBarcode.SaveAsImage("myBarcode.png");
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.
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 HTMLmyBarcode.SaveAsPng("myBarcode.png");
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");
ImportsIronBarCodePrivate myBarcode AsGeneratedBarcode = 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 HTMLmyBarcode.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.
using IronBarCode;QRCodeWriter.CreateQrCode("https://ironsoftware.com", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPdf("MyQR.pdf");
using IronBarCode;
QRCodeWriter.CreateQrCode("https://ironsoftware.com", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPdf("MyQR.pdf");
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.
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");
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");
ImportsIronBarCodeImportsIronSoftware.DrawingPrivate qrCodeLogo As New QRCodeLogo("visual-studio-logo.png")Private myQRCodeWithLogo AsGeneratedBarcode = 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.
Curtis Chau, Bilgisayar Bilimleri alanında Lisans Derecesine (Carleton Üniversitesi) sahip ve Node.js, TypeScript, JavaScript ve React konularında uzmanlaşmış ön uç geliştirmeyle ilgileniyor. Sezgisel ve estetik açıdan hoş kullanıcı arayüzleri oluşturma tutkunu, Curtis modern çerçevelerle çalışmayı ve iyi yapılandırılmış, görsel olarak çekici kılavuzlar oluşturmayı seviyor.