chenpeng

C#截屏代码方法
描述:传入对应的参数即可实现截取屏幕功能|´・ω・)ノ/// <summary> /// 截取屏幕 /...
扫描右侧二维码阅读全文
19
2020/01

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();
}
Last modification:January 19th, 2020 at 12:22 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment