zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    【Linux】命令——基本命令
    正则表达式
    Letex
    Markdown
    文本编辑器Vim
    【Linux】集群
    【Linux】软件安装
    共线性synteny
    windows触控手势
    【Linux】bin结尾的安装包
  • 原文地址:https://www.cnblogs.com/zsx-blog/p/10671924.html
Copyright © 2011-2022 走看看