2013-09-24 44 views
1

我正在制作一个采用高级屏幕截图的程序。但是我陷入了一个bug,我希望有人能帮助我。在带有图像的Picturebox上绘图并保存它

  • 我可以截图与此代码:

     // The screenshot will be stored in this bitmap. 
        Bitmap capture = new Bitmap(screenBounds.Width, screenBounds.Height); 
    
        // The code below takes the screenshot and 
        // saves it in "capture" bitmap. 
        g = Graphics.FromImage(capture); 
        g.CopyFromScreen(Point.Empty, Point.Empty, screenBounds); 
    
        // This code assigns the screenshot 
        // to the Picturebox so that we can view it 
        pictureBox1.Image = capture; 
        pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; 
    
        // The code below make the form visible again, enables the "Save" button and stops the timer. 
        this.Show(); 
        button2.Enabled = true; 
        timer1.Stop(); 
    
  • 借鉴PictureBox的:

     color = new SolidBrush(Color.Black); 
         Graphics g = pictureBox1.CreateGraphics(); 
         g.FillEllipse(color, e.X, e.Y, 10, 10); 
         g.Dispose(); 
    

问题:我只能保存的截图,不是图纸。
我希望有人能帮助

PS:如果你不明白的东西洞,我是14,并从荷兰,所以我不是最好的英国作家。

+1

哪里是保存'图纸'的代码? –

回答

0

请勿使用CreateGraphics() - 这是一张临时图纸。使用您的拍摄图像:

using (Graphics g = Graphics.FromImage(capture)) { 
    g.FillEllipse(color, e.X, e.Y, 10, 10); 
} 
+0

感谢它的工作! –