VintaSoft Barcode .NET SDK v10.0
How to draw barcode with specified size and resolution?

Example: Here is an example that shows how to draw barcode with specified size and resolution.

Public Shared Sub TestDrawBarcode(filename As String)
        ' draw barcode with size 6 x 2 cm and resolution 300 dpi
        Using barcodeImage As Image = DrawBarcode(BarcodeType.Code128, "TESTBARCODE", 300, 6, 2, UnitOfMeasure.Centimeters)
                ' save barcode image to a file
                barcodeImage.Save(filename)
        End Using
End Sub

Public Shared Function DrawBarcode(barcode As BarcodeType, value As String, resolution As Single, width As Single, height As Single, units As UnitOfMeasure) As Image
        ' create the barcode writer
        Dim writer As New BarcodeWriter()

        ' set barcode writer settings
        writer.Settings.Barcode = barcode
        writer.Settings.Value = value
        writer.Settings.Resolution = resolution
        writer.Settings.PixelFormat = BarcodeImagePixelFormat.Bgr24

        ' return barcode image
        Return writer.GetBarcodeAsBitmap(width, height, UnitOfMeasure.Centimeters)
End Function
              
public static void TestDrawBarcode(string filename)
{
    // draw barcode with size 6 x 2 cm and resolution 300 dpi
    using (Image barcodeImage = DrawBarcode(BarcodeType.Code128, "TESTBARCODE", 300, 6, 2,
                                     UnitOfMeasure.Centimeters))
    {
        // save barcode image to a file
        barcodeImage.Save(filename);
    }
}

public static Image DrawBarcode(BarcodeType barcode, string value, float resolution, float width,
                 float height, UnitOfMeasure units)
{
    // create the barcode writer
    BarcodeWriter writer = new BarcodeWriter();
    
    // set barcode writer settings
    writer.Settings.Barcode = barcode;
    writer.Settings.Value = value;
    writer.Settings.Resolution = resolution;
    writer.Settings.PixelFormat = BarcodeImagePixelFormat.Bgr24;

    // return barcode image
    return writer.GetBarcodeAsBitmap(width, height, UnitOfMeasure.Centimeters);
}