IRONSOFTWAREHOME
寫入1-BPP條碼圖像
using IronBarCode;

var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);

myBarcode.SaveAs1BppBitmap("1bppImage.bmp");
var byteData = myBarcode.To1BppBinaryData();
var anyBitmap = myBarcode.To1BppImage();
Imports IronBarCode

Dim myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8)

myBarcode.SaveAs1BppBitmap("1bppImage.bmp")
Dim byteData = myBarcode.To1BppBinaryData()
Dim anyBitmap = myBarcode.To1BppImage()
NuGet Download
PM > Install-Package BarCode
寫入1-BPP條碼圖像

寫入1-BPP條碼圖像

1bpp圖像是一種單色圖像,它只能顯示兩種顏色,通常是黑色和白色。圖片中的每個像素由一個位表示,其中"0"可能表示黑色,而"1"可能表示白色,或反之亦然。 這種格式最適合速度和準確性至關重要的情境,並且旨在被機器讀取。 在此程式碼範例中,我們將演示如何將我們建立的條碼轉換為1bpp圖像,以獲得最大對比度和可靠性進行掃描。

將條碼轉換為1BPP條碼圖像的5步指南

  • using IronBarCode;
  • var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);
  • myBarcode.SaveAs1BppBitmap("1bppImage.bmp");
  • var byteData = myBarcode.To1BppBinaryData();
  • var anyBitmap = myBarcode.To1BppImage();

程式碼解釋

我們首先導入BarcodeWriter.CreateBarcode方法生成條碼。 我們將兩個變數傳遞給該方法:字串值和條碼型別。 在上述範例中,這些分別是"12345"和EAN8

建立條碼後,我們可以呼叫SaveAs1BppBitmap並傳遞一個文件名。 這樣做會將條碼保存為1bpp Bitmap,名稱是它被保存的文件名。

除了直接保存到Bitmap之外,還有其他保存方法。 IronBarcode 支援使用1bpp二進位資料。 轉換為二進位資料允許您將變數作為二進位資料傳遞給應用程式其他部分或與現有程式碼庫整合。 此外,1-bit-per-pixel (1bpp) 圖像。

在GitHub上查看

準備好開始了嗎?

Nuget Downloads 2,422,100版本:2026.9剛剛發布

Key in blue circle

立即免費取得 30 天試用金鑰

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
預訂您的免費即時演示
Booking Badge

全球數百萬工程師信賴

Iron Software的客戶標誌
獲取您的無義務諮詢
完成下方表單或發送電子郵件至sales@ironsoftware.com
您的詳細資訊將始終保密。
全球數百萬工程師信賴
Iron Software的客戶標誌
立即獲取您的30天試用金鑰
無需信用卡或帳戶建立