Winform 根据Point截图并保存到指定路径

 1 /// <summary>
 2         /// 获取图片流
 3         /// </summary>
 4         /// <param name="ImageXY">图片屏幕起始点</param>
 5         /// <param name="ImageSize">图片大小</param>
 6         /// <returns></returns>
 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             try
15             {
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         /// <summary>
31         /// 保存截图
32         /// </summary>
33         /// <param name="bmp"></param>
34         public string ImageSave(Bitmap bmp,string FilePath,string FileName)
35         {
36             try
37             {
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);

调用

Winform 根据Point截图并保存到指定路径

时间: 2024-08-03 13:11:34

Winform 根据Point截图并保存到指定路径的相关文章

截图怎么保存为指定格式的图片

我们在日常生活中,经常会需要指定格式的图片,那么我们是不是有这样的困惑:截图怎么保存为指定格式的图片?如何截图和转变图片格式?电脑上的截图怎么变成jpg格式把电脑整个屏幕截了图后,怎么保存为图片jpg格式?桌面截图图片,怎么改格式截图截的图片怎样变为JPG图片格式?qq截图怎么转化成JPG怎样把QQ截图格式转换成别的格式 截图及图片处理教程 原文地址:http://blog.51cto.com/13172026/2177414

nodejs 剪切图像在上传,并保存到指定路径下(./public/img/&#39; + req.session.token + &#39;.jpg‘)

前jQuery端接收数据 function upAvatar(img){ console.log(img); // data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMD…/7vA+eq/xZAlzs/wBYlP8AtlpRRXcc9h++B/8AVyJRs30UVRkM2e9M8s+tFFSBE6UUUUGp/9k= $.ajax({ url:'/user/upload', type:'PUT',

php远程下载文件并保存到指定路径

<?php function getFile($url, $save_dir = '', $filename = '', $type = 0) { if (trim($url) == '') { return false; } if (trim($save_dir) == '') { $save_dir = './'; } if (0 !== strrpos($save_dir, '/')) { $save_dir.= '/'; } //创建保存目录 if (!file_exists($save

正則表達式 取出img标签 保存于指定路径

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net; using System.IO; using System.Text; using System.Text.RegularExpressions; namespace DloadPic

正则表达式 取出img标签 保存于指定路径

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net; using System.IO; using System.Text; using System.Text.RegularExpressions; namespace DloadPic

下载图片,并保存到指定大小和清晰度

获取指定链接图片,通过width.height .option来设置图片宽度.高度及清晰度,并保存到指定路径 package main import (     "bytes"     "fmt"     "io/ioutil"     "net/http"     "github.com/KenmyZhang/image/app" ) var (     imagPath = "http://i

Unity3D截图功能总结,并保存在指定的文件夹

快过新年了,一直在加班赶项目,没时间写博客,今天上班最后一天,就休息过年了,将我强几天在做一个截图功能分享出来,网上查了很多,但是都是在Unity Editor下好使,能截图,并显示出来,但是,在Android下,截图成功,并能显示出来,但是就是存不到手机相册中,找了很多原因不知道怎么回事,查阅各种资料最终解决了.我总结了一下,我用过的方法,希望大家 能够用的上. 第一种方法: 使用Application类下的CaptureScreenshot方法.但是我觉得这并不好用,不随意.不能针对某一个相

[Android] 拍照、截图、保存并显示在ImageView控件中

最近在做Android的项目,其中部分涉及到图像处理的内容.这里先讲述如何调用Camera应用程序进行拍照,并截图和保存显示在ImageView控件中以及遇到的困难和解决方法. PS:作者购买了本<Android第一行代码 著:郭霖>,参照里面的内容完成(推荐该书,前面的布局及应用非常不错).网上这类资料非常多,作者仅仅分享给初学者同时在线记录些内容,希望对大家有所帮助. 首先,设置activity_main.xml为LinearLayout布局且 android:orientation=&q

利用wget下载文件,并保存到指定目录

利用WGET下载文件,并保存到指定目录 [email protected] ~/下载 $ wget -P /home/cbx/下载/PDF https://www.linuxmint.com/documentation/user-guide/Cinnamon/chinese_16.0.pdf https://www.linuxmint.com/documentation.php wget是Linux上一个非常不错的下载指令,而其指令的内容虽然说是非常简单,但内藏许多的参数,也算是Linux工作者