问题描述
大家好。我试图获取截图的一部分但不幸的是,当我创建Bitmap时,我收到了ArgumentException。这是一个代码:
公共位图bp(int x,int y,int width,int height)
{
位图位图=新位图(宽度,高度,System.Drawing.Imaging.PixelFormat.Format24bppRgb);
使用(图形g = Graphics.FromImage(位图))
{
g.CopyFromScreen(x,y,0,0,bitmap.Size,CopyPixelOperation.SourceCopy);
}
返回位图;
}
当它试图制作位图时会抛出ArgumentException。 参数无效。
任何人都可以帮忙解决这个问题吗?
我叫这个函数:
位图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));
我从TextBox获取参数
Hello everyone . I am trying to get a part of a screenshot but unfortunately I am getting ArgumentException when I am creating Bitmap. 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. "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
推荐答案
这篇关于位图(Int32,Int32,PixelFormat)抛出ArgumentException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!