[英]Bitmap(Int32, Int32, PixelFormat) throws ArgumentException
I am trying to get a part of a screenshot but unfortunately I am getting ArgumentException
when I am creating Bitmap
. 我正在尝试获取屏幕截图的一部分,但是不幸的是,当我创建
Bitmap
时遇到了ArgumentException
。 Here's a code : 这是一个代码:
public Bitmap bp(int x, int y, int width, int height)
{
Bitmap bitmap = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(x, y, 0, 0, bitmap.Size, CopyPixelOperation.SourceCopy);
}
return bitmap;
}
When it's trying to make bitmap it throws: 当试图制作位图时,它抛出:
ArgumentException.
ArgumentException。 "Parameter isn't valid".
“参数无效”。
Can any one help to handle this ? 有人可以帮忙吗?
I Call this Function : 我称这个功能为:
Bitmap ln = bp(Convert.ToInt32(textBox55.Text),
Convert.ToInt32(textBox56.Text), Convert.ToInt32(textBox59.Text) -
Convert.ToInt32(textBox55.Text), Convert.ToInt32(textBox56.Text) -
Convert.ToInt32(textBox60.Text));
I am getting Parameters from TextBox
我从
TextBox
获取参数
You must be passing width and height as 0 to this method. 您必须将width和height作为0传递给此方法。
Width and height must be greater than 0. 宽度和高度必须大于0。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.