博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Winform 根据Point截图并保存到指定路径
阅读量:4318 次
发布时间:2019-06-06

本文共 2036 字,大约阅读时间需要 6 分钟。

1 ///  2         /// 获取图片流 3         ///  4         /// 图片屏幕起始点 5         /// 图片大小 6         /// 
7 public string CutImage(Point ImageXY, Size ImageSize, string FilePath,string FileName) 8 { 9 int[] sCreem = { Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height };10 Bitmap bmp = new Bitmap(sCreem[0], sCreem[1]);11 Graphics g = Graphics.FromImage(bmp);12 g.CopyFromScreen(0, 0, 0, 0, new Size(sCreem[0], sCreem[1]));13 string FileNamePath = "";14 try15 {16 Rectangle rect = new Rectangle(ImageXY, ImageSize);17 if (!rect.IsEmpty)18 {19 Bitmap imgbmp = new Bitmap(rect.Width, rect.Height);20 imgbmp = bmp.Clone(rect, PixelFormat.Format32bppRgb);21 FileNamePath = ImageSave(imgbmp, FilePath, FileName);22 }23 return FileNamePath;24 }25 catch (Exception ex)26 {27 throw ex;28 }29 }30 /// 31 /// 保存截图32 /// 33 /// 34 public string ImageSave(Bitmap bmp,string FilePath,string FileName)35 {36 try37 {38 SaveFileDialog save = new SaveFileDialog();39 if (!Directory.Exists(FilePath))//如果不存在就创建file文件夹40 {41 Directory.CreateDirectory(FilePath);//创建该文件夹42 }43 save.FileName = FilePath;44 bmp.Save(save.FileName + FileName + ".jpg", ImageFormat.Jpeg);45 return FilePath + FileName + ".jpg";46 }47 catch (Exception ex)48 {49 throw ex;50 }51 }
ImageCut
1 cut.CutImage(PointToScreen(Control.Location), Control.Size, System.IO.Directory.GetCurrentDirectory() + "\\Image\\", FileName);
调用

 

转载于:https://www.cnblogs.com/pyffcwj/p/3909466.html

你可能感兴趣的文章
matlab综合实验题库,数学实验matlab题库答案
查看>>
oracle wri$_adv_objects突增,SYSTEM Tablespace — oracle-tech
查看>>
python抓取oracle数据,python爬虫,抓取oracle-base上的一些常用脚本
查看>>
oracle分页用子查询,[亲测]Oracle查询--子查询,分页查询(二)
查看>>
oracle动态语句怎么传参数值,DATAX动态参数数据传递
查看>>
php怎么设置文本区域,PHP txt下载不写文本区域内容
查看>>
linux各个目录名称,描述Linux发行版的系统目录名称命名规则以及用途
查看>>
linux 脚本里切换用户密码,shell,切换用户,执行指定,脚本
查看>>
linux配置无密码登陆,Linux下配置ssh无密码登录
查看>>
linux视频对讲qt方案,QT下视频通话的实现
查看>>
顺序串c语言,数据结构c语言实现定长顺序串
查看>>
sql的一个查询,情景:a表中存在的数据,且在b表中不存在 (not in,not exists...
查看>>
关于MDK编译器优化产生的一个小问题
查看>>
为什么说 Java 程序员到了必须掌握 Spring Boot 的时候?
查看>>
Prefixes and Suffixes
查看>>
HMAC256 Token
查看>>
HDU 2586 + HDU 4912 最近公共祖先
查看>>
POJ 3481 SBT做法
查看>>
Css 后代选择器与子代选择器的区别
查看>>
广播技术
查看>>