zoukankan      html  css  js  c++  java
  • c#抓屏(截屏)

    先是给大家一个类:
        class ScreenShot
        {
            public static void CaptureImage(Point SourcePoint, Point DestinationPoint, Rectangle SelectionRectangle, string FilePath)
            {
                using (Bitmap bitmap = new Bitmap(SelectionRectangle.Width, SelectionRectangle.Height))
                {
                    using (Graphics g = Graphics.FromImage(bitmap))
                    {
                        g.CopyFromScreen(SourcePoint, DestinationPoint, SelectionRectangle.Size);
                    }
                    bitmap.Save(FilePath, ImageFormat.Bmp);
                }
            }
        }
         所需添加引用如下:
    using System;
    using System.Drawing;
    using System.Drawing.Imaging;
         调用方法:
            private void button1_Click(object sender, EventArgs e)
            {
                saveFileDialog1.DefaultExt = "bmp";
                saveFileDialog1.Filter = "bmp files (*.bmp)|*.bmp";
                saveFileDialog1.Title = "导出地图为...";
                saveFileDialog1.ShowDialog();
                if (saveFileDialog1.FileName.Length > 0)
                {
                    ScreenPath = saveFileDialog1.FileName;
                }
                else
                {
                    return;
                }
                this.Refresh();
                //3个参数:获得控件所在屏幕坐标,目标坐标点为(0,0),获得控件大小。
                ScreenShot.CaptureImage(axMapControl1.PointToScreen(Point.Empty), Point.Empty, new Rectangle(axMapControl1.Location, axMapControl1.Size), ScreenPath);       
            }
  • 相关阅读:
    VMdomainXml
    C 本地文件夸网文件Cp操作
    C++ auto 与 register、static keyword 浅析
    机器学习笔记——SVM
    NYOJ 298-点的变换(经典矩阵解决点平移、缩放、翻转和旋转)
    HDU 5407 CRB and Candies(LCM +最大素因子求逆元)
    Java总结之网络
    五月份小结
    算法——字符串匹配之BM算法
    javaweb_page指令
  • 原文地址:https://www.cnblogs.com/skyshenwei/p/1654084.html
Copyright © 2011-2022 走看看