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>
  • 相关阅读:
    volatile关键字,使一个变量在多个线程间可见。
    grep sed awk
    mysql高级聚合
    Hive高级聚合GROUPING SETS,ROLLUP以及CUBE
    用SecureCRT来上传和下载文件
    mysql导出导入数据
    redis入门
    spark 常用技巧总结2
    生成数据库字典
    spark 常用技巧总结
  • 原文地址:https://www.cnblogs.com/zsx-blog/p/10671924.html
Copyright © 2011-2022 走看看