Load Image from a picturebox

3

I'm doing a webcam program and I can not save the webcam image, until now only the camera appears in a picturebox, and I have a picturebox2 where I capture the image, but I need to save that image in a folder, either at desk or anywhere, and I do not know how to do it!

Someone to help me, I have my save button and I need to press that button to open the window to save the image.

    
asked by Sergio Rivera 28.04.2016 в 16:59
source

2 answers

3

I understand that if you open the dialog to record it is because you use the SaveFileDialog

private void button1_Click(object sender, System.EventArgs e)
{
    SaveFileDialog saveFileDialog1 = new SaveFileDialog();
    saveFileDialog1.Filter = "jpg files (*.jpg)|*.jpg"  ;
    saveFileDialog1.Title = "Save an Image File";

    if(saveFileDialog1.ShowDialog() == DialogResult.OK)
    {
        System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile();

        pictureBox1.Image.Save(fs, ImageFormat.Jpeg);
    }
}

You could also use the name of the file

if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
   pictureBox1.Image.Save(saveFileDialog1.FileName, ImageFormat.Jpeg);
}
    
answered by 28.04.2016 в 17:14
0

Try this:

string miCarpeta = @"C:\Imaginas\Imagina42.jpg";
pictureBox1.Image.Save(miCarpeta, ImageFormat.Jpeg);
    
answered by 28.04.2016 в 17:04