I have a BitmapSource
. I save it to a png like this:
PngBitmapEncoder enc = new PngBitmapEncoder();
enc.Frames.Add(myBitmapSource);
enc.Save(fs);
How can I save it without any alpha channel?
Use FormatConvertedBitmap
to convert to 24 bits per pixel before encoding it:
var noAlphaSource = new FormatConvertedBitmap
{
Source = myBitmapSource,
DestinationFormat = PixelFormats.Rgb24
};
var encoder = new PngBitmapEncoder();
enc.Frames.Add(noAlphaSource);
enc.Save(fs);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With