WPF - 如何在没有任何Alpha通道的情况下保存PNG?

Kyl*_*yle 5 c# wpf image

我有一个BitmapSource.我把它保存到这样的png:

PngBitmapEncoder enc = new PngBitmapEncoder();
enc.Frames.Add(myBitmapSource);
enc.Save(fs);
Run Code Online (Sandbox Code Playgroud)

如何在没有任何alpha通道的情况下保存它?

Ray*_*rns 3

用于FormatConvertedBitmap在编码之前转换为每像素 24 位:

var noAlphaSource = new FormatConvertedBitmap
{
  Source = myBitmapSource,
  DestinationFormat = PixelFormats.Rgb24
};

var encoder = new PngBitmapEncoder();
enc.Frames.Add(noAlphaSource);
enc.Save(fs);
Run Code Online (Sandbox Code Playgroud)