我正在尝试尝试捕获网页中特定区域的图像。下面的代码工作正常,但问题是它每次只给我一个大小为1.64kb的空白图像。
函数调用
protected void btn_Click(object sender, EventArgs e)
{
System.Drawing.Image image = CaptureScreen(50, 99, 930, 450);
image.Save(Server.MapPath("/img/screen.jpg"));
}
功能定义
public System.Drawing.Image CaptureScreen(int sourceX, int sourceY, int destX, int destY)
{
Bitmap bmp = new Bitmap(930, 430);
Graphics g = Graphics.FromImage(bmp);
Size xx=new Size();
xx.Width=930;
xx.Height=450;
g.CopyFromScreen(sourceX, sourceY, destX, destY, xx);
return bmp;
}