C# Get Desktop Screenshot ZZ
I found this feature while looking inside Graphics class and since it was so simple to use, I decided to post it here.
As I said, it doesn't require more than 15 lines of code - this function: Graphics.CopyFromScreen does all the 'hard work' so we only need to put this into a Bitmap and save/display it.
To the code!
There are 3 steps that you need to follow:
- create a Bitmap that's exactly the screen's size
- using that Bitmap, create a Graphics object (Graphics.FromImage)
- use CopyFromScreen() and save the Bitmap
The code looks like this:
- private void takeScreenShot()
- {
- Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- using (Graphics g = Graphics.FromImage(bmp))
- {
- g.CopyFromScreen(0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size);
- bmp.Save("screenshot.png"); // saves the image
- }
- }
C# Get Desktop Screenshot ZZ的更多相关文章
- Pyqt 屏幕截图工具
从Pyqt的examples中看到一段截图代码, (路径:examplas\desktop\screenshot.py) 所以想自己UI下界面,手动练习下 通过UI生成的: Screenshot.py ...
- java 图片处理
/* * 图片处理类 */ package image; import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.j ...
- 编译x11版本qt
用buildroot 选择x11相关 在选择qt x11版本 export PATH=~/buildroot/output/host/usr/bin:$PATH 进入~/buildroot/out ...
- 更改mac电脑图片默认存储位置
1.创建存储位置screenshot 2.打开terminal 3.defaults write com.apple.screencapture location ~/Desktop/screensh ...
- 用IDesktopWallpaper接口设置png壁纸
#include <Windows.h> #include <string> #include "Shobjidl.h" int main() { std: ...
- [ZZ] The Naked Truth About Anisotropic Filtering
http://www.extremetech.com/computing/51994-the-naked-truth-about-anisotropic-filtering In the seemin ...
- Running a Remote Desktop on a Windows Azure Linux VM (远程桌面到Windows Azure Linux )-摘自网络(试了,没成功 - -!)
A complete click-by-click, step-by-step video of this article is available ...
- ZZ:Solaris 10 软件包分析
ZZ:Solaris 10 软件包分析 http://blog.chinaunix.net/uid-22759617-id-276756.html # Last updated: 2006-02-14 ...
- Power BI官方视频(3) Power BI Desktop 8月份更新功能概述
Power BI Desktop 8月24日发布了更新版本.现将更新内容翻译整理如下,可以根据后面提供的链接下载最新版本使用. 1.主要功能更新 1.1 数据钻取支持在线版 以前的desktop中进行 ...
随机推荐
- iOS 动画基础
原文:http://www.cnblogs.com/lujianwenance/p/5733846.html 今天说一下有关动画的基础,希望能帮助到一些刚接触iOS动画或者刚开始学习iOS的同学, ...
- iOS 图片按比例压缩,指定大小压缩
使用系统方法UIImageJPEGRepresentation(UIimage *image,CGFloat quality)进行图片质量压缩,暂且叫参数quality为压缩比吧,取值范围为0-1. ...
- 类型与通用语言运行时:System.Object
CLR 要求每个类型最终都要继承自 System.Object 类型 //隐式继承 Object class Employee { ... } //显示继承继承 Object class Employ ...
- 将表单数据转化为json数据
/** * 将Form表单转成符合后台要求的json格式数据 * @param frm form表单Id * * @return json格式的数据 */function getFormJson(fr ...
- 04_XML_01_入门基础
[什么是XML] Extensible Markup Language,翻译过来即可扩展标记语言,可以用来标记数据.定义数据类型,是一种允许用户对自己的标记语言进行定义的源语言. 在XML语言中,它允 ...
- 《JavaScript高级程序设计》 阅读计划
第一周 第1章 JavaScript简介 1 第2章 在Html中使用JavaScript 1 第3章 基本概念 3 第二周 第4章 变量.作用域和内存 ...
- ASP.NET中的母版页
添加一个"母版页",使用<asp:ContentPlaceHolder>挖坑,新建的母版页已经自动设置了两个ContentPlaceHolder创建使用母版页的具体页面 ...
- 在阿里云服务器ubuntu14.04运行netcore
从netcore1.0正式发布就很激动,想要赶紧学习. 最近博客园的一篇文章给了完整的指导非常感谢,但是在实际实现到发布到阿里云服务器遇到一些问题,记录下来. 首先上基础文章http://www.cn ...
- clr介绍
CLR(公用语言运行时)和Java虚拟机一样也是一个运行时环境,它负责资源管理(内存分配和垃圾收集),并保证应用和底层操作系统之间必要的分离..NET提供了一个运行时环境,叫做公用语言运行时(Comm ...
- .net闭包的应用
这里体现出闭包的数据共享 , , , , , , , , , }; ; ; values.ToList().ForEach(s => result1 += s); values.ToList() ...