LEADTOOLSバーコード(Leadtools.Barcodeアセンブリ)

フレームを表示

ForeColorプロパティ(BarcodeWriteOptions)








バーコードの書き込み時に使用するバーコードの前景(バーまたはシンボル)の色を取得または設定します。
構文
[DescriptionAttribute("Foreground (bar) color to use when writing the barcode")]
[CategoryAttribute("				Colors")]
[DisplayNameAttribute("Fore color")]
public RasterColor ForeColor {get; set;}
'Declaration
 
<DescriptionAttribute("Foreground (bar) color to use when writing the barcode")>
<CategoryAttribute("				Colors")>
<DisplayNameAttribute("Fore color")>
Public Property ForeColor As RasterColor
'Usage
 
Dim instance As BarcodeWriteOptions
Dim value As RasterColor
 
instance.ForeColor = value
 
value = instance.ForeColor
[DescriptionAttribute("Foreground (bar) color to use when writing the barcode")]
[CategoryAttribute("				Colors")]
[DisplayNameAttribute("Fore color")]
public RasterColor ForeColor {get; set;}
@property (nonatomic, copy) LTRasterColor *foreColor
public RasterColor getForeColor()
public void setForeColor(RasterColor value)
            
DescriptionAttribute("Foreground (bar) color to use when writing the barcode")
CategoryAttribute("				Colors")
DisplayNameAttribute("Fore color")
 <br/>get_ForeColor();<br/>set_ForeColor(value);<br/>Object.defineProperty('ForeColor'); 
[DescriptionAttribute("Foreground (bar) color to use when writing the barcode")]
[CategoryAttribute("				Colors")]
[DisplayNameAttribute("Fore color")]
public:
property RasterColor ForeColor {
   RasterColor get();
   void set (    RasterColor value);
}

属性値

バーコードを書き込むとき、バーコードフォアグラウンドの(バーまたはシンボル)カラーを指定するRasterColor。デフォルト値は、「黒いです」(#000000のRGB)。
解説

imageと特別な処理にでなく新しいバーコードを描画することが実行されるとき、LEADTOOLSはForeColorBackColorを使います。BackColorに透過色を指定することで、画像の背景の上にバーコードを「重ねる」ことができます。しかし、これは推薦されません。

サンプル

このサンプルは、特定の色でUPC-Aバーコードをimageへ書き込みます。

Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Forms
Imports Leadtools.Barcode
Imports Leadtools.ImageProcessing

      
Public Sub BarcodeWriteOptions_ColorsExample()
   Dim imageFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "MyBarcode.png")
   Dim engine As New BarcodeEngine()
   Dim writer As BarcodeWriter = engine.Writer

   ' We will create a Red over Yellow backround
   Dim foreColor As RasterColor = RasterColor.FromKnownColor(RasterKnownColor.Red)
   Dim backColor As RasterColor = RasterColor.FromKnownColor(RasterKnownColor.Yellow)

   ' Create a UPC-A barcode
   Dim barcode As BarcodeData = BarcodeData.CreateDefaultBarcodeData(BarcodeSymbology.UPCA)
   barcode.Bounds = New LogicalRectangle(0, 0, 400, 200, LogicalUnit.Pixel)

   ' Create a 24 BPP image the same size as the barcode
   ' The image will have red over yellow colors
   Dim resolution As Integer = 300
   Dim pixels As LeadRect = barcode.Bounds.ToRectangle(resolution, resolution)
   Using image As RasterImage = RasterImage.Create(pixels.Width, pixels.Height, 24, resolution, backColor)
      ' Change the barcode colors to be Red over Yellow
      Dim options As OneDBarcodeWriteOptions = DirectCast(writer.GetDefaultOptions(BarcodeSymbology.UPCA), OneDBarcodeWriteOptions)
      options.ForeColor = foreColor
      options.BackColor = backColor

      ' Write the barcode
      writer.WriteBarcode(image, barcode, options)

      ' Save as PNG
      Using codecs As New RasterCodecs()
         codecs.Save(image, imageFileName, RasterImageFormat.Png, 24)
      End Using
   End Using
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms;
using Leadtools.Barcode;
using Leadtools.ImageProcessing;

      
public void BarcodeWriteOptions_ColorsExample()
{
   string imageFileName = Path.Combine(LEAD_VARS.ImagesDir, "MyBarcode.png");
   BarcodeEngine engine = new BarcodeEngine();
   BarcodeWriter writer = engine.Writer;

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

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

   // 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.ToRectangle(resolution, resolution);
   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())
      {
         codecs.Save(image, imageFileName, RasterImageFormat.Png, 24);
      }
   }
}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms;
using Leadtools.Barcode;
using Leadtools.ImageProcessing;
using Leadtools.Examples;

public void BarcodeWriteOptions_ColorsExample(Stream outStream)
{
   BarcodeEngine engine = new BarcodeEngine();
   BarcodeWriter writer = engine.Writer;
   // We will create a Red over Yellow backround
   RasterColor foreColor = RasterColor.FromKnownColor(RasterKnownColor.Red);
   RasterColor backColor = RasterColor.FromKnownColor(RasterKnownColor.Yellow);

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

   // 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.ToRectangle(resolution, resolution);
   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
      RasterCodecs codecs = new RasterCodecs();
      codecs.Save(image, outStream, RasterImageFormat.Png, 24);
   }
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Forms
Imports Leadtools.Barcode
Imports Leadtools.ImageProcessing

Public Sub BarcodeWriteOptions_ColorsExample(ByVal outStream As Stream)
  Dim engine As BarcodeEngine = New BarcodeEngine()
  Dim writer As BarcodeWriter = engine.Writer
  ' We will create a Red over Yellow backround
  Dim foreColor As RasterColor = RasterColor.FromKnownColor(RasterKnownColor.Red)
  Dim backColor As RasterColor = RasterColor.FromKnownColor(RasterKnownColor.Yellow)

  ' Create a UPC-A barcode
  Dim barcode As BarcodeData = BarcodeData.CreateDefaultBarcodeData(BarcodeSymbology.UPCA)
  barcode.Bounds = New LogicalRectangle(0, 0, 400, 200, LogicalUnit.Pixel)

  ' Create a 24 BPP image the same size as the barcode
  ' The image will have red over yellow colors
  Dim resolution As Integer = 300
  Dim pixels As LeadRect = barcode.Bounds.ToRectangle(resolution, resolution)
  Using image As RasterImage = RasterImage.Create(pixels.Width, pixels.Height, 24, resolution, backColor)
    ' Change the barcode colors to be Red over Yellow
    Dim options As OneDBarcodeWriteOptions = TryCast(writer.GetDefaultOptions(BarcodeSymbology.UPCA), OneDBarcodeWriteOptions)
    options.ForeColor = foreColor
    options.BackColor = backColor

    ' Write the barcode
    writer.WriteBarcode(image, barcode, options)

    ' Save as PNG
    Dim codecs As RasterCodecs = New RasterCodecs()
    codecs.Save(image, outStream, RasterImageFormat.Png, 24)
  End Using
End Sub
必要条件

ターゲットプラットホーム

参照

参照

BarcodeWriteOptionsクラス
BarcodeWriteOptionsメンバ
BackColorプロパティ

Leadtools.Barcodeは、バーコードモジュールのライセンスと、解除キーが必要です。詳細は、以下を参照してください。LEADTOOLSツールキット機能