【发布时间】:2013-12-14 09:12:52
【问题描述】:
创建位图图像列表时出现 OutOfmemory 错误...
我该怎么办...?
感谢您的帮助;)
这是我的代码:
foreach (var bytearray in imageDataBlocksPresta)
{
if (bytearray != null)
{
MemoryStream ms;
using (ms = new MemoryStream(bytearray, 0, bytearray.Length))
{
BitmapImage photo = new BitmapImage();
photo.DecodePixelHeight = 800;
photo.DecodePixelWidth = 624;
photo.SetSource(ms);//ERROR
listphotoPresta.Add(photo);
}
}
else//si photo null
{
BitmapImage photo = new BitmapImage();
photo.DecodePixelHeight = 800;
photo.DecodePixelWidth = 624;
photo.UriSource = new Uri("/Images/NoImageIcon.jpg", UriKind.RelativeOrAbsolute);
listphotoPresta.Add(photo);
}
【问题讨论】:
-
你有多少字节数组?错误是在第一次 foarch 迭代中发生还是在以后(何时)发生?
-
当多张照片已经添加到列表中时会发生错误。字节数组的长度在 30k 和 40k 之间。导致错误发生的不是照片大小,而是所有的总和。
标签: windows-phone-8 out-of-memory bitmapimage