【发布时间】:2013-12-10 10:12:10
【问题描述】:
正如我们所知,只有 11.5MB 内存可用于 Windows Phone 8 任务代理。我试图在后台任务代理中制作动态锁屏图像。当我得到 480*800 的图像时,它可以正常工作,但是当我将其更改为 768*1280 时出现异常:
内存不足
1 像素投射 4K
所以
(480*800*4)/1024/1024=1.46M
(768*1280*4)/1024/1024 = 3.75M
当我尝试将 byte[] 转换为 BitmapImage 时:
public BitmapImage ConvertDownloadStringToStream(byte[] downloadImageBytes)
{
if (!(downloadImageBytes.Length > 0))
return null;
RationImageInfo currentRationInfor = GetBitmapImageWidthByDeveiceRatio();
BitmapImage convertBitmapImage = new BitmapImage() { DecodePixelWidth =768, DecodePixelHeight = 1280};
using (MemoryStream imageStream = new MemoryStream(downloadImageBytes))
{
convertBitmapImage.SetSource(imageStream);//out of memory
}
return convertBitmapImage;
}
我在SetSource() 方法中遇到内存不足异常。有人对此有什么建议吗?
【问题讨论】:
标签: windows-phone-8 lockscreen