内部处理后如何存储一组图像?

时间:2014-06-26 17:35:41

标签: c# image

经过一些处理后,我一直试图保存一组图像。这是我一直在做的事情: 1 - 从目录中获取所有文件 2 - 处理所有这些 3 - 保存

作为一个例子:当我尝试处理它们时,我在一个文件夹中有128个图像并再次保存它(程序)只保存其中一些。这是我的代码。

foreach (string file in Directory.EnumerateFiles(path, "*.bmp"))
{
    Bitmap bmp = new Bitmap(file);
    string path = txtNewPath.Text+ RandonImageName + ".bmp";
    processImage(bmp).Save(path);
}

2 个答案:

答案 0 :(得分:0)

似乎没有为每张图片更改保存已处理图像的路径。

  

string path = txtNewPath.Text + imageName +“。bmp”;

您必须根据当前枚举的imageName变量更改变量file

答案 1 :(得分:0)

在保存我添加的每个图像后,我找到了一个解决方案:Thread.Sleep(1000); //这样,应用程序将等待1秒,然后继续保存。

完整的代码是:

foreach (string file in Directory.EnumerateFiles(path, "*.bmp"))
{
    Bitmap bmp = new Bitmap(file);
    string path = txtNewPath.Text+ RandonImageName + ".bmp";
    processImage(bmp).Save(path);    
    Thread.Sleep(1000);
}