VisualBrush makes Visual blurred

天大地大妈咪最大 提交于 2019-12-12 02:58:07

问题


i have a problem with the WPF VisualBrush. Here you find two images from my application. The bigger on is a image which shows a control with text. The smaller one is a extract from the first on who i use a visual brush to make it. My problem is, that when the resolution of my Visual (the content for VisualBrush) would be smaller then the visual brush looks more blurred. I don't no why. I use the following code to declare the visual brush.

 var blendBrush = new VisualBrush
        {
            Visual = Host.Viewer,
            TileMode = TileMode.None,
            AlignmentX = AlignmentX.Left,
            AlignmentY = AlignmentY.Top,
            Stretch = Stretch.None,
            ViewboxUnits = BrushMappingMode.Absolute,
        };

Host.Viewer is the control you see it on the big image. Everytime the control size is changed i update the ViewBox values with the following routine:

var viewBox = new System.Windows.Rect(topLeft, new Size(width, height));
        visualBrush.Viewbox = viewBox;

topLeft is the start coordinates and the width and height values are the size of extract i needed. I hope anyone can help how i can prevent that the control would be blurry!

Thanks Daniel


回答1:


Okay i found the problem. Host.Viewer contains in deeply part a canvas which contains a image object. Images could look blurry in .NET 4.0 and higher. The problem could resolve to set UseLayoutRounding = true; and BitmapScalingMode = BitmapScalingMode.NearestNeighbor; for the Canvas and the Rootparent-object.



来源:https://stackoverflow.com/questions/25959192/visualbrush-makes-visual-blurred

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