WinUI | ComponentOne
Controls / BarCode / Save as Image
In This Topic
    Save as Image
    In This Topic

    The BarCode control supports the export to image format functionality. You can save the image of the BarCode and use it for other purposes, like copy the image to clipboard, assign the image to a picture control or utilize the image in office productivity applications like Microsoft Office, WordPad etc.

    The C1BarCode class provides the SaveAsync(System.IO.Stream stream, C1.WinUI.BarCode.ImageFormat imgFormat) method that can be used to save the image of the barcode in different image formats such as BMP, PNG and JPEG. The SaveAsync method accepts two parameters, stream, where the barcode will be saved, and imgFormat, which stands for the format of the barcode image.

    C#
    Copy Code
    private async void SaveImage_Click(object sender, RoutedEventArgs e)
    {
          //Save the image
         FileStream fstream = File.OpenWrite("D:/New folder/bcimg.png");
         barCode.SaveAsync(fstream, ImageFormat.Png);
         fstream.Close();
       }