private void button2_Click(object sender, EventArgs e)
{
Rectangle tScreenRect = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
tScreenRect.Width = 50;
tScreenRect.Height = 30;
Bitmap tSrcBmp = new Bitmap(tScreenRect.Width, tScreenRect.Height); // 用于屏幕原始图片保存
Bitmap tSrcBmp1 = new Bitmap(tScreenRect.Width, tScreenRect.Height); // 用于屏幕原始图片保存
Graphics gp = Graphics.FromImage(tSrcBmp);
Graphics gp1 = Graphics.FromImage(tSrcBmp1);
//string Text1 = Cursor.Position.X.ToString();
//string Text = Cursor.Position.Y.ToString();
//int x = int.Parse(Text1);
//int y = int.Parse(Text);
gp.CopyFromScreen(1257, 300, 0, 0, tScreenRect.Size);
gp.DrawImage(tSrcBmp, 0, 0, tScreenRect, GraphicsUnit.Pixel);
gp1.CopyFromScreen(1306, 300, 0, 0, tScreenRect.Size);
gp1.DrawImage(tSrcBmp1, 0, 0, tScreenRect, GraphicsUnit.Pixel);
tSrcBmp.Save(@"F:/VC++程序/Cmouse/22.png");
tSrcBmp1.Save(@"F:/VC++程序/Cmouse/33.png");
}
C#截取某一范围的图
最新推荐文章于 2024-05-20 14:20:25 发布