VisualBrush使视觉模糊 [英] VisualBrush makes Visual blurred
问题描述
我有一个问题与WPF VisualBrush
。 此处您可以从我的应用程序中找到两个图片。较大的是显示带有文本的控件的图像。较小的一个是从我第一次提取,我使用视觉刷来做它。我的问题是,当我的Visual(内容 VisualBrush
)的分辨率会更小,那么视觉画刷看起来更模糊。我不知道为什么。我使用下面的代码来声明视觉画笔。
var blendBrush = new VisualBrush
{
Visual = Host.Viewer,
TileMode = TileMode.None,
AlignmentX = AlignmentX.Left,
AlignmentY = AlignmentY.Top,
Stretch = Stretch.None,
ViewboxUnits = BrushMappingMode.Absolute,
};
Host.Viewer
它在大图像上。每次更改控件大小时,使用以下例程更新 ViewBox
值:
var viewBox = new System.Windows.Rect(topLeft,new Size(width,height));
visualBrush.Viewbox = viewBox;
topLeft
是开始坐标, code> width 和 height
值是我需要的提取大小。
感谢
丹尼尔
好的,我发现了问题。 Host.Viewer
深深地包含一个包含图像对象的画布。图像可能看起来模糊的.NET 4.0及更高版本。该问题可以解决为设置
和Rootparent对象。 UseLayoutRounding = true;
和 BitmapScalingMode = BitmapScalingMode.NearestNeighbor;
> Canvas
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 set UseLayoutRounding = true;
and BitmapScalingMode = BitmapScalingMode.NearestNeighbor;
for the Canvas
and the Rootparent-object.
这篇关于VisualBrush使视觉模糊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!