最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

基于C#實現(xiàn)屏幕桌面截圖

 更新時間:2022年12月12日 14:50:31   作者:芝麻粒兒  
這篇文章主要為大家詳細介紹了如何利用C#實現(xiàn)屏幕桌面截圖以及左上角區(qū)域截圖功能,文中的示例代碼講解詳細,對我們學(xué)習(xí)C#有一定的幫助,感興趣的小伙伴可以了解一下

實踐過程

效果

代碼

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        [DllImport("user32.dll", EntryPoint = "GetSystemMetrics")]
        private static extern int GetSystemMetrics(int mVal);
        private void button1_Click(object sender, EventArgs e)
        {
            Bitmap _Source = new Bitmap(GetSystemMetrics(0), GetSystemMetrics(1));
            using (Graphics g = Graphics.FromImage(_Source))
            {
                g.CopyFromScreen(0, 0, 0, 0, _Source.Size);
                g.Dispose();
            }
            pictureBox1.Image = _Source;
        }
    }
partial class Form1
{
    /// <summary>
    /// 必需的設(shè)計器變量。
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// 清理所有正在使用的資源。
    /// </summary>
    /// <param name="disposing">如果應(yīng)釋放托管資源,為 true;否則為 false。</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows 窗體設(shè)計器生成的代碼

    /// <summary>
    /// 設(shè)計器支持所需的方法 - 不要
    /// 使用代碼編輯器修改此方法的內(nèi)容。
    /// </summary>
    private void InitializeComponent()
    {
        this.button1 = new System.Windows.Forms.Button();
        this.pictureBox1 = new System.Windows.Forms.PictureBox();
        ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
        this.SuspendLayout();
        // 
        // button1
        // 
        this.button1.Location = new System.Drawing.Point(24, 12);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(75, 23);
        this.button1.TabIndex = 0;
        this.button1.Text = "抓取桌面";
        this.button1.UseVisualStyleBackColor = true;
        this.button1.Click += new System.EventHandler(this.button1_Click);
        // 
        // pictureBox1
        // 
        this.pictureBox1.Location = new System.Drawing.Point(105, 12);
        this.pictureBox1.Name = "pictureBox1";
        this.pictureBox1.Size = new System.Drawing.Size(515, 306);
        this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
        this.pictureBox1.TabIndex = 1;
        this.pictureBox1.TabStop = false;
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(648, 330);
        this.Controls.Add(this.pictureBox1);
        this.Controls.Add(this.button1);
        this.Name = "Form1";
        this.Text = "Form1";
        ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
        this.ResumeLayout(false);

    }

    #endregion

    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.PictureBox pictureBox1;
}
  public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Image memory = new Bitmap(300,200);
            Graphics g = Graphics.FromImage(memory);
            g.CopyFromScreen(0,0, 0, 0, new Size(300,200));
            pictureBox1.Image = memory;
        }
    }
partial class Form1
{
    /// <summary>
    /// 必需的設(shè)計器變量。
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// 清理所有正在使用的資源。
    /// </summary>
    /// <param name="disposing">如果應(yīng)釋放托管資源,為 true;否則為 false。</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows 窗體設(shè)計器生成的代碼

    /// <summary>
    /// 設(shè)計器支持所需的方法 - 不要
    /// 使用代碼編輯器修改此方法的內(nèi)容。
    /// </summary>
    private void InitializeComponent()
    {
        this.pictureBox1 = new System.Windows.Forms.PictureBox();
        this.button1 = new System.Windows.Forms.Button();
        ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
        this.SuspendLayout();
        // 
        // pictureBox1
        // 
        this.pictureBox1.Location = new System.Drawing.Point(12, 12);
        this.pictureBox1.Name = "pictureBox1";
        this.pictureBox1.Size = new System.Drawing.Size(309, 200);
        this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
        this.pictureBox1.TabIndex = 0;
        this.pictureBox1.TabStop = false;
        // 
        // button1
        // 
        this.button1.Location = new System.Drawing.Point(327, 32);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(131, 23);
        this.button1.TabIndex = 1;
        this.button1.Text = "抓取左上角的圖片";
        this.button1.UseVisualStyleBackColor = true;
        this.button1.Click += new System.EventHandler(this.button1_Click);
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(470, 225);
        this.Controls.Add(this.button1);
        this.Controls.Add(this.pictureBox1);
        this.Name = "Form1";
        this.Text = "Form1";
        this.Load += new System.EventHandler(this.Form1_Load);
        ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
        this.ResumeLayout(false);

    }

    #endregion

    private System.Windows.Forms.PictureBox pictureBox1;
    private System.Windows.Forms.Button button1;
}

以上就是基于C#實現(xiàn)屏幕桌面截圖的詳細內(nèi)容,更多關(guān)于C#屏幕桌面截圖的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • C#語音識別用法實例

    C#語音識別用法實例

    這篇文章主要介紹了C#語音識別用法,實例分析了C#利用微軟操作系統(tǒng)自動的語音識別功能,讀取信息的技巧,需要的朋友可以參考下
    2015-01-01
  • c# 實現(xiàn)IComparable、IComparer接口、Comparer類的詳解

    c# 實現(xiàn)IComparable、IComparer接口、Comparer類的詳解

    本篇文章是對c#中實現(xiàn)IComparable、IComparer接口、Comparer類進行了詳細的分析詳解,需要的朋友參考下
    2013-05-05
  • C#列出所有物理網(wǎng)絡(luò)適配器的方法

    C#列出所有物理網(wǎng)絡(luò)適配器的方法

    這篇文章主要介紹了C#列出所有物理網(wǎng)絡(luò)適配器的方法,實例分析了C#操作網(wǎng)絡(luò)設(shè)備的技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-04-04
  • Asp.Net中MVC緩存詳解

    Asp.Net中MVC緩存詳解

    這篇文章主要介紹了Asp.Net中MVC緩存的種類區(qū)別等內(nèi)容,一下來學(xué)習(xí)下。
    2017-12-12
  • RSA密鑰--JAVA和C#的區(qū)別及聯(lián)系

    RSA密鑰--JAVA和C#的區(qū)別及聯(lián)系

    這篇文章主要介紹了關(guān)于RSA密鑰事件JAVA和C#的區(qū)別及聯(lián)系,文章從RSA語法介紹開始展開詳細介紹了C#轉(zhuǎn)JAVA及JAVA轉(zhuǎn)C#,需要的小伙伴可以可以參考一下
    2021-10-10
  • C#通過經(jīng)緯度計算2個點之間距離的實現(xiàn)代碼

    C#通過經(jīng)緯度計算2個點之間距離的實現(xiàn)代碼

    這篇文章主要介紹了C#通過經(jīng)緯度計算2個點之間距離實現(xiàn)代碼,本文對實現(xiàn)原理、經(jīng)緯度基本知識等一并做了講解,需要的朋友可以參考下
    2014-08-08
  • C#自定義控件添加右鍵菜單的方法

    C#自定義控件添加右鍵菜單的方法

    這篇文章主要介紹了C#自定義控件添加右鍵菜單的方法,本文用到control控件,專門自定義右鍵菜單,下面小編給大家整理下,有需要的小伙伴可以來參考下
    2015-08-08
  • 如何讓C#、VB.NET實現(xiàn)復(fù)雜的二進制操作

    如何讓C#、VB.NET實現(xiàn)復(fù)雜的二進制操作

    VB.NET和C#屬于高級語言,對二進制位操作的支持不是很好,比如沒有了移位運算等,用的時候確實很不方便,所以在閑暇之余我重新封裝了一個用于C#、VB.NET的位操作類庫,通過該類庫可以實現(xiàn)數(shù)據(jù)移位、循環(huán)移位、轉(zhuǎn)換為二進制、將二進制轉(zhuǎn)換為數(shù)據(jù)等
    2013-07-07
  • C# 控件屬性和InitializeComponent()關(guān)系案例詳解

    C# 控件屬性和InitializeComponent()關(guān)系案例詳解

    這篇文章主要介紹了C# 控件屬性和InitializeComponent()關(guān)系案例詳解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下
    2021-08-08
  • C#測量程序運行時間及cpu使用時間實例方法

    C#測量程序運行時間及cpu使用時間實例方法

    對一個服務(wù)器程序想統(tǒng)計每秒可以處理多少數(shù)據(jù)包,要如何做?答案是用處理數(shù)據(jù)包的總數(shù),除以累記處理數(shù)據(jù)包用的時間,下面我們看一個代碼實例就明白了
    2013-11-11

最新評論

澜沧| 宾阳县| 阿拉善盟| 武鸣县| 峨边| 齐齐哈尔市| 社旗县| 泊头市| 嘉义县| 区。| 板桥市| 洛南县| 三门峡市| 湘潭市| 敦化市| 榆社县| 五指山市| 安吉县| 喀喇| 黎平县| 新昌县| 江山市| 革吉县| 连云港市| 麟游县| 安庆市| 广安市| 福清市| 江安县| 花莲县| 盘山县| 万年县| 江孜县| 香河县| 星子县| 万宁市| 灵台县| 抚远县| 莲花县| 上高县| 滨州市|