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中进行 ...
随机推荐
- Java LoggingAPI 使用方法
因为不想导入Log4j的jar,项目只是测试一些东西,因此选用了JDK 自带的Logging,这对于一些小的项目或者自己测试一些东西是比较好的选择. Log4j中是通过log4j.properties ...
- WORDPRESS插件开发学习(一)HELLO WORLD
WORDPRESS插件开发学习系列文章第一篇,在每篇文章的后面追加固定的字符“Hello World” 一.打开wordpress目录->wp-content->plugins 二.在pl ...
- 移动web经验积累
1.从最小宽度时候开发,调试到iphone4来开发 2.宽度百分比,高度由具体内容决定, 3.文字需要设置最大高度,溢出隐藏 white-space: nowrap; text-overflow: e ...
- skymvc网站测试之mysql数据生成
skymvc网站测试之mysql数据生成 使用方法: 删除数据 /index.php?m=test_mysql&a=autoDelete 重置自增ID /index.php?m=test_my ...
- js获取get方式提交的参数返回json格式数据
/** * 获取GET提交的参数 * @return JSON格式 * @author Terry */ function getArgs(){ var args = {}; var match = ...
- Python 学习笔记(1) - 开始
找一个能看的教程(不用太过于纠结以至于耗费大量时间,很可能还没开始就放弃了. -- 这条要作为新的做事准则放入我的日常了,警惕一开始就追求完美常常会什么也得不到.) 我喜欢看书不爱视频,所以找了这个: ...
- STM32固件库
一.STM32固件库开发和传统寄存器开发方式的区别 二.CMSIS标准 CMSIS标准--Cortex Microcontroller Software Interface Standard,是ARM ...
- gulp 中的增量编译
最近花一点时间学了下 gulp,顺便学了下 sass,因为工作中并不需要用(我比较希望学习是需求驱动),所以一直拖到现在才学.突然觉得学习这类工具性价比很高,半天一天即可上手,技能树丰富了(尽管可能只 ...
- IEngineEditor与IWorkspaceEdit,以及相关的事件监听
转自原文 IEngineEditor与IWorkspaceEdit,以及相关的事件监听 IEngineEditor适用于直接在图层上的编辑,例如使用"要素编辑"工具菜单上的&quo ...
- C语言写解一元二次方程程序心得
前言:在网上看到不少解一元二次方程的小程序,在使用时总得出一大堆小数,感觉很不爽,遂自己重新写了一遍. 首先,先回忆一下一元二次方程的求根公式: 分别读取二次项.一次项和常数项系数并且求出delta ...