以编程方式截取网页屏幕截图[关闭]

2024-04-18

如何以 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();

但这是行不通的。它只给了我一张白色的空白图片。我在这里缺少什么?

有没有其他方法可以以编程方式获取网页的屏幕截图?


我找啊找啊找啊找啊找到了网页缩略图 http://www.codeproject.com/KB/cs/webpage_thumbnailer.aspx (a 代码项目 http://en.wikipedia.org/wiki/The_Code_Project文章)。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

以编程方式截取网页屏幕截图[关闭] 的相关文章

随机推荐