VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > c#编程 >
  • [C#] 截取屏幕

复制代码
/// <summary>
/// 截取屏幕
/// </summary>
/// <param name="x">起点X坐标</param>
/// <param name="y">起点Y坐标</param>
/// <param name="width">截取宽度</param>
/// <param name="height">截取高度</param>
/// <returns></returns>
private void CaptureScreen(double x, double y, double width, double height)
{
    int ix = Convert.ToInt32(x);
    int iy = Convert.ToInt32(y);
    int iw = Convert.ToInt32(width);
    int ih = Convert.ToInt32(height);

    System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(iw, ih);
    System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
    graphics.CopyFromScreen(ix, iy, 0, 0, new System.Drawing.Size(iw, ih));
    graphics.Dispose();
}
复制代码

相关教程