How to make a squared image to a round image on Windows Phone

好久不见. 提交于 2020-12-29 03:23:05

问题


how is it possible to make a round image on Windows Phone of a squared image. I have a lot of images which should be displayed as a circle. But how can I do this?

Thank.


回答1:


In XAML you want to make the circle using an Ellipse control. Then give it an ImageBrush fill.

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



回答2:


My idea is very simple:

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

Or you can apply an OpacityMask to an Image to create a variety of opacity-related photo masking

<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>



回答3:


You can use Image.Clip but i prefer the @robwirving solution. But you need to choice now! Information here => http://msdn.microsoft.com/fr-fr/library/system.windows.uielement.clip(v=vs.110).aspx



来源:https://stackoverflow.com/questions/21092218/how-to-make-a-squared-image-to-a-round-image-on-windows-phone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!