本文介绍了WPF多边形到位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将wpf多边形形状转换为位图图像?我正在尝试将Visual参数作为位图发送,但似乎无法正常工作.还有其他方法可以将WPF多边形转换为位图吗?
How can I convert the wpf polygon shape as a bitmap image? I am trying to send as Visual parameter to change as bitmap, but it doesn't seem to be working. Is there any other way to convert the WPF polygon to bitmap?
am使用如下
RenderTargetBitmap RTbmap = new RenderTargetBitmap((int)yellowPolygon.Width, (int)yellowPolygon.Height, 96, 96, PixelFormats.Default);
RTbmap.Render(yellowPolygon);
image1.Source = RTbmap;
推荐答案
将Width
和Height
更改为ActualWidth
和ActualHeight
.
通过点定义的线,面等具有不确定的宽度和高度.渲染为位图时,应使用ActualWidth
和ActualHeight
.
Line, polygon etc which are defined via points have undefined width and height. When rendering to a bitmap you should use ActualWidth
and ActualHeight
.
我只是在一个示例项目中尝试过,并且效果很好.
I just tried this in a sample project and it works just fine.
这篇关于WPF多边形到位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!