So i made a program similar to paint and i wanted to add a save option to it, however when ever i saved the drawing/image on my panel that i created the only thing i got was a white rectangle. Do you guys know what the problem is with my code? Any help would be appreciated!
string path;
private void button3_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Bitmap | *.bmp";
if(sfd.ShowDialog() == DialogResult.OK)
{
path = sfd.FileName;
using(var Bitmap = new Bitmap(panel1.Width, panel1.Height))
{
panel1.DrawToBitmap(Bitmap, new Rectangle(0,0, Bitmap.Width, Bitmap.Height));
try
{
Bitmap.Save(path);
}
catch(Exception ex) { MessageBox.Show(ex.Message); }
}
}
}