WinUI コントロール
画像として保存
コントロール > BarCode > 画像として保存

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#
コードのコピー
private async void SaveImage_Click(object sender, RoutedEventArgs e)
{
        //画像を保存します
        FileStream fstream = File.OpenWrite("D:/New folder/bcimg.png");
     barCode.SaveAsync(fstream, ImageFormat.Png);
     fstream.Close();
   }