Error processing SSI file
LEADTOOLS Barcode (Leadtools.Barcode assembly)

Show in webframe

ForeColor Property (IBarcodeWriteOptions)








Gets or sets the barcode foreground (bars or symbol) color used when writing barcodes.
Syntax
[CategoryAttribute("				Colors")]
[DisplayNameAttribute("Fore color")]
[DescriptionAttribute("Foreground (bar) color to use when writing the barcode")]
RasterColor ForeColor {get; set;}
'Declaration
 
<CategoryAttribute("				Colors")>
<DisplayNameAttribute("Fore color")>
<DescriptionAttribute("Foreground (bar) color to use when writing the barcode")>
Property ForeColor As RasterColor
'Usage
 
Dim instance As IBarcodeWriteOptions
Dim value As RasterColor
 
instance.ForeColor = value
 
value = instance.ForeColor
[CategoryAttribute("				Colors")]
[DisplayNameAttribute("Fore color")]
[DescriptionAttribute("Foreground (bar) color to use when writing the barcode")]
RasterColor ForeColor {get; set;}
CategoryAttribute("				Colors")
DisplayNameAttribute("Fore color")
DescriptionAttribute("Foreground (bar) color to use when writing the barcode")
<br/>get_ForeColor();<br/>set_ForeColor(value);<br/>Object.defineProperty('ForeColor'); 
[CategoryAttribute("				Colors")]
[DisplayNameAttribute("Fore color")]
[DescriptionAttribute("Foreground (bar) color to use when writing the barcode")]
property RasterColor ForeColor {
   RasterColor get();
   void set (    RasterColor value);
}

Property Value

A RasterColor that specifies the barcode foreground (bars or symbol) color when writing barcodes. Default value is "Black" (RGB of #000000).
Remarks

LEADTOOLS will use ForeColor and BackColor when drawing the new barcode to the image and no special processing is performed. Note that you can specify a transparent color for BackColor to "overlay" the barcode on top of the background of the image. This however, is not recommended.

Example

This example writes a UPC-A barcode to an image with specific colors.

Copy Code  
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Barcode;
using Leadtools.ImageProcessing;

      
public async Task BarcodeWriteOptions_ColorsExample()
{
   string imageFileName = @"MyBarcode.png";
   BarcodeEngine engine = new BarcodeEngine();
   BarcodeWriter writer = engine.Writer;

   // We will create a Red over Yellow backround
   RasterColor foreColor = RasterColorHelper.FromKnownColor(RasterKnownColor.Red);
   RasterColor backColor = RasterColorHelper.FromKnownColor(RasterKnownColor.Yellow);

   // Create a UPC-A barcode
   BarcodeData barcode = BarcodeData.CreateDefaultBarcodeData(BarcodeSymbology.UPCA);
   barcode.Bounds = LeadRectHelper.Create(0, 0, 400, 200);

   // Create a 24 BPP image the same size as the barcode
   // The image will have red over yellow colors
   int resolution = 300;
   LeadRect pixels = barcode.Bounds;
   using(RasterImage image = RasterImage.Create(pixels.Width, pixels.Height, 24, resolution, backColor))
   {
      // Change the barcode colors to be Red over Yellow
      OneDBarcodeWriteOptions options = writer.GetDefaultOptions(BarcodeSymbology.UPCA) as OneDBarcodeWriteOptions;
      options.ForeColor = foreColor;
      options.BackColor = backColor;

      // Write the barcode
      writer.WriteBarcode(image, barcode, options);

      // Save as PNG
      using(RasterCodecs codecs = new RasterCodecs())
      {
         StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(imageFileName);
         await codecs.SaveAsync(image, LeadStreamFactory.Create(saveFile), RasterImageFormat.Png, 24);
      }
   }
}
Requirements

Target Platforms

See Also

Reference

IBarcodeWriteOptions Interface
IBarcodeWriteOptions Members
BackColor Property

Error processing SSI file
Leadtools.Barcode requires a Barcode Module license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features