C#에서 QR 코드 및 바코드를 생성하는 방법

Generate QR Codes in C# - Complete Tutorial for .NET Developers

This article was translated from English: Does it need improvement?
Translated
View the article in English

C# 애플리케이션에서 QR 코드를 생성해야 하십니까? 이 튜토리얼은 QR 코드를 생성, 사용자 정의, 검증하는 방법을 정확히 보여줍니다. IronBarcode을 사용하여 간단한 한 줄 구현에서부터 로고 삽입과 이진 데이터 인코딩 같은 고급 기능까지 다룹니다.

재고 시스템, 이벤트 티켓 발행 플랫폼 또는 비접촉 결제 솔루션을 구축 중든, .NET 애플리케이션에서 전문 등급의 QR 코드 기능을 구현하는 방법을 배웁니다.

IronBarcode로 한 줄 QR 코드 생성 빠른 시작

빠르게 QR 코드를 생성할 준비가 되셨나요? IronBarcode의 QRCodeWriter API를 사용하여 단 한 줄의 코드로 QR 코드를 생성할 수 있는 방법을 안내합니다. 사용자 정의는 선택사항이지만 강력합니다.

  1. NuGet 패키지 관리자를 사용하여 https://www.nuget.org/packages/BarCode 설치하기

    PM > Install-Package BarCode
  2. 다음 코드 조각을 복사하여 실행하세요.

    var qr = QRCodeWriter.CreateQrCode("https://ironsoftware.com/", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium); qr.SaveAsPng("MyQR.png");
  3. 실제 운영 환경에서 테스트할 수 있도록 배포하세요.

    무료 체험판으로 오늘 프로젝트에서 IronBarcode 사용 시작하기

    arrow pointer

How Do I Install a QR Code Library in C#?

NuGet 패키지 관리자를 사용하여 간단한 명령어로 IronBarcode을 설치하세요:

Install-Package BarCode

NuGet으로 설치하기

또는 IronBarcode DLL을 직접 다운로드하여 프로젝트에 참조로 추가하세요.

필요한 네임스페이스 가져오기

IronBarcode의 QR 코드 생성 기능에 액세스하려면 다음 네임스페이스를 추가하세요:

:path=/static-assets/barcode/content-code-examples/tutorials/csharp-qr-code-generator-3.cs
using IronBarCode;

// You may add styling with color, logo images or branding:
QRCodeLogo qrCodeLogo = new QRCodeLogo("visual-studio-logo.png");
GeneratedBarcode myQRCodeWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/", qrCodeLogo);

myQRCodeWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen);

// Save as PDF
myQRCodeWithLogo.SaveAsPdf("MyQRWithLogo.pdf");

// Also Save as HTML
myQRCodeWithLogo.SaveAsHtmlFile("MyQRWithLogo.html");
Imports IronBarCode

' You may add styling with color, logo images or branding:
Private qrCodeLogo As New QRCodeLogo("visual-studio-logo.png")
Private myQRCodeWithLogo As GeneratedBarcode = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/", qrCodeLogo)

myQRCodeWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen)

' Save as PDF
myQRCodeWithLogo.SaveAsPdf("MyQRWithLogo.pdf")

' Also Save as HTML
myQRCodeWithLogo.SaveAsHtmlFile("MyQRWithLogo.html")
$vbLabelText   $csharpLabel

How Can I Create a Simple QR Code in C#?

단 한 줄의 코드로 IronBarcodeCreateQrCode 메소드를 사용하여 QR 코드를 생성하세요:

:path=/static-assets/barcode/content-code-examples/tutorials/csharp-qr-code-generator-4.cs
using IronBarCode;
using IronSoftware.Drawing;
using System;

// Verifying QR Codes
QRCodeLogo qrCodeLogo = new QRCodeLogo("visual-studio-logo.png");
GeneratedBarcode MyVerifiedQR = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/", qrCodeLogo);

MyVerifiedQR.ChangeBarCodeColor(System.Drawing.Color.LightBlue);

if (!MyVerifiedQR.Verify())
{
    Console.WriteLine("\t LightBlue is not dark enough to be read accurately.  Lets try DarkBlue");
    MyVerifiedQR.ChangeBarCodeColor(Color.DarkBlue);
}
MyVerifiedQR.SaveAsHtmlFile("MyVerifiedQR.html");

// open the barcode html file in your default web browser
System.Diagnostics.Process.Start("MyVerifiedQR.html");
Imports Microsoft.VisualBasic
Imports IronBarCode
Imports IronSoftware.Drawing
Imports System

' Verifying QR Codes
Private qrCodeLogo As New QRCodeLogo("visual-studio-logo.png")
Private MyVerifiedQR As GeneratedBarcode = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/", qrCodeLogo)

MyVerifiedQR.ChangeBarCodeColor(System.Drawing.Color.LightBlue)

If Not MyVerifiedQR.Verify() Then
	Console.WriteLine(vbTab & " LightBlue is not dark enough to be read accurately.  Lets try DarkBlue")
	MyVerifiedQR.ChangeBarCodeColor(Color.DarkBlue)
End If
MyVerifiedQR.SaveAsHtmlFile("MyVerifiedQR.html")

' open the barcode html file in your default web browser
System.Diagnostics.Process.Start("MyVerifiedQR.html")
$vbLabelText   $csharpLabel

CreateQrCode 메소드는 세 가지 매개변수를 수용합니다:

  • 텍스트 콘텐츠: 인코딩할 데이터(URL, 텍스트 또는 모든 문자열 데이터 지원)
  • 크기: 정사각형 QR 코드의 픽셀 크기(이 예에서는 500x500)
  • 오류 수정: 불리한 조건에서의 가독성 결정(낮음, 중간, 사분위, 높음)

더 높은 오류 수정 수준은 QR 코드가 부분적으로 손상되거나 가려졌을 때도 읽을 수 있도록 하지만, 데이터 모듈이 더 많은 밀도로 구성되게 만듭니다.

 IronBarcode로 C#에서 생성한 표준 QR 코드 "hello world" 텍스트를 포함하는 기본 QR 코드, 500x500 픽셀로 생성되며 중간 오류 수정을 사용함

QR 코드에 로고를 추가하려면 어떻게 하나요?

QR 코드에 로고를 삽입하면 브랜드 인식이 증가하면서도 스캔 가능성을 유지합니다. IronBarcode은 자동으로 로고의 위치와 크기를 조정하여 QR 코드의 무결성을 유지합니다:

:path=/static-assets/barcode/content-code-examples/tutorials/csharp-qr-code-generator-5.cs
using IronBarCode;
using System;
using System.Linq;

// Create Some Binary Data - This example equally well for Byte[] and System.IO.Stream
byte[] BinaryData = System.Text.Encoding.UTF8.GetBytes("https://ironsoftware.com/csharp/barcode/");

// WRITE QR with Binary Content
QRCodeWriter.CreateQrCode(BinaryData, 500).SaveAsImage("MyBinaryQR.png");

// READ QR with Binary Content
var MyReturnedData = BarcodeReader.Read("MyBinaryQR.png").First();
if (BinaryData.SequenceEqual(MyReturnedData.BinaryValue))
{
    Console.WriteLine("\t Binary Data Read and Written Perfectly");
}
else
{
    throw new Exception("Corrupted Data");
}
Imports Microsoft.VisualBasic
Imports IronBarCode
Imports System
Imports System.Linq

' Create Some Binary Data - This example equally well for Byte[] and System.IO.Stream
Private BinaryData() As Byte = System.Text.Encoding.UTF8.GetBytes("https://ironsoftware.com/csharp/barcode/")

' WRITE QR with Binary Content
QRCodeWriter.CreateQrCode(BinaryData, 500).SaveAsImage("MyBinaryQR.png")

' READ QR with Binary Content
Dim MyReturnedData = BarcodeReader.Read("MyBinaryQR.png").First()
If BinaryData.SequenceEqual(MyReturnedData.BinaryValue) Then
	Console.WriteLine(vbTab & " Binary Data Read and Written Perfectly")
Else
	Throw New Exception("Corrupted Data")
End If
$vbLabelText   $csharpLabel

CreateQrCodeWithLogo 메소드는 다음을 통해 로고 배치를 지능적으로 처리합니다:

  • QR 코드 가독성을 유지하기 위해 자동으로 로고의 크기를 조정
  • 데이터 손상을 피하기 위해 침묵 구역 내에 위치
  • QR 코드 색상을 변경할 때도 로고의 원래 색상 유지

이 접근 방식은 모든 스캔 장치와 애플리케이션에서 여러분의 브랜드 QR 코드가 완전히 기능하도록 보장합니다.

 Visual Studio 로고를 임베드한 QR 코드 IronBarcode의 자동 로고 크기 조정 및 배치를 보여주는 Visual Studio 로고가 삽입된 QR 코드

QR 코드를 다양한 형식으로 어떻게 내보낼 수 있습니까?

IronBarcode는 다양한 사용 사례에 맞는 여러 가지 내보내기 형식을 지원합니다. QR 코드를 이미지, PDF 또는 HTML 파일로 내보내기:

:path=/static-assets/barcode/content-code-examples/tutorials/csharp-qr-code-generator-6.cs
using IronBarCode;
using System;
using System.Linq;

BarcodeResults result = BarcodeReader.Read("QR.png", new BarcodeReaderOptions() { ExpectBarcodeTypes = BarcodeEncoding.QRCode });
if (result != null)
{
    Console.WriteLine(result.First().Value);
}
Imports IronBarCode
Imports System
Imports System.Linq

Private result As BarcodeResults = BarcodeReader.Read("QR.png", New BarcodeReaderOptions() With {.ExpectBarcodeTypes = BarcodeEncoding.QRCode})
If result IsNot Nothing Then
	Console.WriteLine(result.First().Value)
End If
$vbLabelText   $csharpLabel

각 형식은 특정 목적을 위해 사용됩니다:

맞춤화 후 QR 코드 가독성을 어떻게 확인하나요?

색상 수정 및 로고 추가는 QR 코드 스캔 가능성에 영향을 줄 수 있습니다. 사용자 정의한 QR 코드가 읽기 가능한 상태로 유지되도록 Verify() 메소드를 사용하세요:

:path=/static-assets/barcode/content-code-examples/tutorials/csharp-qr-code-generator-7.cs
using IronBarCode;
using System;
using System.Linq;

BarcodeReaderOptions options = new BarcodeReaderOptions
{
    Speed = ReadingSpeed.Faster,
    ExpectMultipleBarcodes = false,
    ExpectBarcodeTypes = BarcodeEncoding.All,
    Multithreaded = false,
    MaxParallelThreads = 0,
    CropArea = null,
    UseCode39ExtendedMode = false,
    RemoveFalsePositive = false,
    ImageFilters = null
};

BarcodeResults result = BarcodeReader.Read("QR.png", options);
if (result != null)
{
    Console.WriteLine(result.First().Value);
}
Imports IronBarCode
Imports System
Imports System.Linq

Private options As New BarcodeReaderOptions With {
	.Speed = ReadingSpeed.Faster,
	.ExpectMultipleBarcodes = False,
	.ExpectBarcodeTypes = BarcodeEncoding.All,
	.Multithreaded = False,
	.MaxParallelThreads = 0,
	.CropArea = Nothing,
	.UseCode39ExtendedMode = False,
	.RemoveFalsePositive = False,
	.ImageFilters = Nothing
}

Private result As BarcodeResults = BarcodeReader.Read("QR.png", options)
If result IsNot Nothing Then
	Console.WriteLine(result.First().Value)
End If
$vbLabelText   $csharpLabel

Verify() 메소드는 QR 코드에 대한 포괄적인 스캔 테스트를 수행합니다. 이는 배포 전에 다양한 스캔 장치와 조명 조건에서의 호환성을 보장합니다.

 진한 파란색으로 검증된 QR 코드와 Visual Studio 로고 신뢰할 수 있는 스캔을 위한 적절한 대비를 보여주는 어두운 파란색의 성공적으로 검증된 QR 코드

QR 코드에 바이너리 데이터를 어떻게 인코딩하나요?

QR 코드는 바이너리 데이터를 효율적으로 저장하는 데 뛰어납니다. 이 기능은 암호화된 데이터 전송, 파일 공유 및 IoT 장치 설정과 같은 고급 응용 프로그램을 가능하게 합니다:

:path=/static-assets/barcode/content-code-examples/tutorials/csharp-qr-code-generator-8.cs
using IronBarCode;
using System;
using System.Linq;

// Convert string to binary data
byte[] binaryData = System.Text.Encoding.UTF8.GetBytes("https://ironsoftware.com/csharp/barcode/");

// Create QR code from binary content
QRCodeWriter.CreateQrCode(binaryData, 500).SaveAsPng("MyBinaryQR.png");

// Read and verify binary data integrity
var myReturnedData = BarcodeReader.Read("MyBinaryQR.png").First();

// Confirm data matches original
if (binaryData.SequenceEqual(myReturnedData.BinaryValue))
{
    Console.WriteLine("Binary Data Read and Written Perfectly");
}
else
{
    throw new Exception("Data integrity check failed");
}
Imports IronBarCode
Imports System
Imports System.Linq

' Convert string to binary data
Dim binaryData As Byte() = System.Text.Encoding.UTF8.GetBytes("https://ironsoftware.com/csharp/barcode/")

' Create QR code from binary content
QRCodeWriter.CreateQrCode(binaryData, 500).SaveAsPng("MyBinaryQR.png")

' Read and verify binary data integrity
Dim myReturnedData = BarcodeReader.Read("MyBinaryQR.png").First()

' Confirm data matches original
If binaryData.SequenceEqual(myReturnedData.BinaryValue) Then
    Console.WriteLine("Binary Data Read and Written Perfectly")
Else
    Throw New Exception("Data integrity check failed")
End If
$vbLabelText   $csharpLabel

QR 코드의 바이너리 인코딩은 여러 가지 이점을 제공합니다:

  • 효율성: 데이터를 컴팩트한 바이너리 형식으로 저장
  • 다재다능성: 모든 데이터 유형(파일, 암호화된 콘텐츠, 직렬화된 객체) 처리
  • 무결성: 인코딩 문제 없이 정확한 바이트 시퀀스를 보존

이 기능은 기본 QR 코드 라이브러리와 IronBarcode를 구별하여 응용 프로그램에서 고급 데이터 교환 시나리오를 가능하게 합니다.

 이진 인코딩된 데이터를 포함하는 QR 코드 IronBarcode의 고급 인코딩 기능을 보여주는 바이너리 데이터를 저장하는 QR 코드

How Do I Read QR Codes in C#?

IronBarcode는 유연한 QR 코드 읽기 기능을 제공합니다. 다음은 가장 간단한 접근 방식입니다:

:path=/static-assets/barcode/content-code-examples/tutorials/csharp-qr-code-generator-9.cs
using IronBarCode;
using System;
using System.Linq;

// Read QR code with optimized settings
BarcodeResults result = BarcodeReader.Read("QR.png", new BarcodeReaderOptions() { 
    ExpectBarcodeTypes = BarcodeEncoding.QRCode 
});

// Extract and display the decoded value
if (result != null && result.Any())
{
    Console.WriteLine(result.First().Value);
}
else
{
    Console.WriteLine("No QR codes found in the image.");
}
Imports IronBarCode
Imports System
Imports System.Linq

' Read QR code with optimized settings
Dim result As BarcodeResults = BarcodeReader.Read("QR.png", New BarcodeReaderOptions() With {
    .ExpectBarcodeTypes = BarcodeEncoding.QRCode
})

' Extract and display the decoded value
If result IsNot Nothing AndAlso result.Any() Then
    Console.WriteLine(result.First().Value)
Else
    Console.WriteLine("No QR codes found in the image.")
End If
$vbLabelText   $csharpLabel

세밀한 제어가 필요한 보다 복잡한 시나리오의 경우:

:path=/static-assets/barcode/content-code-examples/tutorials/csharp-qr-code-generator-10.cs
using IronBarCode;
using System;
using System.Linq;

// Configure advanced reading options
BarcodeReaderOptions options = new BarcodeReaderOptions
{
    Speed = ReadingSpeed.Faster,           // Optimize for speed
    ExpectMultipleBarcodes = false,        // Single QR code expected
    ExpectBarcodeTypes = BarcodeEncoding.QRCode, // QR codes only
    Multithreaded = true,                  // Enable parallel processing
    MaxParallelThreads = 4,                // Utilize multiple CPU cores
    RemoveFalsePositive = true,            // Filter out false detections
    ImageFilters = new ImageFilterCollection() // Apply preprocessing
    {
        new AdaptiveThresholdFilter(),    // Handle varying lighting
        new ContrastFilter(),              // Enhance contrast
        new SharpenFilter()                // Improve edge definition
    }
};

// Read with advanced configuration
BarcodeResults result = BarcodeReader.Read("QR.png", options);
Imports IronBarCode
Imports System
Imports System.Linq

' Configure advanced reading options
Dim options As New BarcodeReaderOptions With {
    .Speed = ReadingSpeed.Faster,           ' Optimize for speed
    .ExpectMultipleBarcodes = False,        ' Single QR code expected
    .ExpectBarcodeTypes = BarcodeEncoding.QRCode, ' QR codes only
    .Multithreaded = True,                  ' Enable parallel processing
    .MaxParallelThreads = 4,                ' Utilize multiple CPU cores
    .RemoveFalsePositive = True,            ' Filter out false detections
    .ImageFilters = New ImageFilterCollection() From { ' Apply preprocessing
        New AdaptiveThresholdFilter(),      ' Handle varying lighting
        New ContrastFilter(),               ' Enhance contrast
        New SharpenFilter()                 ' Improve edge definition
    }
}

' Read with advanced configuration
Dim result As BarcodeResults = BarcodeReader.Read("QR.png", options)
$vbLabelText   $csharpLabel

고급 읽기 옵션은 조명이 불량하거나 이미지 왜곡, 저품질 출력과 같은 어려운 조건에서 확실한 QR 코드 감지를 가능하게 합니다.

QR 코드 개발의 다음 단계는 무엇인가요?

IronBarcode으로 QR 코드 생성을 마스터한 후, 이러한 고급 주제를 탐구해보세요:

리소스 다운로드

전체 소스 코드 및 예제에 액세스하세요:

API 문서

API 참조에서 전체 기능 세트를 탐색하세요:

대안: 고급 QR 응용 프로그램을 위한 IronQR

최첨단 QR 코드 기능이 필요한 프로젝트의 경우 IronQR를 고려하세요—99.99%의 정확도를 자랑하는 기계 학습 기반 읽기 기능 및 고급 생성 옵션을 갖춘 Iron Software의 전문 QR 코드 라이브러리입니다.

.NET 응용 프로그램에서 QR 코드를 구현할 준비가 되셨나요? 무료 체험판을 시작하세요 또는 IronBarcode를 다운로드하세요.

자주 묻는 질문

C#에서 QR 코드를 생성하는 방법은 무엇인가요?

IronBarcode's QRCodeWriter.CreateQrCode() 메서드를 사용하면 C#에서 QR 코드를 생성할 수 있습니다. 이 메서드는 콘텐츠, 크기 및 오류 수정 수준을 전달하여 효율적으로 QR 코드를 생성할 수 있도록 합니다.

QR 코드는 어떤 이미지 형식으로 내보낼 수 있나요?

IronBarcode를 사용하면 QR 코드를 PNG, JPEG, PDF, HTML 등 다양한 형식으로 내보낼 수 있습니다. 이를 위해 SaveAsPng() , SaveAsJpeg() , SaveAsPdf() , SaveAsHtmlFile() 과 같은 메서드를 사용할 수 있습니다.

QR 코드에 회사 로고를 추가하려면 어떻게 해야 하나요?

IronBarcode는 로고 이미지가 포함된 QRCodeLogo 객체를 전달할 수 있는 CreateQrCodeWithLogo() 메서드를 제공합니다. 이 라이브러리는 QR 코드가 읽기 쉽도록 로고의 크기와 위치를 정확하게 조정합니다.

QR 코드 오류 수정이란 무엇이며, 어떤 수준을 선택해야 할까요?

QR 코드의 오류 수정 기능 덕분에 코드가 부분적으로 손상되더라도 스캔이 가능합니다. IronBarcode는 낮은(7%), 중간(15%), 사분위수(25%), 높은(30%)의 네 가지 오류 수정 수준을 제공합니다. 중간 수준은 대부분의 용도에 적합하며, 높은 수준은 까다로운 환경에 이상적입니다.

사용자 지정 QR 코드의 가독성을 어떻게 확인할 수 있나요?

GeneratedBarcode 객체의 Verify() 메서드를 사용하면 색상 변경이나 로고 추가와 같은 수정 후에도 사용자 지정 QR 코드가 스캔 가능한 상태로 유지되는지 확인할 수 있습니다.

QR 코드에 이진 데이터를 인코딩할 수 있습니까?

네, IronBarcode의 CreateQrCode() 메서드는 바이트 배열 인코딩을 지원하므로 파일이나 암호화된 콘텐츠와 같은 바이너리 데이터를 QR 코드 내에 저장할 수 있습니다.

C#에서 이미지의 QR 코드를 읽는 방법은 무엇인가요?

C#에서 이미지의 QR 코드를 읽으려면 IronBarcode의 BarcodeReader.Read() 메서드를 사용하십시오. 성능을 최적화하려면 BarcodeReaderOptionsBarcodeEncoding.QRCode 지정하십시오.

QR 코드의 최대 데이터 용량은 얼마입니까?

IronBarcode로 생성된 QR 코드는 선택한 오류 수정 수준에 따라 최대 2,953바이트, 4,296개의 영숫자 또는 7,089개의 숫자 자릿수를 저장할 수 있습니다.

QR 코드의 색상을 변경하면서도 스캔이 가능하도록 하려면 어떻게 해야 할까요?

IronBarcode의 ChangeBarCodeColor() 메서드를 사용하면 QR 코드의 색상을 변경할 수 있습니다. 색상 변경 후에는 반드시 Verify() 메서드를 사용하여 QR 코드의 가독성이 색상 변경으로 인해 영향을 받지 않는지 확인하십시오.

전문 QR 코드 라이브러리는 어떤 기능을 제공하나요?

Iron Software의 전문 라이브러리인 IronQR은 머신 러닝 기반 QR 코드 판독(99.99% 정확도) 및 복잡한 애플리케이션에 최적화된 강력한 QR 코드 생성 기능과 같은 고급 기능을 포함하고 있습니다.

제이콥 멜러, 팀 아이언 최고기술책임자
최고기술책임자

제이콥 멜러는 Iron Software의 최고 기술 책임자(CTO)이자 C# PDF 기술을 개척한 선구적인 엔지니어입니다. Iron Software의 핵심 코드베이스를 최초로 개발한 그는 창립 초기부터 회사의 제품 아키텍처를 설계해 왔으며, CEO인 캐머런 리밍턴과 함께 회사를 NASA, 테슬라, 그리고 전 세계 정부 기관에 서비스를 제공하는 50명 이상의 직원을 보유한 기업으로 성장시켰습니다.

제이콥은 맨체스터 대학교에서 토목공학 학사 학위(BEng)를 최우등으로 취득했습니다(1998~2001). 1999년 런던에서 첫 소프트웨어 회사를 설립하고 2005년 첫 .NET 컴포넌트를 개발한 후, 마이크로소프트 생태계 전반에 걸쳐 복잡한 문제를 해결하는 데 전문성을 발휘해 왔습니다.

그의 대표 제품인 IronPDF 및 Iron Suite .NET 라이브러리는 전 세계적으로 3천만 건 이상의 NuGet 설치 수를 기록했으며, 그의 핵심 코드는 전 세계 개발자들이 사용하는 다양한 도구에 지속적으로 활용되고 있습니다. 25년의 실무 경험과 41년의 코딩 전문성을 바탕으로, 제이콥은 차세대 기술 리더들을 양성하는 동시에 기업 수준의 C#, Java, Python PDF 기술 혁신을 주도하는 데 주력하고 있습니다.

시작할 준비 되셨나요?
Nuget 다운로드 2,317,217 | 버전: 2026.7 방금 출시
Still Scrolling Icon

아직도 스크롤하고 계신가요?

빠른 증거를 원하시나요? PM > Install-Package BarCode
샘플을 실행하세요 실이 바코드로 변하는 모습을 지켜보세요.