Leadtools.Barcode名前空間 :BarcodeAlignment列挙体 |
[SerializableAttribute()] public enum BarcodeAlignment : System.Enum, System.IComparable, System.IConvertible, System.IFormattable
'Declaration
<SerializableAttribute()> Public Enum BarcodeAlignment Inherits System.Enum Implements System.IComparable, System.IConvertible, System.IFormattable
'Usage
Dim instance As BarcodeAlignment
[SerializableAttribute()] public enum BarcodeAlignment : System.IComparable, System.IConvertible, System.IFormattable
typedef NS_ENUM(NSInteger, LTBarcodeAlignment)
public enum BarcodeAlignment
Leadtools.Barcode.BarcodeAlignment = function() { }; Leadtools.Barcode.BarcodeAlignment.prototype = {<br/> Near = 0, Center = 1, Far = 2, };
[SerializableAttribute()] public enum class BarcodeAlignment : public System.Enum, System.IComparable, System.IConvertible, System.IFormattable
値 | メンバ | 説明 |
---|---|---|
0 | Near |
バーコードをBarcodeData.Bounds。の近端に配置します。これは、水平方向の配置の場合は左端(LogicalRectangle.Left)、垂直方向の配置の場合は上端(LogicalRectangle.Top)になります。 バーコード実際の幅または高さは使用しません。 ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
1 | Center |
バーコードをBarcodeData.Bounds。の中央に配置します。これは、水平方向の配置の場合は水平方向の中央(LogicalRectangle.Left + (LogicalRectangle.Width - "barcodeWidth") / 2) 、垂直方向の配置の場合は垂直方向の中央(LogicalRectangle.Top + (LogicalRectangle.Height - "barcodeHeight") / 2)になります。 ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
2 | Far |
バーコードをBarcodeData.Bounds。の遠端に配置します。これは、水平方向の配置の場合は右端(LogicalRectangle.Right - "barcodeWidth")、垂直方向の配置の場合は下端 (LogicalRectangle.Bottom - "barcodeHeight")になります。 ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
バーコードの書き込み時に必ずしもすべてのサイズが使用できるとは限らず、boundsの幅と高さの値に特別な意味がある場合があります。そのため、バーコードを書き込むときにBarcodeWriterオブジェクトが出力四角形(BarcodeData.Bounds)によって定義された領域全体を使用しない場合があります。詳細については、「バーコードの書き込み―四角形とXModule」を参照してください。
領域全体が使用されない場合は、配置値を設定することで、書き込みバーコードを四角形の左、上、右、下、中央のいずれに揃えるかを指定できます。これらのために、バーコードがどのように書き込まれるかについて制御するために、BarcodeAlignment列挙体を使うことができます。
配置がサポートされているのは、2Dバーコード体系(Datamatrix、MicroPDF417、PDF417とQR)のみです。BarcodeAlignmentが、以下のプロパティのための型として使われます:
DatamatrixBarcodeWriteOptions.HorizontalAlignmentとDatamatrixBarcodeWriteOptions.VerticalAlignment。
MicroPDF417BarcodeWriteOptions.HorizontalAlignmentとMicroPDF417BarcodeWriteOptions.VerticalAlignment。
PDF417BarcodeWriteOptions.HorizontalAlignmentとPDF417BarcodeWriteOptions.VerticalAlignment。
QRBarcodeWriteOptions.HorizontalAlignmentとQRBarcodeWriteOptions.VerticalAlignment。
デフォルトがすべてのこれらのプロパティのために高く評価するNoteは、BarcodeAlignment.Nearです。
以下のサンプルは、BarcodeAlignmentを使用して、配置の変更によって設定可能な9通りの位置にQRバーコードを書き込みます。これらの場所は、上/left、上/中心、上/右、中心/left、中心/中心、中心/右、下/left、下/中心と下/右です。
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.Forms Imports Leadtools.Barcode Imports Leadtools.ImageProcessing Public Sub BarcodeAlignment_Example() Dim imageFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "MyBarcode.tif") Dim engine As New BarcodeEngine() Dim writer As BarcodeWriter = engine.Writer ' Create the QR barcode Dim barcode As BarcodeData = BarcodeData.CreateDefaultBarcodeData(BarcodeSymbology.QR) ' Create the image (8.5 by 11 inches at 300 DPI) Dim resolution As Integer = 300 Using image As RasterImage = RasterImage.Create(CType(8.5 * resolution, Integer), CType(11.0 * resolution, Integer), 1, resolution, RasterColor.FromKnownColor(RasterKnownColor.White)) ' We will control the position by alignment, so set the barcode bound to be the whole image barcode.Bounds = New LogicalRectangle(0, 0, image.ImageWidth, image.ImageHeight, LogicalUnit.Pixel) Dim options As QRBarcodeWriteOptions = DirectCast(writer.GetDefaultOptions(BarcodeSymbology.QR), QRBarcodeWriteOptions) ' Let the engine determine the size of the barcode using X Module (default behavior) ' Use these alignments Dim verticalAlignments() As BarcodeAlignment = {BarcodeAlignment.Near, BarcodeAlignment.Center, BarcodeAlignment.Far} Dim horizontalAlignments() As BarcodeAlignment = {BarcodeAlignment.Near, BarcodeAlignment.Center, BarcodeAlignment.Far} For Each verticalAlignment As BarcodeAlignment In verticalAlignments For Each horizontalAlignment As BarcodeAlignment In horizontalAlignments ' Write the barcode using these alignments options.HorizontalAlignment = verticalAlignment options.VerticalAlignment = horizontalAlignment writer.WriteBarcode(image, barcode, options) Next Next ' The image now have 9 barcodes ' Save the image Using codecs As New RasterCodecs() codecs.Save(image, imageFileName, RasterImageFormat.CcittGroup4, 1) 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 BarcodeAlignment_Example() { string imageFileName = Path.Combine(LEAD_VARS.ImagesDir, "MyBarcode.tif"); BarcodeEngine engine = new BarcodeEngine(); BarcodeWriter writer = engine.Writer; // Create the QR barcode BarcodeData barcode = BarcodeData.CreateDefaultBarcodeData(BarcodeSymbology.QR); // Create the image (8.5 by 11 inches at 300 DPI) int resolution = 300; using(RasterImage image = RasterImage.Create((int)(8.5 * resolution), (int)(11.0 * resolution), 1, resolution, RasterColor.FromKnownColor(RasterKnownColor.White))) { // We will control the position by alignment, so set the barcode bound to be the whole image barcode.Bounds = new LogicalRectangle(0, 0, image.ImageWidth, image.ImageHeight, LogicalUnit.Pixel); QRBarcodeWriteOptions options = writer.GetDefaultOptions(BarcodeSymbology.QR) as QRBarcodeWriteOptions; // Let the engine determine the size of the barcode using X Module (default behavior) // Use these alignments BarcodeAlignment[] verticalAlignments = { BarcodeAlignment.Near, BarcodeAlignment.Center, BarcodeAlignment.Far }; BarcodeAlignment[] horizontalAlignments = { BarcodeAlignment.Near, BarcodeAlignment.Center, BarcodeAlignment.Far }; foreach(BarcodeAlignment verticalAlignment in verticalAlignments) { foreach(BarcodeAlignment horizontalAlignment in horizontalAlignments) { // Write the barcode using these alignments options.HorizontalAlignment = verticalAlignment; options.VerticalAlignment = horizontalAlignment; writer.WriteBarcode(image, barcode, options); } } // The image now have 9 barcodes // Save the image using(RasterCodecs codecs = new RasterCodecs()) { codecs.Save(image, imageFileName, RasterImageFormat.CcittGroup4, 1); } } } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }
using Leadtools; using Leadtools.Codecs; using Leadtools.Barcode; using Leadtools.ImageProcessing; public async Task BarcodeAlignment_Example() { string imageFileName = @"MyBarcode.tif"; BarcodeEngine engine = new BarcodeEngine(); BarcodeWriter writer = engine.Writer; // Create the QR barcode BarcodeData barcode = BarcodeData.CreateDefaultBarcodeData(BarcodeSymbology.QR); // Create the image (8.5 by 11 inches at 300 DPI) int resolution = 300; using(RasterImage image = RasterImage.Create((int)(8.5 * resolution), (int)(11.0 * resolution), 1, resolution, RasterColorHelper.FromKnownColor(RasterKnownColor.White))) { // We will control the position by alignment, so set the barcode bound to be the whole image barcode.Bounds = LeadRectHelper.Create(0, 0, image.ImageWidth, image.ImageHeight); QRBarcodeWriteOptions options = writer.GetDefaultOptions(BarcodeSymbology.QR) as QRBarcodeWriteOptions; // Let the engine determine the size of the barcode using X Module (default behavior) // Use these alignments BarcodeAlignment[] verticalAlignments = { BarcodeAlignment.Near, BarcodeAlignment.Center, BarcodeAlignment.Far }; BarcodeAlignment[] horizontalAlignments = { BarcodeAlignment.Near, BarcodeAlignment.Center, BarcodeAlignment.Far }; foreach(BarcodeAlignment verticalAlignment in verticalAlignments) { foreach(BarcodeAlignment horizontalAlignment in horizontalAlignments) { // Write the barcode using these alignments options.HorizontalAlignment = verticalAlignment; options.VerticalAlignment = horizontalAlignment; writer.WriteBarcode(image, barcode, options); } } // The image now have 9 barcodes // Save the image using(RasterCodecs codecs = new RasterCodecs()) { StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(imageFileName); await codecs.SaveAsync(image, LeadStreamFactory.Create(saveFile), RasterImageFormat.CcittGroup4, 1); } } }
using Leadtools; using Leadtools.Codecs; using Leadtools.Forms; using Leadtools.Barcode; using Leadtools.ImageProcessing; using Leadtools.Examples; public void BarcodeAlignment_Example(RasterImage image, Stream outStream) { BarcodeEngine engine = new BarcodeEngine(); BarcodeWriter writer = engine.Writer; // Create the QR barcode BarcodeData barcode = BarcodeData.CreateDefaultBarcodeData(BarcodeSymbology.QR); // Create the image (8.5 by 11 inches at 300 DPI) // We will control the position by alignment, so set the barcode bound to be the whole image barcode.Bounds = new LogicalRectangle(0, 0, image.ImageWidth, image.ImageHeight, LogicalUnit.Pixel); QRBarcodeWriteOptions options = writer.GetDefaultOptions(BarcodeSymbology.QR) as QRBarcodeWriteOptions; // Let the engine determine the size of the barcode using X Module (default behavior) // Use these alignments BarcodeAlignment[] verticalAlignments = { BarcodeAlignment.Near, BarcodeAlignment.Center, BarcodeAlignment.Far }; BarcodeAlignment[] horizontalAlignments = { BarcodeAlignment.Near, BarcodeAlignment.Center, BarcodeAlignment.Far }; foreach(BarcodeAlignment verticalAlignment in verticalAlignments) { foreach(BarcodeAlignment horizontalAlignment in horizontalAlignments) { // Write the barcode using these alignments options.HorizontalAlignment = verticalAlignment; options.VerticalAlignment = horizontalAlignment; writer.WriteBarcode(image, barcode, options); } } // The image now have 9 barcodes // Save the image RasterCodecs codecs = new RasterCodecs(); codecs.Save(image, outStream, RasterImageFormat.CcittGroup4, 1); }
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.Forms Imports Leadtools.Barcode Imports Leadtools.ImageProcessing Public Sub BarcodeAlignment_Example(ByVal image As RasterImage, ByVal outStream As Stream) Dim engine As BarcodeEngine = New BarcodeEngine() Dim writer As BarcodeWriter = engine.Writer ' Create the QR barcode Dim barcode As BarcodeData = BarcodeData.CreateDefaultBarcodeData(BarcodeSymbology.QR) ' Create the image (8.5 by 11 inches at 300 DPI) ' We will control the position by alignment, so set the barcode bound to be the whole image barcode.Bounds = New LogicalRectangle(0, 0, image.ImageWidth, image.ImageHeight, LogicalUnit.Pixel) Dim options As QRBarcodeWriteOptions = TryCast(writer.GetDefaultOptions(BarcodeSymbology.QR), QRBarcodeWriteOptions) ' Let the engine determine the size of the barcode using X Module (default behavior) ' Use these alignments Dim verticalAlignments As BarcodeAlignment() = { BarcodeAlignment.Near, BarcodeAlignment.Center, BarcodeAlignment.Far } Dim horizontalAlignments As BarcodeAlignment() = { BarcodeAlignment.Near, BarcodeAlignment.Center, BarcodeAlignment.Far } For Each verticalAlignment As BarcodeAlignment In verticalAlignments For Each horizontalAlignment As BarcodeAlignment In horizontalAlignments ' Write the barcode using these alignments options.HorizontalAlignment = verticalAlignment options.VerticalAlignment = horizontalAlignment writer.WriteBarcode(image, barcode, options) Next horizontalAlignment Next verticalAlignment ' The image now have 9 barcodes ' Save the image Dim codecs As RasterCodecs = New RasterCodecs() codecs.Save(image, outStream, RasterImageFormat.CcittGroup4, 1) End Sub
System.Object
System.ValueType
System.Enum
Leadtools.Barcode.BarcodeAlignment