As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center提供指导。
7年前关闭。
在以URL为输入的情况下,如何以编程方式截取网页概览?
这是我到目前为止所拥有的:
但这是行不通的。它只给我一张白色的空白图片。我在这里想念什么?
还有其他方法可以通过编程方式获取网页的屏幕截图吗?
7年前关闭。
在以URL为输入的情况下,如何以编程方式截取网页概览?
这是我到目前为止所拥有的:
// The size of the browser window when we want to take the screenshot (and the size of the resulting bitmap)
Bitmap bitmap = new Bitmap(1024, 768);
Rectangle bitmapRect = new Rectangle(0, 0, 1024, 768);
// This is a method of the WebBrowser control, and the most important part
webBrowser1.DrawToBitmap(bitmap, bitmapRect);
// Generate a thumbnail of the screenshot (optional)
System.Drawing.Image origImage = bitmap;
System.Drawing.Image origThumbnail = new Bitmap(120, 90, origImage.PixelFormat);
Graphics oGraphic = Graphics.FromImage(origThumbnail);
oGraphic.CompositingQuality = CompositingQuality.HighQuality;
oGraphic.SmoothingMode = SmoothingMode.HighQuality;
oGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
Rectangle oRectangle = new Rectangle(0, 0, 120, 90);
oGraphic.DrawImage(origImage, oRectangle);
// Save the file in PNG format
origThumbnail.Save(@"d:\Screenshot.png", ImageFormat.Png);
origImage.Dispose();
但这是行不通的。它只给我一张白色的空白图片。我在这里想念什么?
还有其他方法可以通过编程方式获取网页的屏幕截图吗?
最佳答案
我搜索并搜索发现Webpage thumbnailer(有关The Code Project的文章)。
关于c# - 以编程方式拍摄网页的截图,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2316564/
10-09 00:28