Vinod Maurya
Vinod Maurya

Reputation: 4187

Convert WriteableBitmap pixel format to Bgra32 in c# wpf

I have a WriteableBitmap which loads the bitmap image from file(mostly bmp). The bitmap files I am using have different pixel formats such as Indexed8, Bgra32, etc etc. The problem is that my code only works for bgra32 pixel format. So I need help in converting the bitmaps to Bgra32 pixel format in c# wpf.

Thanks

Upvotes: 9

Views: 5785

Answers (1)

Vinod Maurya
Vinod Maurya

Reputation: 4187

I have found the solution:

 if (bmpSource.Format != PixelFormats.Bgra32)
     bmpSource = new FormatConvertedBitmap(bmpSource, PixelFormats.Bgra32, null, 0);

Upvotes: 19

Related Questions