图像无法在 Windows Phone 7.5 上完全加载 [英] Image won't load completely on Windows Phone 7.5

查看:21
本文介绍了图像无法在 Windows Phone 7.5 上完全加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 WP7.5 Silverlight 应用程序中有一个 Image 元素,我尝试以 XAML 和编程方式更改其源.无论我尝试什么,我都无法完全加载大图像(大小或字节,我不知道).

I have an Image element in my WP7.5 Silverlight app for which I tried changing its source both in XAML and programmatically. Whatever I try, I cannot load big images(in size or in bytes, I don't know) completely.

这是我的代码:

<controls:PanoramaItem>
  <ScrollViewer VerticalAlignment="Top" VerticalScrollBarVisibility="Auto" Margin="2, 4, 0, 0" HorizontalScrollBarVisibility="Disabled">
    <StackPanel x:name="stackPanel">
      <TextBlock x:Name="debugger" Foreground="Black"/>
      <Image Source="http://d24w6bsrhbeh9d.cloudfront.net/photo/1574819_460s.jpg" VerticalAlignment="Top" ImageOpened="Image_ImageOpened"/>
    </StackPanel>
  </ScrollViewer>
</controls:PanoramaItem>


private void Image_ImageOpened(object sender, RoutedEventArgs e)
{
    debugger.Text = "DONE";
}

推荐答案

参见 MSDN 上的有限图像大小.

由于 Windows Phone 的屏幕分辨率有限,另一个优化性能的方法是将图像大小限制为 2000 x 2000 像素,这是 Windows Phone 环境下图像的大小限制.较大的图像将以较低的分辨率进行采样.此外,如果您使用大于 2000 x 2000 像素的图像,它们的显示速度会明显变慢.

Due to the limited screen resolution of Windows Phone, another way to optimize performance is to limit the image size to 2000 x 2000 pixels, which is the size limit of images in the Windows Phone environment. Larger images will be sampled at a lower resolution. Also, if you use images that are larger than 2000 x 2000 pixels, they will be significantly slower to appear.

如果您必须使用大于 2000 x 2000 的图像,您应该只显示满足 2000 限制的文件的一部分.您可以通过将图像加载到 WriteableBitmap 并使用 LoadJpeg(WriteableBitmap, Stream) 扩展方法来实现.

If you must use images larger than 2000 x 2000 you should only display a portion of the file that meets the 2000 limit. You can do this by loading the image into a WriteableBitmap and using the LoadJpeg(WriteableBitmap, Stream) extension method.

这篇关于图像无法在 Windows Phone 7.5 上完全加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆