silverlight - Silverlight 中的位图图像大小限制

标签 silverlight windows-phone-7 bitmapimage

我正在制作一个 Windows Phone 7 应用程序,该应用程序涉及从网络获取大图像并将其放入 ScrollViewer 以供用户滚动浏览。不过,我认为我遇到了 BitmapImage 的限制,因为图像似乎在 2048 像素的高度或宽度处被截断。

这是 Silverlight BitmapImage 的已知限制吗?在这种情况下是否可以使用其他一些类来允许滚动浏览大图像?

谢谢

最佳答案

是的,有 2k x 2k 的限制。这是一种限制,白皮书“为 Windows Phone 创建高性能 Silverlight 应用程序”中描述了一种解决方法 http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=3a8636bf-185f-449a-a0ce-83502b9ec0ec

Size Limitations: Since the Windows Phone camera is 5 MP and the screen resolution is smaller than on other platforms, the limits for images that can be processed are 2k x 2k pixels. Anything larger than that will be automatically sampled at a lower resolution and the image will lose some richness. Processing Images Larger than 2k x 2k There are scenarios where you need to process images larger than 2k x 2k, e.g. Photo editor, or cropping images. In those scenarios, you can process the images that are larger than 2k x 2k into a file, and then display a portion that fits into 2K x 2K. You can use the combination of WriteableBitmap with LoadJpeg to do it.   Example #5 – LoadingLargeImages

XAML:

<StackPanel>
    <Image Height="3000" Width="3000" Name="image1" Stretch="Fill" />
    <Button Content="Load" Height="70" Width="152" Click="btnLoad_Click" />
</StackPanel>

代码隐藏:

private void btnLoad_Click(object sender, RoutedEventArgs e)
{
    StreamResourceInfo sri = null;
    Uri uri = new                                                                           Uri("LoadJpegSample;component/Test3k3k.JPG", UriKind.Relative);
    sri = Application.GetResourceStream(uri);

    WriteableBitmap wb = new WriteableBitmap((int)this.image1.Width, (int)this.image1.Height);

    Extensions.LoadJpeg(wb, sri.Stream);
    this.image1.Source = wb;
}

Things to Know When Using Larger than 2k x 2k Images:

  • It is significantly slower to display
  • Do NOT use it for animation or panning scenarios.

WriteableBitmapEx 的 Resize 方法如果没有可用的 JPEG 流,也可以用于此任务。

关于silverlight - Silverlight 中的位图图像大小限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3890520/

相关文章:

asp.net - 在 WPF 和 Silverlight 之间进行选择

c# - 调试 C# 时如何找出内存中生成的项目?

c# - 简单的基本问题

c - 将位图文件读入结构

java - 如何在 java 中仅使用 java.io.* 将颜色转换为灰度;图书馆?

.net - Silverlight:流中的 BitmapImage 引发异常(灾难性失败(HRESULT 异常:0x8000FFFF (E_UNEXPECTED)))

silverlight - Silverlight 中的 Diffie-Hellman

silverlight - 更改 TargetNullValue 的 TextBlock 样式

c# - WP7 从 PhoneApplicationPage 外部执行导航

c# - 我的数据绑定(bind)有什么问题?