VisualBrush makes Visual blurred
Asked Answered
H

1

0

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

Halona answered 21/9, 2014 at 12:31 Comment(0)
H
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.

Halona answered 22/9, 2014 at 13:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.