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 imagePicker使用方法,方便使用!三步轻松搞定!
自己总结的修改头像的方法,只为方便自己查询使用!转发 步骤:1.遵守代理协议 <UIImagePickerControllerDelegate,UINavigationControllerDel ...
- 从零基础到App Store
- C++指针学习笔记
本文参考http://www.prglab.com/cms/pages/c-tutorial/advanced-data/pointers.php 1.存储其它变量地址的变量(如下面例子中的addre ...
- autoplay media studio couldn't load
AutoPlay Media Studio 7 (English version) is installed on target machine. Following error occurred w ...
- python 自动化之路 logging日志模块
logging 日志模块 http://python.usyiyi.cn/python_278/library/logging.html 中文官方http://blog.csdn.net/zyz511 ...
- JS脚本延时
JS脚本延时 function sleep(milliseconds) { var start = new Date().getTime(); for (var i = 0; i < 1e7 ...
- HTML5:一个拖拽网页元素的例子
关键字:HTML5, Drag&Drop, JavaScript, CSS 运行环境:Chrome <!DOCTYPE html> <html> <head> ...
- Toy Storage
Toy Storage 题型与2318 TOYS一样,注意要对线段排序,现在模板又更新了~~ #include<iostream> #include<cstdio> #incl ...
- Ubuntu15.10 编译VLC Android(安卓)过程记录
持续更新中... 最后一次修改于 2016-03-20 15:33:45 1.必要库的安装 除基本编译环境(gcc.g++等外),需要额外安装如下的库(用于下载必要的依赖文件) (1)JDK 推荐安装 ...
- css实现红十字会图标
一同事应聘TX,出了一道题,分别用1,2,3,5个标签实现红十字会图标,图标水平.垂直居中,短边50px,长边150px.如图: 其中用2,3,5个标签实现不难,略过.一个标签的我比较有兴趣,午休时间 ...