←Select platform

BackColor Property

Summary
Gets or sets the barcode background (spaces) color used when reading barcodes.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public RasterColor BackColor { get; set; } 
@property (nonatomic, copy) LTRasterColor *backColor; 
public RasterColor getBackColor() 
public void setBackColor(RasterColor value) 
public: 
property RasterColor BackColor { 
   RasterColor get(); 
   void set (    RasterColor ); 
} 
BackColor # get and set (BarcodeReadOptions) 

Property Value

A RasterColor that specifies the barcode background (spaces) color to use when searching for barcodes. The default value is "White" (RGB of #FFFFFF). The default value is #FFFFFFFF.

Remarks

If the input image is bitonal (B/W), then this value will not be used. The foreground color is always considered to be black (or the foreground color in the image palette) and the background color is always considered to be white (or the background color in the image palette).

When the input image is not bitonal, LEADTOOLS will perform an intensity detect operation on the image to convert it to black and white before searching for the barcodes and uses the value of ForeColor and BackColor as the high and low threshold.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Barcode; 
using Leadtools.ImageProcessing; 
 
 
public void BarcodeReadOptions_ColorsExample() 
{ 
   string imageFileName = Path.Combine(LEAD_VARS.ImagesDir, "Barcode2.tif"); 
 
   // Create a Barcode engine 
   BarcodeEngine engine = new BarcodeEngine(); 
 
   // Get the Barcode reader instance 
   BarcodeReader reader = engine.Reader; 
 
   using (RasterCodecs codecs = new RasterCodecs()) 
   { 
      using (RasterImage image = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)) 
      { 
         // Invert the image 
         Console.WriteLine("Inverting the image"); 
         Leadtools.ImageProcessing.Color.InvertCommand invert = new Leadtools.ImageProcessing.Color.InvertCommand(); 
         invert.Run(image); 
 
         // All barcodes have default options of black foreground color and white background color, so 
         // reading the barcode with default options should not return any barcodes right now 
 
         // Read the QR barcode from this image using default options 
         Console.WriteLine("Reading using default options"); 
         BarcodeData barcode = reader.ReadBarcode(image, LeadRect.Empty, BarcodeSymbology.QR, null); 
 
         // Show its location and data if found 
         // This will print out "Not found" 
         if (barcode != null) 
         { 
            Console.WriteLine("Found at {0}, data:\n{1}", barcode.Bounds, barcode.Value); 
         } 
         else 
         { 
            Console.WriteLine("Not found"); 
         } 
 
         // Now create QR read options to have white foreground color and black background color 
         QRBarcodeReadOptions qrReadOptions = new QRBarcodeReadOptions(); 
         qrReadOptions.ForeColor = RasterColor.FromKnownColor(RasterKnownColor.White); 
         qrReadOptions.BackColor = RasterColor.FromKnownColor(RasterKnownColor.Black); 
 
         // And use it to try to read the QR barcode again 
         Console.WriteLine("Reading using specific options that instruct the engine to look for white on black barcodes"); 
         barcode = reader.ReadBarcode(image, LeadRect.Empty, BarcodeSymbology.QR, qrReadOptions); 
 
         // Show its location and data if found 
         // This will find the barcode and print its information now 
         if (barcode != null) 
         { 
            Console.WriteLine("Found at {0}, data:\n{1}", barcode.Bounds, barcode.Value); 
         } 
         else 
         { 
            Console.WriteLine("Not found"); 
         } 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Barcode Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.