用C# 实现全屏幕截图(2)_C/C++语言_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

用C# 实现全屏幕截图(2)

作者:黑客防线网安C/C++教程基地 来源:黑客防线网安C/C++教程基地 浏览次数:0

本篇关键词:截图屏幕实现 
黑客防线网安网讯:     & isClipping) {    rectSelected.Width = e.X - rectSelected.X;    rectSelected.Height = e.Y - rectSelected.Y;    this.Invalidate();    }    }    protected override void OnM...
     & isClipping) {
    rectSelected.Width = e.X - rectSelected.X;
    rectSelected.Height = e.Y - rectSelected.Y;
    this.Invalidate();
    }
    }
    protected override void OnMouseUp(MouseEventArgs e) {
    if (e.Button == MouseButtons.Left && isClipping) {
    rectSelected.Width = e.X - rectSelected.X;
    rectSelected.Height = e.Y - rectSelected.Y;
    this.Invalidate();
    resultBmp = new Bitmap(rectSelected.Width, rectSelected.Height);
    using (Graphics g = Graphics.FromImage(resultBmp)) {
    g.DrawImage(screen,new Rectangle(0, 0, rectSelected.Width, rectSelected.Height), rectSelected, GraphicsUnit.Pixel);
    }
    this.DialogResult = DialogResult.OK;
    }
    }
    protected override void OnPaint(PaintEventArgs e) {
    Graphics g = e.Graphics;
    g.DrawImage(screen, 0, 0);
    g.DrawImage(coverLayer, 0, 0);
    PaintRectangle();
    }
    protected override void OnPaintBackground(PaintEventArgs e) {
    }
    protected override void OnKeyDown(KeyEventArgs e) {
    if (e.KeyCode == Keys.Escape) {
    this.DialogResult = DialogResult.Cancel;
    }
    }
    private void PaintRectangle() {
    using (Graphics g = Graphics.FromImage(coverLayer)) {
    g.Clear(coverColor);
    GraphicsPath path = new GraphicsPath();
    path.AddRectangle(this.Bounds);
    path.AddRectangle(rectSelected);
    g.FillPath(rectBrush, path);
    g.DrawRectangle(Pens.Blue, rectSelected);
    }
    }
    public Bitmap ResultBitmap {
    get { return resultBmp; }
    }
    }
    上面的代码都很容易看明白这里有一个技巧就是GraphicsPath它自动会形成一个中空的区域上面的实现很容易扩展:多区域截图,多裁判截图等都很容易实现
    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-15239-1.html
网站维护教程更新时间:2012-04-04 22:52:12  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer