Reputation: 22045
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?
Upvotes: 5
Views: 1998
Reputation: 62919
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);
Upvotes: 3
Reputation: 942040
A 24bpp bitmap doesn't have an alpha channel. Supported by the PNG encoder. Create a WriteableBitmap with PixelFormats.Rgb24.
Upvotes: 1