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. 拷贝JAR包

    package com.cici; import java.io.File; import java.io.FileInputStream; import java.util.ArrayList; i ...

  2. centos下安装python3.7.0以上版本时报错ModuleNotFoundError: No module named '_ctypes'

    centos下安装python3.7.0以上版本时报错ModuleNotFoundError: No module named '_ctypes'的解决办法 3.7版本需要一个新的包libffi-de ...

  3. 【AtCoder】【模拟】【模型转化】Camel and Oases(AGC012)

    题意: 有一个骆驼,n个绿洲遍布在数轴上,第i个绿洲的坐标为x[i],保证x[i]单增.骆驼的驼峰有体积初始值V.当驼峰的体积变为v的时候,驼峰中至多只能够存储v L的水.骆驼希望走完所有的绿洲,并且 ...

  4. Mac解决某些命令失效问题

    PS:今天安装groovy,需要设置环境变量,vim -/.bash_profile,然后立马执行了source -/.bash_profile.最后,发现ls,more,vim等常用命令失效了.立马 ...

  5. Educational Codeforces Round 7

    622A - Infinite Sequence    20171123 暴力枚举\(n\)在哪个区间即可,时间复杂度为\(O(\sqrt{n})\) #include<stdlib.h> ...

  6. Servlet 参数

    1.应用参数,在web.xml配置,所有Servlet共用 <context-param> <param-name>driver</param-name> < ...

  7. http跳转htts的htaccess文件设置

    RewriteEngine OnRewriteCond %{SERVER_PORT} 80RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]Options ...

  8. overflow:hidden;和clear:both;的不同点

    overflow:hidden;是针对被浮动元素的父级元素,是让父级元素找回原来的高,因为浮动的元素会让父级元素的高塌陷: 而clear:both:它是在新的元素上面书写,它是让上面浮动的元素不要干扰 ...

  9. iOS开发支付篇-内购(IAP)

    一,前言 经典文章参考: . http://yimouleng.com/2015/12/17/ios-AppStore/ 内购流程 . http://www.jianshu.com/p/b199a46 ...

  10. java手写线程池,完善中

    package com.test001.threadpool; import java.util.LinkedList; import java.util.List; import java.util ...