0
我试图循环遍历所有加载的图像,我能够处理多达40个图像,然后我得到Out的内存错误,尽管我正在处理变量tempImage。代码在“Bitmap tempImage = new Bitmap(fileName);”线,PLZ的帮助! 有没有办法处理大量的输入文件?像批处理一样,将进程分成块?由于该操作将持续超过一分钟,程序将在此之前崩溃。在System.Drawing.dll中发生未处理的异常类型'System.OutOfMemoryException'
foreach (string fileName in openFileDialog.FileNames)
{
circleDetection examDetect = new circleDetection();
Bitmap tempImage = new Bitmap(fileName);
directory.Text = fileName;
PictureBox picBox = new PictureBox();
picBox.Width = 200;
picBox.Height = 200;
picBox.Location = new System.Drawing.Point(picBoard.Controls.Count * (picBox.Width + 5) + 5, 5);
picBox.SizeMode = PictureBoxSizeMode.Zoom;
picBox.BorderStyle = BorderStyle.FixedSingle;
examDetect.ProcessImage(tempImage);
picBox.Image = examDetect.getImage();
Console.WriteLine(i++);
student.Add(compare(examDetect));
picBoard.Controls.Add(picBox);
tempImage.Dispose();
}
在'foreach'循环中使用'using'并查看会发生什么 –
您的位图有多大?因为你的考试系列已经有了tempimage的参考资料,所以处置tempimage也无济于事。 –
为什么你将'tempImage'添加到'Exam'(对位图持有一个引用),然后处理它? –