Creating 1BPP Barcode Images in C#

When it comes to bulk processing barcodes, several factors need to be considered, including the size and dimensions of the barcode. One effective option for ensuring quick processing and accurate reading by machines is the use of 1-bpp barcode images. A 1-bpp image is a monochrome image that can display only two colors, typically black and white. Each pixel in this image is represented by a single bit; "0" may represent black while "1" represents white, or vice versa.

The 1-bpp barcode image has the smallest possible file size, with each pixel being represented by just one bit. This compact size makes it highly efficient for storing and transmitting barcode images to printers.

IronBarcode supports converting the barcodes into 1bpp images and more, providing flexibility for all situations. In this how-to, we'll briefly go through all the options IronBarcode offers when it comes to creating 1bpp barcode images.

Get started with IronBarcode

Start using IronBarcode in your project today with a free trial.

First Step:
green arrow pointer



Creating 1BPP Barcode Images Example

Converting the barcode into a 1bpp image is quite simple; we need to call the To1BppImage method. The method saves the barcode as a 1bpp image.

:path=/static-assets/barcode/content-code-examples/how-to/create-1-bpp-barcode-images-image.cs
using IronBarCode;

// Create a barcode with "12345" encoded in the EAN8 format
var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);

// Converts the barcode into a 1bpp image
var anyBitmap = myBarcode.To1BppImage();
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Saving as 1BPP Bitmap

Alternatively, if users want to save as a bitmap instead, IronBarcode also supports this; we call the SaveAs1BppBitmap method and provide a file path to save it as. Here's a brief example.

:path=/static-assets/barcode/content-code-examples/how-to/create-1-bpp-barcode-images-bitmap.cs
using IronBarCode;

// Create a barcode with "12345" encoded in the EAN8 format
var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);

// Save the barcode as a 1bpp Bitmap 
myBarcode.SaveAs1BppBitmap("1bppImage.bmp");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Saving as Binary Data

For users who want to save it as binary data, IronBarcode also supports this feature. We call To1BppBinaryData instead. Saving data to a binary format allows you to use the data elsewhere in the application and integrate it with existing applications as well.

:path=/static-assets/barcode/content-code-examples/how-to/create-1-bpp-barcode-images-binary.cs
using IronBarCode;

// Create a barcode with "12345" encoded in the EAN8 format
var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);

// Save the barcode as a 1pp binary data object
var byteData = myBarcode.To1BppBinaryData();
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel
Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...Read More