【问题标题】:Load .BMP image in WP7 App在 WP7 应用程序中加载 .BMP 图像
【发布时间】:2012-12-10 08:07:50
【问题描述】:

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

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

谢谢

【问题讨论】:

    标签: windows-phone-7


    【解决方案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?

    【讨论】:

    • 感谢您的快速回复,但我需要显示一个 bmp... 最好的方法是什么?
    • 相应地编辑了我的答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-08
    • 2010-12-19
    • 2016-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多