我正在List<Image>从大约250张图片的文件夹中加载一个.我做了一个DateTime比较,加载这250个图像需要整整11秒.那个地狱很慢,我非常想加快速度.
图像在我的本地硬盘上,甚至不是外部硬盘.
代码:
DialogResult dr = imageFolderBrowser.ShowDialog();
if(dr == DialogResult.OK) {
DateTime start = DateTime.Now;
//Get all images in the folder and place them in a List<>
files = Directory.GetFiles(imageFolderBrowser.SelectedPath);
foreach(string file in files) {
sourceImages.Add(Image.FromFile(file));
}
DateTime end = DateTime.Now;
timeLabel.Text = end.Subtract(start).TotalMilliseconds.ToString();
}
Run Code Online (Sandbox Code Playgroud)
编辑:是的,我需要所有的照片.我正在计划的事情是将每个中心的30个像素柱取出并从中制作出新的图像.有点像360度的图片.只是现在,我只是用随机图像进行测试.
我知道可能有更好的框架可以做到这一点,但我需要首先工作.
EDIT2:切换到秒表,差别只有几毫秒.还尝试使用Directory.EnumerateFiles,但没有任何区别.
编辑3:我在32位Win7客户端上运行.NET 4.