I'm working on a graphic application in C# windows form app. I have a form that I can draw on it. so I created a Graphic object from the form.
void StartPoint()
{
Graphics graphic;
graphic = PaintWindow.CreateGraphics();
}
I want to know how can I export this graphic as a png or jpg file after drawing something. before this, I searched for this question but I didn't find any useful. some people resolve this with printing that part of the screen:
graphic.CopyFromScreen(...);
this way is not useful for me because some times I need to transparent my background image. also, I tried Bitmap way :
private void ExportBTN_Click(object sender, EventArgs e)
{
Bitmap b = new Bitmap(PaintWindow.Width, PaintWindow.Height, graphic);
b.Save(...);
}
but when I save, the image file is completely black.
this is my application: