[英]create the same effect on a text as the title of windows
I create a transparency window with different textblock but my text isn't always readable because it's depends of colors user's window. 我用不同的文本块创建了一个透明窗口,但是我的文本并不总是可读的,因为它取决于用户窗口的颜色。
So I want apply the same effect on a text like the effect of my title window, It's like a white shadow. 因此,我想对文本应用相同的效果,例如标题窗口的效果,就像一个白色阴影。
Thank you 谢谢
The best way to do this would be to use a shader effect. 最好的方法是使用着色器效果。 I tried to do this with the built in Blur effect but it seems they don't blend with Alpha.
我尝试使用内置的“模糊”效果来做到这一点,但似乎它们没有与Alpha融合。
Below is an example of how I would start and doesn't represent an end product. 以下是我如何开始而不代表最终产品的示例。 HLSL border effect based off of Emboss effect.
HLSL边界效果基于浮雕效果。
View the full image for a better understanding. 查看完整图像以更好地理解。 This effect only adds like 2 px border so the scaling makes it look even worse.
这种效果只会增加2 px的边框,因此缩放会使其看起来更糟。
I'm pretty bad at writing HLSL the code on the right is just copy-pasted from http://brooknovak.wordpress.com/2008/09/16/simple-image-filters-written-as-hlsl-pixel-shaders/ with modification. 我在编写HLSL时非常不好,右边的代码只是从http://brooknovak.wordpress.com/2008/09/16/simple-image-filters-writing-as-hlsl-pixel-shaders复制粘贴而来/经过修改。
I'm sure someone who knew HLSL / GLSL could write a blur effect that works correctly. 我确定知道HLSL / GLSL的人可以编写出可以正常工作的模糊效果。 Note that this effect works across a full image and thus needs to know the image size.
请注意,此效果可作用于整个图像,因此需要知道图像尺寸。 You should put them in a constant buffer and use them instead of the hardcoded 500.0 for width and height.
您应该将它们放在恒定缓冲区中,并使用它们来代替宽度和高度的硬编码500.0。 They need to be the width/height of the rendered object.
它们必须是渲染对象的宽度/高度。 In my example it is actually the entire left half side of the window not just the size of the text because my XAML looks like this...
在我的示例中,实际上是窗口的整个左半边,而不仅仅是文本的大小,因为我的XAML看起来像这样……
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
Loaded="Window_Loaded" Background="Transparent">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="264*" />
<ColumnDefinition Width="239*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="218*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="The quick brown fox jumped over the lazy dog." Foreground="White" Background="Transparent" Grid.RowSpan="3" x:Name="PART_TextBlock"/>
<TextBox x:Name="PART_TextBox" Grid.Column="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible" AcceptsReturn="True" AcceptsTab="True" />
<TextBlock x:Name="PART_Error" Grid.Column="1" Grid.Row="1"/>
<Button Content="Compile & Apply" Grid.Column="1" Grid.Row="2" Padding="4,1" Margin="4" HorizontalAlignment="Center" Click="Button_Click" />
</Grid>
</Window>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.