[英]How can I create a screenshot of a http website and save it on my server?
[英]How can I create a screenshot?
如何在 c# Windows Forms 應用程序中創建屏幕截圖?
我試過了:
ScreenCapture sc = new ScreenCapture();
Image img = sc.CaptureScreen();
this.imageDisplay.Image = img;
sc.CaptureWindowToFile(this.Handle, "C:\\temp2.png", ImageFormat.png);`
第二次嘗試
using (var bitmap = new Bitmap(1680, 1050))
{
DrawToBitmap(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
bitmap.Save(@"c:\TEST.bmp");
}
我會在同一主題上向您推薦這篇文章Capture screenshot of active window? 但看起來接受的答案是您從中復制原始代碼的地方。 該代碼依賴於 2004 年的第 3 方庫( https://www.developerfusion.com/code/4630/capture-a-screen-shot/ ),因此您需要將其添加到您的項目中才能使用您的代碼。
但是同一個問題還有 10 個其他不依賴於 3rd 方庫的答案,其中大多數應該可以正常工作。 比如這個:
Rectangle bounds = 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);
}
bitmap.Save("test.jpg", ImageFormat.Jpeg);
}
https://stackoverflow.com/a/1163770/612620
這個問題可能應該被標記為Capture screenshot of active window?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.