티스토리 뷰

Nuget에서 ZXing.Net를 가지고 만들었습니다.

 

추가 참조 :

비쥬얼스튜디오 - 참조 - NuGet 페키지 관리 - ZXing.Net 검색

작성자 : Michael Jahn - v0.16.6 [ 2021.01.22 기준 ] - 설치진행함.

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace QRCode
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        /// <summary>
        /// 생성
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            ZXing.BarcodeWriter barcodeWriter = new ZXing.BarcodeWriter();
            barcodeWriter.Format = ZXing.BarcodeFormat.QR_CODE;
            
            barcodeWriter.Options.Width  = this.pictureBox1.Width;
            barcodeWriter.Options.Height = this.pictureBox1.Height;
            
            string strQRCode = "QRCODE TEST"; // 한글은 안되더라 ㅠ
                        
            this.pictureBox1.Image = barcodeWriter.Write(strQRCode);
            string deskPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);            
            barcodeWriter.Write(strQRCode).Save(deskPath + @"\test.jpg", ImageFormat.Jpeg);
        }
 
        /// <summary>
        /// 읽기
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            ZXing.BarcodeReader barcodeReader = new ZXing.BarcodeReader();            
            string deskPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
 
            var barcodeBitmap = (Bitmap)Image.FromFile(deskPath + @"\test.jpg");
            var result = barcodeReader.Decode(barcodeBitmap);
 
            this.textBox1.Text = result.Text;
        }
    }
}

 

:: 자료를 찾고 보니 QR code 보다 // 카메라 캡쳐 이미지 생성 하는 걸 찾아야 한다는 걸 알게 됨...................................

Total
Today
Yesterday
최근에 올라온 글
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31