C# 截取屏幕
程序员文章站
2023-09-28 18:38:39
/// /// 截取屏幕 /// /// 起点X坐标 /// 起点Y坐标 /// 截取宽度 ///
/// <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(); }