Q
將屏幕捕獲到位圖
55
A
回答
95
如果使用.NET 2.0(或更高版本)的框架,你可以使用CopyFromScreen()
方法這裏詳述:
http://www.geekpedia.com/tutorial181_Capturing-screenshots-using-Csharp.html
//Create a new bitmap.
var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height,
PixelFormat.Format32bppArgb);
// Create a graphics object from the bitmap.
var gfxScreenshot = Graphics.FromImage(bmpScreenshot);
// Take the screenshot from the upper left corner to the right bottom corner.
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
Screen.PrimaryScreen.Bounds.Y,
0,
0,
Screen.PrimaryScreen.Bounds.Size,
CopyPixelOperation.SourceCopy);
// Save the screenshot to the specified path that the user has chosen.
bmpScreenshot.Save("Screenshot.png", ImageFormat.Png);
5
// Use this version to capture the full extended desktop (i.e. multiple screens)
Bitmap screenshot = new Bitmap(SystemInformation.VirtualScreen.Width,
SystemInformation.VirtualScreen.Height,
PixelFormat.Format32bppArgb);
Graphics screenGraph = Graphics.FromImage(screenshot);
screenGraph.CopyFromScreen(SystemInformation.VirtualScreen.X,
SystemInformation.VirtualScreen.Y,
0,
0,
SystemInformation.VirtualScreen.Size,
CopyPixelOperation.SourceCopy);
screenshot.Save("Screenshot.png", System.Drawing.Imaging.ImageFormat.Png);
0
嘗試this代碼
Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics gr = Graphics.FromImage(bmp);
gr.CopyFromScreen(0, 0, 0, 0, bmp.Size);
pictureBox1.Image = bmp;
bmp.Save("img.png",System.Drawing.Imaging.ImageFormat.Png);
0
Bitmap memoryImage;
//Set full width, height for image
memoryImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height,
PixelFormat.Format32bppArgb);
Size s = new Size(memoryImage.Width, memoryImage.Height);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
memoryGraphics.CopyFromScreen(0, 0, 0, 0, s);
string str = "";
try
{
str = string.Format(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
@"\Screenshot.png");//Set folder to save image
}
catch { };
memoryImage.save(str);
相關問題
- 1. 將GLSurfaceView的屏幕捕獲到位圖
- 2. 捕獲屏幕截圖
- 3. 捕獲MKMapView屏幕截圖
- 4. ASP.NET - 捕獲屏幕截圖
- 5. 捕獲屏幕截圖
- 6. 捕獲屏幕
- 7. 捕獲屏幕
- 8. 捕獲屏幕圖像而不捕獲屏幕捕獲垃圾郵件
- 9. 捕獲屏幕內存到位圖(visual c + + 6.0)
- 10. 將屏幕截圖捕捉到屏幕上時不起作用
- 11. 使用ScreenCapture捕獲屏幕截圖並捕獲屏幕截圖.CaptureScreenshot
- 12. 捕獲android屏幕
- 13. PowerShell屏幕捕獲
- 14. windows屏幕捕獲
- 15. 屏幕捕獲API
- 16. HTML5捕獲屏幕
- 17. C#捕獲屏幕爲8位(256色)位圖
- 18. 登錄屏幕中的屏幕捕獲
- 19. 屏幕捕獲的代碼屏幕捕獲Android的任何屏幕
- 20. 將OpenGL繪製到屏幕外位圖
- 21. 捕獲屏幕截圖 - html2canvas不工作
- 22. 在MVC中捕獲屏幕圖像
- 23. 在硒中捕獲屏幕截圖
- 24. 用ImageMagick ++捕獲X11屏幕截圖
- 25. 捕獲屏幕截圖的iframe
- 26. Web瀏覽器的屏幕捕獲位圖太重
- 27. 嘗試捕獲並打印到屏幕
- 28. 會話0捕獲屏幕
- 29. 屏幕捕獲在IOS中
- 30. 屏幕捕獲問題
不錯和簡單...就像一個魅力...感謝! – 2009-10-10 13:04:38
你的回答不正確,請與(g.CopyFromScreen(更新 0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy); – 2013-01-27 06:12:41
但是否多顯示器上工作PC – EaterOfCode 2013-07-31 18:31:27