Amit Ziv

Amit Ziv

  • NA
  • 40
  • 8.7k

printscreen a panel control

Apr 12 2014 8:04 AM
Hi, im doing a paint program and it all works perfectly
except for the save image thingy...
i got this code, but it just saves the control without the graphics i paint on top (with pen):
any ideas? pls?
ImageFormat img; Bitmap bt; Graphics screenShot;
        private void button1_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            { 

                
                img = ImageFormat.Jpeg;
                
                bt = new Bitmap(panel1.Width, panel1.Height, PixelFormat.Format16bppGrayScale);
                   
                screenShot = Graphics.FromImage(bt);
                
                screenShot.CopyFromScreen(panel1.Location.X, panel1.Location.Y, panel1.Width, panel1.Height, panel1.Bounds.Size, CopyPixelOperation.SourceCopy);
            }

            bt.Save(saveFileDialog1.FileName, img);
        }        

Answers (5)