Alternative of blur effect on DrawingVisual

喜你入骨 提交于 2019-12-13 15:40:16

问题


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:


DrawingVisuals 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!