C# 截屏並保存圖片

public void fu_ScreenCut(String strFileName)
        {
            int nWidth, nHeight;    //顯示器寬度、高度

            //獲取顯示器尺寸
            nWidth = Screen.PrimaryScreen.Bounds.Width;
            nHeight = Screen.PrimaryScreen.Bounds.Height;

            Bitmap bit = new Bitmap(nWidth, nHeight);   //實例化一個圖像,尺寸大小爲主顯示器尺寸
            Graphics g = Graphics.FromImage(bit);
            g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            g.CopyFromScreen(0, 0,0,0 ,new Size(nWidth, nHeight));
            bit.Save(strFileName);

        }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章