1-BPPバーコード画像の作成
1bpp画像は、通常黒と白の2色のみを表示できるモノクロ画像です。画像内の各ピクセルは1ビットで表され、"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();
コードの説明
We first import the IronBarcode library, then we generate a barcode using the BarcodeWriter.CreateBarcode method. このメソッドに渡す変数は、文字列値とバーコードの種類です。 上記の例では、それぞれ"12345"と"EAN8"です。
After creating the barcode, we can call the save method SaveAs1BppBitmap and pass it a file name. これにより、指定したファイル名で1bppビットマップとしてバーコードが保存されます。
ビットマップに直接保存する以外にも、代替の保存メソッドがあります。 IronBarcode supports saving the barcode as 1bpp binary data using the To1BppBinaryData method. バイナリデータへの変換により、アプリケーションの他のセクションにバイナリデータとして変数を渡したり、既存のコードベースと統合することができます。 Furthermore, IronBarcode also supports saving the barcode as a 1-bit-per-pixel (1bpp) image using the To1BppImage method.





