我一个窗体里面放了一个WEBBROSER,然后截取窗体的图片就获得了webbrowser当前浏览的图片了,但是不知道为什么有时候截的图是白色的,我滚动条隐藏了也一样 ,怎么才能让他总是截图成功呢?
//截图代码
Bitmap bit1 = new Bitmap(this.Width, this.Height);
this.DrawToBitmap(bit1, new Rectangle(0, 0, this.Width, this.Height));
int border = (this.Width - this.ClientSize.Width) / 2;//边框宽度
int caption = (this.Height - this.ClientSize.Height) - border;//标题栏高度
Bitmap bit2 = bit1.Clone(new Rectangle(border, caption, this.ClientSize.Width, this.ClientSize.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb);
bit1.Save("D:\AAA.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);//包括标题栏和边框
bit2.Save("D:\BBB.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);//不包括标题栏和边框
bit1.Dispose();
bit2.Dispose();