C#實(shí)現(xiàn)屏幕拷貝的方法
更新時(shí)間:2015年06月12日 10:05:23 作者:zhuzhao
這篇文章主要介紹了C#實(shí)現(xiàn)屏幕拷貝的方法,實(shí)例分析了兩種常用的屏幕拷貝實(shí)現(xiàn)技巧,需要的朋友可以參考下
本文實(shí)例講述了C#實(shí)現(xiàn)屏幕拷貝的方法。分享給大家供大家參考。具體如下:
方法一:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; namespace WindowsApplication2 { public partial class Form21 : Form { public Form21() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Rectangle screenRect = Screen.PrimaryScreen.WorkingArea; Bitmap dumpBitmap = new Bitmap(screenRect.Width, screenRect.Height); Graphics tg = Graphics.FromImage(dumpBitmap); tg.CopyFromScreen(0, 0, 0, 0, new Size(dumpBitmap.Width, dumpBitmap.Height)); this.pictureBox1.BackgroundImage = dumpBitmap; this.pictureBox1.BackgroundImageLayout = ImageLayout.Stretch; dumpBitmap.Save(@"c:/image1.bmp"); } } }
方法二:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication2 { public partial class Form22 : Form { public Form22() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Rectangle rect = new Rectangle(0, 0, this.Size.Width, this.Size.Height); Bitmap dumpBitmap = new Bitmap(this.Size.Width, this.Size.Height); this.DrawToBitmap(dumpBitmap, rect); this.pictureBox1.BackgroundImage = dumpBitmap; this.pictureBox1.BackgroundImageLayout = ImageLayout.Stretch; dumpBitmap.Save(@"c:/image2.bmp"); } } }
希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。
相關(guān)文章
基于C#實(shí)現(xiàn)設(shè)置桌面背景功能
這篇文章主要為大家詳細(xì)介紹了如何利用C#實(shí)現(xiàn)設(shè)置桌面背景功能,文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)C#有一定的幫助,感興趣的小伙伴可以跟隨小編一起了解一下2022-12-12C# BeginInvoke實(shí)現(xiàn)異步編程方式
這篇文章主要介紹了C# BeginInvoke實(shí)現(xiàn)異步編程方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-01-01C#實(shí)現(xiàn)的簡(jiǎn)單鏈表類實(shí)例
這篇文章主要介紹了C#實(shí)現(xiàn)的簡(jiǎn)單鏈表類,涉及C#針對(duì)鏈表的定義、實(shí)現(xiàn)及鏈表節(jié)點(diǎn)的增加、刪除與修改技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-08-08C#通過HttpWebRequest發(fā)送帶有JSON Body的POST請(qǐng)求實(shí)現(xiàn)
本文主要介紹了C#通過HttpWebRequest發(fā)送帶有JSON Body的POST請(qǐng)求實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09C#實(shí)現(xiàn)單鏈表(線性表)完整實(shí)例
這篇文章主要介紹了C#實(shí)現(xiàn)單鏈表(線性表)的方法,結(jié)合完整實(shí)例形式分析了單鏈表的原理、實(shí)現(xiàn)方法與相關(guān)注意事項(xiàng),需要的朋友可以參考下2016-06-06