开发者

How to clip an image in a heart shape in Silverlight?

开发者 https://www.devze.com 2023-03-23 11:56 出处:网络
I am working on image processing application in Silverlight. Currently I am开发者_Python百科 stuck to one.

I am working on image processing application in Silverlight. Currently I am开发者_Python百科 stuck to one.

The problem is I want to clip the image in heart shape. How to clip the image in heart shape in Silverlight?


You can use a clipping path - something like this:

<Image Source="myimage.jpg" Width="300" Height="300" >
  <Image.Clip>
   <PathGeometry >
    <PathFigure x:Name="pf" StartPoint="150,50" IsClosed="True" >
     <ArcSegment IsLargeArc="True" Point="250,150" Size="141,141" SweepDirection="Clockwise" />
     <LineSegment Point="150,250" />
     <LineSegment Point="50,150" />
     <ArcSegment IsLargeArc="True" Point="50,150" Size="141,141" SweepDirection="Clockwise" />
    </PathFigure>
   </Image.Clip>
 </Image>

(you'll need to vary the exact path to suit your image).

Alternatively you can use an opacity mask in the shape of a heart.


I would recommend just creating a heart in Photoshop or something with the center transparent and the outsides a solid color. Then just draw the heart onto your image. This way you don't have to deal with clipping and you can have more control over the shape.

0

精彩评论

暂无评论...
验证码 换一张
取 消