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
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 setUseLayoutRounding = true;
andBitmapScalingMode = BitmapScalingMode.NearestNeighbor;
for theCanvas
and the Rootparent-object.