Altbilgi içeriğine atla
VIDEOLAR

C#'ta Aynı Anda Birden Fazla Barkod Nasıl Okunur?

DevExpress Barkod'dan IronBarcode'a Geçiş

Grid, grafik, zamanlayıcı veya pivot kontrolleri için DevExpress kullanıyorsanız, bunları tutun. Bu geçiş, BarCodeControl'i başsız çalışabilen, UI bağlamı dışında dağıtılabilen ve barkodları okuyabilen bir kütüphane ile değiştirmek hakkındadır. WinForms veya Blazor uygulamanız için güvendiğiniz DevExpress UI kontrolleri bu geçişten etkilenmez. Yalnızca barkodla ilgili kod değişir.

Bu geçişi gerektiren tipik senaryo üç şeyden biridir: bir okuma gerekliliği ortaya çıkar ve DevExpress bunu karşılayamaz; yeni bir servis, WinForms derlemelerinin olmadığı bir ASP.NET Core veya bulut fonksiyonunda barkod üretimi gerektirir; veya süit yenilemesi yaklaşır ve yalnızca barkod çıktısı için tam bir UI araç seti kullanmanın maliyet-başına-özellik matematiği artık mantıklı gelmez.

Adım 1: IronBarcode'u Kurun

dotnet add package BarCode

Aynı projede başka DevExpress kontrolleri bulunduruyorsanız, DevExpress NuGet paketlerini yerinde bırakın. Yalnızca kaynak dosyalarınızdaki barkodla ilgili kod değişir. DevExpress'ün belirli bir projede görünmesinin tek nedeni barkod üretimiyse ve orada başka DX kontrolleri kullanmıyorsanız, geçişten sonra DevExpress paketlerini o projeden kaldırabilirsiniz:

# Only remove DevExpress packages if no other DX controls are used in this project
dotnet remove package DevExpress.Win.Navigation
# Only remove DevExpress packages if no other DX controls are used in this project
dotnet remove package DevExpress.Win.Navigation
SHELL

Adım 2: Lisans Başlatma Ekle

Uygulama başlatıldığında IronBarcode lisans aktivasyonunu bir kez ekleyin — Program.cs, App.xaml.cs veya ana bilgisayarınızı inşa edicinizde:

// In Program.cs (ASP.NET Core) or application entry point
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";
// In Program.cs (ASP.NET Core) or application entry point
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";
Imports IronBarCode

' In Program.vb (ASP.NET Core) or application entry point
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY"
$vbLabelText   $csharpLabel

Ağ çağrısı yok. Kontrol edilecek hata kodu yok. Yerel doğrulama.

Adım 3: Barkoda Özgü Kodu Değiştirin

Kod tabanınızda DevExpress barkod tiplerini arayın. Diğer her şey kalır:

# Find barcode-related DevExpress usage — ignore grid, chart, and other DX components
grep -r "BarCodeControl\|Code128Generator\|QRCodeGenerator\|DataMatrixGenerator\|PDF417Generator\|AztecCodeGenerator\|DevExpress.XtraPrinting.BarCode" --include="*.cs" .
grep -r "barCode\.Module\|DrawToBitmap\|BarCode\.Symbology" --include="*.cs" .
# Find barcode-related DevExpress usage — ignore grid, chart, and other DX components
grep -r "BarCodeControl\|Code128Generator\|QRCodeGenerator\|DataMatrixGenerator\|PDF417Generator\|AztecCodeGenerator\|DevExpress.XtraPrinting.BarCode" --include="*.cs" .
grep -r "barCode\.Module\|DrawToBitmap\|BarCode\.Symbology" --include="*.cs" .
SHELL

Bu aramanın sonuçları tam olarak neyi değiştireceğinizdir. Başka bir şey yok.

Kod Göç Örnekleri

Code 128 Üretimi

Bu, en yaygın geçiştir. BarCodeControl ile Code128Generator sembolojisi bir tek BarcodeWriter.CreateBarcode çağrısına dönüşür.

Öncesi — DevExpress WinForms kontrolü:

using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
using System.Drawing;
using System.Drawing.Imaging;

public void GenerateCode128(string data, string outputPath)
{
    var barCode = new BarCodeControl();
    var symbology = new Code128Generator();
    symbology.CharacterSet = Code128CharacterSet.CharsetAuto;
    barCode.Symbology = symbology;
    barCode.Text = data;
    barCode.Module = 0.02f;
    barCode.ShowText = true;

    barCode.Width = 400;
    barCode.Height = 100;
    var bitmap = new Bitmap(barCode.Width, barCode.Height);
    barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
    bitmap.Save(outputPath, ImageFormat.Png);
    bitmap.Dispose();
}
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
using System.Drawing;
using System.Drawing.Imaging;

public void GenerateCode128(string data, string outputPath)
{
    var barCode = new BarCodeControl();
    var symbology = new Code128Generator();
    symbology.CharacterSet = Code128CharacterSet.CharsetAuto;
    barCode.Symbology = symbology;
    barCode.Text = data;
    barCode.Module = 0.02f;
    barCode.ShowText = true;

    barCode.Width = 400;
    barCode.Height = 100;
    var bitmap = new Bitmap(barCode.Width, barCode.Height);
    barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
    bitmap.Save(outputPath, ImageFormat.Png);
    bitmap.Dispose();
}
Imports DevExpress.XtraEditors
Imports DevExpress.XtraPrinting.BarCode
Imports System.Drawing
Imports System.Drawing.Imaging

Public Sub GenerateCode128(data As String, outputPath As String)
    Dim barCode As New BarCodeControl()
    Dim symbology As New Code128Generator()
    symbology.CharacterSet = Code128CharacterSet.CharsetAuto
    barCode.Symbology = symbology
    barCode.Text = data
    barCode.Module = 0.02F
    barCode.ShowText = True

    barCode.Width = 400
    barCode.Height = 100
    Dim bitmap As New Bitmap(barCode.Width, barCode.Height)
    barCode.DrawToBitmap(bitmap, New Rectangle(0, 0, barCode.Width, barCode.Height))
    bitmap.Save(outputPath, ImageFormat.Png)
    bitmap.Dispose()
End Sub
$vbLabelText   $csharpLabel

Sonrası — IronBarcode:

// NuGet: dotnet add package BarCode
using IronBarCode;

public void GenerateCode128(string data, string outputPath)
{
    BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
        .ResizeTo(400, 100)
        .SaveAsPng(outputPath);
}
// NuGet: dotnet add package BarCode
using IronBarCode;

public void GenerateCode128(string data, string outputPath)
{
    BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
        .ResizeTo(400, 100)
        .SaveAsPng(outputPath);
}
Imports IronBarCode

Public Sub GenerateCode128(data As String, outputPath As String)
    BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128) _
        .ResizeTo(400, 100) _
        .SaveAsPng(outputPath)
End Sub
$vbLabelText   $csharpLabel

barCode.Module = 0.02f döküman-birimi boyutlandırması kalktı. .ResizeTo(400, 100), pikselleri doğrudan alır. Manuel Bitmap tahsisi ve DrawToBitmap çağrısı, boyutlandırmayı otomatik olarak halleden .SaveAsPng() ile değiştirildi.

QR Kod Oluşturma

Öncesi — Hata düzeltmeli DevExpress QR:

using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
using System.Drawing;
using System.Drawing.Imaging;

public void GenerateQrCode(string url, string outputPath)
{
    var barCode = new BarCodeControl();
    var symbology = new QRCodeGenerator();
    symbology.ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H;
    symbology.CompactionMode = QRCodeCompactionMode.AlphaNumeric;
    barCode.Symbology = symbology;
    barCode.Text = url;

    barCode.Width = 500;
    barCode.Height = 500;
    var bitmap = new Bitmap(barCode.Width, barCode.Height);
    barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
    bitmap.Save(outputPath, ImageFormat.Png);
    bitmap.Dispose();
}
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
using System.Drawing;
using System.Drawing.Imaging;

public void GenerateQrCode(string url, string outputPath)
{
    var barCode = new BarCodeControl();
    var symbology = new QRCodeGenerator();
    symbology.ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H;
    symbology.CompactionMode = QRCodeCompactionMode.AlphaNumeric;
    barCode.Symbology = symbology;
    barCode.Text = url;

    barCode.Width = 500;
    barCode.Height = 500;
    var bitmap = new Bitmap(barCode.Width, barCode.Height);
    barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
    bitmap.Save(outputPath, ImageFormat.Png);
    bitmap.Dispose();
}
Imports DevExpress.XtraEditors
Imports DevExpress.XtraPrinting.BarCode
Imports System.Drawing
Imports System.Drawing.Imaging

Public Sub GenerateQrCode(url As String, outputPath As String)
    Dim barCode As New BarCodeControl()
    Dim symbology As New QRCodeGenerator()
    symbology.ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H
    symbology.CompactionMode = QRCodeCompactionMode.AlphaNumeric
    barCode.Symbology = symbology
    barCode.Text = url

    barCode.Width = 500
    barCode.Height = 500
    Dim bitmap As New Bitmap(barCode.Width, barCode.Height)
    barCode.DrawToBitmap(bitmap, New Rectangle(0, 0, barCode.Width, barCode.Height))
    bitmap.Save(outputPath, ImageFormat.Png)
    bitmap.Dispose()
End Sub
$vbLabelText   $csharpLabel

Sonrası — IronBarcode:

using IronBarCode;

public void GenerateQrCode(string url, string outputPath)
{
    QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
        .SaveAsPng(outputPath);
}
using IronBarCode;

public void GenerateQrCode(string url, string outputPath)
{
    QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
        .SaveAsPng(outputPath);
}
Imports IronBarCode

Public Sub GenerateQrCode(url As String, outputPath As String)
    QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest) _
        .SaveAsPng(outputPath)
End Sub
$vbLabelText   $csharpLabel

QRCodeErrorCorrectionLevel.H, QRCodeWriter.QrErrorCorrectionLevel.Highest'a eşlenir. CompactionMode.AlphaNumeric ayarı, içeriğe göre IronBarcode tarafından otomatik olarak ele alınır.

Marka logosu ile QR kod (net yeni yetenek — DevExpress ile mümkün değil):

using IronBarCode;

public void GenerateBrandedQrCode(string url, string logoPath, string outputPath)
{
    QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
        .AddBrandLogo(logoPath)
        .SaveAsPng(outputPath);
}
using IronBarCode;

public void GenerateBrandedQrCode(string url, string logoPath, string outputPath)
{
    QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
        .AddBrandLogo(logoPath)
        .SaveAsPng(outputPath);
}
Imports IronBarCode

Public Sub GenerateBrandedQrCode(url As String, logoPath As String, outputPath As String)
    QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest) _
        .AddBrandLogo(logoPath) _
        .SaveAsPng(outputPath)
End Sub
$vbLabelText   $csharpLabel

Data Matrix Üretimi

Önce — DevExpress:

using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;

var barCode = new BarCodeControl();
var symbology = new DataMatrixGenerator();
symbology.MatrixSize = DataMatrixSize.Matrix26x26;
barCode.Symbology = symbology;
barCode.Text = "PART-7734-X";
// ... DrawToBitmap pattern
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;

var barCode = new BarCodeControl();
var symbology = new DataMatrixGenerator();
symbology.MatrixSize = DataMatrixSize.Matrix26x26;
barCode.Symbology = symbology;
barCode.Text = "PART-7734-X";
// ... DrawToBitmap pattern
Imports DevExpress.XtraEditors
Imports DevExpress.XtraPrinting.BarCode

Dim barCode As New BarCodeControl()
Dim symbology As New DataMatrixGenerator()
symbology.MatrixSize = DataMatrixSize.Matrix26x26
barCode.Symbology = symbology
barCode.Text = "PART-7734-X"
' ... DrawToBitmap pattern
$vbLabelText   $csharpLabel

Sonrası — IronBarcode:

using IronBarCode;

BarcodeWriter.CreateBarcode("PART-7734-X", BarcodeEncoding.DataMatrix)
    .ResizeTo(260, 260)
    .SaveAsPng("datamatrix.png");
using IronBarCode;

BarcodeWriter.CreateBarcode("PART-7734-X", BarcodeEncoding.DataMatrix)
    .ResizeTo(260, 260)
    .SaveAsPng("datamatrix.png");
Imports IronBarCode

BarcodeWriter.CreateBarcode("PART-7734-X", BarcodeEncoding.DataMatrix) _
    .ResizeTo(260, 260) _
    .SaveAsPng("datamatrix.png")
$vbLabelText   $csharpLabel

PDF417 Üretimi

Önce — DevExpress:

using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;

var barCode = new BarCodeControl();
barCode.Symbology = new PDF417Generator();
barCode.Text = "SHIPMENT-DATA-2026";
// ... DrawToBitmap pattern
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;

var barCode = new BarCodeControl();
barCode.Symbology = new PDF417Generator();
barCode.Text = "SHIPMENT-DATA-2026";
// ... DrawToBitmap pattern
Imports DevExpress.XtraEditors
Imports DevExpress.XtraPrinting.BarCode

Dim barCode As New BarCodeControl()
barCode.Symbology = New PDF417Generator()
barCode.Text = "SHIPMENT-DATA-2026"
' ... DrawToBitmap pattern
$vbLabelText   $csharpLabel

Sonrası — IronBarcode:

using IronBarCode;

BarcodeWriter.CreateBarcode("SHIPMENT-DATA-2026", BarcodeEncoding.PDF417)
    .ResizeTo(400, 150)
    .SaveAsPng("pdf417.png");
using IronBarCode;

BarcodeWriter.CreateBarcode("SHIPMENT-DATA-2026", BarcodeEncoding.PDF417)
    .ResizeTo(400, 150)
    .SaveAsPng("pdf417.png");
Imports IronBarCode

BarcodeWriter.CreateBarcode("SHIPMENT-DATA-2026", BarcodeEncoding.PDF417) _
    .ResizeTo(400, 150) _
    .SaveAsPng("pdf417.png")
$vbLabelText   $csharpLabel

Okuma Ekleyin (Net Yeni Yetenek)

DevExpress bir okuma API'si sağlamaz. Bir okuma gereksinimi geldiyse, IronBarcode burada kendini hemen öder:

using IronBarCode;

// Read from an image file
var results = BarcodeReader.Read("uploaded-label.png");
foreach (var result in results)
{
    Console.WriteLine($"Found {result.Format}: {result.Value}");
}

// Read with options for better accuracy on difficult images
var options = new BarcodeReaderOptions
{
    Speed = ReadingSpeed.Balanced,
    ExpectMultipleBarcodes = true,
    MaxParallelThreads = 4
};
var detailedResults = BarcodeReader.Read("multi-barcode-sheet.png", options);
using IronBarCode;

// Read from an image file
var results = BarcodeReader.Read("uploaded-label.png");
foreach (var result in results)
{
    Console.WriteLine($"Found {result.Format}: {result.Value}");
}

// Read with options for better accuracy on difficult images
var options = new BarcodeReaderOptions
{
    Speed = ReadingSpeed.Balanced,
    ExpectMultipleBarcodes = true,
    MaxParallelThreads = 4
};
var detailedResults = BarcodeReader.Read("multi-barcode-sheet.png", options);
Imports IronBarCode

' Read from an image file
Dim results = BarcodeReader.Read("uploaded-label.png")
For Each result In results
    Console.WriteLine($"Found {result.Format}: {result.Value}")
Next

' Read with options for better accuracy on difficult images
Dim options As New BarcodeReaderOptions With {
    .Speed = ReadingSpeed.Balanced,
    .ExpectMultipleBarcodes = True,
    .MaxParallelThreads = 4
}
Dim detailedResults = BarcodeReader.Read("multi-barcode-sheet.png", options)
$vbLabelText   $csharpLabel

ASP.NET Core Barkod Uç Noktası

Bu, WinForms çözümleri olmadan BarCodeControl ile mümkün değildi. IronBarcode bunu doğal olarak destekler:

using IronBarCode;

// In Program.cs or a controller
app.MapGet("/label/{sku}", (string sku) =>
{
    var pngBytes = BarcodeWriter.CreateBarcode(sku, BarcodeEncoding.Code128)
        .ResizeTo(400, 100)
        .ToPngBinaryData();

    return Results.File(pngBytes, "image/png", $"{sku}.png");
});

app.MapGet("/qr/{data}", (string data) =>
{
    var pngBytes = QRCodeWriter.CreateQrCode(data, 300, QRCodeWriter.QrErrorCorrectionLevel.Highest)
        .ToPngBinaryData();

    return Results.File(pngBytes, "image/png");
});
using IronBarCode;

// In Program.cs or a controller
app.MapGet("/label/{sku}", (string sku) =>
{
    var pngBytes = BarcodeWriter.CreateBarcode(sku, BarcodeEncoding.Code128)
        .ResizeTo(400, 100)
        .ToPngBinaryData();

    return Results.File(pngBytes, "image/png", $"{sku}.png");
});

app.MapGet("/qr/{data}", (string data) =>
{
    var pngBytes = QRCodeWriter.CreateQrCode(data, 300, QRCodeWriter.QrErrorCorrectionLevel.Highest)
        .ToPngBinaryData();

    return Results.File(pngBytes, "image/png");
});
Imports IronBarCode

' In Program.vb or a controller
app.MapGet("/label/{sku}", Function(sku As String)
    Dim pngBytes = BarcodeWriter.CreateBarcode(sku, BarcodeEncoding.Code128) _
        .ResizeTo(400, 100) _
        .ToPngBinaryData()

    Return Results.File(pngBytes, "image/png", $"{sku}.png")
End Function)

app.MapGet("/qr/{data}", Function(data As String)
    Dim pngBytes = QRCodeWriter.CreateQrCode(data, 300, QRCodeWriter.QrErrorCorrectionLevel.Highest) _
        .ToPngBinaryData()

    Return Results.File(pngBytes, "image/png")
End Function)
$vbLabelText   $csharpLabel

PDF'lerden Barkod Okuma

IronBarcode, PDF dosyalarından yerel olarak okur. PdfiumViewer yok, render döngüsü yok, ek paketler yok:

using IronBarCode;

// Read all barcodes from all pages of a PDF
var results = BarcodeReader.Read("shipping-manifest.pdf");
foreach (var result in results)
{
    Console.WriteLine($"Barcode: {result.Value} | Format: {result.Format}");
}
using IronBarCode;

// Read all barcodes from all pages of a PDF
var results = BarcodeReader.Read("shipping-manifest.pdf");
foreach (var result in results)
{
    Console.WriteLine($"Barcode: {result.Value} | Format: {result.Format}");
}
Imports IronBarCode

' Read all barcodes from all pages of a PDF
Dim results = BarcodeReader.Read("shipping-manifest.pdf")
For Each result In results
    Console.WriteLine($"Barcode: {result.Value} | Format: {result.Format}")
Next
$vbLabelText   $csharpLabel

Yaygın Geçiş Sorunları

barCode.Module Belge Birimlerini Kullanır, Pikseli Değil

barCode.Module, belgedeki en dar çubuğun genişliğini kontrol eder (render DPI bağlamına bağlıdır). Bu bir piksel sayısı değildir. Geçiş sırasında, modül değerini piksellere dönüştürmeye çalışmayın - bunun yerine, hangi piksel boyutlarını istediğinize karar verin ve doğrudan .ResizeTo(width, height) kullanın.

// Before: barCode.Module = 0.02f  — document units, indirect sizing
// After:
.ResizeTo(400, 100)  // explicit pixel dimensions
// Before: barCode.Module = 0.02f  — document units, indirect sizing
// After:
.ResizeTo(400, 100)  // explicit pixel dimensions
' Before: barCode.Module = 0.02F  — document units, indirect sizing
' After:
.ResizeTo(400, 100)  ' explicit pixel dimensions
$vbLabelText   $csharpLabel

DrawToBitmap, Önceden Ayrılmış Bitmap Gerektirir

Eski model, belirli bir boyuttaki bir Bitmap tahsis ederdi, ardından bunu render etmek için DrawToBitmap çağrılırdı. IronBarcode'un .SaveAsPng() bunu dahili olarak halleder. Önceden herhangi bir şey tahsis etmezsiniz.

// Before: must know size upfront, allocate, draw, save, dispose
barCode.Width = 400;
barCode.Height = 100;
var bitmap = new Bitmap(barCode.Width, barCode.Height);
barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
bitmap.Save(path, ImageFormat.Png);
bitmap.Dispose();

// After: size specified once, everything else handled
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
    .ResizeTo(400, 100)
    .SaveAsPng(path);
// Before: must know size upfront, allocate, draw, save, dispose
barCode.Width = 400;
barCode.Height = 100;
var bitmap = new Bitmap(barCode.Width, barCode.Height);
barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
bitmap.Save(path, ImageFormat.Png);
bitmap.Dispose();

// After: size specified once, everything else handled
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
    .ResizeTo(400, 100)
    .SaveAsPng(path);
' Before: must know size upfront, allocate, draw, save, dispose
barCode.Width = 400
barCode.Height = 100
Dim bitmap As New Bitmap(barCode.Width, barCode.Height)
barCode.DrawToBitmap(bitmap, New Rectangle(0, 0, barCode.Width, barCode.Height))
bitmap.Save(path, ImageFormat.Png)
bitmap.Dispose()

' After: size specified once, everything else handled
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128) _
    .ResizeTo(400, 100) _
    .SaveAsPng(path)
$vbLabelText   $csharpLabel

WinForms Veri Bağlama

BarCodeControl bir WinForms tasarımcısında bir veri kaynağına bağlıysa, IronBarcode eşdeğeri, değeri modelinizden açıkça okumak ve BarcodeWriter.CreateBarcode 'a geçmektir. IronBarcode, WinForms veri bağlamasında yer almaz — bu bir programatik API, bir UI kontrolü değil. Oluşturulan barkodu bir formda göstermeniz gerekiyorsa, görüntü baytlarını oluşturun ve bir PictureBox üzerinde ayarlayın:

using IronBarCode;

// Generate and display in a WinForms PictureBox
private void UpdateBarcodeDisplay(string value)
{
    var bytes = BarcodeWriter.CreateBarcode(value, BarcodeEncoding.Code128)
        .ResizeTo(400, 100)
        .ToPngBinaryData();

    using var ms = new System.IO.MemoryStream(bytes);
    pictureBox1.Image = System.Drawing.Image.FromStream(ms);
}
using IronBarCode;

// Generate and display in a WinForms PictureBox
private void UpdateBarcodeDisplay(string value)
{
    var bytes = BarcodeWriter.CreateBarcode(value, BarcodeEncoding.Code128)
        .ResizeTo(400, 100)
        .ToPngBinaryData();

    using var ms = new System.IO.MemoryStream(bytes);
    pictureBox1.Image = System.Drawing.Image.FromStream(ms);
}
Imports IronBarCode
Imports System.IO

' Generate and display in a WinForms PictureBox
Private Sub UpdateBarcodeDisplay(value As String)
    Dim bytes = BarcodeWriter.CreateBarcode(value, BarcodeEncoding.Code128) _
        .ResizeTo(400, 100) _
        .ToPngBinaryData()

    Using ms As New MemoryStream(bytes)
        pictureBox1.Image = System.Drawing.Image.FromStream(ms)
    End Using
End Sub
$vbLabelText   $csharpLabel

Ad Alanı Değiştirme

Kaldırılacak eski ithalatlar:

// Remove these
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
// Remove these
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
$vbLabelText   $csharpLabel

Eklenecek yeni ithalat:

// Add this
using IronBarCode;
// Add this
using IronBarCode;
Imports IronBarCode
$vbLabelText   $csharpLabel

API Eşleme Başvurusu

DevExpress Barkod IronBarcode Eşdeğeri
new BarCodeControl() Statik — örnek yok
new Code128Generator() + barCode.Symbology = symbology BarcodeEncoding.Code128 parametresi
new QRCodeGenerator() + QRCodeErrorCorrectionLevel.H QRCodeWriter.CreateQrCode(data, size, QRCodeWriter.QrErrorCorrectionLevel.Highest)
new DataMatrixGenerator() + DataMatrixSize.Matrix26x26 BarcodeWriter.CreateBarcode(data, BarcodeEncoding.DataMatrix)
new PDF417Generator() BarcodeWriter.CreateBarcode(data, BarcodeEncoding.PDF417)
new AztecCodeGenerator() BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Aztec)
barCode.Text = value İlk argüman CreateBarcode veya CreateQrCode
barCode.Module = 0.02f .ResizeTo(width, height) piksellerde
barCode.ShowText = true .AddBarcodeText()
DrawToBitmap(bitmap, rect) .SaveAsPng(path)
new Bitmap(w, h) + manuel imha Gerekli değil
Bitmap → MemoryStream → HTTP .ToPngBinaryData()
Okuma API'si yok BarcodeReader.Read(path)
using DevExpress.XtraEditors + using DevExpress.XtraPrinting.BarCode using IronBarCode

Geçiş Kontrol Listesi

Güncellenmesi gereken tüm dosyaları bulmak için bu grep desenini kullanın:

grep -r "BarCodeControl\|Code128Generator\|QRCodeGenerator\|DataMatrixGenerator\|PDF417Generator\|AztecCodeGenerator" --include="*.cs" .
grep -r "barCode\.Module\|barCode\.Symbology\|DrawToBitmap\|DevExpress\.XtraPrinting\.BarCode" --include="*.cs" .
grep -r "BarCodeControl\|Code128Generator\|QRCodeGenerator\|DataMatrixGenerator\|PDF417Generator\|AztecCodeGenerator" --include="*.cs" .
grep -r "barCode\.Module\|barCode\.Symbology\|DrawToBitmap\|DevExpress\.XtraPrinting\.BarCode" --include="*.cs" .
SHELL

Her bir eşleşme üzerinde çalışın:

  • using DevExpress.XtraEditors; ve using DevExpress.XtraPrinting.BarCode;'i using IronBarCode; ile değiştirin
  • new BarCodeControl() + semboloji kurulumunu BarcodeWriter.CreateBarcode(data, BarcodeEncoding.X) ile değiştirin
  • new QRCodeGenerator() + semboloji kurulumunu QRCodeWriter.CreateQrCode(data, size, errorLevel) ile değiştirin
  • barCode.Module = X'i .ResizeTo(width, height) ile değiştirin
  • DrawToBitmap + bitmap.Save modelini .SaveAsPng(path) ile değiştirin
  • Bitmap-to-MemoryStream modelini .ToPngBinaryData() ile değiştirin
  • Uygulama başlatıldığında IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY" ekleyin
  • Okuma becerisinin gerektiği her yerde BarcodeReader.Read() çağrıları ekleyin

Bir proje, yalnızca barkod kontrolleri için DevExpress kullanıyorsa ve başka DX bileşenleri kullanmıyorsa, tüm barkod referansları değiştirildikten sonra DevExpress NuGet paketlerini kaldırın. Proje, DevExpress grid, grafik veya diğer UI kontrollerini kullanıyorsa, bu paketleri yerinde bırakın — bu geçiş yalnızca barkod kodunu etkiler.

Sıkça Sorulan Sorular

Neden DevExpress Barcode'dan IronBarcode'a geçiş yapmalıyım?

Yaygın nedenler arasında lisanslamanın basitleştirilmesi (SDK + runtime anahtar karmaşıklığının kaldırılması), veri geçiş limitlerinin ortadan kaldırılması, yerel PDF desteği kazanılması, Docker/CI/CD dağıtımının iyileştirilmesi ve üretim kodunda API tekrarlama azalması yer alır.

DevExpress API çağrılarını IronBarcode ile nasıl değiştiririm?

Örnek oluşturma ve lisanslama tekrarlamalarını IronBarCode.License.LicenseKey = "anahtar" ile değiştirin. Okuyucu çağrılarını BarcodeReader.Read(yol) ile ve yazıcı çağrılarını BarcodeWriter.CreateBarcode(veri, kodlama) ile değiştirin. Statik yöntemler örnek yönetimi gerektirmez.

DevExpress Barcode'dan IronBarcode'a geçiş sırasında ne kadar kod değişiyor?

Çoğu geçiş daha az kod satırıyla sonuçlanır. Lisanslama tekrarlamaları, örnek oluşturucular ve açık format yapılandırması kaldırılır. Temel okuma/yazma işlemleri, daha temiz sonuç nesneleriyle daha kısa IronBarcode eşdeğerlerine dönüştürülür.

Geçiş sırasında hem DevExpress Barcode hem de IronBarcode'un yüklü kalması gerekiyor mu?

Hayır. Çoğu geçiş doğrudan değişim yapılır, paralel bir işletim yerine geçer. Bir hizmet sınıfını bir seferde geçirin, NuGet referansını değiştirin ve sonraki sınıfa geçmeden önce başlatma ve API çağrı desenlerini güncelleyin.

IronBarcode için NuGet paketi adı nedir?

Paket 'IronBarCode' (büyük B ve C harfleriyle). 'Install-Package IronBarCode' veya 'dotnet add package IronBarCode' ile kurun. Kodda kullanılan yönerge 'using IronBarCode;' şeklindedir.

IronBarcode, Docker dağıtımını DevExpress Barcode'a kıyasla nasıl kolaylaştırır?

IronBarcode, harici SDK dosyaları veya montajlı lisans yapılandırması olmayan bir NuGet paketidir. Docker'da, IRONBARCODE_LICENSE_KEY ortam değişkenini ayarlayın ve paket lisans doğrulamasını başlangıçta kendi kendine yapar.

IronBarcode, DevExpress'ten göç ettikten sonra tüm barkod formatlarını otomatik olarak algılıyor mu?

Evet. IronBarcode, desteklenen tüm formatlardaki sembolojiyi otomatik olarak algılar. Açık BarcodeTypes sayımı gerekli değildir. Format zaten biliniyorsa ve performans önemliyse, BarcodeReaderOptions arama alanını optimize etmek için sınırlamayı sağlar.

IronBarcode, ayrı bir kütüphane olmadan PDF'lerden barkod okuyabiliyor mu?

Evet. BarcodeReader.Read("document.pdf") PDF dosyalarını yerel olarak işlemler. Sonuçlar her barkod için SayfaNumarası, Format, Değer ve Güven içerir. Harici bir PDF render adımı gerekmez.

IronBarcode, paralel barkod işlemeyi nasıl yönetiyor?

IronBarcode'un statik yöntemleri durumsuz ve thread-safe'dir. Dağıtılmış dosya listeleri üzerinde per-thread örnek yönetimi olmadan doğrudan Parallel.ForEach kullanın. BarcodeReaderOptions.MaxParallelThreads, iç thread bütçesini kontrol eder.

DevExpress Barcode'dan IronBarcode'a geçiş yaparken hangi sonuç özellikleri değişiyor?

Yaygın yeniden adlandırmalar: BarcodeValue, Value olur; BarcodeType, Format olur. IronBarcode sonuçları ayrıca Güven ve SayfaNumarası ekler. Çözüm çapında arama-değiştirme, mevcut sonuç işleme kodundaki yeniden adlandırmaları ele alır.

Bir CI/CD hattında IronBarcode lisanslamasını nasıl ayarlayabilirim?

IRONBARCODE_LICENSE_KEY'i bir boru hattı sırrı olarak saklayın ve uygulama başlangıç kodunda IronBarCode.License.LicenseKey olarak atayın. Bir sır, geliştirme, test, aşama ve üretim dahil olmak üzere tüm ortamları kapsar.

IronBarcode, özel biçimlendirmeye sahip QR kodu üretimini destekliyor mu?

Evet. QRCodeWriter.CreateQrCode() özelleştirilmiş renkler için ChangeBarCodeColor(), logo yerleştirme için AddBrandLogo(), yapılandırılabilir hata düzeltme seviyeleri ve PNG, JPG, PDF ve akış dahil birden çok çıktı formatını destekler.

Curtis Chau
Teknik Yazar

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ı...

Daha Fazla Oku

Iron Destek Ekibi

Haftada 5 gün, 24 saat çevrimiçiyiz.
Sohbet
E-posta
Beni Ara