Tell me how you can open and save a picture from a PIctureBox, through SaveFileDialog and OpenFileDialog

    2 answers 2

    Getting name

    SaveFileDialog dlg = new SaveFileDialog(); dlg.FileName = "filename"; dlg.DefaultExt = ".txt"; dlg.Filter = "Text documents (.txt)|*.txt"; Nullable<bool> result = dlg.ShowDialog(); if (result == true) { string filename = dlg.FileName; } 

    Drawing

     Bitmap b = new Bitmap(pb.Image); Graphics g = Graphics.FromImage(b); // ... Здесь рисование pb.Image = bmp; 

    Preservation

     pb.Image.Save(filename, ImageFormat.Jpeg); 
    • I did not quite understand what kind of drawing .... In particular, this is // ... Here is drawing Yes, and the error in the Nullable line <bool> result = dlg.ShowDialog (); Error 1 Implicit conversion of type "System.Windows.Forms.DialogResult" to "bool?" impossible D: \ dima \ New Year \ New Year \ Form2.cs 66 37 New Year - Angus123
    • Drawing is your drawing action on a PictureBox. In general, they may not be at all. SaveFileDialog is Microsoft.Win32.SaveFileDialog. - Nicolas Chabanovsky
    • Oh, I see. What about mistakes? And if it's not a secret, do you have Skype? But it is not convenient for each question to write here. - Angus123
    • I'm just confused, the compiler constantly swears ... here is the code that I draw in the Mouse_Move event if (paint) {SolidBrush s = new SolidBrush (colorDialog1.Color); g.FillEllipse (s, eX, eY, Convert.ToInt32 (numericUpDown1.Value), Convert.ToInt32 (numericUpDown2.Value)); } And I need the picture to not disappear ... or are there other ways of drawing? - Angus123
     MyImage_pb.ImageLocation = "URL"; MyImage_pb.Load(); 

    1. MyImage_pb - image object (_pb - PictureBox)
    2. URL - link to the image (direct path to the image on the computer is also considered a link)

    Personally, I like it, and it always confidently loads it this way :)

    More information about PictureBox