WPF v4 中的图像调整大小锯齿,但 v3.5 下不支持
我正在使用 WPF 进行图像调整大小管道,该管道在 .NET v3.5 下运行良好。我刚刚将项目升级到目标 v4.0,现在所有调整大小的图像都存在严重别名。图像管道代码均未更改。
默认 WPF 设置在 v3.5 和 v4.0 之间是否发生了变化?
如何在 WPF 中控制已调整大小的位图图像的抖动?
我正在使用 BitmapImage、DrawingVisual、DrawingContext、RenderTargetBitmap、BitmapEncoder 和BitmapFrame
但我没有看到任何与抖动相关的属性。 GDI+ 有很多设置,所以我猜我遗漏了一些东西。
更新:我见过的所有解决方案似乎都假定 Window 对象或 XAML 环境。它在没有 UI 的 Windows 服务内运行。我需要一种以编程方式影响此设置的方法。
我特意从 GDI+ 切换到 WPF,因为 GDI+ 在长时间运行的进程(例如服务和应用程序)中存在内存泄漏。网络应用程序。
I am using WPF for an image resizing pipeline which has been working beautifully under .NET v3.5. I just upgraded the project to target v4.0 and now all of my resized images are heavily aliased. None of the image pipeline code has changed.
Has a default WPF setting changed between v3.5 and v4.0?
How do I control the dithering of my resized bitmap images in WPF?
I'm using BitmapImage
, DrawingVisual
, DrawingContext
, RenderTargetBitmap
, BitmapEncoder
, and BitmapFrame
but I'm not seeing any properties related to dithering. GDI+ had a bunch of settings, so I'm guessing that I'm missing something.
Update: it appears that all of the solutions I've seen assume a Window object or XAML environment. This runs inside a Windows Service which has no UI. I need a way to programmatically affect this setting.
I specifically switched from GDI+ to WPF because GDI+ has memory leaks in long running processes like services & web apps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我能够影响
BitmapScalingMode
设置的唯一方法是从DrawingVisual
类继承并通过其受保护的访问器设置它:如果其他人知道更好的方法设置这个的方式,我会很高兴听到它。
看起来这会起作用:
……但事实并非如此。显然,位于 XAML 窗口运行时之外必然意味着它无法设置适当的值。
The only way I've been able to affect the setting of
BitmapScalingMode
is to inherit from theDrawingVisual
class and set it via its protected accessor:If anyone else knows of a better way to set this, I would be excited to hear about it.
It seems that this would work:
...but it does not. Apparently being outside of the XAML windowing runtime must mean that it cannot set the appropriate values.
默认的 BitmapScalingMode 在 3.0 中是 Fant,但在 4.0 中现在是 BiLinear。您可以通过几种不同的方式更改默认值。几个 此处描述。
The default BitmapScalingMode was Fant in 3.0 but in 4.0 it is now BiLinear. You can change the default a few different ways. A couple described here.