冰楓論壇

標題: [C#] 擷取螢幕畫面 [打印本頁]

作者: whitefox    時間: 2023-6-1 14:59
標題: [C#] 擷取螢幕畫面
將目前畫面擷取下來另存一張點陣圖(bitmap)
  1. public void CaptureScreen()
  2. {
  3.     System.Drawing.Size size = Screen.PrimaryScreen.Bounds.Size;
  4.     System.Drawing.Bitmap bitmap
  5.         = new System.Drawing.Bitmap(size.Width, size.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
  6.     System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);
  7.     g.CopyFromScreen(0, 0, 0, 0, size);
  8.     bitmap.Save("screen.png", System.Drawing.Imaging.ImageFormat.Png);
  9. }
複製代碼





歡迎光臨 冰楓論壇 (https://bingfong.com/) Powered by 冰楓