2012-12-09 42 views
0

我试图在Windows Phone 7应用程序中加载BMP图像,但是扩展名是。 bmp图像不会出现。但是,该代码适用于.jpg,.png和.gif。 我使用下面的代码片段:在WP7中加载.BMP图像App

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

感谢

回答

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?

+0

感谢您的快速回复,但我需要显示一个bmp ...什么是最好的方式来做到这一点? – notGeek

+0

据此编辑我的答案。 –