Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#winform DrawToBitmap屏幕外_C#_Winforms_Drawtobitmap - Fatal编程技术网

c#winform DrawToBitmap屏幕外

c#winform DrawToBitmap屏幕外,c#,winforms,drawtobitmap,C#,Winforms,Drawtobitmap,如果windows窗体控件比您的显示器大,有没有办法截取它的屏幕 例如,我的winform是3000px乘以3000px 显示器是1080p this.Height = 3000; this.Width = 3000; Graphics g = this.CreateGraphics(); //new bitmap object to save the image Bitmap bmp = new Bitmap(th

如果windows窗体控件比您的显示器大,有没有办法截取它的屏幕

例如,我的winform是3000px乘以3000px

显示器是1080p

this.Height = 3000;
this.Width = 3000;                               

Graphics g = this.CreateGraphics();
//new bitmap object to save the image        
Bitmap bmp = new Bitmap(this.Width, this.Height + 1000);
//Drawing control to the bitmap        
this.DrawToBitmap(bmp, new Rectangle(0, 0, this.Width, this.Height + 1000));
bmp.Save(@"C:\Users\Watson\Documents\Visual Studio 2013\WebSites\WebSite3\Images\button.jpg", ImageFormat.Jpeg);
bmp.Dispose();

屏幕截图始终受限于我的显示器大小。即使应用程序不在屏幕上,也有办法渲染它吗?

您需要将控件自身设置为解除锁定

Panel1.Dock = DockStyle.None // If Panel Dockstyle is in Fill mode.      
Panel1.Width = 5000  // Original Size without scrollbar     
Panel1.Height = 5000 // Original Size without scrollbar      
Dim bmp As New Bitmap(Me.Panel1.Width, Me.Panel1.Height)     
Me.Panel1.DrawToBitmap(bmp, New Rectangle(0, 0, Me.Panel1.Width, Me.Panel1.Height))     
bmp.Save("C:\panel.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)      
Panel1.Dock = DockStyle.Fill
松开后,Drawtobitmap将返回面板宽度和高度的图像


您是否尝试过使用
Gdi32.CreateCompatibleBitmap()
?这个方法是在gdi32.dll中定义的。另外,检查这个线程:你想抓取它的是什么?t3chb0t,基本上如果我的表单是3000 x 3000,我希望Drawtobitmap返回一个该大小的图像。但事实并非如此。它返回一个受监视器大小约束的图像。因此,返回的图像大小将是1980 x 1096,而不是3000 x 3000质量,我无法获得链接中的任何示例。返回的图像始终等于监视器的大小。将窗体大小设置为大于监视器大小时,总是会将窗体大小减小为监视器大小。例如,这个.Height=3000;然后看看这是什么,高度是。。。是1096。。。你到底是如何创建一个大于你监视器大小的表单屏幕截图的?