如何存储一组经过内部处理的图像

本文关键字:内部 经过 图像 一组 处理 何存储 存储 | 更新日期: 2023-09-27 18:10:37

我一直在尝试保存一些处理后的一组图像。以下是我一直在做的事情:1 -从目录中获取所有文件2 -处理所有问题3 - Saving

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

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

如何存储一组经过内部处理的图像

似乎保存处理过的图像的路径并没有为每个图像更改。

string path = txtNewPath。Text+ imageName + ".bmp";

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

我找到了一个解决方案,在保存每个图像后我添加: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);
}