在WP7 App中加载.BMP图像

时间:2012-12-09 23:49:03

标签: windows-phone-7

我正在尝试在Windows Phone 7应用程序中加载BMP图像,但扩展名是。 bmp图像没有出现。但是,代码适用于.jpg,.png和.gif。 我正在使用以下代码段:

Uri uri = new Uri("Images/test.bmp", UriKind.Relative);
ImageSource img = new System.Windows.Media.Imaging.BitmapImage(uri);
imageView.Source = img;

由于

1 个答案:

答案 0 :(得分:1)

将其另存为png。 Silverlight不支持bmp开箱即用(请参阅Silverlight 4 BitmapImage - bmp file support)。

或者,如果您确实需要这样做,则需要使用第三方库。 .net Image Tools Library拥有您需要的BMP转换器。这个问题中有一些示例代码:Silverlight 4: How can I convert bmp byte array to png byte array?