码迷,mamicode.com
首页 > Windows程序 > 详细

C# 截取屏幕

时间:2020-01-15 12:15:20      阅读:99      评论:0      收藏:0      [点我收藏+]

标签:turn   new   drawing   screen   returns   capture   from   name   bit   

/// <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();
}

C# 截取屏幕

标签:turn   new   drawing   screen   returns   capture   from   name   bit   

原文地址:https://www.cnblogs.com/flamegreat/p/12195730.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!