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?
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?
A 24bpp bitmap doesn't have an alpha channel. Supported by the PNG encoder. Create a WriteableBitmap with PixelFormats.Rgb24.
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);