zoukankan      html  css  js  c++  java
  • WinForm当前窗口抓图

    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;

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

            
    private void button1_Click(object sender, EventArgs e)
            {
                
    //当前窗口宽度
                int iWidth = this.Width;
                
    //当前窗口高度
                int iHeight = this.Height;
                
    //截取主屏幕
                Screen scrPrimary = Screen.PrimaryScreen;
                
    //创建一个和屏幕一样大的Bitmap
                Image myImage = new Bitmap(iWidth, iHeight);
                
    //从一个继承自Image类的对象中创建Graphics对象
                Graphics graphi = Graphics.FromImage(myImage);
                
    //抓屏并拷贝到myimage里
                graphi.CopyFromScreen(new Point(this.Location.X,this.Location.Y), new Point(00), new Size(iWidth, iHeight));
                
    //保存并存储文件
                myImage.Save(@"c:/1.jpeg");
            }
        }
    }
  • 相关阅读:
    Laravel框架中的event事件操作
    PHP魔术方法实例
    PHP 面向对象
    ThinkPHP中where()使用方法详解
    PHP常见错误提示含义解释
    php面向对象编程self和static的区别
    php文件路径获取文件名
    php三种无限分类
    php高精度计算问题
    转:JavaScript定时机制、以及浏览器渲染机制 浅谈
  • 原文地址:https://www.cnblogs.com/zhangpengshou/p/2078938.html
Copyright © 2011-2022 走看看