亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

 更新時間:2022年12月12日 14:50:31   作者:芝麻粒兒  
這篇文章主要為大家詳細(xì)介紹了如何利用C#實現(xiàn)屏幕桌面截圖以及左上角區(qū)域截圖功能,文中的示例代碼講解詳細(xì),對我們學(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)屏幕桌面截圖的詳細(xì)內(nèi)容,更多關(guān)于C#屏幕桌面截圖的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 詳解c# 可空類型(Nullable)

    詳解c# 可空類型(Nullable)

    這篇文章主要介紹了c# 可空類型(Nullable)的相關(guān)資料,文中示例代碼非常詳細(xì),幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下
    2020-07-07
  • C#實現(xiàn)Excel導(dǎo)入sqlite的方法

    C#實現(xiàn)Excel導(dǎo)入sqlite的方法

    這篇文章主要介紹了C#實現(xiàn)Excel導(dǎo)入sqlite的方法,是C#程序設(shè)計中非常重要的一個實用技巧,需要的朋友可以參考下
    2014-09-09
  • Unity實現(xiàn)仿3D輪轉(zhuǎn)圖效果

    Unity實現(xiàn)仿3D輪轉(zhuǎn)圖效果

    這篇文章主要為大家詳細(xì)介紹了Unity實現(xiàn)仿3D輪轉(zhuǎn)圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-01-01
  • C#中Dictionary的作用及用法講解

    C#中Dictionary的作用及用法講解

    這篇文章主要介紹了C#中Dictionary的作用及用法講解,本文還對dictionary類用什么接口實現(xiàn)、Dictionary的基本用法做了講解,需要的朋友可以參考下
    2014-10-10
  • C#字體池技術(shù)實現(xiàn)代碼詳解

    C#字體池技術(shù)實現(xiàn)代碼詳解

    在本篇文章里小編給大家整理的是關(guān)于C#字體池技術(shù)實現(xiàn)代碼詳解內(nèi)容,有需要的朋友們可以學(xué)習(xí)下。
    2019-11-11
  • C#中遍歷DataSet數(shù)據(jù)集對象實例

    C#中遍歷DataSet數(shù)據(jù)集對象實例

    這篇文章主要介紹了C#中遍歷DataSet數(shù)據(jù)集對象實例,經(jīng)常忘記如何操作DataSet,這里記下來并分享,讓需要的朋友可以參考下
    2014-08-08
  • c# 關(guān)閉窗體時提示的小例子

    c# 關(guān)閉窗體時提示的小例子

    這篇文章介紹了c#中關(guān)閉窗體時提示的小例子代碼,有需要的朋友可以參考一下
    2013-07-07
  • C#拷貝文件簡單實現(xiàn)方法

    C#拷貝文件簡單實現(xiàn)方法

    這篇文章主要介紹了C#拷貝文件簡單實現(xiàn)方法,主要分析了FileInfo類中CopyTo方法針對文件復(fù)制的操作技巧,非常簡單實用,需要的朋友可以參考下
    2015-04-04
  • Unity 修改FBX模型動畫的操作

    Unity 修改FBX模型動畫的操作

    這篇文章主要介紹了Unity 修改FBX模型動畫的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-04-04
  • C#使用zxing/zbar/thoughtworkQRcode解析二維碼的示例代碼

    C#使用zxing/zbar/thoughtworkQRcode解析二維碼的示例代碼

    zxing是谷歌開源的二維碼庫,zbar,thoughtworkQRcode也是開源的,三者之間比較各有優(yōu)劣,本文將通過一個案例demo源碼,帶來認(rèn)識學(xué)習(xí)下這三者的實際解碼效果,感興趣的可以了解一下
    2023-07-07

最新評論