C# Windows Uygulamalarında QR Kodu Nasıl Oluşturulur
Bu eğitim, endüstriyel uygulamalarda ve perakende sektöründe giderek daha popüler hale gelen QR kodlarının nasıl oluşturulacağına dair derinlemesine bir bakış sunar. En popüler ve güçlü kütüphanelerden biri olan IronBarcode kullanılarak QR kodlarının nasıl oluşturulacağı gösterilecektir.
C# Windows Forms Uygulamalarında QR Kodu Nasıl Oluşturulur
- Microsoft Visual Studio'da bir Windows Forms Uygulaması oluşturun
- QR kodu kütüphanesini kurun
- Barkod oluşturmak için ad alanları ekleyin
- Tek bir kod satırı ile bir QR kodu oluşturun
- QR kodu görüntüsüne bir logo ekleyin
- Bir resmi PDF veya HTML olarak kaydedin
1. Microsoft Visual Studio'da bir Windows Forms Uygulaması Oluşturun
Visual Studio'yu açın > Yeni Proje Oluştur'a tıklayın > Windows Forms Uygulama Şablonu'nu seçin > İleri'ye basın > Proje Adını verin > İleri'ye basın > Hedef .NET Framework'ünüzü seçin > Oluştur butonuna tıklayın.
Projeyi oluşturduktan sonra, Visual Studio araç kutusundan şu denetimleri kullanarak formu tasarlayın: PictureBox, Label, TextBox ve Button.
Bir görüntü yüklemek ve QR Kodu oluşturmak için Windows Forms Uygulama UI'si
2. Install the QR Code Generator .NET Library in C
İlk adım barkod kütüphanesini kurmaktır. Bunu aşağıdaki üç yöntemden biri kullanarak yapabilirsiniz:
2.1. Paket Yöneticisi Konsolu
Paket Yöneticisi Konsolu'na aşağıdaki komutu yazın. Bu, sizin için paketi indirip kuracaktır.
Install-Package BarCode
Paket Yöneticisi Konsol UI'sinde kurulum ilerlemesi
2.2. NuGet Paketleri Yöneticisi Çözümü
Barkod kütüphanesini NuGet Paket Çözümü kullanarak da kurabilirsiniz. Sadece bu adımları izleyin:
Araçlar > NuGet Paket Yöneticisi > Çözüm İçin NuGet Paketlerini Yönet üzerine tıklayın.
Bu, sizin için NuGet Paket Yöneticisi'ni açacaktır. Gözat'a tıklayın, BarCode'u arayın ve ardından sınıf kütüphanesini kurun.
NuGet Paket Yöneticisi'nde BarCode kütüphanesini bulma
2.3. Bağlantıdan İndirin
Alternatif olarak, IronBarCode.Dll indirilebilir ve projenize bir referans olarak eklenebilir, .NET Barcode DLL içerisinden.
3. Ad Alanlarını İçe Aktarma
Bu eğitici için, yeterli referansların sağlanması amacıyla IronBarCode ad alanı ve diğer sistem derlemeleri gereklidir.
using IronBarCode; // Provides functionality for QR and barcode generation
using System; // Contains fundamental classes and base classes that define commonly-used value and reference data types
using System.Drawing; // Provides access to GDI+ basic graphic functionality
using System.Linq; // Provides classes and interfaces that support queries
using IronBarCode; // Provides functionality for QR and barcode generation
using System; // Contains fundamental classes and base classes that define commonly-used value and reference data types
using System.Drawing; // Provides access to GDI+ basic graphic functionality
using System.Linq; // Provides classes and interfaces that support queries
Imports IronBarCode ' Provides functionality for QR and barcode generation
Imports System ' Contains fundamental classes and base classes that define commonly-used value and reference data types
Imports System.Drawing ' Provides access to GDI+ basic graphic functionality
Imports System.Linq ' Provides classes and interfaces that support queries
4. 1 Satır Kod ile QR Kodu Oluşturun
Aşağıdaki örnek kod, sadece bir satır kod ile bir QR kodu görüntüsü oluşturmanıza olanak tanır. Bir QR kodu oluşturmak istediğiniz metni, metin kutusuna girin. Bu kodu "PNG Oluştur" buton tıklama olayına yerleştirin. QR kodu görüntüleri PNG formatında kaydedilebilir.
// Simple QR Code generation
private void button1_Click(object sender, EventArgs e)
{
// Generate a QR code from the text provided in the TextBox
GeneratedBarcode qrCode = QRCodeWriter.CreateQrCode(textBox1.Text);
// Save the generated QR code as a PNG file
qrCode.SaveAsPng("QrCode.png");
}
// Simple QR Code generation
private void button1_Click(object sender, EventArgs e)
{
// Generate a QR code from the text provided in the TextBox
GeneratedBarcode qrCode = QRCodeWriter.CreateQrCode(textBox1.Text);
// Save the generated QR code as a PNG file
qrCode.SaveAsPng("QrCode.png");
}
' Simple QR Code generation
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
' Generate a QR code from the text provided in the TextBox
Dim qrCode As GeneratedBarcode = QRCodeWriter.CreateQrCode(textBox1.Text)
' Save the generated QR code as a PNG file
qrCode.SaveAsPng("QrCode.png")
End Sub
QR kodu üreteci çıkışı burada:
5. Bir QR Kod Görseline Logo Ekleme
CreateQrCodeWithLogo yöntemini QRCodeWriter sınıfından kullanarak, QR koduna ek bilgiler, örneğin bir logo, eklenebilir. Örnek kod bunun ne kadar kolay olduğunu gösterir.
Bilgisayarınızdan logoyu tarayın ve PictureBox içinde açılacaktır. Kod şu şekildedir:
// Open file dialog to select an image
OpenFileDialog open = new OpenFileDialog();
// Set image file filters to ensure valid image types are opened
open.Filter = "Image Files(*.jpg; *.png; *.jpeg; *.gif; *.bmp)|*.jpg; *.png; *.jpeg; *.gif; *.bmp";
if (open.ShowDialog() == DialogResult.OK) {
// Display image in PictureBox and store file path for later use
pictureBox1.Image = new Bitmap(open.FileName);
// Store image file path in class data member
ImageFileName = open.FileName;
}
// Open file dialog to select an image
OpenFileDialog open = new OpenFileDialog();
// Set image file filters to ensure valid image types are opened
open.Filter = "Image Files(*.jpg; *.png; *.jpeg; *.gif; *.bmp)|*.jpg; *.png; *.jpeg; *.gif; *.bmp";
if (open.ShowDialog() == DialogResult.OK) {
// Display image in PictureBox and store file path for later use
pictureBox1.Image = new Bitmap(open.FileName);
// Store image file path in class data member
ImageFileName = open.FileName;
}
' Open file dialog to select an image
Dim open As New OpenFileDialog()
' Set image file filters to ensure valid image types are opened
open.Filter = "Image Files(*.jpg; *.png; *.jpeg; *.gif; *.bmp)|*.jpg; *.png; *.jpeg; *.gif; *.bmp"
If open.ShowDialog() = DialogResult.OK Then
' Display image in PictureBox and store file path for later use
pictureBox1.Image = New Bitmap(open.FileName)
' Store image file path in class data member
ImageFileName = open.FileName
End If
Sonra, metin kutusuna metni yazın, bu kodu PNG Üret düğmesinde yerleştirin ve tıklayın.
// Generate a QR code with a logo
GeneratedBarcode qrCode = QRCodeWriter.CreateQrCodeWithLogo(textBox1.Text, ImageFileName, 500);
// Save the generated QR code with logo as a PNG file
qrCode.SaveAsPng("QrCodeWithImage.png");
// Generate a QR code with a logo
GeneratedBarcode qrCode = QRCodeWriter.CreateQrCodeWithLogo(textBox1.Text, ImageFileName, 500);
// Save the generated QR code with logo as a PNG file
qrCode.SaveAsPng("QrCodeWithImage.png");
' Generate a QR code with a logo
Dim qrCode As GeneratedBarcode = QRCodeWriter.CreateQrCodeWithLogo(textBox1.Text, ImageFileName, 500)
' Save the generated QR code with logo as a PNG file
qrCode.SaveAsPng("QrCodeWithImage.png")
Bu kod, barcode'a Iron logosu ekler. Otomatik olarak uygun bir boyuta ayarlar, böylece yalnızca kod okunabilir kalır ve logoyu QR kodu kare ızgarasına hizalar, böylece uygun görünür.
Logo Görselle C# QR Kodu Üret
6. PDF veya HTML Görseli Olarak Kaydetme
Son olarak, oluşturulan QR kodu bir PDF veya HTML görseli olarak kaydedilebilir. Kodun son satırı, kolaylık sağlaması adına PDF'inizi varsayılan PDF tarayıcınızda açar. PDF Oluştur düğmesine SaveAsPdf ve HTML Oluştur düğmesine de SaveAsHtmlFile ekleyin.
// Generate a QR code with a logo
GeneratedBarcode qrCode = QRCodeWriter.CreateQrCodeWithLogo(textBox1.Text, ImageFileName, 500);
// Save the QR code as a PDF file
qrCode.SaveAsPdf("QRWithLogo.pdf");
// Also, save the QR code as an HTML file
qrCode.SaveAsHtmlFile("QRWithLogo.html");
// Generate a QR code with a logo
GeneratedBarcode qrCode = QRCodeWriter.CreateQrCodeWithLogo(textBox1.Text, ImageFileName, 500);
// Save the QR code as a PDF file
qrCode.SaveAsPdf("QRWithLogo.pdf");
// Also, save the QR code as an HTML file
qrCode.SaveAsHtmlFile("QRWithLogo.html");
' Generate a QR code with a logo
Dim qrCode As GeneratedBarcode = QRCodeWriter.CreateQrCodeWithLogo(textBox1.Text, ImageFileName, 500)
' Save the QR code as a PDF file
qrCode.SaveAsPdf("QRWithLogo.pdf")
' Also, save the QR code as an HTML file
qrCode.SaveAsHtmlFile("QRWithLogo.html")
Özet
IronBarcode, geliştiricilerin bar kodlara ve QR kodlara veri okutma ve yazmalarına izin veren kullanıcı dostu bir API sunar ve C# .NET için doğruluğu optimize eder ve gerçek dünya durumlarında düşük hata oranını garanti eder. IronBarcode hakkında daha fazla bilgi için lütfen belge web sitesini ziyaret edin.
Ek olarak, IronBarcode ayrıca resimlerden barkod okumayı destekler, ayrıca barkodları daha doğru okumak için ek seçenekler veya görüntülere filtre uygulamak sağlanır.
Şu anda, tam Iron Suite'i satın alırsanız, yalnızca iki fiyatına beş kütüphane alabilirsiniz. Daha fazla bilgi için lütfen fiyatlandırma sayfasını ziyaret edin.
Sıkça Sorulan Sorular
C# Windows Uygulamalarında QR kodu nasıl oluşturabilirim?
IronBarcode kütüphanesini kullanarak C# Windows Uygulamalarında QR kodu oluşturabilirsiniz, QRCodeWriter.CreateQrCode yöntemini kullanarak. Bu size metin girişinden bir QR kodu oluşturma ve onu bir PNG dosyası olarak kaydetme olanağı tanır.
QR kodu oluşturma için IronBarcode kullanmanın avantajları nelerdir?
IronBarcode, yüksek doğruluk ve düşük hata oranları ile QR kodu oluşturma için kullanımı kolay bir API sağlar. Ayrıca QR kodlarına logolar eklemek ve QR kodlarını PDF veya HTML dosyaları olarak kaydetmek gibi ek özellikleri destekler.
QR kodu oluşturma için Microsoft Visual Studio'da bir Windows Forms Uygulaması nasıl kurulur?
Microsoft Visual Studio'da bir Windows Forms Uygulaması kurmak için Visual Studio'yu açın, 'Yeni Proje Oluştur' seçeneğini seçin, 'Windows Forms Uygulama Şablonu'nu seçin, projenizi adlandırın, hedef .NET Framework'ü seçin ve 'Oluştur' a tıklayın.
Bir C# projesine QR kod kütüphanesi kurma süreci nedir?
IronBarcode kütüphanesi, Paket Yöneticisi Konsolu, NuGet Paket Yöneticisi Çözümü veya IronBarCode.DLL doğrudan indirerek bir C# projesine kurulabilir.
IronBarcode kullanarak bir QR koduna logo ekleyebilir miyim?
Evet, IronBarcode kütüphanesi kullanılarak, bilgisayarınızdan bir görüntü seçmenize olanak tanıyan QRCodeWriter sınıfından CreateQrCodeWithLogo yöntemini kullanarak bir QR koduna logo ekleyebilirsiniz.
IronBarcode kullanarak bir QR kodunu PDF veya HTML'ye dönüştürmek mümkün mü?
Evet, IronBarcode kullanarak bir QR kodunu SaveAsPdf ile PDF'ye veya SaveAsHtmlFile ile HTML dosyasına dönüştürebilirsiniz.
IronBarcode ile QR kodları oluşturmak için hangi ad alanları gereklidir?
IronBarcode ile QR kodları oluşturmak için 'IronBarCode' ad alanını, System, System.Drawing ve System.Linq gibi sistem ad alanlarıyla birlikte dahil etmeniz gerekir.
IronBarcode'un sağladığı ek barkod özellikleri nelerdir?
IronBarcode, görüntülerden çeşitli barkod formatlarını okumayı destekler, gelişmiş doğruluk seçenekleri sunarken barkod tanımını iyileştirmek için filtreler uygulama yeteneği de sağlar.
IronBarcode kullanımı hakkında daha ayrıntılı belgeleri nerede bulabilirim?
IronBarcode'un dokümantasyon sitesini ziyaret edebilir ve kütüphaneyi QR kodu oluşturma ve diğer barkod ile ilgili görevler için kullanma hakkında daha ayrıntılı bilgi ve rehberlik alabilirsiniz.
QR kodu:




