I want to show an image from a console application and I have written code to do so. But when it shows the image, it shows a weird Form
box. And if I save the image and open it normally, it shows the image.
Code:
Bitmap bmpScreenCapture = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(bmpScreenCapture);
g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
Screen.PrimaryScreen.Bounds.Y,
0, 0,
bmpScreenCapture.Size,
CopyPixelOperation.SourceCopy);
bmpScreenCapture.Save("potato.png", ImageFormat.Png);
Form imageForm = new Form();
//imageForm.FormBorderStyle = FormBorderStyle.None;
imageForm.Controls.Add(new PictureBox() { Image = bmpScreenCapture, Visible = true });
imageForm.Show();