How to Create a QR Code as an Image

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

Creating a QR code as an image involves generating a visual representation of a QR code, which encodes data (such as a URL, text, or other information) in a two-dimensional matrix composed of black and white squares. These squares can be scanned and decoded by a camera or QR code reader.

立即開始在您的項目中使用 IronQR 並免費試用。

第一步:
green arrow pointer

Create QR Code as Images

Creating a QR code with IronQR is very simple. You only need one line of code to create the QR code as an object. To export the QR code as an image, use the Save method followed by the SaveAs method.

:path=/static-assets/qr/content-code-examples/how-to/create-qr-code-image.cs
using IronQr;
using IronSoftware.Drawing;

// Creating a QR code
QrCode qrCode = QrWriter.Write("12345");

// Save QR code to AnyBitmap
AnyBitmap anyBitmap = qrCode.Save();

// Save AnyBitmap to PNG
anyBitmap.SaveAs("simpleQrCode.png", AnyBitmap.ImageFormat.Png);
Imports IronQr
Imports IronSoftware.Drawing

' Creating a QR code
Private qrCode As QrCode = QrWriter.Write("12345")

' Save QR code to AnyBitmap
Private anyBitmap As AnyBitmap = qrCode.Save()

' Save AnyBitmap to PNG
anyBitmap.SaveAs("simpleQrCode.png", AnyBitmap.ImageFormat.Png)
$vbLabelText   $csharpLabel
QR code

The Save method returns an AnyBitmap object. With this object, we can export to various image formats, such as:

  • JPEG (.jpg or .jpeg): JPEG is a commonly used compressed format for digital photos. It uses lossy compression, reducing file size while maintaining acceptable quality.
  • PNG (.png): PNG is a lossless image format ideal for web use. It supports transparency and retains high quality without data loss.
  • Bmp (.bmp): The Bitmap format is an uncompressed raster image format used primarily on Windows platforms. It retains high-quality images but produces large file sizes.
  • GIF (.gif): GIF supports animations and transparency but is limited to 256 colors. It is widely used for simple web graphics and short animations.
  • TIFF (.tiff or .tif): TIFF is a flexible format used for high-quality images, often in professional photography. It can be lossless or compressed.
  • WBMP (.wbmp): WBMP is a monochrome format used in wireless communication. If unsupported, it defaults to BMP.
  • WebP (.webp): WebP is a modern image format that provides excellent compression (both lossy and lossless), making it ideal for the web.
  • Icon (.ico): Icon format stores small square images used as icons for programs or files, commonly in operating systems.
  • WMF (.wmf): WMF is a vector and raster image format used primarily on Windows. It is often used for graphics in legacy systems.
  • RawFormat (.raw): Raw format refers to unprocessed image data, typically used in digital photography. It retains maximum quality and is used by professionals for image editing.

Supported QR Code Types

Multiple types of QR codes are supported for both creation and reading. Below are the supported QR code types:

  • QRCode: This is the standard QR code most commonly used today. It can store a significant amount of data (up to 7,089 numeric characters or 4,296 alphanumeric characters), making it suitable for a wide range of applications, from website URLs to contact information.
QR code
  • MicroQRCode: The Micro QR Code is a smaller version of the standard QR code, designed for situations where space is limited. It can store less data than a standard QR code (up to 35 numeric characters or 21 alphanumeric characters), but its compact size makes it ideal for applications where a standard QR code would be too large, such as on small packaging or tiny printed labels.
QR code
  • RMQRCode: RMQR Code (Rectangular Micro QR Code) is another compact version of the QR code but in a rectangular shape rather than a square. This version allows for flexibility in its aspect ratio, which can be useful for applications where a rectangular space is available. It can store data similar to the Micro QR Code but is designed for specific use cases where the available space is non-square.
QR code

常見問題解答

如何在 C# 中創建圖像形式的 QR 碼?

要在 C# 中創建圖像形式的 QR 碼,請從 NuGet 下載 IronQR 庫。使用您所需的數據創建 QR 碼對象,然後使用 Save 方法生成 AnyBitmap。最後,使用 SaveAs 方法將其導出為例如 PNG 或 JPEG 圖像格式。

以不同格式導出 QR 碼圖像的最簡單方法是什麼?

使用 IronQR,您可以通過在 AnyBitmap 對象上使用 SaveAs 方法來導出各種格式的 QR 碼圖像。支持的格式包括 JPEG、PNG、BMP、GIF、TIFF、WBMP、WebP、Icon、WMF 和 RawFormat。

支持創建哪些類型的 QR 碼?

IronQR 支持創建標準 QRCode、MicroQRCode 和 RMQRCode 類型。標準 QRCode 用於大型數據,MicroQRCode 用於在有限空間中的有限數據,RMQRCode 為特定應用提供矩形形狀。

我如何製作具有透明背景的 QR 碼?

要使用 IronQR 創建具有透明背景的 QR 碼,將 QR 碼導出為 PNG 文件,因為 PNG 格式支持透明。

使用 WebP 格式於 QR 碼的優點是什麼?

WebP 格式提供了極佳的壓縮效果,包括有損和無損壓縮,因其減少的文件大小並保持圖像質量,使其非常適合用於網頁。

IronQR 可以用於將 URL 編碼為 QR 碼嗎?

是的,IronQR 可以將 URL 編碼為 QR 碼。只需將 URL 作為字符串傳遞給 QRCodeWriter 的 CreateQrCode 方法。

JPEG 和 PNG 格式對於 QR 碼有什麼不同?

JPEG 是一種有損壓縮格式,適合在保持可接受質量的同時減少文件大小,而 PNG 是一種無損格式,適合網頁使用,保持高質量並支持透明。

什麼是 Micro QR Code?

Micro QR Code 是標準 QR 碼的較小版本,專為有限空間情況而設計,儲存的數據較少,但更緊湊,適合小型包裝等應用。

RMQRCode 的矩形形狀如何有用?

RMQRCode 的矩形形狀允許靈活的寬高比,使其適用於非正方形空間的應用,為印刷材料提供更多設計選擇。

Curtis Chau
技術作家

Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。

除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。

準備好開始了嗎?
Nuget 下載 47,669 | 版本: 2025.11 剛剛發布