C#截取当前活动窗体的图片
2024-09-06 08:58:16
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Drawing.Imaging;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
CaptureImage(this.Location,new Point (0,0), new Rectangle(this.Location.X, this.Location.Y, this.Width, this.Height), "c:\\ls.bmp");
}
public void CaptureImage(Point SourcePoint, Point DestinationPoint,Rectangle SelectionRectangle, string FilePath)
{
using (Bitmap bitmap = new Bitmap(SelectionRectangle.Width,
SelectionRectangle.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(SourcePoint, DestinationPoint,
SelectionRectangle.Size);
}
bitmap.Save(FilePath, ImageFormat.Bmp);
bitmap.Dispose();
}
}
}
}
最新文章
- sphinx :undefined reference to `libiconv' 报错解决办法
- shiro错误No SecurityManager accessible to the calling code
- java IO复习(三)
- RSA不对称加密,公钥加密私钥解密,私钥加密公钥解密
- Android源代码下载之《Android新闻client源代码》
- List Set Map用法和区别
- HTML 表单元素之 input 元素
- VC加载显示bmp图片的函数
- elasticsearch系列(三)分表分库
- 【Beta阶段】计划安排
- Loadrunner检查点使用总结
- 给echart初始化的dom节点绑定时间获取点击的值渲染省市区
- Linux 小知识翻译 - 「小型移动式PC」
- 【原创】有关Silverlight中 ";Silverlight提示4004错误"; 的解决方案及思路。
- nc工具学习
- [iOS微博项目 - 4.2] - 设置转发微博背景
- 正则表达式-RegExp-常用正则表达式
- 软工1816 · Alpha冲刺(4/10)
- Django学习笔记之Django视图View
- python接口测试(二)——配置文件的使用