将WriteableBitmap像素格式转换为c#wpf中的Bgra32

Vin*_*rya 9 c# wpf image-processing

我有一个WriteableBitmap从文件加载位图图像(主要是bmp).我使用的位图文件有不同的像素格式,如Indexed8,Bgra32等.问题是我的代码仅适用于bgra32像素格式.所以我需要帮助将位图转换为c#wpf中的Bgra32像素格式.

谢谢

Vin*_*rya 18

我找到了解决方案:

 if (bmpSource.Format != PixelFormats.Bgra32)
     bmpSource = new FormatConvertedBitmap(bmpSource, PixelFormats.Bgra32, null, 0);
Run Code Online (Sandbox Code Playgroud)