2010-11-17 76 views
8

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

感谢

回答

16

我已经找到了解决办法:

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