Product Info


Overview

Licensing

FAQ

Forums

Examples

History


Downloads

Evaluation version

On-line manual

Purchase

Buy now

Contact us

Testimonials


First of all, let me compliment you on your Barcode.NET Library. We evaluated a number of products to use in our application, and yours was our favorite.

Dan Konigsberg
CampMinder, LLC





VintaSoftBarcode.NET SDK - FAQ

General questions:

 

Redistribution:

 

Programming:

 

 

For which purposes can I use the VintaSoftBarcode.NET SDK?

The library allows to read and write 1D, postal and 2D barcodes in digital images and PDF files.

 

 

From which parts does the library consist?

The library contains:

  • Vintasoft.Barcode.dll file - a 100% managed .NET class library
  • Documentation in CHM format (Help\Vintasoft.Barcode.chm file)
  • Demo application (Bin\vX.X\BarcodeDemo.exe file)
  • Examples for MS Visual Basic .NET, MS Visual C#, ASP.NET (files in the Examples directory)
  • Examples of demo images with barcodes (files in the Images directory)

 

 

In which programming languages can I use the VintaSoftBarcode.NET SDK?

With Single Developer license or Site license you can use component in:

  • Microsoft Visual Studio .NET : Visual Basic, Visual C#, Visual C++, Visual J#
  • Borland Delphi, Borland C# Builder, Borland C++ BuilderX
  • any other languages which are compatible with .NET Framework.

With Server license you can use component in:

  • ASP.NET on server-side

 

 

What restrictions does the unregistered version have?

Unregistered version has the following restrictions:

  • nag screen is shown before each barcode reading process in Bin/X.X/Vintasoft.Barcode.dll
  • barcode value is replaced by the "*DEMO*" string for QR, GS1 Databar and IntelligentMail barcodes
  • some symbols from the read barcode is replaced by '*' in Bin/X.X/NoNagScreen/Vintasoft.Barcode.dll
  • barcodes can be read only from first page of PDF document
  • watermark is added to generated barcode

 

 

I have problems. What should I do?

Answers to most of questions can be found in the documentation or in this FAQ. Please write to our support team to get more help.

 

 

What files do I need to include in the setup package of my program?

You need include only one file: Vintasoft.Barcode.dll. This file must be placed in the same folder as the assembly that references it. Make sure that the version you distribute is the version your assembly was compiled with.

 

 

Can I re-distribute the Vintasoft.Barcode.dll file with my application without royalties?

Yes, this library is royalty free. You pay only for registration one time.
Only Vintasoft.Barcode.dll file can be re-distributed with your application. Site license has no limitations in re-distribution. Single Developer license has limitation in re-distribution. Server license is not royalty free. Please read the license agreement for more info.

 

 

How can I maximize barcode reading speed?

Here are some tips which allow to to maximize a barcode reading speed:

  • Recognize only necessary barcode types (see Settings.ScanBarcodeTypes property). This can increase barcode reading speed up to 2 times.
  • Recognize barcodes only in necessary directions (see Settings.ScanDirection property). This can increase barcode reading speed up to 20%.
  • Find "good" threshold for your color images and use it (see Settings.Threshold property), do not use authomatic threshold mode (see Settings.ThresholdMode property) if this is possible. This can increase barcode reading speed up to 10%.
  • Set the ExpectedBarcodes Property if number of barcodes is known.
  • Use black-white images with barcodes. This can increase barcode reading speed up to 20%.
  • Disable Settings.RemovePeas feature if image with barcodes has good quality. This can increase barcode reading speed up to 5%.
  • Don't use ScanDirection.Angle45and135 direction if you don't have low and wide barcodes rotated to 30-60 degrees. This can increase barcode reading speed up to 30%.
  • Disable Settings.SearchDistortedDataMatrixBarcodes feature if you have rectangular or square DataMatrix barcodes. This can increase DataMatrix barcode reading speed up to 50%.

 

 

How can I get the most stable barcode writing and recognition system?

Here is a list of steps which help you to create stable barcode reading system:

  • Make collection of test images with barcodes (at least 10 images).
    If you acquire images from scanner - make collection of test images with different brightness and contrast.
  • Read barcodes from test images with different Threshold and calculate minimal and average value of the ReadingQuality property
  • Choose the parameters which give maximum average value of ReadingQuality property
  • Recommended minimum average value of ReadingQuality is 0,75 - this allows you to get the most stable barcode recognition system.

We do not recommend to process images with barcodes (deskew, despeckle, etc) before reading of barcodes because this can greatly decrease quality of recognition.

 

 

Are there any recommendations for 1D barcodes creation and further reading?

Code 39 and Code 128 are the most stable linear barcodes for damage and distortion.
The most compact barcode is Code 128 (both numeric and symbol data).

Recommendations for barcode creation and further reading:

  • Create 1D barcodes with cell size (single-wide bar) at least 2 pixels
  • The more barcode height, the more reading quality
  • Use the padding for barcodes with size not less 4 cell size
  • Use optional checksum for barcodes without default checksum (Code 39, Interleaved 2of5, Standard 2of5). This will help you to avoid mistakes in recognition barcodes from images with low quality.

 

 

Are there any recommendations for 2D barcodes creation and further reading?

Data Matrix is the most stable 2D barcodes for damage and distortion. Aztec and Data Matrix are the most compact barcodes. After come QR and PDF417.
All 2D barcodes can contain text and binary data and can restore up to 30% of damaged data using Reed-Solomon error correction algorithm.

Recommendations for barcode creation and further reading:

  • Create Aztec, QR Code and Data Matrix barcodes with cell size at least 3 pixels
  • Create PDF417 barcode with cell size at least 2 pixels
  • Use the padding for PDF417 and Data Matrix barcodes with size not less 2 cell size
  • Use the padding for QR Code barcode with size not less 4 cell size

 

 

Does library support multithreading?

Yes, multithreading is supported since version 5.0. Main algorithm can be scaled to N threads.

 


 

How can I recognize barcode in color image with low quality?

There are two ways:

  • You should use the Automatic Recognition (see ReaderSettings.AutomaticRecognition).
  • You should use the iteration process of threshold detection. Here is a simple example that demonstrates how to detect barcodes in a color image with difficult-to-locate threshold:

[VB.NET]
Private Shared Sub ScanWithIterations(ByVal fileName As String, ByVal barcodes As BarcodeType, _
ByVal expectedBarcodes As Integer, ByVal iterationCount As Integer, ByVal minThreshold As Integer, ByVal maxThreshold As Integer)
    Dim barcodeImage As Image = Image.FromFile(fileName)
    Dim reader As New BarcodeReader()
    reader.Settings.ScanBarcodeTypes = barcodes
    reader.Settings.ExpectedBarcodes = expectedBarcodes
    reader.Settings.ThresholdIterations = iterationCount
    reader.Settings.Threshold1D = minThreshold
    reader.Settings.Threshold2D = maxThreshold
    ' read barcodes
    Dim barcodesInfo As IBarcodeInfo() = reader.readBarcodes(barcodeImage)
    If barcodesInfo.Length = 0 Then
        Console.WriteLine("No barcodes found.")
    Else
        For i As Integer = 0 To barcodesInfo.Length - 1
            Dim inf As IBarcodeInfo = barcodesInfo(i)
            Console.WriteLine(String.Format("[{0}] {1} (Threshold: {2})", inf.BarcodeType, inf.Value, inf.Threshold))
        Next
    End If
    barcodeImage.Dispose()
End Sub

Private Shared Sub TestScanWithIterationsCode128orDataMatrix(ByVal fileName As String)
    ' find one Code 128 or DataMatrix barcode from 400 to 600 threshold (10 iterations)
    ScanWithIterations(fileName, BarcodeType.Code128 Or BarcodeType.DataMatrix, 1, 10, 400, 600)
End Sub

[C#]
static void ScanWithIterations(string fileName, BarcodeType barcodes, int expectedBarcodes, 
    int iterationCount, int minThreshold, int maxThreshold)
{
    Image barcodeImage = Image.FromFile(fileName);
    BarcodeReader reader = new BarcodeReader();
    reader.Settings.ScanBarcodeTypes = barcodes;
    reader.Settings.ExpectedBarcodes = expectedBarcodes;
    reader.Settings.ThresholdIterations = iterationCount;
    reader.Settings.Threshold1D = minThreshold;
    reader.Settings.Threshold2D = maxThreshold;
    // read barcodes
    IBarcodeInfo[] barcodesInfo = reader.ReadBarcodes(barcodeImage);
    if (barcodesInfo.Length == 0)
    {
        Console.WriteLine("No barcodes found.");
    }
    else
    {
        for (int i = 0; i < barcodesInfo.Length; i++)
        {
            IBarcodeInfo inf = barcodesInfo[i];
            Console.WriteLine(string.Format("[{0}] {1} (Threshold: {2})", inf.BarcodeType, inf.Value, inf.Threshold));
        }
    }
    barcodeImage.Dispose();
}

static void TestScanWithIterationsCode128orDataMatrix(string fileName)
{
    // find one Code 128 or DataMatrix barcode from 400 to 600 threshold (10 iterations)
    ScanWithIterations(fileName, BarcodeType.Code128 | BarcodeType.DataMatrix, 1, 10, 400, 600);
}
    

 

 

How can I read barcodes from multipage TIFF file?

Here is a simple code:

[VB.NET]
Private Shared Sub ReadBarcodesFromMiltipageTiffFile(ByVal fileName As String, ByVal barcodes As BarcodeType)
    ' open tiff image
    Dim tiffImage As Image = Image.FromFile(fileName)
    Dim index As Guid = tiffImage.FrameDimensionsList(0)
    Dim dimension As New FrameDimension(index)
    Dim pageCount As Integer = tiffImage.GetFrameCount(dimension)
    ' create reader
    Dim reader As New BarcodeReader()
    reader.Settings.ScanBarcodeTypes = barcodes
    ' read barcodes from all pages
    For i As Integer = 0 To pageCount - 1
        ' selects a page
        tiffImage.SelectActiveFrame(dimension, i)
        ' read barcodes from page i
        Dim barcodesInfo As IBarcodeInfo() = reader.readBarcodes(tiffImage)
        ' write information
        Console.WriteLine(String.Format("Page {0}: ", i))
        If barcodesInfo.Length = 0 Then
            Console.WriteLine("No barcodes found.")
        Else
            For j As Integer = 0 To barcodesInfo.Length - 1
                Console.WriteLine(String.Format("[{0}] {1}", barcodesInfo(j).BarcodeType, barcodesInfo(j).Value))
            Next
        End If
    Next
    ' free resources
    tiffImage.Dispose()
End Sub

[C#]
static void ReadBarcodesFromMiltipageTiffFile(string fileName, BarcodeType barcodes)
{
    // open tiff image
    Image tiffImage = Image.FromFile(fileName);
    Guid index = tiffImage.FrameDimensionsList[0];
    FrameDimension dimension = new FrameDimension(index);
    int pageCount = tiffImage.GetFrameCount(dimension);
    // create reader
    BarcodeReader reader = new BarcodeReader();
    reader.Settings.ScanBarcodeTypes = barcodes;
    // read barcodes from all pages
    for (int i = 0; i < pageCount; i++)
    {
        // selects a page
        tiffImage.SelectActiveFrame(dimension, i);
        // read barcodes from page i
        IBarcodeInfo[] barcodesInfo = reader.ReadBarcodes(tiffImage);
        // write information
        Console.WriteLine(string.Format("Page {0}: ", i));
        if (barcodesInfo.Length == 0)
        {
            Console.WriteLine("No barcodes found.");
        }
        else
        {
            for (int j = 0; j < barcodesInfo.Length; j++)
                Console.WriteLine(string.Format("[{0}] {1}", barcodesInfo[j].BarcodeType, barcodesInfo[j].Value));
        }
    }
    // free resources
    tiffImage.Dispose();
}

 

 

How can I read barcodes from PDF document?

Here is a simple code:

[VB.NET]
Private Shared Sub ReadBarcodesFromPdfDocument(ByVal fileName As String, ByVal barcodes As BarcodeType)
    ' open PDF document
    Dim pdfImageViewer As New PdfImageViewer(fileName)
    ' create reader
    Dim reader As New BarcodeReader()
    reader.Settings.ScanBarcodeTypes = barcodes
    ' read barcodes from all pages
    For i As Integer = 0 To pdfImageViewer.PageCount - 1
        ' get all images names from page i
        Dim imageNames As String() = pdfImageViewer.GetImageNames(i)
        ' foreach images in page i
        For k As Integer = 0 To imageNames.Length - 1
            Console.WriteLine(String.Format("Page {0}, image {1}: ", i, imageNames(k)))
            Dim barcodeImage As Image
            ' get image with name imageNames[k]
            Try
                barcodeImage = pdfImageViewer.GetImage(i, imageNames(k))
            Catch e As Exception
                ' not supported image format
                Console.WriteLine(e.Message)
                Continue For
            End Try
            ' read barcodes 
            Dim barcodesInfo As IBarcodeInfo() = reader.readBarcodes(barcodeImage)
            ' write information
            If barcodesInfo.Length = 0 Then
                Console.WriteLine("No barcodes found.")
            Else
                For j As Integer = 0 To barcodesInfo.Length - 1
                    Console.WriteLine(String.Format("[{0}] {1}", barcodesInfo(j).BarcodeType, barcodesInfo(j).Value))
                Next
            End If
        Next
    Next
    ' free resources
    pdfImageViewer.Dispose()
End Sub

[C#]
static void ReadBarcodesFromPdfDocument(string fileName, BarcodeType barcodes)
{
    // open PDF document
    PdfImageViewer pdfImageViewer = new PdfImageViewer(fileName);
    // create reader
    BarcodeReader reader = new BarcodeReader();
    reader.Settings.ScanBarcodeTypes = barcodes;
    // read barcodes from all pages
    for (int i = 0; i < pdfImageViewer.PageCount; i++)
    {
        // get all images names from page i
        string[] imageNames = pdfImageViewer.GetImageNames(i);
        // foreach images in page i
        for (int k = 0; k < imageNames.Length; k++)
        {
            Console.WriteLine(string.Format("Page {0}, image {1}: ", i, imageNames[k]));
            Image barcodeImage;
            // get image with name imageNames[k]
            try
            {
                barcodeImage = pdfImageViewer.GetImage(i, imageNames[k]);
            }
            catch(Exception e)
            {
                // not supported image format
                Console.WriteLine(e.Message);
                continue;
            }
            // read barcodes 
            IBarcodeInfo[] barcodesInfo = reader.ReadBarcodes(barcodeImage);
            // write information
            if (barcodesInfo.Length == 0)
            {
                Console.WriteLine("No barcodes found.");
            }
            else
            {
                for (int j = 0; j < barcodesInfo.Length; j++)
                    Console.WriteLine(string.Format("[{0}] {1}", barcodesInfo[j].BarcodeType, barcodesInfo[j].Value));
            }
        }
    }
    // free resources
    pdfImageViewer.Dispose();
}

 

 

How can I write barcodes into PDF document in vector form?

Here is a simple code:

[VB.NET]
' Important: You need Vintasoft.Barcode.dll, Vintasoft.Imaging.dll, Vintasoft.Pdf.dll assemblies to run this code.
Private Shared Sub MarkPDF(ByVal pdfFilename As String)
    ' create barcodeWriter
    Dim barcodeWriter As New BarcodeWriter()
    ' using DataMatrix 2D barcode
    barcodeWriter.Settings.Barcode = BarcodeType.Code128
    ' barcode padding
    Dim padding As Single = 5

    ' open PDF document
    Dim document As New PdfDocument(pdfFilename)
    ' foreach pages
    For i As Integer = 0 To document.Pages.Count - 1
        Dim page As PdfPage = document.Pages(i)
        ' barcode value - page number
        barcodeWriter.Settings.Value = (i + 1).ToString()
        ' write barcode graphics path
        Dim barcodePath As GraphicsPath = barcodeWriter.GetBarcodeAsGraphicsPath()
        ' translate barcode to right-bottom page corner
        Using m As New Matrix()
            Dim barcodeWidth As Single = barcodePath.GetBounds().Width
            m.Translate(page.MediaBox.Right - barcodeWidth - padding, padding)
            barcodePath.Transform(m)
        End Using
        ' fill barcode path
        Using g As PdfGraphics = page.GetGraphics()
            Dim brush As New PdfBrush(Color.Black)
            g.FillPath(brush, barcodePath)
        End Using
        barcodePath.Dispose()
    Next

    ' saving document
    Dim resultFileName As String = Path.GetFileNameWithoutExtension(pdfFilename) & "_marked.pdf"
    document.Save(Path.Combine(Path.GetDirectoryName(pdfFilename), resultFileName))
    ' free resources
    document.Dispose()
End Sub

[C#]
// Important: You need Vintasoft.Barcode.dll, Vintasoft.Imaging.dll, Vintasoft.Pdf.dll assemblies to run this code.
static void MarkPDF(string pdfFilename)
{
    // create barcodeWriter
    BarcodeWriter barcodeWriter = new BarcodeWriter();
    // using DataMatrix 2D barcode
    barcodeWriter.Settings.Barcode = BarcodeType.DataMatrix;
    // barcode padding
    float padding = 5;

    // open PDF document
    PdfDocument document = new PdfDocument(pdfFilename);
    // foreach pages
    for (int i = 0; i < document.Pages.Count; i++)
    {
        PdfPage page = document.Pages[i];
        // barcode value - page number
        barcodeWriter.Settings.Value = (i + 1).ToString();
        // write barcode graphics path
        GraphicsPath barcodePath = barcodeWriter.GetBarcodeAsGraphicsPath();
        // translate barcode to right-bottom page corner
        using (Matrix m = new Matrix())
        {
            float barcodeWidth = barcodePath.GetBounds().Width;
            m.Translate(page.MediaBox.Right - barcodeWidth - padding, padding);
            barcodePath.Transform(m);
        }
        // fill barcode path
        using (PdfGraphics g = page.GetGraphics())
        {
            PdfBrush brush = new PdfBrush(Color.Black);
            g.FillPath(brush, barcodePath);
        }
        barcodePath.Dispose();
    }

    // saving document
    string resultFileName = Path.GetFileNameWithoutExtension(pdfFilename) + "_marked.pdf";
    document.Save(Path.Combine(Path.GetDirectoryName(pdfFilename), resultFileName));
    // free resources
    document.Dispose();
}

 

 

How can I use my checksum in barcode (in reader and writer)?

You must use ReaderSettings.VerifyBarcodeMethod property to validate correctness of barcode(check checksum). Here is a simple code which illustrate how to create and read Code 39 barcode with cheksum at base 1000:

[VB.NET]
' Generate checksum at base 1000.
Private Shared Function GenerateChecksum(ByVal value As String) As String
    Dim checkSum As Integer = 0
    For i As Integer = 0 To value.Length - 1
        checkSum += CByte(AscW(value(i))) * i
        checkSum = checkSum Mod 1000
    Next
    'result - [000..999]
    Return checkSum.ToString().PadLeft(3, "0"c)
End Function

' Testing Checksum in barcode value.
Private Shared Function TestChecksum(ByVal barcodeValue As String) As Boolean
    Dim value As String = barcodeValue.Substring(0, barcodeValue.Length - 3)
    Dim readChecksum As String = barcodeValue.Substring(barcodeValue.Length - 3)
    Return readChecksum = GenerateChecksum(value)
End Function

' Verify barcode method.
Private Shared Sub VerifyBarcodeMethod(ByVal reader As BarcodeReader, ByVal barcodeInfo As IBarcodeInfo)
    If TestChecksum(barcodeInfo.Value) Then
        barcodeInfo.Confidence = 100
    Else
        barcodeInfo.Confidence = 0
    End If
End Sub

Private Shared Sub TestCode39Barcode(ByVal value As String)
    ' create writer
    Dim writer As New BarcodeWriter()
    writer.Settings.Barcode = BarcodeType.Code39

    ' create reader
    Dim reader As New BarcodeReader()
    reader.Settings.ScanBarcodeTypes = BarcodeType.Code39
    reader.Settings.MinConfidence = 100
    reader.Settings.AutomaticRecognition = True
    reader.Settings.ExpectedBarcodes = 1

    ' write barcode without checksum
    writer.Settings.Value = value
    Dim barcodeNoChecksumImage As Image = writer.GetBarcodeAsBitmap()

    ' write barcode with checksum
    writer.Settings.Value = value & GenerateChecksum(value)
    Dim barcodeWithMyChecksumImage As Image = writer.GetBarcodeAsBitmap()

    'set VerifyBarcodeMethod
    reader.Settings.VerifyBarcodeMethod = AddressOf VerifyBarcodeMethod

    Dim infos As IBarcodeInfo()

    'read barcodes from barcode image without checksum
    'no barcodes found
    infos = reader.readBarcodes(barcodeNoChecksumImage)
    Console.WriteLine("Scan (NoChecksum):")
    For i As Integer = 0 To infos.Length - 1
        Console.WriteLine(infos(i).Value)
    Next

    'read barcodes from barcode image with checksum
    'found one barcode
    infos = reader.readBarcodes(barcodeWithMyChecksumImage)
    Console.WriteLine("Scan (MyChecksum):")
    For i As Integer = 0 To infos.Length - 1
        Console.WriteLine(infos(i).Value)
    Next
End Sub

[C#]
// Generate checksum at base 1000.
static string GenerateChecksum(string value)
{
    int checkSum = 0;
    for (int i = 0; i < value.Length; i++)
    {
        checkSum += ((byte)value[i]) * i;
        checkSum %= 1000;
    }
    //result - [000..999]
    return checkSum.ToString().PadLeft(3, '0');
}

// Testing Checksum in barcode value.
static bool TestChecksum(string barcodeValue)
{
    string value = barcodeValue.Substring(0, barcodeValue.Length - 3);
    string readChecksum = barcodeValue.Substring(barcodeValue.Length - 3);
    return readChecksum == GenerateChecksum(value);
}

// Verify barcode method.
static void VerifyBarcodeMethod(BarcodeReader reader, IBarcodeInfo barcodeInfo)
{
    if (TestChecksum(barcodeInfo.Value))
        barcodeInfo.Confidence = 100;
    else
        barcodeInfo.Confidence = 0;
}

static void TestCode39Barcode(string value)
{
    // create writer
    BarcodeWriter writer = new BarcodeWriter();
    writer.Settings.Barcode = BarcodeType.Code39;

    // create reader
    BarcodeReader reader = new BarcodeReader();
    reader.Settings.ScanBarcodeTypes = BarcodeType.Code39;
    reader.Settings.MinConfidence = 100;
    reader.Settings.AutomaticRecognition = true;
    reader.Settings.ExpectedBarcodes = 1;

    // write barcode without checksum
    writer.Settings.Value = value;
    Image barcodeNoChecksumImage = writer.GetBarcodeAsBitmap();

    // write barcode with checksum
    writer.Settings.Value = value + GenerateChecksum(value);
    Image barcodeWithMyChecksumImage = writer.GetBarcodeAsBitmap();

    //set VerifyBarcodeMethod
    reader.Settings.VerifyBarcodeMethod = VerifyBarcodeMethod;

    IBarcodeInfo[] infos;

    //read barcodes from barcode image without checksum
    //no barcodes found
    infos = reader.ReadBarcodes(barcodeNoChecksumImage);
    Console.WriteLine("Scan (NoChecksum):");
    for (int i = 0; i < infos.Length; i++)
        Console.WriteLine(infos[i].Value);

    //read barcodes from barcode image with checksum
    //found one barcode
    infos = reader.ReadBarcodes(barcodeWithMyChecksumImage);
    Console.WriteLine("Scan (MyChecksum):");
    for (int i = 0; i < infos.Length; i++)
        Console.WriteLine(infos[i].Value);
}

 

 

How can I draw barcode with specified size and resolution?

[VB.NET]
Private Shared Function DrawBarcode(ByVal barcode As BarcodeType, ByVal value As String, ByVal resolution As Single, _ 
ByVal width As Single, ByVal height As Single, ByVal units As UnitOfMeasure) As Image
    Dim writer As New BarcodeWriter()
    writer.Settings.Barcode = barcode
    writer.Settings.Value = value
    writer.Settings.Resolution = resolution
    writer.Settings.SetWidth(width, units)
    writer.Settings.SetHeight(height, units)
    Return writer.GetBarcodeAsBitmap()
End Function

Private Shared Sub TestDrawBarcode(ByVal fileName As String)
    ' Draw barcode 6x2 cm in 600 DPI
    Dim barcodeImage As Image = DrawBarcode(BarcodeType.Code128, "TESTBARCODE", 600, 6, 2, UnitOfMeasure.Centimeters)
    barcodeImage.Save(fileName)
    barcodeImage.Dispose()
End Sub

[C#]
static Image DrawBarcode(BarcodeType barcode, string value, float resolution, float width, float height, UnitOfMeasure units)
{
    BarcodeWriter writer = new BarcodeWriter();            
    writer.Settings.Barcode = barcode;
    writer.Settings.Value = value;
    writer.Settings.Resolution = resolution;
    writer.Settings.SetWidth(width, units);
    writer.Settings.SetHeight(height, units);
    return writer.GetBarcodeAsBitmap();
}

static void TestDrawBarcode(string fileName)
{
    // Draw barcode 6x2 cm in 600 DPI
    Image barcodeImage = DrawBarcode(BarcodeType.Code128, "TESTBARCODE", 600, 6, 2, UnitOfMeasure.Centimeters);
    barcodeImage.Save(fileName);
    barcodeImage.Dispose();
}