众所周知,Windows Phone 8 任务代理只能使用 11.5MB 内存。我试图在后台任务代理中制作动态锁屏图像。当我得到 480*800 图像时,它工作正常,但当我将其更改为 768*1280 时,出现异常:
内存不足
1 像素投射 4 K
so
(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()
方法。有人对此有什么建议吗?
我猜内存会增加。
尝试将其保存到文件中,释放变量/资源,然后使用构造函数参数从文件中加载它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)