C# 獲取當前屏幕的圖片

直接貼代碼:有更好的大家一起交流啊

 

 Rectangle bounds = Screen.GetBounds(Screen.GetBounds(Point.Empty));

 using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
            {
                using (Graphics g = Graphics.FromImage(bitmap))
                {
                    g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
                }
               
                //Convert the Image to a JPG
                MemoryStream ms = new MemoryStream();
                bitmap.Save(ms, imgFormat);
                return ms;
            }

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