VintaSoft Barcode .NET SDK v9.2
Get barcode image as System.Windows.Media.Imaging.BitmapSource object in WPF

Example: Here is an example that shows how to get barcode as WPF image and save the image to a file.

' create the barcode writer
Dim barcodeWriter As New BarcodeWriter()

' set barcode writer settings
barcodeWriter.Settings.Barcode = BarcodeType.Code128
barcodeWriter.Settings.Value = "012345abcde"

' get barcode image as BitmapSource object
Dim image As BitmapSource = barcodeWriter.GetBarcodeAsBitmapSource()

' save the barcode image to a file
Dim encoder As New PngBitmapEncoder()
encoder.Frames.Add(BitmapFrame.Create(image))
Using stream As Stream = File.OpenWrite("imageWihBarcode.png")
        encoder.Save(stream)
End Using
              
// create the barcode writer
BarcodeWriter barcodeWriter = new BarcodeWriter();

// set barcode writer settings
barcodeWriter.Settings.Barcode = BarcodeType.Code128;
barcodeWriter.Settings.Value = "012345abcde";

// get barcode image as BitmapSource object
BitmapSource image = barcodeWriter.GetBarcodeAsBitmapSource();

// save the barcode image to a file
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(image));
using (Stream stream = File.OpenWrite("imageWihBarcode.png"))
    encoder.Save(stream);