ScaleTransform导致输出模糊/拉伸;怎么修? [英] ScaleTransform causes blurry/stretched output; how to fix?

查看:429
本文介绍了ScaleTransform导致输出模糊/拉伸;怎么修?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将WPF 3.5应用程序更新为WPF4.此后,我注意到在某些情况下,将元素的LayoutTransform设置为ScaleTransform会导致输出模糊.看起来该元素的内容正在被渲染 以较小的尺寸显示,然后在显示时被拉伸为位图.

I recently updated a WPF 3.5 application to WPF 4. Since then, I have noticed that under certain conditions, setting an element's LayoutTransform to be a ScaleTransform will cause blurry output. It looks as though the contents of the element are being rendered at a smaller size, then being stretched as a bitmap when being displayed.

我正在使用TextFormattingMode.Ideal,所以这不是TextFormattingMode.Display问题.此外,所有内容(包括GeometryDrawings(应为矢量图形),而不仅仅是文本)都将受到影响(并且看上去模糊).

I'm using TextFormattingMode.Ideal, so it's not a TextFormattingMode.Display issue. Additionally, all content, including GeometryDrawings (which should be vector graphics), not just text, is affected (and looks blurry).

如果ScaleX和ScaleY是0.25的整数倍,则不会发生.因此,例如,按1.25或1.75缩放会产生清晰的输出.缩放1.4或1.7会产生模糊的输出.

It doesn't happen if ScaleX and ScaleY are integral multiples of 0.25. So, for example, scaling by 1.25 or 1.75 produces crisp output. Scaling by 1.4 or 1.7 produces blurry output.

它仅在某些元素上发生.例如,主窗口包含带有工具栏的DockPanel,然后是主窗口内容.这些控件(工具栏和主要内容)中的每一个都有独立应用的LayoutTransform(具有相同的比例). 工具栏可以正常缩放;主要内容是模糊的.

It only happens for certain elements. For example, the main window contains a DockPanel with a toolbar and then the main window content. Each of these controls (toolbar and main content) has a LayoutTransform (with the same scale) applied independently. The toolbar scales normally; the main content is blurry.

主窗口具有"UseLayoutRounding ="True"" (这是在移植到WPF 4时添加的.)

The main window has 'UseLayoutRounding="True"' (this was added when porting to WPF 4).

我还无法创建简化的副本.

I haven't been able to create a simplified repro yet.

我目前的假设是,视觉树中的某些东西导致WPF退回到通过位图拉伸实现缩放的状态;我计划继续简化应用程序的XAML,直到问题不再发生为止.

My current hypothesis is that something in the visual tree is causing WPF to fall back to implementing scaling via bitmap stretching; I plan to keep simplifying the XAML of the app until the problem stops occurring.

在此期间,是否有人知道这是什么原因或有其他建议?我在这个论坛和网络上进行了搜索,但没有找到任何看起来相关的帖子.

In the meantime, does anyone know what's causing this, or have any other suggestions? I searched this forum and the web but didn't find any posts that seemed relevant.

推荐答案

要重现我的视觉效果在看到的情况下,您可以指定"CacheMode =" BitmapCache"在已应用LayoutTransform的元素上.但是,此属性实际上未在我的应用程序中指定.

To reproduce the visual effect that I'm seeing, you can specify 'CacheMode="BitmapCache"' on the element that has a LayoutTransform applied. However, this property is not actually specified in my application.

是否存在某种情况导致WPF自动使用BitmapCache CacheMode?

Is there some condition that causes WPF to use a BitmapCache CacheMode automatically?


这篇关于ScaleTransform导致输出模糊/拉伸;怎么修?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆