基本信息
源码名称:c# 屏幕截图(右键>换 即可截取屏幕)
源码大小:0.04M
文件格式:.zip
开发语言:C#
更新时间:2016-09-02
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
           
        }
        public static Bitmap GetBitmap(API.RECT rect)
        {
            //要截图的长宽
            int width = rect.X2 - rect.X1;
            int height = rect.Y2 - rect.Y1;
            Bitmap image = new Bitmap(width, height);
            //创建画布
            Graphics g = Graphics.FromImage(image);
            g.CopyFromScreen(rect.X1, rect.Y1, 0, 0, image.Size);
            //返回Bitmap
            return image;
        }

        /// <summary>
        /// 鼠标右键
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 换ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            API.RECT APIS = new API.RECT();
            //你自己随意截图的坐标
            APIS.X1 = 0;
            APIS.X2 = 1920; 
            APIS.Y1 = 0;
            APIS.Y2 = 1080;
            //坐标设置好以后, 截图并显示在pictureBox1中
            this.pictureBox1.Image = GetBitmap(APIS);
        }
    }
    /// <summary>
    /// 坐标
    /// </summary>
    public class API
    {
        public struct RECT
        {

            public int X1;

            public int Y1;

            public int X2;

            public int Y2;

        }
     
    }
      
}