该功能将图像流旋转90度。
在Windows Phone上调用它5-6次后,我得到了SystemOutOfMemory
异常
private WriteableBitmap _rotate(Stream stream)
{
var bmp = new BitmapImage();
bmp.SetSource(stream);
var src = new WriteableBitmap(bmp);
var w = src.PixelWidth;
var h = src.PixelHeight;
var p = src.Pixels;
var dst = new WriteableBitmap(h, w);
var i = 0;
var rp = dst.Pixels;
for (var x = 0; x < w; x++) {
for (var y = h - 1; y >= 0; y--) {
var srcInd = y * w + x;
rp[i] = p[srcInd];
i++;
}
}
/* Trying to free memory, but nothing of that works */
//bmp = null;
//src = null;
return dst;
}
我知道那个函数中的问题,因为当我没有打电话时 - 一切正常。
答案 0 :(得分:0)
尝试使用它:
GC.Collect();
GC.WaitForPendingFinalizers();