Skip to main content
 首页 » 编程设计

c#之图片无法在 Windows Phone 7.5 上完全加载

2024年02月23日24zhwl

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

这是我的代码:

<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"; 
} 

请您参考如下方法:

参见 Limited Image Size在 MSDN 上。

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.

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.