.net 图像控制中多边形的绘制

.net 图像控制中多边形的绘制,.net,wpf,vb.net,image,polygon,.net,Wpf,Vb.net,Image,Polygon,我正在制作一个程序,用vb.net在WPF中的图像控件中,在图片和幻灯片之间进行星形擦除转换 现在我正在图像控件中绘制星形的图片 我是按表格做的 这是在窗体上绘制多边形的代码 'here i draw the star points MyPolygon.Points = myPointCollection 'and here i draw the the star with the image from imagebrush MyPolygon.Fill = imagebrush 但

我正在制作一个程序,用vb.net在WPF中的图像控件中,在图片和幻灯片之间进行星形擦除转换

现在我正在图像控件中绘制星形的图片

我是按表格做的 这是在窗体上绘制多边形的代码

'here i draw the star points
  MyPolygon.Points = myPointCollection

'and here i draw the the star with the image from imagebrush
  MyPolygon.Fill = imagebrush
但是我不知道如何在图像控件中绘制这个

我可以使用source属性将整个图片放在图像控件中

但这是不可能的,它不会被画成星星


是否有在图像控件中绘制多边形的方法?

您可以在运行时使用可写位图库在位图图像上绘制多边形,并可以将图像控件的源设置为创建的位图。

您不能将
多边形
放在
图像
控件中。您必须将其添加到一些布局容器中,如
网格
画布

canvas.Children.Add(MyPolygon);
或在XAML中:

<Canvas x:Name="canvas">
    <Polygon x:Name="MyPolygon"/>
</Canvas>