C# 截取屏幕

/// 
/// 截取屏幕
/// 
/// 起点X坐标
/// 起点Y坐标
/// 截取宽度
/// 截取高度
/// 
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();
}

你可能感兴趣的:(C# 截取屏幕)