问题
I want to give a blur effect to my DrawingVisual
. I can do this using BitmapEffect
properties like:
DrawingVisual drawingVisual = new DrawingVisual();
DrawingContext drawingContext = drawingVisual.RenderOpen();
var effect = new System.Windows.Media.Effects.BlurBitmapEffect();
effect.Radius = 10;
drawingVisual.BitmapEffect = effect;
But the compiler give me a warning that Bitmap effect properties is obsolete.
What other alternative I can use to achive the effect on DrawingVisual
?
回答1:
Effect property of DrawingVisual in not support in 3.5SP1 but there is another way to achieve this to apply shader effect to visual. Here is the example how we can apply shader effect to DrawingVisual
回答2:
DrawingVisual
s do not yet support the new Effect methodology that uses pixel shaders (the built-in BlurEffect
is what you should be using). You can either wait until they do, or you can workaround it by rendering your visuals into an Image
of some sort and using the Image.Effect
property.
来源:https://stackoverflow.com/questions/1304347/alternative-of-blur-effect-on-drawingvisual