采用WPF技术开发截图程序 (可下载)
发布日期:2021-05-09 09:06:56 浏览次数:16 分类:博客文章

本文共 6546 字,大约阅读时间需要 21 分钟。

������  QQ���������������������������������������������������������������������������������������������������QQ���������������������������������������������������������������������������QQ������������������������������������������������������������������������������������������������������������������

������������������������������������������������������WPF���������������������������������������������������������������MFC���winform������������������������������������������������������������������������low������������WPF���������������������������������������������������������������������������������������������������������������������������������������������������

 ������  ���������������������������  ���������������������������������������������������QQ������920519255���

������������������������ ���������������������������������������������������������������������

���������������1������������������������������������������������������������������������2������������+���������������������������������������������������������������

���������������������������

������������������������

���������������������������������������������������������������������������

���������������

��������������������������������������������������������������������������������� ���������������������������������������������
���������������������������������������������������������������������������������������������������

 ���������������������������������������������������������������

������������

  ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

������������������

public Bitmap GetScreenSnapshot()        {            System.Drawing.Rectangle rc = SystemInformation.VirtualScreen;            var bitmap = new Bitmap(rc.Width, rc.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);            using (Graphics memoryGrahics = Graphics.FromImage(bitmap))            {                memoryGrahics.CopyFromScreen(rc.X, rc.Y, 0, 0, rc.Size, CopyPixelOperation.SourceCopy);            }            return bitmap;        }

������������������

 ������������������������������������������������������������

������������

���������������������������������������������������������������������������������������������������������������winform������������������������

���������������������������winform���������������������������������������������������������������wpf���������������winform���������������������wpf���������������������������������������������������������������������������������������������������������

������������������������������������������������������������������������������

������������������������ ������������������������ ���ESC���������
1
���
���
X

���������������������������������������������������������borderSelect���������

private void ImgScreen_MouseMove(object sender, MouseEventArgs e)        {            if (!_isMouseDown)                return;            gridCover.Visibility = Visibility.Visible;            //������������������������            Point currentPoint = e.GetPosition(imgScreen);            Point borderPoint = e.GetPosition(borderSelect);            double xDelta = xDelta_BoderToImgScreen;            double yDelta = yDelta_BoderToImgScreen;            _rectImgCut = ImageHelper.ToRect(currentPoint, _startPoint);            Rect rectBoderCut = ImageHelper.ToRect(new Point(currentPoint.X + xDelta, currentPoint.Y + yDelta),                new Point(_startPoint.X + xDelta, _startPoint.Y + yDelta));            //���������������������������            Thickness thickness = new Thickness(rectBoderCut.Left, rectBoderCut.Top, 0, 0);            borderSelect.SetValue(FrameworkElement.MarginProperty, thickness);            imgCut.SetValue(FrameworkElement.MarginProperty, thickness);            thickness = new Thickness(rectBoderCut.Left, 3, 0, 0);            txtCutInfo.SetValue(FrameworkElement.MarginProperty, thickness);            borderSelect.Width = Math.Abs(_startPoint.X - currentPoint.X);            borderSelect.Height = Math.Abs(_startPoint.Y - currentPoint.Y);            borderSelect.Visibility = Visibility.Visible;            //��������������������� ���������������������������������������������������������������������            imgCut.Source = GetBitmapCut();            Int32Rect imgDestRect = GetCutRect();            txtCutInfo.Text = string.Format($"���:{imgDestRect.Width} ���:{imgDestRect.Height}");        }

���������������������������������������������������������������������������������������wpf������������������������������winform������������������������������������wpf���������������������������������������������������������������������������������������������������������������������������������������

���������������������QQ���������������������������������������������������������������������������QQ������������������������

上一篇:vc++开发安装程序实例
下一篇:自己动手,写一个分布式系统(附c#代码示例)

发表评论

最新留言

感谢大佬
[***.8.128.20]2025年04月08日 17时14分03秒