Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF DropShadowEffect Causing Blurriness

I've observed that applying a DropShadowEffect to a UIElement sporadically causes the UIElement's content to blur a bit. It's a pretty nasty effect: it can cause a photograph to look out of focus or worse- make an entire 'popup' region completely illegible.

I haven't seen anyone else complaining about this, so my inclination is to think that there is something that I am doing wrong.

Sample use (blurs content at random):

<Border>
   <Border.Effect>
      <DropShadowEffect />
   </Border.Effect>
   <!-- (Content) -->
</Border>

But removing the DropShadowEffect clears it up:

<Border>
    <!--<Border.Effect>
            <DropShadowEffect />
        </Border.Effect>-->
    <!-- (Content) -->
</Border>

Any ideas?

EDIT (added screenshot):

alt text http://signmgmt.com/eg/dropshadowblur.png

like image 371
egoodberry Avatar asked Nov 06 '09 15:11

egoodberry


2 Answers

What I do for this kind of scenarios is putting a Background Rectangle and apply the Blur effect just for that, so that the real content will be free from the effect, which in turn increases the performance. Because when you apply the effect to a visual all the subsequent children are also getting the effect applied, which makes the perf and looks gets bad. Try the below

 <Grid>
  <Rectangle ....>
  <Rectangle.Effect>
     <DropShadowEffect />
  </Rectangle.Effect>
 </Rectangle>
....Your content ...
</Grid>
like image 80
Jobi Joy Avatar answered Oct 22 '22 16:10

Jobi Joy


There is a RendingQuality you can use to fix this issue. The default is biased for performance. Just do this:

<DropShadowEffect Color="#FFFD1E1E" ShadowDepth="0" RenderingBias="Quality"/>
like image 22
Kelly Avatar answered Oct 22 '22 14:10

Kelly