• wpf 加阴影效果导致内容模糊的问题解决


    这个和GPU有关,参考地址

    https://www.cplotts.com/2009/02/25/gpu-effects-blurry-text/

    产生问题的代码如下:

     1 <Window
     2     x:Class="EffectsAndBlurryText.Window1"
     3     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     4     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     5     Title="Effects and Blurry Text (Bad)"
     6     Height="300"
     7     Width="500"
     8 >
     9     <Grid>
    10         <Border
    11             Margin="20"
    12             Background="White"
    13             BorderBrush="DarkBlue"
    14             BorderThickness="3"
    15             CornerRadius="25"
    16         >
    17             <Border.Effect>
    18                 <DropShadowEffect Color="DarkGray"/>
    19             </Border.Effect>
    20             <TextBlock
    21                 Text="Why, oh, why is this text blurry?"
    22                 FontSize="24"
    23                 TextWrapping="Wrap"
    24                 Foreground="DarkBlue"
    25                 HorizontalAlignment="Center"
    26                 VerticalAlignment="Center"
    27             />
    28         </Border>
    29     </Grid>
    30 </Window>

    解决问题的代码如下:

     1 <Window
     2     x:Class="EffectsAndBlurryText.Window1"
     3     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     4     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     5     Title="Effects and Blurry Text (Fixed)"
     6     Height="300"
     7     Width="500"
     8 >
     9     <Grid>
    10         <Border
    11             Margin="20"
    12             BorderThickness="3"
    13             CornerRadius="25"
    14             Background="White"
    15             BorderBrush="DarkBlue"
    16         >
    17             <Border.Effect>
    18                 <DropShadowEffect Color="DarkGray"/>
    19             </Border.Effect>
    20         </Border>
    21         <Border
    22             Margin="20"
    23             BorderThickness="3"
    24             CornerRadius="25"
    25         >
    26             <TextBlock
    27                 Text="Ah, now, the text is not blurry."
    28                 FontSize="24"
    29                 TextWrapping="Wrap"
    30                 Foreground="DarkBlue"
    31                 HorizontalAlignment="Center"
    32                 VerticalAlignment="Center"
    33             />
    34         </Border>
    35     </Grid>
    36 </Window>
  • 相关阅读:
    浅谈C++多态性
    OSI七层模型具体解释
    文本框仅仅同意输入数字
    MessageDigest简单介绍
    CF 161D Distance in Tree【树DP】
    第六届蓝桥杯JavaA组国(决)赛真题
    Java实现 蓝桥杯 历届真题 稍大的串
    Java实现 蓝桥杯 历届真题 稍大的串
    Java实现 蓝桥杯 历届真题 稍大的串
    Java实现 蓝桥杯 历届真题 稍大的串
  • 原文地址:https://www.cnblogs.com/zsx-blog/p/10671924.html
Copyright © 2020-2023  润新知