C# 截圖

擷取整個螢幕畫面:
    
// 取得當前螢幕解析度
var size = Screen.PrimaryScreen?.Bounds.Size ?? new Size(0, 0);

// 截圖
Bitmap bitmap = new Bitmap(size.Width, size.Height);
Graphics graphics = Graphics.FromImage(bitmap);
graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);
bitmap.Save("screenshot.png");
    

留言