VintaSoft Barcode .NET SDK v9.2
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 600 dpi
        Using barcodeImage As Image = DrawBarcode(BarcodeType.Code128, "TESTBARCODE", 600, 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.SetWidth(width, units)
        writer.Settings.SetHeight(height, units)

        ' return barcode image
        Return writer.GetBarcodeAsBitmap()
End Function
              
public static void TestDrawBarcode(string filename)
{
    // draw barcode with size 6 x 2 cm and resolution 600 dpi
    using (Image barcodeImage = DrawBarcode(BarcodeType.Code128, "TESTBARCODE", 600, 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.SetWidth(width, units);
    writer.Settings.SetHeight(height, units);
    
    // return barcode image
    return writer.GetBarcodeAsBitmap();
}