2013-10-30 24 views
0

我有圖像。 我想爲圖像製作模糊邊緣。 我可以Image.OpacityMask只添加一個一個LinearGradientBrush,使只有水平或垂直只邊緣模糊:如何在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結合?

回答

1

一種方式是堆棧上的圖像的兩個矩形...

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

我不認爲你可以填充/掩碼中應用多個刷子。

+0

謝謝。但我建議它不能解決我的問題。可能使用LinearGradientBrush是不好的解決方案,您可以提供其他解決方案嗎? – ShevninAnton

+0

它怎麼解決你的問題? – PaulB

+0

我的問題更廣泛,因爲我有兩個圖像控件(它看起來像圖層)。我想在頂部圖像上模糊邊緣,我可以看到第二個圖像(其中邊緣模糊) – ShevninAnton