Silverlight 中的位图图像大小限制 [英] BitmapImage size restrictions in Silverlight

查看:26
本文介绍了Silverlight 中的位图图像大小限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个 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-a02c

<块引用>

尺寸限制:由于 Windows手机摄像头是 5 MP 和屏幕分辨率比其他的小平台,图像的限制可以处理的是 2k x 2k 像素.任何比这更大的东西都会以较低的自动采样分辨率和图像将丢失一些丰富.处理图像大于 2k x 2k 有需要处理的场景大于 2k x 2k 的图像,例如照片编辑器,或裁剪图像.在那些场景,您可以处理图像大于 2k x 2k 的文件,然后显示一部分适合 2K x 2K.您可以使用WriteableBitmap 与的组合LoadJpeg 来做到这一点.示例 #5 –加载大图片

XAML:

<图像高度=3000"宽度=3000"名称=图像1"拉伸=填充"/><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;}

<块引用>

使用大于2k x 2k 图片:

  • 显示速度明显变慢
  • 请勿将其用于动画或平移场景.

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

I'm making a Windows Phone 7 application which involves getting large images from the web and putting it in a ScrollViewer for the user to scroll through. I think I'm hitting a limitation of BitmapImage, though, as the image seems to get cut off at 2048 pixels in either height or width.

Is this a known limitation of Silverlight BitmapImage and is there some other class to use in this case to allow scrolling through the large images?

Thanks

解决方案

Yes, there is a limit of 2k x 2k. This is limitation and a workaround are described in the white paper "Creating High Performing Silverlight Applications for Windows Phone" 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>

Code Behind:

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.

The Resize method of the WriteableBitmapEx can also be used for this task if no JPEG stream is available.

这篇关于Silverlight 中的位图图像大小限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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