I'm developing a program which will capture images four times and save it into a folder
what I did was to put my codes inside a for loop
but my problem is it only saves the first captured image four times instead of capturing four times
private void Form1_Load(object sender, EventArgs e)
{
string path = @"C:\Users\\Jake_PC\\Desktop\\fitting\\";
System.IO.Directory.CreateDirectory(path);
bool useCam = true;
if (!useCam)
measureImage(null);
else
{
try
{
camera = new Capture();
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
return;
}
Application.Idle += viewImage;
captureProcess = true;
}
}
private void btnCapture_Click(object sender, EventArgs e)
{
if (btnCapture.Text == "Back")
{
Application.Restart();
}
else
{
if (captureProcess == true)
{
for (int cap = 0; cap < 4; cap++)
{
string path = @"C:\\Users\\Jake_PC\\Desktop\\fitting\\";
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(path);
ctr = dir.GetFiles().Length;
camera = new Capture();
System.Threading.Thread.Sleep(500);
Application.Idle -= viewImage;
SaveFileDialog dlg = new SaveFileDialog();
img.ToBitmap().Save(@"C:\\Users\\Jake_PC\\Desktop\\fitting\\" + ctr + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
camera.Dispose();
Form1_Load(sender, e);
}
}
}
}