See Also
Other Platforms
Features
Buy Now
Online Help
Demo
Licensing

Back

How to create TIFF barcodes using C# or VB.NET and Barcode Professional for Windows Forms

Technologies used
  • Neodynamic Barcode Professional 3.0 for Windows Forms
  • Microsoft .NET Framework (all versions)
Creating TIFF (Tagged Image File Format) barcodes using C# or VB.NET and Barcode Professional for Windows Forms is a very simple task. In the following lines we'll describe some common scenarios about TIFF barcodes generation.
  • How to create and save a TIFF barcode image at a given resolution

    Use the overloaded Save() method that Barcode Professional for Windows Forms features.
    Example: You want to encode the data 1234567890 in Code 128 and then save the barcode image in TIFF format at 300DPI
    Visual Basic .NET
    Private Sub SaveBarcode()
        'Create a Barcode Professional object
    
        Dim bcp As New Neodynamic.WinControls.BarcodeProfessional.BarcodeProfessional()
        'Set the barcode symbology to Code 128
    
        bcp.Symbology = Neodynamic.WinControls.BarcodeProfessional.Symbology.Code128
        'Set the value to encode
    
        bcp.Code = "1234567890"
        'Barcode dimensions settings (values measured in inches)
    
        bcp.BarHeight = 1.5F
        bcp.BarWidth = 0.02F
        'Resolution
    
        Dim dpi As Single = 300.0F
        'Save the TIFF barcode image on disk
    
        bcp.Save("C:\barcode128.tif", System.Drawing.Imaging.ImageFormat.Tiff, dpi, dpi)
    End Sub
    Visual C# .NET
    private void SaveBarcode()
    {
        //Create a Barcode Professional object
        Neodynamic.WinControls.BarcodeProfessional.BarcodeProfessional bcp = new Neodynamic.WinControls.BarcodeProfessional.BarcodeProfessional();
        //Set the barcode symbology to Code 128
        bcp.Symbology = Neodynamic.WinControls.BarcodeProfessional.Symbology.Code128;
        //Set the value to encode
        bcp.Code = "1234567890";
        //Barcode dimensions settings (values measured in inches)
        bcp.BarHeight = 1.5f;
        bcp.BarWidth = 0.02f;
        //Resolution
        float dpi = 300.0f;
        //Save the TIFF barcode image on disk
        bcp.Save(@"C:\barcode128.tif", System.Drawing.Imaging.ImageFormat.Tiff, dpi, dpi);
    }
  • How to create and save a Monochrome (Black and White 1 bit per pixel) TIFF barcode image at a given resolution

    Based on the previous scenario, just specify the Monochrome property that Barcode Professional for Windows Forms features.
    NOTE
    Keep in mind that generating monochrome images (Black and White 1 bit per pixel format) is a very expensive task in terms of CPU time as well as memory usage.
    Visual Basic .NET
    Private Sub SaveBarcode()
        'Create a Barcode Professional object
    
        Dim bcp As New Neodynamic.WinControls.BarcodeProfessional.BarcodeProfessional()
        'Set the barcode symbology to Code 128
    
        bcp.Symbology = Neodynamic.WinControls.BarcodeProfessional.Symbology.Code128
        'Set the value to encode
    
        bcp.Code = "1234567890"
        'Barcode dimensions settings (values measured in inches)
    
        bcp.BarHeight = 1.5F
        bcp.BarWidth = 0.02F
        'Monochrome (Black and White 1 bit per pixel)
    
        bcp.Monochrome = True
        'Resolution
    
        Dim dpi As Single = 300.0F
        'Save the TIFF barcode image on disk
    
        bcp.Save("C:\barcode128_BW1bpp.tif", System.Drawing.Imaging.ImageFormat.Tiff, dpi, dpi)
    End Sub
    Visual C# .NET
    private void SaveBarcode()
    {
        //Create a Barcode Professional object
        Neodynamic.WinControls.BarcodeProfessional.BarcodeProfessional bcp = new Neodynamic.WinControls.BarcodeProfessional.BarcodeProfessional();
        //Set the barcode symbology to Code 128
        bcp.Symbology = Neodynamic.WinControls.BarcodeProfessional.Symbology.Code128;
        //Set the value to encode
        bcp.Code = "1234567890";
        //Barcode dimensions settings (values measured in inches)
        bcp.BarHeight = 1.5f;
        bcp.BarWidth = 0.02f;
        //Monochrome (Black and White 1 bit per pixel)
        bcp.Monochrome = true;
        //Resolution
        float dpi = 300.0f;
        //Save the TIFF barcode image on disk
        bcp.Save(@"C:\barcode128_BW1bpp.tif", System.Drawing.Imaging.ImageFormat.Tiff, dpi, dpi);
    }
  • How to get a binary representation of a TIFF barcode image at a given resolution

    Use the overloaded GetBarcodeImage() method that Barcode Professional for Windows Forms features.
    Example: You want to encode the data 1234567890 in Code 128 and then get a binary representation of the barcode image in TIFF format at 300DPI
    Visual Basic .NET
    Private Function GetTiffBarcode() As Byte()
        'Create a Barcode Professional object
    
        Dim bcp As New Neodynamic.WinControls.BarcodeProfessional.BarcodeProfessional()
        'Set the barcode symbology to Code 128
    
        bcp.Symbology = Neodynamic.WinControls.BarcodeProfessional.Symbology.Code128
        'Set the value to encode
    
        bcp.Code = "1234567890"
        'Barcode dimensions settings
    
        bcp.BarHeight = 1.5F
        bcp.BarWidth = 0.02F
        'Resolution
    
        Dim dpi As Single = 300.0F
        'Get the TIFF barcode image in binary format
    
        Return bcp.GetBarcodeImage(System.Drawing.Imaging.ImageFormat.Tiff, dpi)            
    End Function
    Visual C# .NET
    private byte[] GetTiffBarcode()
    {
        //Create a Barcode Professional object
        Neodynamic.WinControls.BarcodeProfessional.BarcodeProfessional bcp = new Neodynamic.WinControls.BarcodeProfessional.BarcodeProfessional();
        //Set the barcode symbology to Code 128
        bcp.Symbology = Neodynamic.WinControls.BarcodeProfessional.Symbology.Code128;
        //Set the value to encode
        bcp.Code = "1234567890";
        //Barcode dimensions settings
        bcp.BarHeight = 1.5f;
        bcp.BarWidth = 0.02f;
        //Resolution
        float dpi = 300.0f;
        //Get the TIFF barcode image in binary format
        return bcp.GetBarcodeImage(System.Drawing.Imaging.ImageFormat.Tiff, dpi);            
    }
  • How to get a Base64 representation of a TIFF barcode image at a given resolution

    Use the overloaded GetBarcodeImage() method that Barcode Professional for Windows Forms features in conjunction with the .NET Convert class.
    Example: Based on the previous example, the following code creates a Base64 string representation of the barcode image
    Visual Basic .NET
    Private Function GetTiffBarcode() As String
        'Create a Barcode Professional object
    
        Dim bcp As New Neodynamic.WinControls.BarcodeProfessional.BarcodeProfessional()
        'Set the barcode symbology to Code 128
    
        bcp.Symbology = Neodynamic.WinControls.BarcodeProfessional.Symbology.Code128
        'Set the value to encode
    
        bcp.Code = "1234567890"
        'Barcode dimensions settings
    
        bcp.BarHeight = 1.5F
        bcp.BarWidth = 0.02F
        'Resolution
    
        Dim dpi As Single = 300.0F
        'Get the TIFF barcode image in binary format
    
        Dim buffer() as Byte = bcp.GetBarcodeImage(System.Drawing.Imaging.ImageFormat.Tiff, dpi)            
        'Convert to Base64
    
        Return Convert.ToBase64String(buffer)
    End Function
    Visual C# .NET
    private string GetTiffBarcode()
    {
        //Create a Barcode Professional object
        Neodynamic.WinControls.BarcodeProfessional.BarcodeProfessional bcp = new Neodynamic.WinControls.BarcodeProfessional.BarcodeProfessional();
        //Set the barcode symbology to Code 128
        bcp.Symbology = Neodynamic.WinControls.BarcodeProfessional.Symbology.Code128;
        //Set the value to encode
        bcp.Code = "1234567890";
        //Barcode dimensions settings
        bcp.BarHeight = 1.5f;
        bcp.BarWidth = 0.02f;
        //Resolution
        float dpi = 300.0f;
        //Get the TIFF barcode image in binary format
        byte[] buffer = bcp.GetBarcodeImage(System.Drawing.Imaging.ImageFormat.Tiff, dpi);
        //Convert to Base64
        return Convert.ToBase64String(buffer);
    }
If you need more information or assistance, please contact our .
 Copyright © 2003 - 2008 Neodynamic S.R.L. All rights reserved.