本文已参与「新人创作礼」活动,一起开启掘金创作之路。
private void btnCutter_Click(object sender, EventArgs e) { Image img = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height); Graphics g = Graphics.FromImage(img); g.CopyFromScreen(new Point(0, 0), new Point(0, 0), Screen.AllScreens[0].Bounds.Size); ScreenBody body = new ScreenBody(); body.BackgroundImage = img; body.Show(); }
`using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace ScreenCutter { public partial class ScreenBody : Form { public ScreenBody() { InitializeComponent(); this.WindowState = FormWindowState.Maximized; }
private void ScreenBody_DoubleClick(object sender, EventArgs e)
{
if (((MouseEventArgs)e).Button == MouseButtons.Left)
{
//保存图片
Image memory = new Bitmap(this.Width, this.Height);
Graphics g = Graphics.FromImage(memory);
g.CopyFromScreen(this.Location.X + 1, this.Location.Y + 1, 0, 0, this.Size);
Clipboard.SetImage(memory);//把图片放到剪切板中
this.Close();
}
}
}
}`