1

我正在开发一个程序来获取高级屏幕截图。但是我遇到了一个错误,我希望有人可以帮助我。

  • 我可以用这段代码截屏:

           // 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();
    
  • 在图片框上绘图:

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

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

4

1 回答 1

0

不要使用CreateGraphics()- 这是一个临时图纸。使用您的捕获图像:

using (Graphics g = Graphics.FromImage(capture)) {
  g.FillEllipse(color, e.X, e.Y, 10, 10);
}
于 2013-09-24T18:23:25.773 回答