For a litte project, I tryed creating a ""Paint App".
Now I want to save the painting as File, sadly, my Method will only save the Background and my menuestrip.
This is how I create the Panel and drawing method:
private void panel1_Paint(object sender, PaintEventArgs e) //Bild erstellen
{
Graphics g = panel1.CreateGraphics();
Pen pen = new Pen(colorDialog1.Color);
g.DrawEllipse(pen, pointx, pointy, width, height);
}
private void panel1_MouseMove(object sender, MouseEventArgs e) //Linie malen
{
if (e.Button == MouseButtons.Left)
{
pointx = e.X;
pointy = e.Y;
panel1_Paint(this, null);
}
}
This is how I create a Bmp:
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog save = new SaveFileDialog();
save.CheckFileExists = false;
save.CheckPathExists = true;
save.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png";
save.InitialDirectory = @"C:\Users\";
DialogResult result = save.ShowDialog();
if (result == DialogResult.OK)
{
Bitmap bmp = new Bitmap(panel1.Width, panel1.Height);
panel1.DrawToBitmap(bmp, new Rectangle(0, 0, panel1.Width, panel1.Height));
bmp.Save(save.FileName);
}
}
Thankful for every advice :)
Point>>`[See here](https://stackoverflow.com/questions/31988079/copying-free-hand-drawing-from-panel-in-visual-studio-2013/32112426#32112426) ! For even more advanced doodling [see here](https://stackoverflow.com/questions/49290951/creating-different-brush-patterns-in-c-sharp/49298313#49298313)
– TaW Jun 12 '18 at 13:37