冰楓論壇

標題: [C#] 擷取電腦螢幕畫面(主螢幕部分) [打印本頁]

作者: whitefox    時間: 2023-6-28 22:35
標題: [C#] 擷取電腦螢幕畫面(主螢幕部分)
  1. private static Bitmap bmpScreenshot;
  2. private static Graphics gfxScreenshot;
  3. bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
  4. gfxScreenshot = Graphics.FromImage(bmpScreenshot);
  5. gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
  6. bmpScreenshot.Save(@"c:\ScreenShot.png", System.Drawing.Imaging.ImageFormat.Png);
複製代碼





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