MemoryStream memStream = new MemoryStream();
System.Windows.Media.Imaging.RenderTargetBitmap bmp = new System.Windows.Media.Imaging.RenderTargetBitmap((int)panel.ActualWidth, (int)panel.ActualHeight, 96d, 96d, System.Windows.Media.PixelFormats.Pbgra32);
bmp.Render(panel);
System.Windows.Media.Imaging.JpegBitmapEncoder encoder = new System.Windows.Media.Imaging.JpegBitmapEncoder();
encoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(bmp));
encoder.Save(memStream);
byte[] bt = memStream.ToArray();
memStream.Close(); memStream = new MemoryStream(bt);
BitmapImage biImg = new BitmapImage();
biImg.BeginInit();
biImg.StreamSource = memStream;
biImg.EndInit(); ImageBrush brush = new ImageBrush();
brush.ImageSource = (ImageSource)biImg;
imagePanel2.Background = brush;

UIElementImageShot的更多相关文章

随机推荐

  1. 用Margin还是用Padding?(转载)

    转载出自 海玉的博客 本文地址: http://www.hicss.net/use-margin-or-padding/ 用margin还是用padding这个问题是每个学习CSS进阶时的必经之路. ...

  2. 如何在webpack中成功引用到图片?

    打包图片时,你可曾遇到在产出目录文件夹找不到图片,即便找到了,但是页面说引用不到资源?页面上或者文件中引用的图片地址不对? 一.在webpack中引入图片需要url-loader //webpack配 ...

  3. selenium切换窗口后定位元素出现问题的解决方案

    在做UI自动化的过程中,有时需要由一个窗口跳转到另一个窗口,这时直接去定位页面元素,可能会出现问题,这时,我们需要将driver与新的窗口进行绑定. 完整代码如下:(python版) #coding= ...

  4. 如何运行后台Service?

    Unless you specify otherwise, most of the operations you do in an app run in the foreground on a spe ...

  5. virtualbmc 使用

    virtualbmc 介绍 通常情况下,我们要使用 IPMI必须使用有带外管理功能的物理机.但是在很多测试环境,我们使用的是虚拟机.virtualbmc是一个可以使用 IPMI命令来控制虚机的open ...

  6. css 制作圆角、圆形图形布局

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. Vue使用vue-echarts图表

    vue-echarts和echarts的区别: vue-echarts是封装后的vue插件, 基于 ECharts v4.0.1+ 开发,依赖 Vue.js v2.2.6+,功能一样的只是把它封装成v ...

  8. 《Linux内核原理与分析》第一周作业 20189210

    实验一 Linux系统简介 这一节主要学习了Linux的历史,Linux有关的重要人物以及学习Linux的方法,Linux和Windows的区别.其中学到了LInux中的应用程序大都为开源自由的软件, ...

  9. CentOS7 安装 jexus-5.8.2-x64

    前要提示: 如果你要安装asp.net 请参考: http://www.cnblogs.com/xiaoruilin/p/7867823.html 背景: CentOS7 Mono (Mono JIT ...

  10. NSTextField/NSTextView中显示超链接以及NSMutableAttributedString用法

    扩展NSAttributedString 简单的实现方法是为NSAttributedString 添加一个category. 然后为此category添加额外的方法. 具体实现如下: [代码]c#/c ...