0

我有图像。我想为图像制作模糊边缘。我可以在 Image.OpacityMask 上仅添加一个 LinearGradientBrush 并仅制作水平或仅垂直模糊边缘:

<Image Height="300" Width="450" Name="oldImg" Source="/untitled.jpg">
 <Image.OpacityMask>
  <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
   <GradientStop Offset="0" Color="Transparent"></GradientStop>
   <GradientStop Offset=".3" Color="Black"></GradientStop>
   <GradientStop Offset=".7" Color="Black"></GradientStop>
   <GradientStop Offset="1" Color="Transparent"></GradientStop>
  </LinearGradientBrush>
 </Image.OpacityMask>
</Image>

如何结合垂直和水平的lineargradientbrush?

4

1 回答 1

2

一种方法是在图像顶部堆叠两个矩形......

<Grid>
<Image Height="300" Width="450" Name="oldImg" Source="/untitled.jpg"></Image>
 <Rectangle >
  <Rectangle.Fill>
    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
     <GradientStop Offset="0" Color="White"></GradientStop>
     <GradientStop Offset=".3" Color="Transparent"></GradientStop>
     <GradientStop Offset=".7" Color="Transparent"></GradientStop>
     <GradientStop Offset="1" Color="White"></GradientStop>
    </LinearGradientBrush>
  </Rectangle.Fill>
  </Rectangle>
 <Rectangle>
  <Rectangle.Fill>
    <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
     <GradientStop Offset="0" Color="White"></GradientStop>
     <GradientStop Offset=".3" Color="Transparent"></GradientStop>
     <GradientStop Offset=".7" Color="Transparent"></GradientStop>
     <GradientStop Offset="1" Color="White"></GradientStop>
    </LinearGradientBrush>
  </Rectangle.Fill>
  </Rectangle>
</Grid>

我认为您不能在填充/蒙版中应用多个画笔。

于 2013-10-30T11:25:59.287 回答