Control.DrawToBitmap上的参数异常 - 不是由大图像引起的。 Plz帮助 [英] Argument Exception on Control.DrawToBitmap - Not Caused By Large Image. Plz Help
问题描述
public System.Drawing.Bitmap GetAsBitmap(System.Windows.Forms.Control control)
{
System.Drawing.Graphics g = control.CreateGraphics();
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(AboutForm.btnClose.Width, AboutForm.btnClose.Height);
System.Drawing.Rectangle r = new System.Drawing.Rectangle(0,0, bmp.Width, bmp.Height);
control.DrawToBitmap(bmp, r); // Exception here
return bmp;
}
以上是我正在使用的代码, 我只是希望能够绘制到位图,然后在我的应用程序中使用它的像素。
Above is the code that i am using, i simply want to be able to draw to a bitmap and then use its pixels within my application.
我的目标是使用正常大小的窗口执行此操作,但是现在我做了它一个73x10的关闭按钮 (一点也不大) 确保我得到的Aurgument Exption不是由MSDN文档中的大事件引起的。
这里>> http://msdn.microsoft.com/en-us/library/system.windows.forms.control.drawtobitmap.aspx
My Goal is to do this with a normal sized window, but for now i have it doing a close button that is 73x10 (not big at all) to ensure that the Aurgument Exption that i am getting is not caused by somthing to big as per the MSDN documentation. Here >> http://msdn.microsoft.com/en-us/library/system.windows.forms.control.drawtobitmap.aspx
然而, 我仍然得到错误,dosnt问题,如果我将它设置为3000或10x10 我仍然得到错误。
However, i still get the error, dosnt matter if i set it to 3000 or 10x10 i still get the error.
现在即使是由于尺寸, 在四核3.4 ghz上,在Windows 7 64位上有8个ram,我应该能够至少超过5000x5000:P或更多
now even if it was due to size, on a quad core 3.4 ghz with 8 gigs of ram on windows 7 64 bit, i should be able to go atleast past 5000x5000 :P or more
任何人都可以帮我这个吗?
Can any one help me with this?
谢谢
推荐答案
使用控件的宽度和高度来表示bmp的大小。 摆脱这两个陈述:
Use the control's width and height for the size of bmp. Get rid of these 2 statements:
System.Drawing.Graphics g = control.CreateGraphics();
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(AboutForm.btnClose.Width,AboutForm.btnClose.Height);
System.Drawing.Graphics g = control.CreateGraphics();
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(AboutForm.btnClose.Width, AboutForm.btnClose.Height);
这篇关于Control.DrawToBitmap上的参数异常 - 不是由大图像引起的。 Plz帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!