Customize Barcode Color Scheme in C#

This article describes the options provided by Aspose.BarCode for .NET to adjust the color scheme of a barcode image and its main elements.

Overview

Generally, barcode images are created in black and white colors. To generate barcode labels of different colors, Aspose.BarCode for .NET enables customizing system RGB color for key barcode elements, such as:

  • Background
  • Bars
  • Borders
  • Barcode text
  • Top and bottom captions

Set Barcode Background Color

Setting color for barcode background can be done by initializing the BackColor property of BaseGenerationParameters class. The default background color is set to White.

The barcode image generated with adjusted background color settings (Color.Green) is demonstrated below.

The following code snippet illustrates how to set a barcode background color.

Set Bar Color

To customize the color of bars in a barcode image, it is necessary to set the value to the BarColor property of BarcodeParameters class. The default bar color is Black.

The following image represents the barcode label generated with the customized bar color settings (Color.Green).

The code snippet provided below explains how to adjust bar color.

Set Barcode Border Color

It is possible to vary barcode border color by setting the Color property of class BorderParameters. By default, the color of borders is set to Black. The barcode image provided below has been created setting border color to (Color.Green).

The following code example is used to change the color of barcode borders.

Set Barcode Text Color

The color of barcode text that may be placed on a barcode image can be adjusted as well. To do this, it is required to initialize the Color property in property group CodeTextParameters. By default, the color of barcode text is set to Black. The sample barcode image shown below has been generated with the customized barcode text color setting (Color.Green).

The following code snippet demonstrates how to change barcode text color.

Set Barcode Caption Color

Barcode images created using Aspose.BarCode for .NET may have top and/or bottom captions according to the will of a developer. The color of these elements can be adjusted by setting the value to the TextColor property in property group CaptionParameters. The following barcode images have been generated using the customized caption color settings (Color.Green).

Adjusting Caption Color

The code example given below explains how to adjust caption color for top and bottom captions.