public static Type GetBarcodeDataType(BarcodeSymbology symbology)
symbology
Barcode symbology.
A Type of the derived class associated with a specified symbology or the BarcodeData type when the symbology does not have a specialized data class.
Currently, this method returns the following values:
| Symbology | Return type |
|---|---|
| BarcodeSymbology.Aztec | Type of AztecBarcodeData |
| BarcodeSymbology.Datamatrix | Type of DatamatrixBarcodeData |
| BarcodeSymbology.Maxi | Type of MaxiBarcodeData |
| BarcodeSymbology.MicroPDF417 | Type of MicroPDF417BarcodeData |
| BarcodeSymbology.MicroQR | Type of MicroQRBarcodeData |
| BarcodeSymbology.PDF417 | Type of PDF417BarcodeData |
| BarcodeSymbology.QR | Type of QRBarcodeData |
| All other BarcodeSymbology members | Type of BarcodeData |
using Leadtools;using Leadtools.Codecs;using Leadtools.Barcode;using Leadtools.ImageProcessing;public void BarcodeData_CreateDefaultBarcodeDataExample(){// Create a directory to store the images we will createstring outDir = Path.Combine(LEAD_VARS.ImagesDir, "MyBarcodes");if (Directory.Exists(outDir)){Directory.Delete(outDir, true);}Directory.CreateDirectory(outDir);int resolution = 300;// Create a Barcode engineBarcodeEngine engine = new BarcodeEngine();// Get the Barcode writerBarcodeWriter writer = engine.Writer;// All 1D options have the UseXModule set to false by default, we need to set it to true// so we can calculate the default size. We will change the default options so we can// pass null to CalculateBarcodeDataBounds and WriteBarcode below// For all Standard 1DOneDBarcodeWriteOptions oneDWriteOptions = writer.GetDefaultOptions(BarcodeSymbology.UPCA) as OneDBarcodeWriteOptions;oneDWriteOptions.UseXModule = true;// All GS1 Databar StackedGS1DatabarStackedBarcodeWriteOptions gs1DatabarStackedWriteOptions = writer.GetDefaultOptions(BarcodeSymbology.GS1DatabarStacked) as GS1DatabarStackedBarcodeWriteOptions;gs1DatabarStackedWriteOptions.UseXModule = true;// Patch CodePatchCodeBarcodeWriteOptions patchCodeWriteOptions = writer.GetDefaultOptions(BarcodeSymbology.PatchCode) as PatchCodeBarcodeWriteOptions;patchCodeWriteOptions.UseXModule = true;// All PostNet/PlanetPostNetPlanetBarcodeWriteOptions postNetPlanetWriteOptions = writer.GetDefaultOptions(BarcodeSymbology.PostNet) as PostNetPlanetBarcodeWriteOptions;postNetPlanetWriteOptions.UseXModule = true;// We will use this object to save filesusing (RasterCodecs codecs = new RasterCodecs()){// Get all the available write symbologiesBarcodeSymbology[] symbologies = writer.GetAvailableSymbologies();foreach (BarcodeSymbology symbology in symbologies){// **Symbology** | **Return type**// -------------------------------|------------------------// BarcodeSymbology.Aztec | AztecBarcodeData// BarcodeSymbology.Datamatrix | DatamatrixBarcodeData// BarcodeSymbology.Maxi | MaxiBarcodeData// BarcodeSymbology.MicroPDF417 | MicroPDF417BarcodeData// BarcodeSymbology.MicroQR | MicroQRBarcodeData// BarcodeSymbology.PDF417 | PDF417BarcodeData// BarcodeSymbology.QR | QRBarcodeData// Other BarcodeSymbology members | BarcodeData//// Get Data Typevar dataType = BarcodeData.GetBarcodeDataType(symbology);Console.WriteLine("Processing {0} | Data Type: {1}", symbology, dataType.Name);// Create the default data for this symbologyBarcodeData data = BarcodeData.CreateDefaultBarcodeData(symbology);// Calculate its size with default optionswriter.CalculateBarcodeDataBounds(LeadRect.Empty, resolution, resolution, data, null);// Create an image to write the data toLeadRect pixels = data.Bounds;using (RasterImage image = RasterImage.Create(pixels.Width, pixels.Height, 1, resolution, RasterColor.FromKnownColor(RasterKnownColor.White))){// Write the barcode with default optionswriter.WriteBarcode(image, data, null);// Save itstring outFileName = Path.Combine(outDir, symbology + ".tif");codecs.Save(image, outFileName, RasterImageFormat.Tif, 1);}}}}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";}