Xaml 如何在Windows Phone上将方形图像转换为圆形图像

Xaml 如何在Windows Phone上将方形图像转换为圆形图像,xaml,windows-phone-8,Xaml,Windows Phone 8,可以在Windows phone上从方形图像生成圆形图像吗?我有很多图像应该显示为一个圆圈。但是我该怎么做呢?在XAML中,您希望使用椭圆控件创建圆。然后给它一个图像笔刷填充 <Ellipse Height="100" Width="100"> <Ellipse.Fill> <ImageBrush ImageSource="YourImage.png"/> </Ellipse.Fill> </Ellipse&g

可以在Windows phone上从方形图像生成圆形图像吗?我有很多图像应该显示为一个圆圈。但是我该怎么做呢?

在XAML中,您希望使用椭圆控件创建圆。然后给它一个图像笔刷填充

<Ellipse Height="100" Width="100">
    <Ellipse.Fill>
        <ImageBrush ImageSource="YourImage.png"/>
    </Ellipse.Fill>
</Ellipse>

我的想法很简单:

<Image Source="ImagePath" Width="326" Height="188">
    <Image.Clip>
        <EllipseGeometry Center="170,90" RadiusX="90" RadiusY="90" />
    </Image.Clip>
</Image>

或者,您可以对图像应用不透明遮罩,以创建各种与不透明相关的照片遮罩

<Image Source="ImagePath" >
       <Image.OpacityMask>
              <RadialGradientBrush GradientOrigin="0.5,0.5" Center="0.5,0.5" RadiusX="0.5" RadiusY="0.5">                          
                            <GradientStop Color="#ffffffff" Offset="0.5" />
                            <GradientStop Color="#00ffffff" Offset="0.8" />
               </RadialGradientBrush>
       </Image.OpacityMask>
</Image>

您可以使用Image.Clip,但我更喜欢@robwirving解决方案。但你现在需要选择!
此处的信息=>

仅供参考,这不会保留纵横比。请使用
保留纵横比和剪辑。这两个选项均不适用于Windows Phone 8.1(WinRT)